From 537cdd63d9b9c1836d4af318a7d0b7e68a55fcf8 Mon Sep 17 00:00:00 2001 From: guohb Date: Tue, 2 Apr 2024 15:02:23 +0800 Subject: [PATCH] =?UTF-8?q?kdz=20->=20xfsg=20=E5=8F=91=E8=B5=B7=E6=84=8F?= =?UTF-8?q?=E5=90=91=E5=8D=8F=E8=AE=AE=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cool/store/utils/SecureUtil.java | 63 +++++++ .../com/cool/store/entity/InitiatingDO.java | 98 +++++++++++ .../cool/store/request/InitiatingRequest.java | 160 ++++++++++++++++++ .../store/response/InitiatingResponse.java | 21 +++ .../store/service/IntentAgreementService.java | 4 + .../impl/IntentAgreementServiceImpl.java | 43 +++++ .../store/utils/poi/constant/Constants.java | 5 + .../webb/PCIntentAgreementController.java | 9 + .../resources/application-local.properties | 4 +- .../resources/application-online.properties | 4 +- .../resources/application-test.properties | 4 +- 11 files changed, 412 insertions(+), 3 deletions(-) create mode 100644 coolstore-partner-common/src/main/java/com/cool/store/utils/SecureUtil.java create mode 100644 coolstore-partner-model/src/main/java/com/cool/store/entity/InitiatingDO.java create mode 100644 coolstore-partner-model/src/main/java/com/cool/store/request/InitiatingRequest.java create mode 100644 coolstore-partner-model/src/main/java/com/cool/store/response/InitiatingResponse.java diff --git a/coolstore-partner-common/src/main/java/com/cool/store/utils/SecureUtil.java b/coolstore-partner-common/src/main/java/com/cool/store/utils/SecureUtil.java new file mode 100644 index 000000000..b2f1cbc28 --- /dev/null +++ b/coolstore-partner-common/src/main/java/com/cool/store/utils/SecureUtil.java @@ -0,0 +1,63 @@ +package com.cool.store.utils; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class SecureUtil { + private static final String API_KEY = "c344cbe01972777dcfe7f9767e3d2e7f"; + private static final String API_SECRET = "fAIgCJc3kPmSzD3SgEHU"; + + /** + * 利用java原生的摘要实现SHA256加密 + * @param source 加密内容 + * @param salt 盐 + * @return + */ + public static String sha256(String source, String salt) { + String encodeStr = ""; + try { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + if (salt != null) { + digest.reset(); + digest.update(salt.getBytes("UTF-8")); + } + digest.update(source.getBytes("UTF-8")); + encodeStr = byte2Hex(digest.digest()); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return encodeStr; + } + + /** + * 将byte转为16进制 + * @param bytes + * @return + */ + private static String byte2Hex(byte[] bytes){ + StringBuffer stringBuffer = new StringBuffer(); + for (int i=0;i requestMap = new HashMap<>(); + fillSignatureInfo(requestMap); + String url = xfsgUrl + Constants.INTENTION_CONTRACT_URL + "?timestamp="+requestMap.get("timestamp") + "&signature=" + requestMap.get("signature"); + InitiatingDO initiatingDO = request.toInitiatingDO(); + LineInfoDO lineInfoDO = lineInfoMapper.getByLineId(request.getLineId()); + initiatingDO.setKdzBusinessId(lineInfoDO.getId() + "_" + lineInfoDO.getWorkflowSubStageStatus()); + InitiatingResponse initiatingResponse = httpRestTemplateService.postForObject(url, initiatingDO, InitiatingResponse.class); + return initiatingResponse; + + } + + private void fillSignatureInfo(Map requestMap) { + long timestamp = System.currentTimeMillis(); + String signature = SecureUtil.getSignature(timestamp); + requestMap.put("timestamp", timestamp); + requestMap.put("signature", signature); + } } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/utils/poi/constant/Constants.java b/coolstore-partner-service/src/main/java/com/cool/store/utils/poi/constant/Constants.java index 65536d4a0..f20a3b69e 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/utils/poi/constant/Constants.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/utils/poi/constant/Constants.java @@ -167,4 +167,9 @@ public class Constants public static final String CONTENT_ENCODING = "Content-Encoding"; + public static final String INTENTION_CONTRACT_URL = "/api/coolstore/start-flow/intention-contract"; + + + + } diff --git a/coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PCIntentAgreementController.java b/coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PCIntentAgreementController.java index 02979f2db..295a43155 100644 --- a/coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PCIntentAgreementController.java +++ b/coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PCIntentAgreementController.java @@ -1,5 +1,7 @@ package com.cool.store.controller.webb; +import com.cool.store.request.InitiatingRequest; +import com.cool.store.response.InitiatingResponse; import com.cool.store.response.ResponseResult; import com.cool.store.response.SigningBaseInfoResponse; import com.cool.store.service.IntentAgreementService; @@ -27,4 +29,11 @@ public class PCIntentAgreementController { SigningBaseInfoResponse resp = intentAgreementService.getMiniIntentAgreement(partnerId, lineId); return ResponseResult.success(resp); } + + @PostMapping(path = "/initiating") + @ApiOperation("kdz -> xfsg 发起意向协议流程") + public ResponseResult initiating(@RequestParam + @RequestBody InitiatingRequest request) { + return ResponseResult.success(intentAgreementService.initiating(request)); + } } diff --git a/coolstore-partner-web/src/main/resources/application-local.properties b/coolstore-partner-web/src/main/resources/application-local.properties index b3c29452c..f70348bd0 100644 --- a/coolstore-partner-web/src/main/resources/application-local.properties +++ b/coolstore-partner-web/src/main/resources/application-local.properties @@ -74,4 +74,6 @@ wx.pay.privateKeyPath=D:\\weixin\\apiclient_key.pem aliyun.accessKeyId=LTAI5tQ6QBnWaB5LaJYz6zcD aliyun.accessKeySecret=spqsOgtfr54cwK861O3N3fInydTgjA -coolstore.page.domain=https://t2store.coolstore.cn/ \ No newline at end of file +coolstore.page.domain=https://t2store.coolstore.cn/ + +xfsg.url=https://inf-test.xianfengsg.com/InfService \ No newline at end of file diff --git a/coolstore-partner-web/src/main/resources/application-online.properties b/coolstore-partner-web/src/main/resources/application-online.properties index 0b57d5bb4..16379e74a 100644 --- a/coolstore-partner-web/src/main/resources/application-online.properties +++ b/coolstore-partner-web/src/main/resources/application-online.properties @@ -77,4 +77,6 @@ xxl.job.executor.logretentiondays=3 xxl.job.accessToken=25365115eed84e9ba5e0040abb255a09 exhibition.channel.id=52399 -recommended.channel.id=52400 \ No newline at end of file +recommended.channel.id=52400 + +xfsg.url=https://inf-test.xianfengsg.com/InfService \ No newline at end of file diff --git a/coolstore-partner-web/src/main/resources/application-test.properties b/coolstore-partner-web/src/main/resources/application-test.properties index e94418c21..c292ce1c2 100644 --- a/coolstore-partner-web/src/main/resources/application-test.properties +++ b/coolstore-partner-web/src/main/resources/application-test.properties @@ -79,4 +79,6 @@ xxl.job.accessToken = exhibition.channel.id=52399 recommended.channel.id=52400 -coolstore.page.domain=https://t2store.coolstore.cn/ \ No newline at end of file +coolstore.page.domain=https://t2store.coolstore.cn/ + +xfsg.url=https://inf-test.xianfengsg.com/InfService \ No newline at end of file