添加pos 机退款接口

This commit is contained in:
韩鹏辉 2023-06-14 17:54:49 +08:00
parent f864f69d03
commit 400bbe6e0f
1 changed files with 117 additions and 101 deletions

View File

@ -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<String,Object> map) {
public void auditHandler(Map<String, Object> map) {
execute(map);
}
public void execute(Map<String,Object> map) {
public void execute(Map<String, Object> 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<String,Object> 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<String, Object> 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<String,Object> map) {
public MerchantChannelStatus auditCallback(Map<String, Object> 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<MerchantBackLkl> 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<MerchantBackLkl> 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<MerchantBaseInfo> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("merchantCode", merchantChannelStatus.getMerchantCode());
MerchantBaseInfo baseInfo = merchantBaseInfoService.getOne(queryWrapper1);
if (ObjectUtil.isNotEmpty(baseInfo)) {
LambdaQueryWrapper<UserApp> 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<MerchantBaseInfo> queryWrapper1=new QueryWrapper<>();
queryWrapper1.eq("merchantCode",merchantChannelStatus.getMerchantCode());
MerchantBaseInfo baseInfo=merchantBaseInfoService.getOne(queryWrapper1);
if(ObjectUtil.isNotEmpty(baseInfo)){
LambdaQueryWrapper<UserApp> 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);