From f563ada63ac903d087bf884705c376c9cf1384b3 Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期三, 04 九月 2024 17:59:23 +0800 Subject: [PATCH] 代码提交 --- server/service/src/main/java/com/doumee/biz/zbom/ZbomCRMService.java | 2 server/service/src/main/java/com/doumee/core/utils/Constants.java | 6 +++ server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomCRMServiceImpl.java | 65 +++++++++++++++++++++++++++++--- server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java | 5 ++ server/service/src/main/java/com/doumee/biz/zbom/model/crm/CRMConstants.java | 2 5 files changed, 71 insertions(+), 9 deletions(-) diff --git a/server/service/src/main/java/com/doumee/biz/zbom/ZbomCRMService.java b/server/service/src/main/java/com/doumee/biz/zbom/ZbomCRMService.java index f8babe7..2817f00 100644 --- a/server/service/src/main/java/com/doumee/biz/zbom/ZbomCRMService.java +++ b/server/service/src/main/java/com/doumee/biz/zbom/ZbomCRMService.java @@ -22,7 +22,7 @@ void dealCustomerLogData(CustomerLog customerLog); String zbomEncode(String str); - String getCrmGoUrl(String userName,Integer type); + String getCrmGoUrl(String userName,Integer type,String iamId); CRMBaseResponse<List<CRMCustomerListResponse>> getCustomerList(CrmCustomerListRequest entity ); CRMBaseResponse<List<CRMDaogouBindListResponse>> getDaogouBindList(CrmDaogouBindListRequest entity ); 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 60da93d..eb481d1 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 @@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.doumee.biz.system.SystemDictDataBiz; import com.doumee.biz.zbom.ZbomCRMService; import com.doumee.biz.zbom.model.crm.*; import com.doumee.biz.zbom.model.crm.response.CRMBaseResponse; @@ -17,14 +18,22 @@ import com.doumee.dao.business.CustomerLogMapper; import com.doumee.dao.business.model.CrmInterfaceLog; import com.doumee.dao.business.model.CustomerLog; +import com.doumee.dao.business.model.Member; +import com.doumee.dao.business.model.Users; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.util.Base64Util; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.util.Base64Utils; +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.*; @@ -43,6 +52,8 @@ private CrmInterfaceLogMapper crmInterfaceLogMapper; @Autowired private RedisTemplate<String, Object> redisTemplate; + @Autowired + private SystemDictDataBiz systemDictDataBiz; @@ -244,24 +255,66 @@ * @return */ @Override - public String getCrmGoUrl(String userName,Integer type){ + public String getCrmGoUrl(String userName,Integer type,String iamId){ try { // 鍒涘缓StringBuffer瀵硅薄鐢ㄦ潵鎿嶄綔瀛楃涓� int _t = (int)(System.currentTimeMillis()); String pageKey ="mp";//瀹㈡埛鍒楄〃椤甸潰鐮� + String fileUrl = systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_CRM_API_URL_MP).getCode(); if(Constants.equalsInteger(type,Constants.ONE)){ pageKey = "mpAddIntention";//鏂板鎰忓悜椤甸潰鐮� + fileUrl = systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_CRM_API_URL_MP_ADDINTENTION).getCode(); } - String appkey = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_CRM_AUTH_API_KEY); String url = 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="+pageKey+"&sign="+ DigestUtils.md5Hex( _t + appkey);; + + CRMConstants.IntegerUrl.GO_CRM_AUTH_URL + + "?bindKey="+pageKey + + "&tick=" + this.getTick(iamId, fileUrl); return url; }catch (Exception e){ e.printStackTrace(); } throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鑾峰彇璺宠浆鍦板潃澶辫触鍝︼紒"); } + + public String getTick(String iamId, String fileUrL) throws UnsupportedEncodingException { + Map<String,Object> map = new HashMap<>(); + //鐢ㄦ埛IAM涓婚敭 + map.put("ssouserid",iamId); + //鍞墠灏忕▼搴廰ppid + map.put("appid",systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_IAM_BUSINESS_APPID).getCode()); + //璺宠浆鍦板潃 + map.put("rediUrl",fileUrL); + //鏃堕棿鎴� + map.put("timestamp",System.currentTimeMillis()/1000+""); + //C绔皬绋嬪簭appid + map.put("sourceappid",systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_IAM_CUSTOMER_APPID).getCode()); + System.out.println(JSONObject.toJSONString(map)); + //鑾峰彇tick + String tick = ZbomCRMServiceImpl.encrypt( + systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_CRM_API_URL_PRIVATE_KEY).getCode() + ,JSONObject.toJSONString(map) + ,systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_CRM_API_URL_INIT_VECTOR).getCode()); + + String tickEncoder = URLEncoder.encode(tick,"UTF-8"); + + return tickEncoder; + } + + + public static String encrypt(String key, String value,String initVector) { + try { + IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8")); + SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); + cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); + byte[] encrypted = cipher.doFinal(value.getBytes()); + return Base64Utils.encodeToString(encrypted); + } + catch (Exception ex) { + ex.printStackTrace(); + } + return null; + } + + } diff --git a/server/service/src/main/java/com/doumee/biz/zbom/model/crm/CRMConstants.java b/server/service/src/main/java/com/doumee/biz/zbom/model/crm/CRMConstants.java index 21710ea..e7b321c 100644 --- a/server/service/src/main/java/com/doumee/biz/zbom/model/crm/CRMConstants.java +++ b/server/service/src/main/java/com/doumee/biz/zbom/model/crm/CRMConstants.java @@ -16,7 +16,7 @@ String POST_CUS_DATA_URL ="/api/public/zbom/postCusData"; String CUS_BEFORE_PAGE_LIST_URL ="/api/public/mini/program/cusOrBeforeList"; String DAOGOU_BIND_LIST_URL ="/api/public/mini/program/list"; - String GO_CRM_AUTH_URL ="/oauth/authorize/jump"; + String GO_CRM_AUTH_URL = "/oauth/authorize";//"/oauth/authorize/jump"; } public interface IntegerName{ diff --git a/server/service/src/main/java/com/doumee/core/utils/Constants.java b/server/service/src/main/java/com/doumee/core/utils/Constants.java index babd1ad..5c23d53 100644 --- a/server/service/src/main/java/com/doumee/core/utils/Constants.java +++ b/server/service/src/main/java/com/doumee/core/utils/Constants.java @@ -379,6 +379,12 @@ public static final String WX_TOKEN_CUSTOMER = "WX_TOKEN_CUSTOMER"; public static final String WX_TOKEN_PERSONNEL = "WX_TOKEN_PERSONNEL"; public static final String ZBOM_CRM_POSTCUS_API_KEY = "ZBOM_CRM_POSTCUS_API_KEY"; + public static final String ZBOM_CRM_API_URL_MP = "ZBOM_CRM_API_URL_MP"; + public static final String ZBOM_CRM_API_URL_MP_ADDINTENTION = "ZBOM_CRM_API_URL_MP_ADDINTENTION"; + public static final String ZBOM_CRM_API_URL_PRIVATE_KEY = "ZBOM_CRM_API_URL_PRIVATE_KEY"; + public static final String ZBOM_CRM_API_URL_INIT_VECTOR = "ZBOM_CRM_API_URL_INIT_VECTOR"; + public static final String ZBOM_IAM_CUSTOMER_APPID = "ZBOM_IAM_CUSTOMER_APPID"; + public static final String ZBOM_IAM_BUSINESS_APPID = "ZBOM_IAM_BUSINESS_APPID"; public interface RedisKeys { diff --git a/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java b/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java index f6a361d..4b2d588 100644 --- a/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java +++ b/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java @@ -13,10 +13,12 @@ import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.model.ApiResponse; +import com.doumee.core.model.LoginUserInfo; import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.core.utils.Constants; import com.doumee.dao.business.model.News; +import com.doumee.dao.business.model.Users; import com.doumee.dao.web.reqeust.GenerateQRCodeRequest; import com.doumee.dao.web.response.DailyUpdatesResponse; import com.doumee.dao.web.response.ZSZXCatalogResponse; @@ -120,7 +122,8 @@ @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "type", value = "绫诲瀷 0瀹㈡埛鍒楄〃 1璺宠浆鏂板鎰忓悜瀹㈡埛", required = true) }) public ApiResponse<String> getCrmAuthUrl(@RequestParam Integer type) { - return ApiResponse.success(zbomCRMService.getCrmGoUrl(this.getLoginUserInfo().getIamUsername(),type)); + Users users = this.getLoginUserInfo(); + return ApiResponse.success(zbomCRMService.getCrmGoUrl(users.getIamUsername(),type,users.getIamId())); } -- Gitblit v1.9.3