From 520219f63a2ced43bfb3a02028d0a7896f0e4d2f Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期一, 15 七月 2024 16:06:46 +0800 Subject: [PATCH] 提交 --- server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomCRMServiceImpl.java | 82 ++++++++++++++++++++++++++++++++++++---- 1 files changed, 73 insertions(+), 9 deletions(-) diff --git a/server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomCRMServiceImpl.java b/server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomCRMServiceImpl.java index c360fb8..89a91a3 100644 --- a/server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomCRMServiceImpl.java +++ b/server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomCRMServiceImpl.java @@ -4,15 +4,14 @@ import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.doumee.biz.zbom.ZbomCRMService; -import com.doumee.biz.zbom.model.crm.CRMConstants; -import com.doumee.biz.zbom.model.crm.CrmCustomerInfoRequest; -import com.doumee.biz.zbom.model.crm.CrmCustomerListRequest; -import com.doumee.biz.zbom.model.crm.CrmDaogouBindListRequest; +import com.doumee.biz.zbom.model.crm.*; import com.doumee.biz.zbom.model.crm.response.CRMBaseResponse; import com.doumee.biz.zbom.model.crm.response.CRMCustomerListResponse; import com.doumee.biz.zbom.model.crm.response.CRMDaogouBindListResponse; import com.doumee.biz.zbom.model.zhongtai.ZTConstants; import com.doumee.biz.zbom.model.zhongtai.response.ZTBaseResponse; +import com.doumee.core.constants.ResponseStatus; +import com.doumee.core.exception.BusinessException; import com.doumee.core.utils.Constants; import com.doumee.core.utils.DateUtil; import com.doumee.core.utils.HttpsUtil; @@ -70,13 +69,23 @@ entity.setAreaname(customerLog.getAreaName()); entity.setAreacode(customerLog.getAreaCode()); entity.setOpenid(customerLog.getOpenid()); - entity.setSource(CRMConstants.CRM_SOURCE.SOURCE_ZBJX); - entity.setChannel(CRMConstants.CRM_SOURCE.SOURCE_ZBJX+"00"); +// 鎻愪氦绫诲瀷 0-娴嬭瘯瑁呬慨椋庢牸锛�1-0鍏冨畾鍒讹紱2瑁呬慨璁$畻鍣� + if(Constants.equalsInteger(customerLog.getType(),Constants.ONE)){ + entity.setSource(CRMConstants.CRM_SOURCE.SOURCE_MP01); + entity.setChannel(CRMConstants.CRM_SOURCE.SOURCE_MP01+"00"); + }else{ + entity.setSource(CRMConstants.CRM_SOURCE.SOURCE_MP02); + entity.setChannel(CRMConstants.CRM_SOURCE.SOURCE_MP02+"00"); + } + entity.setOpenId(customerLog.getOpenid()); entity.setDate(DateUtil.dateToString(customerLog.getCreateDate(),"yyyy/MM/dd HH:mm")); + CrmCustomerPostRequest obj = new CrmCustomerPostRequest(); + obj.setCusInfo(new ArrayList<>()); + obj.getCusInfo().add(entity); int status ; String crmInfo; - String param = JSONObject.toJSONString(entity); - CRMBaseResponse result = sendHttpRequest(CRMConstants.IntegerUrl.POST_CUS_DATA_URL,CRMConstants.IntegerName.POST_CUS_DATA_NAME,param); + String param = JSONObject.toJSONString(obj); + CRMBaseResponse result = sendCusHttpRequest(CRMConstants.IntegerUrl.POST_CUS_DATA_URL,CRMConstants.IntegerName.POST_CUS_DATA_NAME,param); if (result != null && (StringUtils.equalsIgnoreCase(result.getCode(), CRMConstants.CODE_SUCCESS))) { status = 1; crmInfo="鎻愪氦鎴愬姛"; @@ -119,6 +128,36 @@ return result;// 榛樿澶辫触 } + public <T> CRMBaseResponse<T> sendCusHttpRequest(String interfaceUrl, String name, String param){ + log.info("銆�"+name+"銆�================寮�濮�===="+ JSONObject.toJSONString(param)); + String appKey = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_CRM_API_KEY); + String url = redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_CRM_API_URL) + interfaceUrl ; + long _t = System.currentTimeMillis(); + if (StringUtils.isNotBlank(appKey)||StringUtils.isNotBlank(url)) { + String res = null; + int success = 0; + try { + url += "?type=postCusData&_t=" + _t + "&token=" + DigestUtils.md5Hex( "postCusData" + _t + appKey); + Map<String,String> headers = new HashMap<>(); + res = HttpsUtil.postJson(url,param); + TypeReference typeReference = + new TypeReference<CRMBaseResponse<T>>(){}; + CRMBaseResponse<T> result = JSONObject.parseObject(res, typeReference.getType()); + logResult(result,name); + if(StringUtils.equals(result.getCode(),CRMConstants.CODE_SUCCESS)){ + return result; + }else{ + success =1; + } + }catch (Exception e){ + success = 1; + log.error("銆�"+name+"銆�================澶辫触===="+ JSONObject.toJSONString(param)); + }finally { + saveInterfaceLog(url,name,param,success,res); + } + } + return null; + } public <T> CRMBaseResponse<T> sendHttpRequest(String interfaceUrl, String name, String param){ log.info("銆�"+name+"銆�================寮�濮�===="+ JSONObject.toJSONString(param)); String appKey = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_CRM_API_KEY); @@ -130,7 +169,6 @@ try { url += "?timestamp=" + _t + "&sign=" + DigestUtils.md5Hex( _t + appKey); Map<String,String> headers = new HashMap<>(); - String index = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_ZHONGTAI_API_URL); res = HttpsUtil.postJson(url,param); TypeReference typeReference = new TypeReference<CRMBaseResponse<T>>(){}; @@ -199,4 +237,30 @@ } return result; } + + /** + * 璺宠浆crm鍔熻兘 鑾峰彇鎺堟潈鍦板潃 + * http://localhost:8080/core/oauth/authorize/jump?timestamp=1719998741&sign=41fbeb13965c43916876db7b5799e8ac&agent_phone_number=199077&bindKey=mp + * @param userName + * @return + */ + @Override + public String getCrmGoUrl(String userName){ + StringBuffer sb = new StringBuffer(); + String result = null; + try { + // 鍒涘缓StringBuffer瀵硅薄鐢ㄦ潵鎿嶄綔瀛楃涓� + int _t = (int)(System.currentTimeMillis()); + String appkey = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_CRM_AUTH_API_KEY); + String url = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_CRM_API_URL) + +CRMConstants.IntegerUrl.GO_CRM_AUTH_URL + + "?timestamp="+_t + +"&agent_phone_number=" + URLEncoder.encode(userName, "UTF-8") + + "&bindKey=mp&sign="+ DigestUtils.md5Hex( _t + appkey);; + return url; + }catch (Exception e){ + e.printStackTrace(); + } + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鑾峰彇璺宠浆鍦板潃澶辫触鍝︼紒"); + } } -- Gitblit v1.9.3