|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tiangua.star.enmus.CommercialCallBackReadyEnum;
|
|
|
import com.tiangua.star.model.CustomerFollowup;
|
|
|
+import com.tiangua.star.model.ThirdStarDto;
|
|
|
import com.tiangua.star.model.XdOrderDto;
|
|
|
import com.tiangua.star.service.CallBackService;
|
|
|
import com.tiangua.star.util.HttpClientThreeUtil;
|
|
@@ -19,11 +20,15 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.security.MessageDigest;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.TreeMap;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -137,6 +142,15 @@ public class CasllBackDataProcessor implements CallBackService {
|
|
|
commercialCallBackReadyEnum.getBusid(),urlTemp,"重庆众诚");
|
|
|
}
|
|
|
break;
|
|
|
+ case Commercial_DAQN:
|
|
|
+ List<String> md5ListDAQN = callBackMap.get(productBizId);
|
|
|
+ log.info("开始处理机构id:{},大连青柠 当日订单数:{},条数:{}", productBizId,md5ListDAQN,md5ListDAQN.size());
|
|
|
+ if (CollectionUtils.isEmpty(md5ListDAQN)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
|
|
|
+// commercialCallBackReadyEnum.getBusid(),urlTemp,"大连青柠");
|
|
|
+ break;
|
|
|
// case Commercial_Test:
|
|
|
// log.info("开始处理机构id:{}", busiId);
|
|
|
// List<String> md5List2 = callBackMap.get(busiId);
|
|
@@ -155,6 +169,45 @@ public class CasllBackDataProcessor implements CallBackService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void thirdProcessInstitutionData(List<ThirdStarDto> thirdStarDtos) {
|
|
|
+ if (CollectionUtils.isEmpty(thirdStarDtos)) {
|
|
|
+ log.info("thirdStarDtos 解析回传数据为null");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, List<String>> groupedByBusiId = thirdStarDtos.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ ThirdStarDto::getProductBizId,
|
|
|
+ Collectors.mapping(ThirdStarDto::getPhoneMd5, Collectors.toList())
|
|
|
+ ));
|
|
|
+ Map<String, List<String>> callBackMap = groupedByBusiId.entrySet().stream()
|
|
|
+ .filter(entry -> CommercialCallBackReadyEnum.of(entry.getKey()) != null)
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
|
|
+ log.info("已经对接third星级回传的机构id:{}", callBackMap.keySet());
|
|
|
+ if (CollectionUtils.isEmpty(callBackMap.keySet())) {
|
|
|
+ log.info("third 无需要处理的星级回传:{}", callBackMap.keySet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String productBizId : callBackMap.keySet()) {
|
|
|
+ CommercialCallBackReadyEnum commercialCallBackReadyEnum = CommercialCallBackReadyEnum.of(productBizId);
|
|
|
+ if (commercialCallBackReadyEnum != null) {
|
|
|
+ switch (commercialCallBackReadyEnum) {
|
|
|
+ case Commercial_DAQN:
|
|
|
+ if (CollectionUtils.isEmpty(thirdStarDtos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ sendDalian(commercialCallBackReadyEnum.getCode(),
|
|
|
+ commercialCallBackReadyEnum.getBusid(),
|
|
|
+ commercialCallBackReadyEnum.getUrl(),thirdStarDtos);
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void sendGetRequestSXRKX(String productBizId,String busiId,String url){
|
|
|
JSONObject param = SignUtil.generateSign(81, 43, "730969D3F673BA42432C574378B9A8F1");
|
|
@@ -283,6 +336,103 @@ public class CasllBackDataProcessor implements CallBackService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void sendDalian(String productBizId,String busiId,String url,List<ThirdStarDto> thirdStarDtos){
|
|
|
+ if (CollectionUtils.isEmpty(thirdStarDtos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<CustomerFollowup> list = new ArrayList<>();
|
|
|
+ Map<String, String> map = new HashMap();
|
|
|
+ JSONObject response = null;
|
|
|
+ String joined = thirdStarDtos.stream()
|
|
|
+ .map(ThirdStarDto::getUniqueIdentify)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+
|
|
|
+ map.put("app_id", "45");
|
|
|
+ map.put("timestamp", String.valueOf(System.currentTimeMillis()/1000));
|
|
|
+ map.put("unique_id", joined);
|
|
|
+ String sign = makeSign(map, "THITVXdSPQRQzArVwtssyD4uMdQIUxEY");
|
|
|
+ map.put("sign", sign);
|
|
|
+ log.info("【大连青宁】请求前参数:{}",map);
|
|
|
+ String responseStr = HttpClientThreeUtil.post(url, JSON.toJSONString(map));
|
|
|
+ response = JSON.parseObject(responseStr);
|
|
|
+ log.info("【大连青宁】响应数据:{}",response);
|
|
|
+ if (response.getInteger("code") == 200) {
|
|
|
+ JSONArray data = response.getJSONArray("data");
|
|
|
+
|
|
|
+ Map<String, ThirdStarDto> dtoMap = thirdStarDtos.stream()
|
|
|
+ .collect(Collectors.toMap(ThirdStarDto::getUniqueIdentify, Function.identity(), (a, b) -> a));
|
|
|
+
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ JSONObject obj = data.getJSONObject(i);
|
|
|
+ String uniqueId = obj.getString("unique_id");
|
|
|
+ Integer star = obj.getInteger("star");
|
|
|
+
|
|
|
+ ThirdStarDto dto = dtoMap.get(uniqueId);
|
|
|
+ if (dto != null) {
|
|
|
+ CustomerFollowup followup = new CustomerFollowup();
|
|
|
+ followup.setStarLevel(new BigDecimal(star));
|
|
|
+ followup.setPhoneMd5(dto.getPhoneMd5());
|
|
|
+ followup.setBusiId(busiId);
|
|
|
+ followup.setProductBizId(Integer.parseInt(productBizId));
|
|
|
+ followup.setFollowTime(new Date());
|
|
|
+ followup.setSourceType(3);
|
|
|
+ list.add(followup);
|
|
|
+ } else {
|
|
|
+ log.warn("未匹配到 unique_id={} 对应的 ThirdStarDto", uniqueId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("busiId:{} 处理数据条:{}", busiId, list.size());
|
|
|
+ handleMappedData(busiId,list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Map<String, String> map = new HashMap();
|
|
|
+ map.put("app_id", "45");
|
|
|
+ map.put("timestamp", String.valueOf(System.currentTimeMillis()/1000));
|
|
|
+ map.put("unique_id", "hryk1744092978");
|
|
|
+ String sign = makeSign(map, "THITVXdSPQRQzArVwtssyD4uMdQIUxEY");
|
|
|
+ map.put("sign", sign);
|
|
|
+ System.out.println(map);
|
|
|
+ }
|
|
|
+ public static String makeSign(Map<String, String> args, String token) {
|
|
|
+ if (args == null || token == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> sortedArgs = new TreeMap<>(args);
|
|
|
+
|
|
|
+ StringBuilder signStr = new StringBuilder();
|
|
|
+ for (Map.Entry<String, String> entry : sortedArgs.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ if (value != null && !value.isEmpty()) {
|
|
|
+ signStr.append(key).append(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println(signStr.toString());
|
|
|
+
|
|
|
+ return md5(md5(signStr.toString()) + token).toUpperCase();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String md5(String str) {
|
|
|
+ try {
|
|
|
+ MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
+ md.update(str.getBytes());
|
|
|
+ byte[] digest = md.digest();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ for (byte b : digest) {
|
|
|
+ sb.append(String.format("%02x", b & 0xff));
|
|
|
+ }
|
|
|
+
|
|
|
+ return sb.toString();
|
|
|
+ } catch (NoSuchAlgorithmException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private void sendGetRequest(String productBizId,String busiId,String url,List<String> md5s){
|
|
|
List<CustomerFollowup> list = new ArrayList<>();
|