Sunshine
2024-11-04 919ed870ea1def0cfdd1dff23bec204975e7f34c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.nova.sankuai.domain.api.tianshi;
 
import com.alibaba.fastjson.JSONObject;
import com.nova.sankuai.domain.dto.CustomerCompareDto;
import com.nova.sankuai.domain.entity.Customer;
import com.nova.sankuai.security.MD5Encryption;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
 
/**
 * <p>
 * 苏州天师公司接口对接
 * </p>
 *
 * @author: zcj  2022/2/14
 */
@Data
@Component
@ApiModel(value = "苏州天师接口公司对接")
public class TianShiUtil {
    @Value("${suzhoutianshi.hitUrl}")
    public String hitUrl;
 
    @Value("${suzhoutianshi.commitUrl}")
    public String commitUrl;
 
    @Value("${suzhoutianshi.source}")
    public String source;
 
    @Value("${suzhoutianshi.secretapi}")
    public String secretapi;
 
 
    public JSONObject parseHitParam(Customer customer) {
        JSONObject object = new JSONObject();
        object.put("source", this.source);
        String phone = MD5Encryption.getMD5(customer.getPhone());
        object.put("mobile", phone);
        object.put("name", customer.getName());
        object.put("city", customer.getCityName().substring(0,customer.getCityName().indexOf('市')));
        return object;
    }
 
 
 
    public JSONObject parseCommitParam(Customer customer) {
        CustomerCompareDto parse = CustomerCompareDto.parse(customer);
        JSONObject json = new JSONObject();
        json.put("source", this.source);
        json.put("name", customer.getName());
        json.put("mobile", customer.getPhone());
        json.put("city", customer.getCityName().substring(0,customer.getCityName().indexOf('市')));
        json.put("age", customer.getAge());
        json.put("money", parse.getQuota());
        json.put("car", parse.isCarStatus() ? "有" : null);
        json.put("house", parse.isHouseStatus() ? "有" : null);
        json.put("shebao", parse.isSocialSecurity() ? "有" : null);
        json.put("gongjijin", parse.isProvidentFund() ? "有" : null);
        json.put("credit_card", parse.isCreditCard() ? "有" : null);
        return json;
    }
 
    public static String getFailMessage(Integer code) {
        Field[] fields = TianShiResponse.class.getFields();
        for (Field field : fields) {
            if (Modifier.isFinal(field.getModifiers())) {
                if (field.getName().contains(Integer.toString(code))) {
                    try {
                        return (String) field.get(null);
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return code.toString();
    }
}