CasllBackDataProcessor.java 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. package com.tiangua.star.service.impl;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.tiangua.star.enmus.CommercialCallBackReadyEnum;
  6. import com.tiangua.star.model.CustomerFollowup;
  7. import com.tiangua.star.model.ThirdStarDto;
  8. import com.tiangua.star.model.XdOrderDto;
  9. import com.tiangua.star.service.CallBackService;
  10. import com.tiangua.star.util.HttpClientThreeUtil;
  11. import com.tiangua.star.util.SignUtil;
  12. import lombok.extern.slf4j.Slf4j;
  13. import org.apache.commons.codec.digest.DigestUtils;
  14. import org.apache.commons.collections4.CollectionUtils;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.apache.http.impl.client.CloseableHttpClient;
  17. import org.apache.http.impl.client.HttpClients;
  18. import org.springframework.beans.factory.annotation.Value;
  19. import org.springframework.stereotype.Service;
  20. import java.math.BigDecimal;
  21. import java.security.MessageDigest;
  22. import java.security.NoSuchAlgorithmException;
  23. import java.util.ArrayList;
  24. import java.util.Date;
  25. import java.util.HashMap;
  26. import java.util.List;
  27. import java.util.Map;
  28. import java.util.TreeMap;
  29. import java.util.function.Function;
  30. import java.util.stream.Collectors;
  31. @Service
  32. @Slf4j
  33. public class CasllBackDataProcessor implements CallBackService {
  34. // HTTP请求工具
  35. private static final CloseableHttpClient httpClient = HttpClients.createDefault();
  36. @Value("${md5.callback.url}")
  37. private String url;
  38. /**
  39. * 处理机构数据入口
  40. */
  41. @Override
  42. public void processInstitutionData(List<XdOrderDto> xdOrderDtos) {
  43. Map<String, List<String>> groupedByBusiId = xdOrderDtos.stream()
  44. .collect(Collectors.groupingBy(
  45. XdOrderDto::getProductBizId,
  46. Collectors.mapping(XdOrderDto::getMobileMd5, Collectors.toList())
  47. ));
  48. Map<String, List<String>> callBackMap = groupedByBusiId.entrySet().stream()
  49. .filter(entry -> CommercialCallBackReadyEnum.of(entry.getKey()) != null)
  50. .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
  51. log.info("已经对接md5星级回传的机构id:{}", callBackMap.keySet());
  52. if (CollectionUtils.isEmpty(callBackMap.keySet())) {
  53. log.info("MD5 无需要处理的星级回传:{}", callBackMap.keySet());
  54. return;
  55. }
  56. for (String productBizId : callBackMap.keySet()) {
  57. CommercialCallBackReadyEnum commercialCallBackReadyEnum = CommercialCallBackReadyEnum.of(productBizId);
  58. if (commercialCallBackReadyEnum != null) {
  59. switch (commercialCallBackReadyEnum) {
  60. case Commercial_ONE:
  61. List<String> md5List = callBackMap.get(productBizId);
  62. log.info("开始处理机构id:{},当日订单数:{},条数:{}", productBizId,md5List,md5List.size());
  63. if (CollectionUtils.isEmpty(md5List)) {
  64. return;
  65. }
  66. sendGetRequest(CommercialCallBackReadyEnum.Commercial_ONE.getCode(),
  67. CommercialCallBackReadyEnum.Commercial_ONE.getBusid(),commercialCallBackReadyEnum.getUrl(),md5List);
  68. break;
  69. case Commercial_LSDJC://乐山都聚财信息技术咨询有限公司
  70. List<String> md5ListLSDJC = callBackMap.get(productBizId);
  71. log.info("开始处理机构id:{},乐山都聚财信息技术咨询有限公司 当日订单数:{},条数:{}", productBizId,md5ListLSDJC,md5ListLSDJC.size());
  72. if (CollectionUtils.isEmpty(md5ListLSDJC)) {
  73. return;
  74. }
  75. String channelTypeLSDJC="21180";
  76. String accessKeyLSDJC="3438EBF8-95AC-4739-8B32-59D273D38689";
  77. sendGetRequestGZWA(commercialCallBackReadyEnum.getCode(),
  78. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),channelTypeLSDJC,accessKeyLSDJC,"乐山都聚财信息技术咨询有限公司",md5ListLSDJC);
  79. break;
  80. case Commercial_SCNAZC://四川诺安至诚信息科技有限公司
  81. List<String> md5ListSCNAZC = callBackMap.get(productBizId);
  82. log.info("开始处理机构id:{},四川诺安至诚信息科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListSCNAZC,md5ListSCNAZC.size());
  83. if (CollectionUtils.isEmpty(md5ListSCNAZC)) {
  84. return;
  85. }
  86. String channelTypeSCNAZC="21180";
  87. String accessKeySCNAZC="818DF3C7-0B11-4043-B7ED-84508F2C00EF";
  88. sendGetRequestGZWA(commercialCallBackReadyEnum.getCode(),
  89. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),channelTypeSCNAZC,accessKeySCNAZC,"四川诺安至诚信息科技有限公司",md5ListSCNAZC);
  90. break;
  91. case Commercial_GZWA://广州维安信息咨询有限公司
  92. List<String> md5ListGZWA = callBackMap.get(productBizId);
  93. log.info("开始处理机构id:{},广州维安信息咨询有限公司 当日订单数:{},条数:{}", productBizId,md5ListGZWA,md5ListGZWA.size());
  94. if (CollectionUtils.isEmpty(md5ListGZWA)) {
  95. return;
  96. }
  97. String channelType="21160";
  98. String accessKey="4A79FD90-DA94-4D4B-AECD-BC48CD418970";
  99. sendGetRequestGZWA(commercialCallBackReadyEnum.getCode(),
  100. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),channelType,accessKey,"弘盛信息咨询有限公司",md5ListGZWA);
  101. break;
  102. case Commercial_TSSX://唐山硕鑫科技有限公司
  103. List<String> md5ListTSSX = callBackMap.get(productBizId);
  104. log.info("开始处理机构id:{},唐山硕鑫科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListTSSX,md5ListTSSX.size());
  105. if (CollectionUtils.isEmpty(md5ListTSSX)) {
  106. return;
  107. }
  108. String channelTypeTSSX="21540";
  109. String accessKeyTSSX="5D3842E0-7A2E-4077-8985-16F9782A0950";
  110. sendGetRequestGZWA(commercialCallBackReadyEnum.getCode(),
  111. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),channelTypeTSSX,accessKeyTSSX,"唐山硕鑫科技有限公司",md5ListTSSX);
  112. break;
  113. case Commercial_SZRJX://苏州荣聚鑫科技有限公司
  114. List<String> md5ListSZRJX = callBackMap.get(productBizId);
  115. log.info("开始处理机构id:{},苏州荣聚鑫科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListSZRJX,md5ListSZRJX.size());
  116. if (CollectionUtils.isEmpty(md5ListSZRJX)) {
  117. return;
  118. }
  119. String channelTypeSZRJX="21540";
  120. String accessKeySZRJX="8AF3F228-913D-4430-883A-2CEA88D8657E";
  121. sendGetRequestGZWA(commercialCallBackReadyEnum.getCode(),
  122. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),channelTypeSZRJX,accessKeySZRJX,"苏州荣聚鑫科技有限公司",md5ListSZRJX);
  123. break;
  124. case Commercial_GZXX://广州星象信息科技有限公司
  125. List<String> md5ListGZXX = callBackMap.get(productBizId);
  126. log.info("开始处理机构id:{},广州星象信息科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListGZXX,md5ListGZXX.size());
  127. if (CollectionUtils.isEmpty(md5ListGZXX)) {
  128. return;
  129. }
  130. String channelTypeGZXX="21540";
  131. String accessKeyGZXX="8620FAD8-775C-4416-BB10-1486F008D2AA";
  132. sendGetRequestGZWA(commercialCallBackReadyEnum.getCode(),
  133. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),channelTypeGZXX,accessKeyGZXX,"广州星象信息科技有限公司",md5ListGZXX);
  134. break;
  135. case Commercial_YBDSHY://延边鼎晟合盈企业管理有限公司
  136. List<String> md5ListYBDSHY = callBackMap.get(productBizId);
  137. log.info("开始处理机构id:{},延边鼎晟合盈企业管理有限公司 当日订单数:{},条数:{}", productBizId,md5ListYBDSHY,md5ListYBDSHY.size());
  138. if (CollectionUtils.isEmpty(md5ListYBDSHY)) {
  139. return;
  140. }
  141. String channelTypeYBDSHY="21540";
  142. String accessKeyYBDSHY="73F3F2EB-1687-44A2-B647-4C00B8DDB77A";
  143. sendGetRequestGZWA(commercialCallBackReadyEnum.getCode(),
  144. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),channelTypeYBDSHY,accessKeyYBDSHY,"延边鼎晟合盈企业管理有限公司",md5ListYBDSHY);
  145. break;
  146. case Commercial_XNLJKJ://西宁蓝鲸优享科技有限公司
  147. List<String> md5ListXNLJKJ = callBackMap.get(productBizId);
  148. log.info("开始处理机构id:{},西宁蓝鲸优享科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListXNLJKJ,md5ListXNLJKJ.size());
  149. if (CollectionUtils.isEmpty(md5ListXNLJKJ)) {
  150. return;
  151. }
  152. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  153. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"西宁蓝鲸优享科技有限公司");
  154. break;
  155. case Commercial_CQHYJF://重庆寰宇金福信息科技有限公司
  156. List<String> md5ListCQHYJF = callBackMap.get(productBizId);
  157. log.info("开始处理机构id:{},重庆寰宇金福信息科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListCQHYJF,md5ListCQHYJF.size());
  158. if (CollectionUtils.isEmpty(md5ListCQHYJF)) {
  159. return;
  160. }
  161. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  162. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"重庆寰宇金福信息科技有限公司");
  163. break;
  164. case Commercial_SRLF://速融(廊坊)信息咨询服务有限公司
  165. List<String> md5ListSRLF = callBackMap.get(productBizId);
  166. log.info("开始处理机构id:{},速融(廊坊)信息咨询服务有限公司 当日订单数:{},条数:{}", productBizId,md5ListSRLF,md5ListSRLF.size());
  167. if (CollectionUtils.isEmpty(md5ListSRLF)) {
  168. return;
  169. }
  170. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  171. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"速融(廊坊)信息咨询服务有限公司");
  172. break;
  173. case Commercial_NJCXS://南京诚享顺科技有限公司
  174. List<String> md5ListNJCXS = callBackMap.get(productBizId);
  175. log.info("开始处理机构id:{},南京诚享顺科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListNJCXS,md5ListNJCXS.size());
  176. if (CollectionUtils.isEmpty(md5ListNJCXS)) {
  177. return;
  178. }
  179. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  180. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"南京诚享顺科技有限公司");
  181. break;
  182. case Commercial_HS://弘盛信息咨询有限公司
  183. List<String> md5ListHS = callBackMap.get(productBizId);
  184. log.info("开始处理机构id:{},弘盛信息咨询有限公司 当日订单数:{},条数:{}", productBizId,md5ListHS,md5ListHS.size());
  185. if (CollectionUtils.isEmpty(md5ListHS)) {
  186. return;
  187. }
  188. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  189. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"弘盛信息咨询有限公司");
  190. break;
  191. case Commercial_JXJJG://4514江西聚金阁
  192. List<String> md5ListJXJJG = callBackMap.get(productBizId);
  193. log.info("开始处理机构id:{},江西聚金阁 当日订单数:{},条数:{}", productBizId,md5ListJXJJG,md5ListJXJJG.size());
  194. if (CollectionUtils.isEmpty(md5ListJXJJG)) {
  195. return;
  196. }
  197. sendGetRequestJXJJG(commercialCallBackReadyEnum.getCode(),
  198. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),md5ListJXJJG);
  199. break;
  200. case Commercial_SZYC://苏州央创
  201. List<String> md5ListSZYC = callBackMap.get(productBizId);
  202. log.info("开始处理机构id:{},苏州央创 当日订单数:{},条数:{}", productBizId,md5ListSZYC,md5ListSZYC.size());
  203. if (CollectionUtils.isEmpty(md5ListSZYC)) {
  204. return;
  205. }
  206. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  207. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"苏州央创");
  208. break;
  209. case Commercial_SXJLHJ2://陕西聚隆汇金(二店)
  210. List<String> md5ListSXJLHJ2 = callBackMap.get(productBizId);
  211. log.info("开始处理机构id:{},陕西聚隆汇金(二店) 当日订单数:{},条数:{}", productBizId,md5ListSXJLHJ2,md5ListSXJLHJ2.size());
  212. if (CollectionUtils.isEmpty(md5ListSXJLHJ2)) {
  213. return;
  214. }
  215. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  216. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"陕西聚隆汇金(二店)");
  217. break;
  218. case Commercial_SXJLHJ://陕西聚隆汇金
  219. List<String> md5ListSXJLHJ = callBackMap.get(productBizId);
  220. log.info("开始处理机构id:{},陕西聚隆汇金 当日订单数:{},条数:{}", productBizId,md5ListSXJLHJ,md5ListSXJLHJ.size());
  221. if (CollectionUtils.isEmpty(md5ListSXJLHJ)) {
  222. return;
  223. }
  224. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  225. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"陕西聚隆汇金");
  226. break;
  227. case Commercial_JXJL://嘉兴聚联
  228. List<String> md5ListJXJL = callBackMap.get(productBizId);
  229. log.info("开始处理机构id:{},嘉兴聚联 当日订单数:{},条数:{}", productBizId,md5ListJXJL,md5ListJXJL.size());
  230. if (CollectionUtils.isEmpty(md5ListJXJL)) {
  231. return;
  232. }
  233. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  234. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"嘉兴聚联");
  235. break;
  236. case Commercial_JDPHAJ://广州金贷普惠按揭服务有限公司
  237. List<String> md5ListJDPHAJ = callBackMap.get(productBizId);
  238. log.info("开始处理机构id:{},广州金贷普惠按揭服务有限公司 当日订单数:{},条数:{}", productBizId,md5ListJDPHAJ,md5ListJDPHAJ.size());
  239. if (CollectionUtils.isEmpty(md5ListJDPHAJ)) {
  240. return;
  241. }
  242. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  243. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"广州金贷普惠按揭服务有限公司");
  244. break;
  245. case Commercial_NXCX://宁夏簇鑫科技有限公司
  246. List<String> md5ListNXCX = callBackMap.get(productBizId);
  247. log.info("开始处理机构id:{},宁夏簇鑫科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListNXCX,md5ListNXCX.size());
  248. if (CollectionUtils.isEmpty(md5ListNXCX)) {
  249. return;
  250. }
  251. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  252. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"宁夏簇鑫科技有限公司");
  253. break;
  254. case Commercial_CDHJT://成都汇锦通创商务信息咨询服务有限公司
  255. List<String> md5ListCDHJT = callBackMap.get(productBizId);
  256. log.info("开始处理机构id:{},成都汇锦通创商务信息咨询服务有限公司 当日订单数:{},条数:{}", productBizId,md5ListCDHJT,md5ListCDHJT.size());
  257. if (CollectionUtils.isEmpty(md5ListCDHJT)) {
  258. return;
  259. }
  260. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  261. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"成都汇锦通创商务信息咨询服务有限公司");
  262. break;
  263. case Commercial_HBSY://湖北十堰华融信息咨询有限公司
  264. List<String> md5ListHBSY = callBackMap.get(productBizId);
  265. log.info("开始处理机构id:{},湖北十堰华融信息咨询有限公司 当日订单数:{},条数:{}", productBizId,md5ListHBSY,md5ListHBSY.size());
  266. if (CollectionUtils.isEmpty(md5ListHBSY)) {
  267. return;
  268. }
  269. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  270. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"湖北十堰华融信息咨询有限公司");
  271. break;
  272. case Commercial_CD://成都蓉鑫诚商有限公司
  273. List<String> md5ListCD = callBackMap.get(productBizId);
  274. log.info("开始处理机构id:{},成都蓉鑫诚商有限公司 当日订单数:{},条数:{}", productBizId,md5ListCD,md5ListCD.size());
  275. if (CollectionUtils.isEmpty(md5ListCD)) {
  276. return;
  277. }
  278. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  279. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"成都蓉鑫诚商有限公司");
  280. break;
  281. case Commercial_QT://齐泰圣鑫有限公司
  282. List<String> md5ListQt = callBackMap.get(productBizId);
  283. log.info("开始处理机构id:{},齐泰圣鑫有限公司 当日订单数:{},条数:{}", productBizId,md5ListQt,md5ListQt.size());
  284. if (CollectionUtils.isEmpty(md5ListQt)) {
  285. return;
  286. }
  287. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  288. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"齐泰圣鑫有限公司");
  289. break;
  290. case Commercial_HZ:
  291. List<String> md5ListHz = callBackMap.get(productBizId);
  292. log.info("开始处理机构id:{},杭州聚壹融商务信息咨询有限公司 当日订单数:{},条数:{}", productBizId,md5ListHz,md5ListHz.size());
  293. if (CollectionUtils.isEmpty(md5ListHz)) {
  294. return;
  295. }
  296. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  297. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"杭州聚壹融商务信息咨询有限公司");
  298. break;
  299. case Commercial_NBHX:
  300. List<String> md5ListNBHX = callBackMap.get(productBizId);
  301. log.info("开始处理机构id:{},宁波垣信信息科技有限公司 当日订单数:{},条数:{}", productBizId,md5ListNBHX,md5ListNBHX.size());
  302. if (CollectionUtils.isEmpty(md5ListNBHX)) {
  303. return;
  304. }
  305. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  306. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"宁波垣信信息科技有限公司");
  307. break;
  308. case Commercial_BJQN:
  309. List<String> md5ListBJQN = callBackMap.get(productBizId);
  310. log.info("开始处理机构id:{},北京签牛企业管理咨询有限公司 当日订单数:{},条数:{}", productBizId,md5ListBJQN,md5ListBJQN.size());
  311. if (CollectionUtils.isEmpty(md5ListBJQN)) {
  312. return;
  313. }
  314. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  315. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),"北京签牛企业管理咨询有限公司");
  316. break;
  317. case Commercial_FOSHAN:
  318. List<String> md5ListFS = callBackMap.get(productBizId);
  319. log.info("开始处理机构id:{},佛山市创智盈通企业管理有限公司 当日订单数:{},条数:{}", productBizId,md5ListFS,md5ListFS.size());
  320. if (CollectionUtils.isEmpty(md5ListFS)) {
  321. return;
  322. }
  323. sendGetRequestFoShan(commercialCallBackReadyEnum.getCode(),
  324. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(), md5ListFS);
  325. break;
  326. // case Commercial_HLJJC:
  327. // List<String> md5ListHLJJC = callBackMap.get(productBizId);
  328. // log.info("开始处理机构id:{},黑龙江省景琛信息咨询有限公司 当日订单数:{},条数:{}", productBizId,md5ListHLJJC,md5ListHLJJC.size());
  329. // if (CollectionUtils.isEmpty(md5ListHLJJC)) {
  330. // return;
  331. // }
  332. // sendGetRequestHeiLongJiang(commercialCallBackReadyEnum.getCode(),
  333. // commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(), md5ListHLJJC);
  334. // break;
  335. case Commercial_CQYXJ:
  336. List<String> md5ListCQYXJ = callBackMap.get(productBizId);
  337. log.info("开始处理机构id:{},重庆优兴嘉 当日订单数:{},条数:{}", productBizId,md5ListCQYXJ,md5ListCQYXJ.size());
  338. if (CollectionUtils.isEmpty(md5ListCQYXJ)) {
  339. return;
  340. }
  341. sendGetRequestCQYXJ(commercialCallBackReadyEnum.getCode(),
  342. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl(),md5ListCQYXJ,"1D4C6329-399F-42CA-AC0C-236E0B048AD0",21540);
  343. break;
  344. case Commercial_SXRKX:
  345. List<String> md5ListSXRKX = callBackMap.get(productBizId);
  346. log.info("开始处理机构id:{},山西瑞凯鑫 当日订单数:{},条数:{}", productBizId,md5ListSXRKX,md5ListSXRKX.size());
  347. if (CollectionUtils.isEmpty(md5ListSXRKX)) {
  348. return;
  349. }
  350. sendGetRequestSXRKX(commercialCallBackReadyEnum.getCode(),
  351. commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl());
  352. break;
  353. // case Commercial_XJZZ:
  354. // List<String> md5ListXJZZ = callBackMap.get(busiId);
  355. // log.info("开始处理机构id:{},当日订单数:{},条数:{}", busiId,md5ListXJZZ,md5ListXJZZ.size());
  356. // if (CollectionUtils.isEmpty(md5ListXJZZ)) {
  357. // return;
  358. // }
  359. // sendGetRequestSXRKX(commercialCallBackReadyEnum.getCode(),
  360. // commercialCallBackReadyEnum.getBusid(),commercialCallBackReadyEnum.getUrl());
  361. // break;
  362. case Commercial_CHONGQINGZC:
  363. List<String> md5ListCq = callBackMap.get(productBizId);
  364. log.info("开始处理机构id:{},重庆众诚 当日订单数:{},条数:{}", productBizId,md5ListCq,md5ListCq.size());
  365. if (CollectionUtils.isEmpty(md5ListCq)) {
  366. return;
  367. }
  368. String url = commercialCallBackReadyEnum.getUrl();
  369. String[] split = url.split(";");
  370. for (String urlTemp : split) {
  371. sendGetRequestHz(commercialCallBackReadyEnum.getCode(),
  372. commercialCallBackReadyEnum.getBusid(),urlTemp,"重庆众诚");
  373. }
  374. break;
  375. // case Commercial_Test:
  376. // log.info("开始处理机构id:{}", busiId);
  377. // List<String> md5List2 = callBackMap.get(busiId);
  378. // if (CollectionUtils.isEmpty(md5List2)) {
  379. // return;
  380. // }
  381. // sendGetRequest(CommercialCallBackReadyEnum.Commercial_Test.getCode(),
  382. // CommercialCallBackReadyEnum.Commercial_Test.getBusid(),commercialCallBackReadyEnum.getUrl(),md5List2);
  383. // break;
  384. }
  385. }
  386. }
  387. }
  388. @Override
  389. public void thirdProcessInstitutionData(List<ThirdStarDto> thirdStarDtos) {
  390. if (CollectionUtils.isEmpty(thirdStarDtos)) {
  391. log.info("thirdStarDtos 解析回传数据为null");
  392. return;
  393. }
  394. Map<String, List<String>> groupedByBusiId = thirdStarDtos.stream()
  395. .collect(Collectors.groupingBy(
  396. ThirdStarDto::getProductBizId,
  397. Collectors.mapping(ThirdStarDto::getPhoneMd5, Collectors.toList())
  398. ));
  399. Map<String, List<String>> callBackMap = groupedByBusiId.entrySet().stream()
  400. .filter(entry -> CommercialCallBackReadyEnum.of(entry.getKey()) != null)
  401. .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
  402. log.info("已经对接third星级回传的机构id:{}", callBackMap.keySet());
  403. if (CollectionUtils.isEmpty(callBackMap.keySet())) {
  404. log.info("third 无需要处理的星级回传:{}", callBackMap.keySet());
  405. return;
  406. }
  407. for (String productBizId : callBackMap.keySet()) {
  408. CommercialCallBackReadyEnum commercialCallBackReadyEnum = CommercialCallBackReadyEnum.of(productBizId);
  409. if (commercialCallBackReadyEnum != null) {
  410. switch (commercialCallBackReadyEnum) {
  411. case Commercial_DAQN:
  412. if (CollectionUtils.isEmpty(thirdStarDtos)) {
  413. return;
  414. }
  415. sendDalian(commercialCallBackReadyEnum.getCode(),
  416. commercialCallBackReadyEnum.getBusid(),
  417. commercialCallBackReadyEnum.getUrl(),thirdStarDtos);
  418. break;
  419. case Commercial_HFYZF:
  420. if (CollectionUtils.isEmpty(thirdStarDtos)) {
  421. return;
  422. }
  423. sendHeFei(commercialCallBackReadyEnum.getCode(),
  424. commercialCallBackReadyEnum.getBusid(),
  425. commercialCallBackReadyEnum.getUrl(),thirdStarDtos);
  426. break;
  427. }
  428. }
  429. }
  430. }
  431. @Override
  432. public JSONObject kydrequest(JSONObject json) {
  433. List<CustomerFollowup> followupList = new ArrayList<>();
  434. CustomerFollowup followup = new CustomerFollowup();
  435. followup.setPhoneMd5(json.getString("phoneMd5"));
  436. String businessId = "389fb67410dc250414104756business";
  437. followup.setBusiId(businessId);
  438. followup.setProductBizId(4413);
  439. followup.setFollowTime(new Date());
  440. followup.setSourceType(3);
  441. String star = json.getString("star");
  442. if ("1".equals(star)) {
  443. followup.setStarLevel(new BigDecimal(0));
  444. } else if ("2".equals(star)) {
  445. followup.setStarLevel(new BigDecimal(1));
  446. }else if ("3".equals(star)) {
  447. followup.setStarLevel(new BigDecimal(2));
  448. }else if ("4".equals(star)) {
  449. followup.setStarLevel(new BigDecimal(3));
  450. }else if ("5".equals(star)) {
  451. followup.setStarLevel(new BigDecimal(4));
  452. }else if ("6".equals(star)) {
  453. followup.setStarLevel(new BigDecimal(5));
  454. }
  455. followupList.add(followup);
  456. handleMappedData(businessId,followupList);
  457. JSONObject jsonObject = new JSONObject();
  458. jsonObject.put("code",0);
  459. jsonObject.put("msg","成功");
  460. return jsonObject;
  461. }
  462. private void sendGetRequestSXRKX(String productBizId,String busiId,String url){
  463. JSONObject param = SignUtil.generateSign(81, 43, "730969D3F673BA42432C574378B9A8F1");
  464. log.info("busiId:{},:山西瑞凯鑫 url:{} ,jsonString:{}" ,busiId, url,param);
  465. String responseStr = HttpClientThreeUtil.post(url, JSON.toJSONString(param));
  466. JSONObject jsonObject = JSON.parseObject(responseStr);
  467. List<CustomerFollowup> followupList = new ArrayList<>();
  468. if (jsonObject.getIntValue("code") == 0) {
  469. JSONObject data = jsonObject.getJSONObject("data");
  470. JSONArray list = data.getJSONArray("list");
  471. if (CollectionUtils.isEmpty(list)) {
  472. log.info("busiId:{} 山西瑞凯鑫 list为空 没有星级数据", busiId);
  473. return;
  474. }
  475. for (int i = 0; i < list.size(); i++) {
  476. JSONObject item = list.getJSONObject(i);
  477. CustomerFollowup customerFollowup = new CustomerFollowup();
  478. customerFollowup.setBusiId(busiId);
  479. customerFollowup.setProductBizId(Integer.parseInt(productBizId));
  480. customerFollowup.setCustomerName(item.getString("name"));
  481. customerFollowup.setStarLevel(new BigDecimal(item.getIntValue("stars")));
  482. customerFollowup.setFollowStatus(item.getString("statusStr"));
  483. customerFollowup.setFollowRemark(item.getString("remark"));
  484. String mobile = item.getString("mobile");
  485. if (StringUtils.isEmpty(mobile)) {
  486. log.error("busiId:{} 山西瑞凯鑫 手机号为空",busiId);
  487. continue;
  488. }
  489. customerFollowup.setPhoneMd5(DigestUtils.md5Hex(mobile));
  490. customerFollowup.setFollowTime(new Date());
  491. followupList.add(customerFollowup);
  492. }
  493. }
  494. if (CollectionUtils.isEmpty(followupList)) {
  495. log.info("busiId:{} 山西瑞凯鑫 无星级数据", busiId);
  496. return;
  497. }
  498. log.info("busiId:{} 山西瑞凯鑫 处理数据条:{}", busiId, followupList.size());
  499. handleMappedData(busiId,followupList);
  500. }
  501. private void sendGetRequestCQYXJ(String productBizId,String busiId,String url,List<String> md5ListCQYXJ,String accessKey,Integer channelType){
  502. JSONObject jsonObject = new JSONObject();
  503. jsonObject.put("accessKey", accessKey);
  504. jsonObject.put("channelType", channelType);
  505. jsonObject.put("phoneMd5List", md5ListCQYXJ);
  506. String jsonString = JSON.toJSONString(jsonObject);
  507. log.info("busiId:{},:重庆优兴嘉 jsonString:{}" ,busiId, jsonString);
  508. String responseStr = HttpClientThreeUtil.post(url, jsonString);
  509. JSONObject response = JSON.parseObject(responseStr);
  510. String code = response.getString("code");
  511. if (!"200".equals(code)) {
  512. log.info("重庆优兴嘉 返回数据错误: " + response.getString("msg"));
  513. return ;
  514. }
  515. JSONArray dataArray = response.getJSONArray("data");
  516. List<CustomerFollowup> followupList = new ArrayList<>();
  517. if (CollectionUtils.isEmpty(dataArray)) {
  518. log.info("busiId:{},:重庆优兴嘉 今天没有星级数据",busiId);
  519. return;
  520. }
  521. for (int i = 0; i < dataArray.size(); i++) {
  522. JSONObject obj = dataArray.getJSONObject(i);
  523. CustomerFollowup followup = new CustomerFollowup();
  524. followup.setPhoneMd5(obj.getString("phoneMd5"));
  525. followup.setBusiId(busiId);
  526. followup.setProductBizId(Integer.parseInt(productBizId));
  527. followup.setFollowTime(new Date());
  528. followup.setSourceType(3);
  529. String star = obj.getString("grade");
  530. if (StringUtils.isEmpty(star)) {
  531. log.info("busiId:{} 重庆优兴嘉 mobile_md5{} 没有填星级:", busiId, followup.getPhoneMd5());
  532. continue;
  533. } else {
  534. if ("0".equals(star)) {
  535. followup.setStarLevel(new BigDecimal(0));
  536. } else if ("10".equals(star)) {
  537. followup.setStarLevel(new BigDecimal(1));
  538. }else if ("20".equals(star)) {
  539. followup.setStarLevel(new BigDecimal(2));
  540. }else if ("30".equals(star)) {
  541. followup.setStarLevel(new BigDecimal(3));
  542. }else if ("40".equals(star)) {
  543. followup.setStarLevel(new BigDecimal(4));
  544. }else if ("50".equals(star)) {
  545. followup.setStarLevel(new BigDecimal(5));
  546. }
  547. }
  548. followupList.add(followup);
  549. }
  550. if (CollectionUtils.isEmpty(followupList)) {
  551. log.info("busiId:{} 重庆优兴嘉 无星级数据", busiId);
  552. return;
  553. }
  554. log.info("busiId:{} 重庆优兴嘉 处理数据条:{}", busiId, followupList.size());
  555. handleMappedData(busiId,followupList);
  556. }
  557. private void sendGetRequestJXJJG(String productBizId,String busiId,String url,List<String> md5ListJXJJG){
  558. StringBuilder stringBuilder = new StringBuilder();
  559. Map<String, String> map = new HashMap<>();
  560. for (int i = 0; i < md5ListJXJJG.size(); i++) {
  561. stringBuilder.append(md5ListJXJJG.get(i));
  562. if (i < md5ListJXJJG.size() - 1) {
  563. stringBuilder.append(",");
  564. }
  565. }
  566. map.put("channel_code", "12");
  567. map.put("md5_phone_list", stringBuilder.toString());
  568. String jsonString = JSON.toJSONString(map);
  569. log.info("busiId:{},:江西聚金阁 jsonString:{}" ,busiId, jsonString);
  570. String responseStr = HttpClientThreeUtil.post(url, jsonString);
  571. JSONObject response = JSON.parseObject(responseStr);
  572. String code = response.getString("code");
  573. if (!"1".equals(code)) {
  574. log.info("江西聚金阁 返回数据错误: " + response.getString("msg"));
  575. return ;
  576. }
  577. JSONArray dataArray = response.getJSONArray("data");
  578. List<CustomerFollowup> followupList = new ArrayList<>();
  579. if (CollectionUtils.isEmpty(dataArray)) {
  580. log.info("busiId:{},:江西聚金阁 今天没有星级数据",busiId);
  581. return;
  582. }
  583. for (int i = 0; i < dataArray.size(); i++) {
  584. JSONObject obj = dataArray.getJSONObject(i);
  585. CustomerFollowup followup = new CustomerFollowup();
  586. followup.setPhoneMd5(obj.getString("phoneMd5"));
  587. followup.setBusiId(busiId);
  588. followup.setProductBizId(Integer.parseInt(productBizId));
  589. followup.setFollowTime(new Date());
  590. followup.setSourceType(3);
  591. String star = obj.getString("star");
  592. if (StringUtils.isEmpty(star)) {
  593. log.info("busiId:{} 江西聚金阁 mobile_md5{} 没有填星级:", busiId, followup.getPhoneMd5());
  594. continue;
  595. } else {
  596. if ("0".equals(star)) {
  597. followup.setStarLevel(new BigDecimal(0));
  598. } else if ("1".equals(star)) {
  599. followup.setStarLevel(new BigDecimal(1));
  600. }else if ("2".equals(star) || "3".equals(star)) {
  601. followup.setStarLevel(new BigDecimal(2));
  602. }else if ("4".equals(star)) {
  603. followup.setStarLevel(new BigDecimal(3));
  604. }else if ("5".equals(star)) {
  605. followup.setStarLevel(new BigDecimal(4));
  606. }else if ("6".equals(star)) {
  607. followup.setStarLevel(new BigDecimal(5));
  608. }
  609. }
  610. followupList.add(followup);
  611. }
  612. if (CollectionUtils.isEmpty(followupList)) {
  613. log.info("busiId:{} 江西聚金阁 无星级数据", busiId);
  614. return;
  615. }
  616. log.info("busiId:{} 江西聚金阁 处理数据条:{}", busiId, followupList.size());
  617. handleMappedData(busiId,followupList);
  618. }
  619. private void sendGetRequestFoShan(String productBizId,String busiId,String url,List<String> md5ListFS){
  620. List<Map<String, String>> jsonList = new ArrayList<>();
  621. for (String md5 : md5ListFS) {
  622. Map<String, String> map = new HashMap<>();
  623. map.put("source", "hr");
  624. map.put("mobile_md5", md5);
  625. jsonList.add(map);
  626. }
  627. String jsonString = JSON.toJSONString(jsonList);
  628. log.info("busiId:{},:佛山市创智盈通企业管理有限公司 jsonString:{}" ,busiId, jsonString);
  629. String responseStr = HttpClientThreeUtil.post(url, jsonString);
  630. JSONObject response = JSON.parseObject(responseStr);
  631. String code = response.getString("code");
  632. if (!"200".equals(code)) {
  633. log.info("佛山市创智盈通企业管理有限公司 返回数据错误: " + response.getString("msg"));
  634. return ;
  635. }
  636. JSONArray dataArray = response.getJSONArray("data");
  637. List<CustomerFollowup> followupList = new ArrayList<>();
  638. if (CollectionUtils.isEmpty(dataArray)) {
  639. log.info("busiId:{},:佛山市创智盈通企业管理有限公司 今天没有星级数据",busiId);
  640. return;
  641. }
  642. for (int i = 0; i < dataArray.size(); i++) {
  643. JSONObject obj = dataArray.getJSONObject(i);
  644. CustomerFollowup followup = new CustomerFollowup();
  645. followup.setPhoneMd5(obj.getString("mobile_md5"));
  646. followup.setBusiId(busiId);
  647. followup.setProductBizId(Integer.parseInt(productBizId));
  648. followup.setFollowTime(new Date());
  649. followup.setSourceType(3);
  650. String star = obj.getString("industry");
  651. if (StringUtils.isEmpty(star)) {
  652. log.info("busiId:{} 佛山创智盈通企业管理有限公司 mobile_md5{} 没有填星级:", busiId, followup.getPhoneMd5());
  653. continue;
  654. } else {
  655. if ("0星".equals(star)) {
  656. followup.setStarLevel(new BigDecimal(0));
  657. } else if ("1星".equals(star)) {
  658. followup.setStarLevel(new BigDecimal(1));
  659. }else if ("2星".equals(star)) {
  660. followup.setStarLevel(new BigDecimal(2));
  661. }else if ("3星".equals(star)) {
  662. followup.setStarLevel(new BigDecimal(3));
  663. }else if ("4星".equals(star)) {
  664. followup.setStarLevel(new BigDecimal(4));
  665. }else if ("5星".equals(star)) {
  666. followup.setStarLevel(new BigDecimal(5));
  667. }
  668. }
  669. followupList.add(followup);
  670. }
  671. if (CollectionUtils.isEmpty(followupList)) {
  672. log.info("busiId:{} 佛山创智盈通企业管理有限公司 无星级数据", busiId);
  673. return;
  674. }
  675. log.info("busiId:{} 佛山创智盈通企业管理有限公司 处理数据条:{}", busiId, followupList.size());
  676. handleMappedData(busiId,followupList);
  677. }
  678. // public void sendGetRequestHeiLongJiang(String productBizId, String busiId, String url, List<String> md5ListHLJJC){
  679. // List<Map<String, String>> jsonList = new ArrayList<>();
  680. // for (String md5 : md5ListHLJJC) {
  681. // Map<String, String> map = new HashMap<>();
  682. // map.put("source", "迅速邦");
  683. // map.put("mobile_md5", md5);
  684. // jsonList.add(map);
  685. // }
  686. // String jsonString = JSON.toJSONString(jsonList);
  687. // log.info("busiId:{},:黑龙江省景琛信息咨询有限公司 jsonString:{}" ,busiId, jsonString);
  688. //
  689. // String responseStr = HttpClientThreeUtil.post(url, jsonString);
  690. // JSONObject response = JSON.parseObject(responseStr);
  691. // String code = response.getString("code");
  692. // if (!"200".equals(code)) {
  693. // log.info("黑龙江省景琛信息咨询有限公司 返回数据错误: " + response.getString("msg"));
  694. // return ;
  695. // }
  696. // JSONArray dataArray = response.getJSONArray("data");
  697. // List<CustomerFollowup> followupList = new ArrayList<>();
  698. // if (CollectionUtils.isEmpty(dataArray)) {
  699. // log.info("busiId:{},:黑龙江省景琛信息咨询有限公司 今天没有星级数据",busiId);
  700. // return;
  701. // }
  702. //
  703. // for (int i = 0; i < dataArray.size(); i++) {
  704. // JSONObject obj = dataArray.getJSONObject(i);
  705. // CustomerFollowup followup = new CustomerFollowup();
  706. // followup.setPhoneMd5(obj.getString("mobile_md5"));
  707. // followup.setBusiId(busiId);
  708. // followup.setProductBizId(Integer.parseInt(productBizId));
  709. // followup.setFollowTime(new Date());
  710. // followup.setSourceType(3);
  711. // String star = obj.getString("industry");
  712. // if (StringUtils.isEmpty(star)) {
  713. // log.info("busiId:{} 黑龙江省景琛信息咨询有限公司 mobile_md5{} 没有填星级:", busiId, followup.getPhoneMd5());
  714. // continue;
  715. // } else {
  716. // if ("1星".equals(star)) {
  717. // followup.setStarLevel(new BigDecimal(1));
  718. // }else if ("2星".equals(star)) {
  719. // followup.setStarLevel(new BigDecimal(2));
  720. // }else if ("3星".equals(star)) {
  721. // followup.setStarLevel(new BigDecimal(3));
  722. // }else if ("4星".equals(star)) {
  723. // followup.setStarLevel(new BigDecimal(4));
  724. // }else if ("5星".equals(star)) {
  725. // followup.setStarLevel(new BigDecimal(5));
  726. // }
  727. // }
  728. // followupList.add(followup);
  729. // }
  730. //
  731. // if (CollectionUtils.isEmpty(followupList)) {
  732. // log.info("busiId:{} 黑龙江省景琛信息咨询有限公司 无星级数据", busiId);
  733. // return;
  734. // }
  735. // log.info("黑龙江省景琛信息咨询有限公司:{}", followupList);
  736. // log.info("busiId:{} 黑龙江省景琛信息咨询有限公司 处理数据条:{}", busiId, followupList.size());
  737. // handleMappedData(busiId,followupList);
  738. //
  739. // }
  740. //融享客通用
  741. private void sendGetRequestGZWA(String productBizId,String busiId,String url,String channelType,String accessKey,String companyName,List<String> md5ListGZWA){
  742. JSONObject object = new JSONObject();
  743. object.put("accessKey",accessKey);
  744. object.put("channelType", channelType);
  745. object.put("phoneMd5List", md5ListGZWA);
  746. String jsonString = JSON.toJSONString(object);
  747. log.info("星级回传请求参数{}:{}",companyName,jsonString);
  748. String responseStr = HttpClientThreeUtil.post(url, jsonString);
  749. JSONObject response = JSON.parseObject(responseStr);
  750. log.info("星级回传返回参数{}:{}",companyName,response);
  751. String code = response.getString("code");
  752. if (!"200".equals(code)) {
  753. log.info("busiId:{},companyName {},24h返回数据错误: {},{}" ,busiId,companyName,
  754. response.getString("msg"),response.getString("code"));
  755. return;
  756. }
  757. JSONArray dataArray = response.getJSONArray("data");
  758. List<CustomerFollowup> followupList = new ArrayList<>();
  759. // 遍历 data 数组,创建实体对象并设置对应字段
  760. for (int i = 0; i < dataArray.size(); i++) {
  761. JSONObject obj = dataArray.getJSONObject(i);
  762. CustomerFollowup followup = new CustomerFollowup();
  763. followup.setBusiId(busiId);
  764. followup.setProductBizId(Integer.parseInt(productBizId));
  765. followup.setPhoneMd5(obj.getString("phoneMd5"));
  766. String star = obj.getString("grade");
  767. if (StringUtils.isEmpty(star)) {
  768. log.info("busiId:{} companyName {}, mobile_md5{} 没有填星级:", busiId, companyName ,followup.getPhoneMd5());
  769. continue;
  770. } else {
  771. if ("0".equals(star)) {
  772. followup.setStarLevel(new BigDecimal(0));
  773. } else if ("10".equals(star)) {
  774. followup.setStarLevel(new BigDecimal(1));
  775. }else if ("20".equals(star)) {
  776. followup.setStarLevel(new BigDecimal(2));
  777. }else if ("30".equals(star)) {
  778. followup.setStarLevel(new BigDecimal(3));
  779. }else if ("40".equals(star)) {
  780. followup.setStarLevel(new BigDecimal(4));
  781. }else if ("50".equals(star)) {
  782. followup.setStarLevel(new BigDecimal(5));
  783. }
  784. }
  785. followup.setSourceType(3);
  786. followup.setFollowTime(new Date());
  787. followupList.add(followup);
  788. }
  789. if (CollectionUtils.isEmpty(followupList)) {
  790. log.info("busiId:{} companyName:{},没有24h星级数据", busiId,companyName);
  791. return;
  792. }
  793. log.info("busiId:{} companyName:{} 处理数据条:{}", busiId, companyName,followupList.size());
  794. handleMappedData(busiId,followupList);
  795. }
  796. //https://api.zhudaicms.com/ 通用
  797. private void sendGetRequestHz(String productBizId,String busiId,String url,String companyName){
  798. String responseStr = HttpClientThreeUtil.get(url,null);
  799. JSONObject response = JSON.parseObject(responseStr);
  800. String code = response.getString("code");
  801. if (!"101".equals(code)) {
  802. log.info("busiId:{},companyName {},24h返回数据错误: {},{}" ,busiId,companyName,
  803. response.getString("msg"),response.getString("code"));
  804. return;
  805. }
  806. JSONArray dataArray = response.getJSONArray("data");
  807. List<CustomerFollowup> followupList = new ArrayList<>();
  808. // 遍历 data 数组,创建实体对象并设置对应字段
  809. for (int i = 0; i < dataArray.size(); i++) {
  810. JSONObject obj = dataArray.getJSONObject(i);
  811. CustomerFollowup followup = new CustomerFollowup();
  812. followup.setBusiId(busiId);
  813. followup.setProductBizId(Integer.parseInt(productBizId));
  814. followup.setPhoneMd5(obj.getString("md5mobile"));
  815. followup.setStarLevel(new BigDecimal(obj.getString("stars")));
  816. followup.setSourceType(3);
  817. followup.setFollowTime(new Date());
  818. followupList.add(followup);
  819. }
  820. if (CollectionUtils.isEmpty(followupList)) {
  821. log.info("busiId:{} companyName:{},没有24h星级数据", busiId,companyName);
  822. return;
  823. }
  824. log.info("busiId:{} companyName:{} 处理数据条:{}", busiId, companyName,followupList.size());
  825. handleMappedData(busiId,followupList);
  826. }
  827. private void sendDalian(String productBizId,String busiId,String url,List<ThirdStarDto> thirdStarDtos){
  828. if (CollectionUtils.isEmpty(thirdStarDtos)) {
  829. return;
  830. }
  831. List<CustomerFollowup> list = new ArrayList<>();
  832. Map<String, String> map = new HashMap();
  833. JSONObject response = null;
  834. String joined = thirdStarDtos.stream()
  835. .map(ThirdStarDto::getUniqueIdentify)
  836. .collect(Collectors.joining(","));
  837. map.put("app_id", "18");
  838. map.put("timestamp", String.valueOf(System.currentTimeMillis()/1000));
  839. map.put("unique_id", joined);
  840. String sign = makeSign(map, "0xUGDHmMeiCYU7yyVgvSCeTMCillkDLZ");
  841. map.put("sign", sign);
  842. log.info("【大连青宁】请求前参数:{}",map);
  843. String responseStr = HttpClientThreeUtil.post(url, JSON.toJSONString(map));
  844. response = JSON.parseObject(responseStr);
  845. log.info("【大连青宁】响应数据:{}",response);
  846. if (response.getInteger("code") == 200) {
  847. JSONArray data = response.getJSONArray("data");
  848. Map<String, ThirdStarDto> dtoMap = thirdStarDtos.stream()
  849. .collect(Collectors.toMap(ThirdStarDto::getUniqueIdentify, Function.identity(), (a, b) -> a));
  850. for (int i = 0; i < data.size(); i++) {
  851. JSONObject obj = data.getJSONObject(i);
  852. String uniqueId = obj.getString("unique_id");
  853. Integer star = obj.getInteger("star");
  854. ThirdStarDto dto = dtoMap.get(uniqueId);
  855. if (dto != null) {
  856. CustomerFollowup followup = new CustomerFollowup();
  857. followup.setStarLevel(new BigDecimal(star));
  858. followup.setPhoneMd5(dto.getPhoneMd5());
  859. followup.setBusiId(busiId);
  860. followup.setProductBizId(Integer.parseInt(productBizId));
  861. followup.setFollowTime(new Date());
  862. followup.setSourceType(3);
  863. list.add(followup);
  864. } else {
  865. log.warn("未匹配到 unique_id={} 对应的 ThirdStarDto", uniqueId);
  866. }
  867. }
  868. }
  869. log.info("busiId:{} 处理数据条:{}", busiId, list.size());
  870. handleMappedData(busiId,list);
  871. }
  872. private void sendHeFei(String productBizId,String busiId,String url,List<ThirdStarDto> thirdStarDtos){
  873. if (CollectionUtils.isEmpty(thirdStarDtos)) {
  874. return;
  875. }
  876. List<CustomerFollowup> list = new ArrayList<>();
  877. Map<String, String> map = new HashMap();
  878. JSONObject response = null;
  879. String joined = thirdStarDtos.stream()
  880. .map(ThirdStarDto::getUniqueIdentify)
  881. .collect(Collectors.joining(","));
  882. map.put("app_id", "80");
  883. map.put("timestamp", String.valueOf(System.currentTimeMillis()/1000));
  884. map.put("unique_id", joined);
  885. String sign = makeSign(map, "38b1924a86ca479c842953ff59f724be");
  886. map.put("sign", sign);
  887. log.info("【合肥裕之丰】请求前参数:{}",map);
  888. String responseStr = HttpClientThreeUtil.post(url, JSON.toJSONString(map));
  889. response = JSON.parseObject(responseStr);
  890. log.info("【合肥裕之丰】响应数据:{}",response);
  891. if (response.getInteger("code") == 200) {
  892. JSONArray data = response.getJSONArray("data");
  893. Map<String, ThirdStarDto> dtoMap = thirdStarDtos.stream()
  894. .collect(Collectors.toMap(ThirdStarDto::getUniqueIdentify, Function.identity(), (a, b) -> a));
  895. for (int i = 0; i < data.size(); i++) {
  896. JSONObject obj = data.getJSONObject(i);
  897. String uniqueId = obj.getString("unique_id");
  898. Integer star = obj.getInteger("star");
  899. ThirdStarDto dto = dtoMap.get(uniqueId);
  900. if (dto != null) {
  901. CustomerFollowup followup = new CustomerFollowup();
  902. followup.setStarLevel(new BigDecimal(star));
  903. followup.setPhoneMd5(dto.getPhoneMd5());
  904. followup.setBusiId(busiId);
  905. followup.setProductBizId(Integer.parseInt(productBizId));
  906. followup.setFollowTime(new Date());
  907. followup.setSourceType(3);
  908. list.add(followup);
  909. } else {
  910. log.warn("未匹配到 unique_id={} 对应的 ThirdStarDto", uniqueId);
  911. }
  912. }
  913. }
  914. log.info("busiId:{} 处理数据条:{}", busiId, list.size());
  915. handleMappedData(busiId,list);
  916. }
  917. public static void main(String[] args) {
  918. Map<String, String> map = new HashMap();
  919. map.put("app_id", "45");
  920. map.put("timestamp", String.valueOf(System.currentTimeMillis()/1000));
  921. map.put("unique_id", "hryk1744092978");
  922. String sign = makeSign(map, "THITVXdSPQRQzArVwtssyD4uMdQIUxEY");
  923. map.put("sign", sign);
  924. System.out.println(map);
  925. }
  926. public static String makeSign(Map<String, String> args, String token) {
  927. if (args == null || token == null) {
  928. return "";
  929. }
  930. Map<String, String> sortedArgs = new TreeMap<>(args);
  931. StringBuilder signStr = new StringBuilder();
  932. for (Map.Entry<String, String> entry : sortedArgs.entrySet()) {
  933. String key = entry.getKey();
  934. String value = entry.getValue();
  935. if (value != null && !value.isEmpty()) {
  936. signStr.append(key).append(value);
  937. }
  938. }
  939. System.out.println(signStr.toString());
  940. return md5(md5(signStr.toString()) + token).toUpperCase();
  941. }
  942. private static String md5(String str) {
  943. try {
  944. MessageDigest md = MessageDigest.getInstance("MD5");
  945. md.update(str.getBytes());
  946. byte[] digest = md.digest();
  947. StringBuilder sb = new StringBuilder();
  948. for (byte b : digest) {
  949. sb.append(String.format("%02x", b & 0xff));
  950. }
  951. return sb.toString();
  952. } catch (NoSuchAlgorithmException e) {
  953. e.printStackTrace();
  954. return "";
  955. }
  956. }
  957. private void sendGetRequest(String productBizId,String busiId,String url,List<String> md5s){
  958. List<CustomerFollowup> list = new ArrayList<>();
  959. JSONObject map = new JSONObject();
  960. JSONObject response = null;
  961. for (String md5 : md5s) {
  962. map.put("customer_phone", md5);
  963. map.put("customer_source", "LCD-HX");
  964. String responseStr = HttpClientThreeUtil.post(url, map.toJSONString());
  965. response = JSON.parseObject(responseStr);
  966. if (response.getInteger("code") == 1) {
  967. JSONObject data = response.getJSONObject("data");
  968. CustomerFollowup param = new CustomerFollowup();
  969. JSONArray logList = data.getJSONArray("log_list");
  970. if (CollectionUtils.isNotEmpty(logList)) {
  971. StringBuilder result = new StringBuilder();
  972. for (int i = 0; i < logList.size(); i++) {
  973. JSONObject logEntry = logList.getJSONObject(i);
  974. String logTime = logEntry.getString("log_time");
  975. String content = logEntry.getString("content");
  976. result.append(logTime).append("-").append(content);
  977. if (i < logList.size() - 1) {
  978. result.append(";");
  979. }
  980. }
  981. param.setFollowRemark(result.toString());
  982. }
  983. param.setPhoneMd5(md5);
  984. param.setStarLevel(data.getBigDecimal("customer_starlevel"));
  985. param.setProductBizId(Integer.parseInt(productBizId));
  986. param.setBusiId(busiId);
  987. param.setSourceType(3);
  988. list.add(param);
  989. } else {
  990. log.warn("url:{} ,productBizId:{},md5:{} 获取结果失败",url,productBizId,md5);
  991. }
  992. }
  993. log.info("busiId:{} 处理数据条:{}", busiId, list.size());
  994. handleMappedData(busiId,list);
  995. }
  996. private void handleMappedData(String busiId,List<CustomerFollowup> data) {
  997. log.info("busiId:{} 【CasllBackDataProcessor】成功处理 {} 条映射数据 明细:{}",busiId, data.size(), data);
  998. String post = HttpClientThreeUtil.post(url, JSON.toJSONString(data));
  999. log.info("busiId:{}【CasllBackDataProcessor】post结果:{}",busiId, post);
  1000. }
  1001. }