Просмотр исходного кода

海南谨昇信息服务有限公司

wanxc 3 недель назад
Родитель
Сommit
c334fc0034

+ 12 - 4
src/main/java/com/tiangua/star/controller/GXRHMd5CallBackController.java

@@ -11,6 +11,13 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+
 
 /**
  * @author
@@ -53,16 +60,17 @@ public class GXRHMd5CallBackController {
 
 //    @PostMapping("/sendGetRequestHeiLongJiang")
 //    public void processInstitutionData() {
-//        String s1 = "99C0B3015254F583F3BF7C8430F328A5";
-//        String s2 = "8C32A04C7FED4B5EF9451CDB5D9DE770";
+//        String s1 = "16cdb6e6e52e241a24d6bb6ae4b17cbb";
+//       // String s2 = "8C32A04C7FED4B5EF9451CDB5D9DE770";
 //
 //        List<String> strings = new ArrayList<>();
 //        strings.add(s1);
-//        strings.add(s2);
+//   //     strings.add(s2);
 ////
 ////        String md5ListStr = [A4DAB7668AACAC1D134C1F37351689B2, AD7DE46FF63D14586BDB2960F8DFADA3, 830A6BF59D2BD7CC9BF348968F339679, BB0827AA0A5488D9888A9AB5F91EC1D9, 5DC81C7B49DF99B9EFD6AE60930684C3, 3FA262C2228781E91693FD1E491AD992, 2AA2F6D980D3AA1A99BC2668E6D17DF2, 5EF5B85D827A0D8DAF4F2F58492EAEF2, 5642D0403C64E28A35A458DD51D1835C, B042388F090D43BD65BF8041A077D498, 17E7DC0697D9778AC8CF3E34C1473A02, 19799C273D2A4AB61C83D032CAD58077, 6AD4F0A0B434BADD714008D993CCEB09, 1DC1BD9F6701A9D89E188A1215F644F0, 4350DEA1CE1875F7F307FA5D9BCD532A, 87E365716EC2308152C63EB815461794, 577DF2744FD39D6A8B62EE51E709ED33, 088249775E8CEB938D3FB8B0F24C0142];
 ////        strings.add(md5ListStr);
+//        Map<String, String> hashMap = new HashMap<>();
 //        //sendGetRequestCQYXJ("4516","bff040093fee250512093334business","https://gw.rongxk.com/crm/api/channel/queryCustomerGrade",strings,"1D4C6329-399F-42CA-AC0C-236E0B048AD0",21540);
-//        sendGetRequestGZWA("4618", "a2f5cc8171d6250604105336business", "https://gw.rongxk.cn/crm/api/channel/queryCustomerGrade","苏州荣聚鑫科技有限公司","21540","8AF3F228-913D-4430-883A-2CEA88D8657E",strings);
+//        sendGetRequestHNJS("4879","584c550f633a251017054419business","http://122.114.55.45:9501/openapi/customer/return","373cd4a2-0b01-409e-8c74-81fce8962aef","wn2c213vPDF04T3PRbzOUzED19J8Tukh","海南谨昇信息服务有限公司",strings,hashMap);
 //    }
 }

+ 1 - 0
src/main/java/com/tiangua/star/enmus/CommercialCallBackReadyEnum.java

@@ -44,6 +44,7 @@ public enum CommercialCallBackReadyEnum implements StringCodeable {
     Commercial_SZRJX("4618", "a2f5cc8171d6250604105336business", "https://gw.rongxk.cn/crm/api/channel/queryCustomerGrade"),//苏州荣聚鑫科技有限公司
     Commercial_GZXX("4504", "3058badbe272250507060325business", "https://gw.rongxk.cn/crm/api/channel/queryCustomerGrade"),//广州星象信息科技有限公司
     Commercial_YBDSHY("4672", "f11b39f57671250617035916business", "https://gw.rongxk.cn/crm/api/channel/queryCustomerGrade"),//延边鼎晟合盈企业管理有限公司
+    Commercial_HNJS("4879","584c550f633a251017054419business","http://122.114.55.45:9501/openapi/customer/return"),//海南谨昇信息服务有限公司
     Commercial_HFYZF("4598", "eea00c739c37250527052046business", "https://rxccrm.chkoala.com/api/xiaoan/queryByUniqueId");//合肥裕之丰
 
 

+ 125 - 0
src/main/java/com/tiangua/star/service/impl/CasllBackDataProcessor.java

@@ -7,6 +7,7 @@ import com.tiangua.star.enmus.CommercialCallBackReadyEnum;
 import com.tiangua.star.model.*;
 import com.tiangua.star.service.CallBackService;
 import com.tiangua.star.util.HttpClientThreeUtil;
+import com.tiangua.star.util.MD5Util;
 import com.tiangua.star.util.SignUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.digest.DigestUtils;
@@ -72,6 +73,19 @@ public class CasllBackDataProcessor implements CallBackService {
                         sendGetRequest(CommercialCallBackReadyEnum.Commercial_ONE.getCode(),
                                 CommercialCallBackReadyEnum.Commercial_ONE.getBusid(),commercialCallBackReadyEnum.getUrl(),md5List);
                         break;
+                    case Commercial_HNJS://海南谨昇信息服务有限公司
+                        List<String> md5ListHNJS = callBackMap.get(productBizId);
+                        log.info("开始处理机构id:{},海南谨昇信息服务有限公司 当日订单数:{},条数:{}", productBizId,md5ListHNJS,md5ListHNJS.size());
+                        if (CollectionUtils.isEmpty(md5ListHNJS)) {
+                            return;
+                        }
+                        String appid="373cd4a2-0b01-409e-8c74-81fce8962aef";
+                        String secretKey="wn2c213vPDF04T3PRbzOUzED19J8Tukh";
+                        sendGetRequestHNJS(commercialCallBackReadyEnum.getCode(),
+                                commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),appid,secretKey,"海南谨昇信息服务有限公司",md5ListHNJS,resultMap);
+                        break;
+
+
                     case Commercial_ZZCF://郑州澄丰信息咨询有限公司
                         List<String> md5ListZZCF = callBackMap.get(productBizId);
                         log.info("开始处理机构id:{},郑州澄丰信息咨询有限公司 当日订单数:{},条数:{}", productBizId,md5ListZZCF,md5ListZZCF.size());
@@ -1143,6 +1157,117 @@ public class CasllBackDataProcessor implements CallBackService {
 //        handleMappedData(busiId,followupList);
 //
 //    }
+
+    private void sendGetRequestHNJS(String productBizId,String busiId,String url,String appid,String secretKey,String companyName,List<String> md5ListGZWA,Map<String, String> resultMap){
+
+        JSONObject object = new JSONObject();
+        object.put("md5s", md5ListGZWA);
+        String paramString = JSONObject.toJSONString(object);
+        String sign = MD5Util.MD5(paramString.concat(secretKey)).toLowerCase();
+        String checkUrl = url + "?appid=" + appid + "&sign=" + sign;
+        log.info("星级回传请求参数{}:{}",companyName,paramString);
+        String responseStr = HttpClientThreeUtil.post(checkUrl, paramString);
+        JSONObject response = JSON.parseObject(responseStr);
+        if (StringUtils.isEmpty(responseStr)) {
+            log.error("busiId:{},companyName:{} 星级回传响应为空", busiId, companyName);
+            return;
+        }
+        log.info("星级回传返回参数{}:{}",companyName,response);
+        String code = response.getString("code");
+        if (!"200".equals(code)) {
+            log.info("busiId:{},companyName {},24h返回数据错误: {},{}" ,busiId,companyName,
+                    response.getString("msg"),response.getString("code"));
+            return;
+        }
+
+        JSONArray dataArray = response.getJSONArray("data");
+        List<CustomerFollowup> followupList = new ArrayList<>();
+        String s = resultMap.get(busiId);
+        JSONObject jsonObject = JSON.parseObject(s);
+        // 遍历 data 数组,创建实体对象并设置对应字段
+        for (int i = 0; i < dataArray.size(); i++) {
+            JSONObject obj = dataArray.getJSONObject(i);
+            CustomerFollowup followup = new CustomerFollowup();
+            followup.setBusiId(busiId);
+            followup.setProductBizId(Integer.parseInt(productBizId));
+            followup.setPhoneMd5(obj.getString("phone_md5"));
+            String star = obj.getString("star");
+            if (StringUtils.isEmpty(star)) {
+                log.info("busiId:{} companyName {}, mobile_md5{} 没有填星级:", busiId, companyName ,followup.getPhoneMd5());
+                continue;
+            } else {
+                if (StringUtils.isEmpty(s)){//没有配置映射
+                    if ("0".equals(star)) {
+                        followup.setStarLevel(new BigDecimal(0));
+                    } else if ("1".equals(star)) {
+                        followup.setStarLevel(new BigDecimal(1));
+                    }else if ("2".equals(star)) {
+                        followup.setStarLevel(new BigDecimal(2));
+                    }else if ("3".equals(star)) {
+                        followup.setStarLevel(new BigDecimal(3));
+                    }else if ("4".equals(star)) {
+                        followup.setStarLevel(new BigDecimal(4));
+                    }else if ("5".equals(star)) {
+                        followup.setStarLevel(new BigDecimal(5));
+                    }
+                }else {
+                    //{  客户  :  我方
+                    //	"1星": "5星",
+                    //	"2星": "4星",
+                    //	"3星": "3星",
+                    //	"4星": "2星",
+                    //	"5星": "1星"
+                    //}
+                    try {
+                        Map<String, String> starMap = JSON.parseObject(jsonObject.toString(), Map.class);
+                        String level = starMap.get(star);
+                        if (StringUtils.isEmpty(level)) {
+                            if ("0".equals(star)) {
+                                followup.setStarLevel(new BigDecimal(0));
+                            } else if ("1".equals(star)) {
+                                followup.setStarLevel(new BigDecimal(1));
+                            }else if ("2".equals(star)) {
+                                followup.setStarLevel(new BigDecimal(2));
+                            }else if ("3".equals(star)) {
+                                followup.setStarLevel(new BigDecimal(3));
+                            }else if ("4".equals(star)) {
+                                followup.setStarLevel(new BigDecimal(4));
+                            }else if ("5".equals(star)) {
+                                followup.setStarLevel(new BigDecimal(5));
+                            }
+                        }else {
+                            followup.setStarLevel(new BigDecimal(level));
+                        }
+                    }catch (Exception e){
+                        if ("0".equals(star)) {
+                            followup.setStarLevel(new BigDecimal(0));
+                        } else if ("1".equals(star)) {
+                            followup.setStarLevel(new BigDecimal(1));
+                        }else if ("2".equals(star)) {
+                            followup.setStarLevel(new BigDecimal(2));
+                        }else if ("3".equals(star)) {
+                            followup.setStarLevel(new BigDecimal(3));
+                        }else if ("4".equals(star)) {
+                            followup.setStarLevel(new BigDecimal(4));
+                        }else if ("5".equals(star)) {
+                            followup.setStarLevel(new BigDecimal(5));
+                        }
+                    }
+
+                }
+            }
+            followup.setSourceType(3);
+            followup.setFollowTime(new Date());
+            followupList.add(followup);
+        }
+        if (CollectionUtils.isEmpty(followupList)) {
+            log.info("busiId:{} companyName:{},没有24h星级数据", busiId,companyName);
+            return;
+        }
+        log.info("busiId:{} companyName:{} 处理数据条:{}", busiId, companyName,followupList.size());
+        handleMappedData(busiId,followupList);
+
+    }
     //融享客通用
     private void sendGetRequestGZWA(String productBizId,String busiId,String url,String channelType,String accessKey,String companyName,List<String> md5ListGZWA,Map<String, String> resultMap){
 

+ 96 - 0
src/main/java/com/tiangua/star/util/MD5Util.java

@@ -0,0 +1,96 @@
+package com.tiangua.star.util;
+
+import java.security.MessageDigest;
+
+/**
+ * The type Md 5 util.
+ */
+public abstract class MD5Util {
+    /**
+     * Md 5 string.
+     *
+     * @param pwd the pwd
+     * @return the string
+     */
+    public final static String MD5(String pwd) {
+        //用于加密的字符  
+        char md5String[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',  
+                'A', 'B', 'C', 'D', 'E', 'F' };  
+        try {  
+            //使用平台的默认字符集将此 String 编码为 byte序列,并将结果存储到一个新的 byte数组中  
+            byte[] btInput = pwd.getBytes();  
+               
+            //信息摘要是安全的单向哈希函数,它接收任意大小的数据,并输出固定长度的哈希值。  
+            MessageDigest mdInst = MessageDigest.getInstance("MD5");  
+               
+            //MessageDigest对象通过使用 update方法处理数据, 使用指定的byte数组更新摘要  
+            mdInst.update(btInput);  
+               
+            // 摘要更新之后,通过调用digest()执行哈希计算,获得密文  
+            byte[] md = mdInst.digest();  
+               
+            // 把密文转换成十六进制的字符串形式  
+            int j = md.length;  
+            char str[] = new char[j * 2];  
+            int k = 0;  
+            for (int i = 0; i < j; i++) {   //  i = 0  
+                byte byte0 = md[i];  //95  
+                str[k++] = md5String[byte0 >>> 4 & 0xf];    //    5   
+                str[k++] = md5String[byte0 & 0xf];   //   F  
+            }  
+               
+            //返回经过加密后的字符串  
+            return new String(str);  
+               
+        } catch (Exception e) {  
+            return null;  
+        }  
+    }
+
+    private static String byteArrayToHexString(byte b[]) {
+        StringBuffer resultSb = new StringBuffer();
+        for (int i = 0; i < b.length; i++)
+            resultSb.append(byteToHexString(b[i]));
+
+        return resultSb.toString();
+    }
+
+    private static String byteToHexString(byte b) {
+        int n = b;
+        if (n < 0)
+            n += 256;
+        int d1 = n / 16;
+        int d2 = n % 16;
+        return hexDigits[d1] + hexDigits[d2];
+    }
+
+    /**
+     * Md 5 encode string.
+     *
+     * @param origin      the origin
+     * @param charsetname the charsetname
+     * @return the string
+     */
+    public static String MD5Encode(String origin, String charsetname) {
+        String resultString = null;
+        try {
+            resultString = new String(origin);
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            if (charsetname == null || "".equals(charsetname))
+                resultString = byteArrayToHexString(md.digest(resultString
+                        .getBytes()));
+            else
+                resultString = byteArrayToHexString(md.digest(resultString
+                        .getBytes(charsetname)));
+        } catch (Exception exception) {
+        }
+        return resultString;
+    }
+
+    private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
+            "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
+
+    public static void main(String[] a) {
+        System.out.println(MD5Encode("13758525535NsArzbOcYie4XMW5iGrkA","UTF-8"));
+    }
+}