From 400bbe6e0f24fb383263d94cade6884a33e7992c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E9=B9=8F=E8=BE=89?= <18322780655@163.com> Date: Wed, 14 Jun 2023 17:54:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0pos=20=E6=9C=BA=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/task/LklMerAuditHandler.java | 218 ++++++++++-------- 1 file changed, 117 insertions(+), 101 deletions(-) diff --git a/pluss-service-bundle/src/main/java/cn/pluss/platform/task/LklMerAuditHandler.java b/pluss-service-bundle/src/main/java/cn/pluss/platform/task/LklMerAuditHandler.java index 527360f..ed528d4 100644 --- a/pluss-service-bundle/src/main/java/cn/pluss/platform/task/LklMerAuditHandler.java +++ b/pluss-service-bundle/src/main/java/cn/pluss/platform/task/LklMerAuditHandler.java @@ -42,7 +42,7 @@ import java.util.Map; @Slf4j @Component @RequiredArgsConstructor -public class LklMerAuditHandler{ +public class LklMerAuditHandler { @Setter(onMethod_ = {@Lazy, @Autowired}) @@ -61,7 +61,6 @@ public class LklMerAuditHandler{ private MerchantBaseInfoService merchantBaseInfoService; - @Setter(onMethod_ = {@Autowired, @Lazy}) private MerchantCashPlaceService cashPlaceService; @@ -70,13 +69,12 @@ public class LklMerAuditHandler{ private MerchantAuditRecordService merchantAuditRecordService; - private final UserAppMapper userAppMapper; private final UserInfoMapper userInfoMapper; private final MerchantStoreMapper merchantStoreMapper; private final MerchantImageMapper merchantImageMapper; - private final LaKalaInterfaceImpl laKalaInterface; + private final LaKalaInterfaceImpl laKalaInterface; private final RestTemplate restTemplate; @@ -100,28 +98,29 @@ public class LklMerAuditHandler{ private MerchantChannelFeeMapper merchantChannelFeeMapper; - - public void auditHandler(Map map) { + public void auditHandler(Map map) { execute(map); } - public void execute(Map map) { + public void execute(Map map) { - if(ObjectUtil.isEmpty(map)||!map.containsKey("status")){ + if (ObjectUtil.isEmpty(map) || !map.containsKey("status")) { log.error("回调数据为空"); return; } - if("SUCCESS".equals(map.get("status").toString())||"REVIEW_PASS".equals(map.get("status").toString())){ - - MerchantChannelStatus mcs = self.auditCallback(map); + MerchantChannelStatus mcs = self.auditCallback(map); + if (ObjectUtil.isNotEmpty(mcs)) { try { + log.info("===================>进件回调,创建店铺开始,商户编号mno为:{}<=====================", map.get("customerNo").toString()); self.createStore(mcs); + + } catch (Exception e) { e.printStackTrace(); log.info("创建店铺信息异常,异常信息:{}", e.getMessage()); @@ -137,117 +136,135 @@ public class LklMerAuditHandler{ } } - } - - - - - - - public MerchantChannelStatus queryMerchatChannelstatus(String customerNo,String externalCustomerNo ){ - Map map= laKalaInterface.queryMerchat(customerNo, externalCustomerNo); - if(ObjectUtil.isEmpty(map)){ - return null; - } - if(map.containsKey("code")&&"000000".equals(map.get("code").toString())&&map.containsKey("data")&&ObjectUtil.isNotEmpty(map.get("data"))){ - String data = LaKaLaUtility.decrypt(lakalaConfig.getPubKey(),map.get("data").toString()); - JSONObject object=JSONObject.parseObject(data); - Map reqMap=new HashMap<>(); - - reqMap.put("customerNo",object.getJSONObject("customer").getString("customerNo")); - reqMap.put("contractId","query".concat(object.getJSONObject("customer").getString("openTime"))); - reqMap.put("userNo",LaKalaInterfaceImpl.userNo); - reqMap.put("externalCustomerNo",object.getJSONObject("customer").getString("externalCustomerNo")); - reqMap.put("termNos",object.getJSONObject("customer").getString("termNo")); - - reqMap.put("agencyNo",object.getJSONObject("customer").getString("agencyNo")); - reqMap.put("activeNo",object.getJSONObject("customer").getString("activeNo")); - reqMap.put("coreTermIds",object.getJSONArray("terminalInfo").toString()); - - return auditCallback(reqMap); - - } - return null; } + public MerchantChannelStatus queryMerchatChannelstatus(String customerNo, String externalCustomerNo) { + Map map = laKalaInterface.queryMerchat(customerNo, externalCustomerNo); + if (ObjectUtil.isEmpty(map)) { + return null; + } + if (map.containsKey("code") && "000000".equals(map.get("code").toString()) && map.containsKey("data") && ObjectUtil.isNotEmpty(map.get("data"))) { + String data = LaKaLaUtility.decrypt(lakalaConfig.getPubKey(), map.get("data").toString()); + JSONObject object = JSONObject.parseObject(data); + Map reqMap = new HashMap<>(); + + reqMap.put("customerNo", object.getJSONObject("customer").getString("customerNo")); + reqMap.put("contractId", "query".concat(object.getJSONObject("customer").getString("openTime"))); + reqMap.put("userNo", LaKalaInterfaceImpl.userNo); + reqMap.put("externalCustomerNo", object.getJSONObject("customer").getString("externalCustomerNo")); + reqMap.put("termNos", object.getJSONObject("customer").getString("termNo")); + + reqMap.put("agencyNo", object.getJSONObject("customer").getString("agencyNo")); + reqMap.put("activeNo", object.getJSONObject("customer").getString("activeNo")); + reqMap.put("coreTermIds", object.getJSONArray("terminalInfo").toString()); + + return auditCallback(reqMap); + + } + return null; + + } + @Transactional(rollbackFor = Exception.class) - public MerchantChannelStatus auditCallback(Map map) { + public MerchantChannelStatus auditCallback(Map map) { MerchantChannelStatus merchantChannelStatus = new MerchantChannelStatus() .setChannel(5) .setMerchantId(map.get("customerNo").toString()); merchantChannelStatus = mcsMapper.selectOne(new QueryWrapper<>(merchantChannelStatus)); - if(merchantChannelStatus.getStatus().equals("3")){ + if (merchantChannelStatus.getStatus().equals("3")) { log.error("此商户已经审核完成"); return merchantChannelStatus; } - merchantChannelStatus.setApplicationId(map.get("contractId").toString()); - merchantChannelStatus.setStatus("3"); - merchantChannelStatus.setExtra(JSONObject.parseObject("{\n" + - "\t\"code\": \"SUCCESS\",\n" + - "\t\"msg\": \"成功\"\n" + - "}")); - merchantChannelStatus.setRemark("成功"); - merchantChannelStatus.setUpdateTime(new Date()); + if ("SUCCESS".equals(map.get("status").toString()) || "REVIEW_PASS".equals(map.get("status").toString())) { + merchantChannelStatus.setApplicationId(map.get("contractId").toString()); + merchantChannelStatus.setStatus("3"); + merchantChannelStatus.setExtra(JSONObject.parseObject("{\n" + + "\t\"code\": \"SUCCESS\",\n" + + "\t\"msg\": \"成功\"\n" + + "}")); + merchantChannelStatus.setRemark("成功"); + merchantChannelStatus.setUpdateTime(new Date()); - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.eq("merchant_code",merchantChannelStatus.getMerchantCode()); - queryWrapper.eq("merchant_id",map.get("customerNo").toString()); - queryWrapper.eq("channel","5"); - queryWrapper.eq("user_no",map.get("userNo").toString()); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("merchant_code", merchantChannelStatus.getMerchantCode()); + queryWrapper.eq("merchant_id", map.get("customerNo").toString()); + queryWrapper.eq("channel", "5"); + queryWrapper.eq("user_no", map.get("userNo").toString()); + + MerchantBackLkl merchantBackLkl = backLklMapper.selectOne(queryWrapper); + if (ObjectUtil.isEmpty(merchantBackLkl)) { + merchantBackLkl = new MerchantBackLkl(); + merchantBackLkl.setMerchantCode(merchantChannelStatus.getMerchantCode()); + merchantBackLkl.setMerchantId(map.get("customerNo").toString()); + merchantBackLkl.setChannel("5"); + merchantBackLkl.setUserNo(map.get("userNo").toString()); + merchantBackLkl.setCustomerNo(map.get("customerNo").toString()); + merchantBackLkl.setExternalCustomerNo(map.get("externalCustomerNo").toString()); + merchantBackLkl.setTermNos(map.get("termNos").toString()); + merchantBackLkl.setAgencyNo(map.get("agencyNo").toString()); + merchantBackLkl.setActiveNo(map.get("activeNo").toString()); + merchantBackLkl.setContractId(map.get("contractId").toString()); + merchantBackLkl.setCoreTermIds(map.get("coreTermIds").toString()); + merchantBackLkl.setCreateTime(new Date()); + backLklMapper.insert(merchantBackLkl); + } + + + MerchantAuditRecord lastRecord = merchantAuditRecordService.getLastRecord(merchantChannelStatus.getMerchantCode()); + if (lastRecord != null) { + lastRecord.setStatus(merchantChannelStatus.getStatus()); + lastRecord.setThirdStatus("1"); + lastRecord.setRemark("成功"); + merchantAuditRecordService.updateById(lastRecord); + mcsMapper.updateById(merchantChannelStatus); + } + + + QueryWrapper queryWrapper1 = new QueryWrapper<>(); + queryWrapper1.eq("merchantCode", merchantChannelStatus.getMerchantCode()); + + MerchantBaseInfo baseInfo = merchantBaseInfoService.getOne(queryWrapper1); + if (ObjectUtil.isNotEmpty(baseInfo)) { + LambdaQueryWrapper qWrapper2 = Wrappers.lambdaQuery(); + qWrapper2.eq(UserApp::getUserId, baseInfo.getUserId()); + UserApp userApp = uaService.getOne(qWrapper2); + sendNotice(userApp, "收银呗审核通知", "拉卡拉进件成功", merchantChannelStatus.getApplicationId()); + } + return merchantChannelStatus; + + } else { + merchantChannelStatus.setApplicationId(map.get("contractId").toString()); + merchantChannelStatus.setStatus("2"); + merchantChannelStatus.setExtra(JSONObject.parseObject("{\n" + + "\t\"code\": \"" + map.get("status") + "\",\n" + + "\t\"msg\": \"" + map.get("remark") + "\"\n" + + "}")); + merchantChannelStatus.setRemark("成功"); + merchantChannelStatus.setUpdateTime(new Date()); + + MerchantAuditRecord lastRecord = merchantAuditRecordService.getLastRecord(merchantChannelStatus.getMerchantCode()); + if (lastRecord != null) { + lastRecord.setStatus("2"); + lastRecord.setThirdStatus("1"); + lastRecord.setRemark(map.get("remark") + ""); + merchantAuditRecordService.updateById(lastRecord); + mcsMapper.updateById(merchantChannelStatus); + } + + + return null; - MerchantBackLkl merchantBackLkl= backLklMapper.selectOne(queryWrapper); - if(ObjectUtil.isEmpty(merchantBackLkl)){ - merchantBackLkl=new MerchantBackLkl(); - merchantBackLkl.setMerchantCode(merchantChannelStatus.getMerchantCode()); - merchantBackLkl.setMerchantId(map.get("customerNo").toString()); - merchantBackLkl.setChannel("5"); - merchantBackLkl.setUserNo(map.get("userNo").toString()); - merchantBackLkl.setCustomerNo(map.get("customerNo").toString()); - merchantBackLkl.setExternalCustomerNo(map.get("externalCustomerNo").toString()); - merchantBackLkl.setTermNos(map.get("termNos").toString()); - merchantBackLkl.setAgencyNo(map.get("agencyNo").toString()); - merchantBackLkl.setActiveNo(map.get("activeNo").toString()); - merchantBackLkl.setContractId(map.get("contractId").toString()); - merchantBackLkl.setCoreTermIds(map.get("coreTermIds").toString()); - merchantBackLkl.setCreateTime(new Date()); - backLklMapper.insert(merchantBackLkl); } - - - - MerchantAuditRecord lastRecord = merchantAuditRecordService.getLastRecord(merchantChannelStatus.getMerchantCode()); - if (lastRecord != null) { - lastRecord.setStatus(merchantChannelStatus.getStatus()); - lastRecord.setThirdStatus("1"); - lastRecord.setRemark("成功"); - merchantAuditRecordService.updateById(lastRecord); - mcsMapper.updateById(merchantChannelStatus); - } - - - QueryWrapper queryWrapper1=new QueryWrapper<>(); - queryWrapper1.eq("merchantCode",merchantChannelStatus.getMerchantCode()); - - MerchantBaseInfo baseInfo=merchantBaseInfoService.getOne(queryWrapper1); - if(ObjectUtil.isNotEmpty(baseInfo)){ - LambdaQueryWrapper qWrapper2 = Wrappers.lambdaQuery(); - qWrapper2.eq(UserApp::getUserId, baseInfo.getUserId()); - UserApp userApp = uaService.getOne(qWrapper2); - sendNotice(userApp, "收银呗审核通知","拉卡拉进件成功",merchantChannelStatus.getApplicationId()); - } - return merchantChannelStatus; } - - public void createStore(MerchantChannelStatus merchantChannelStatus) { // if (!"4".equals(merchantChannelStatus.getStatus()) && !"3".equals(merchantChannelStatus.getStatus())) { // return; @@ -271,7 +288,7 @@ public class LklMerAuditHandler{ sb.append("&syb_m_id=").append(merchantStore.getId()); sb.append("&addressNo=").append(merchantBaseInfo.getAddressNo()); String address = merchantBaseInfo.getProvince() + merchantBaseInfo.getCity() + merchantBaseInfo.getDistrict() + merchantBaseInfo.getAddress(); - String area = merchantBaseInfo.getProvince() +"-"+ merchantBaseInfo.getCity() +"-"+ merchantBaseInfo.getDistrict(); + String area = merchantBaseInfo.getProvince() + "-" + merchantBaseInfo.getCity() + "-" + merchantBaseInfo.getDistrict(); try { String decodeAddress = URLEncoder.encode(address, "UTF-8"); sb.append("&address=").append(decodeAddress); @@ -295,7 +312,6 @@ public class LklMerAuditHandler{ } - public void sendNotice(UserApp userApp, String title, String msg, String uniqueKey) { Notice notice = new Notice(1, 1, userApp); notice.setNoticeCode(uniqueKey);