|
@@ -98,7 +98,7 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
wxCbPayDocs.forEach(wxCbPayDoc -> {
|
|
|
WxQuerySuccessResponseMsgDto querySuccessResponseDto = new WxQuerySuccessResponseMsgDto();
|
|
|
//获取商户信息 从缓存中去 缓存不存在 从数据库重取
|
|
|
- MerchPayCfg merchPayCfg = getMerchPayCfgCache(wxCbPayDoc.getMerchSn());
|
|
|
+ MerchPayCfg merchPayCfg = getMerchPayCfgCache(wxCbPayDoc.getAppid());
|
|
|
|
|
|
MerchNotiBuilder builder = new MerchNotiBuilder();
|
|
|
|
|
@@ -109,17 +109,17 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
|
|
|
if (merchPayCfg == null) {
|
|
|
wxCbPayDoc.setReturnCode("FAIL");
|
|
|
- wxCbPayDoc.setReturnMsg("商户编号为【"+wxCbPayDoc.getMerchSn()+"】的商户支付配置信息不存在");
|
|
|
+ wxCbPayDoc.setReturnMsg("appid为【"+wxCbPayDoc.getAppid()+"】的商户支付配置信息不存在");
|
|
|
wxCbPayDocService.updateWxCbPay(wxCbPayDoc);
|
|
|
- logger.error("商户编号为【"+wxCbPayDoc.getMerchSn()+"】的商户支付配置信息不存在 ");
|
|
|
+ logger.error("appid为【"+wxCbPayDoc.getAppid()+"】的商户支付配置信息不存在 ");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (merchPayCfg.getMerchWxApiKey() == null) {
|
|
|
wxCbPayDoc.setReturnCode(WxContants.ERROR_NO_INFOMATION);
|
|
|
- wxCbPayDoc.setReturnMsg("商户编号为【"+wxCbPayDoc.getMerchSn()+"】的商户支付信息api密钥为空");
|
|
|
+ wxCbPayDoc.setReturnMsg("appid为【"+wxCbPayDoc.getAppid()+"】的商户支付信息api密钥为空");
|
|
|
wxCbPayDocService.updateWxCbPay(wxCbPayDoc);
|
|
|
- logger.error("商户编号为【"+wxCbPayDoc.getMerchSn()+"】的商户支付信息api密钥为空 ");
|
|
|
+ logger.error("appid为【"+wxCbPayDoc.getAppid()+"】的商户支付信息api密钥为空 ");
|
|
|
return;
|
|
|
}
|
|
|
//设置商户配置信息
|
|
@@ -149,6 +149,8 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
errorList.add(wxPayError);
|
|
|
}
|
|
|
MerchNoti merchNoti = new MerchNoti();
|
|
|
+ String allSubOrderId = "";
|
|
|
+ String allSubOrderNo = "";
|
|
|
try {
|
|
|
//返回状态码为成功
|
|
|
if(WxContants.SUCCESS.equals(wxQueryResponseMsg.getReturnCode())){
|
|
@@ -184,6 +186,7 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
//解析xml获取WxQuerySuccessResponseMsgDto
|
|
|
querySuccessResponseDto = ReaderXmlForDOM4J.parse(result, i);
|
|
|
wxCbPayDoc.setSubOrderNo(querySuccessResponseDto.getSubOrderNo());
|
|
|
+ wxCbPayDoc.setSubOrderId(querySuccessResponseDto.getSubOrderId());
|
|
|
wxCbPayDoc.setMchCustomsNo(querySuccessResponseDto.getMchCustomsNo());
|
|
|
wxCbPayDoc.setCustoms(querySuccessResponseDto.getCustoms());
|
|
|
wxCbPayDoc.setFeeType(querySuccessResponseDto.getFeeType());
|
|
@@ -191,6 +194,8 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
wxCbPayDoc.setDuty(querySuccessResponseDto.getDuty());
|
|
|
wxCbPayDoc.setTransportFee(querySuccessResponseDto.getTransportFee());
|
|
|
wxCbPayDoc.setProductFee(querySuccessResponseDto.getProductFee());
|
|
|
+ allSubOrderId = querySuccessResponseDto.getSubOrderId();
|
|
|
+ allSubOrderNo = querySuccessResponseDto.getSubOrderNo();
|
|
|
|
|
|
String state = querySuccessResponseDto.getState();
|
|
|
|
|
@@ -232,6 +237,14 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
.cusDeclStatus(WxDict.MerchNoticeStatus.i_13.getItem())
|
|
|
.build();
|
|
|
}
|
|
|
+ wxCbPayDocService.updateWxCbPay(wxCbPayDoc);
|
|
|
+
|
|
|
+ MerchNoti noti = new MerchNoti();
|
|
|
+ noti.setCode(wxQueryResponseMsg.getErrCode());
|
|
|
+ noti.setAllPayNo(wxQueryResponseMsg.getTransactionId());
|
|
|
+ noti.setCusDeclStatus(merchNoti.getCusDeclStatus());
|
|
|
+ noti.setAllSubOrderNo(allSubOrderNo);
|
|
|
+ updateMerchNoti(noti,allSubOrderId,merchNoti);//更新商户通知
|
|
|
}
|
|
|
}else{//业务状态码失败
|
|
|
wxCbPayDoc.setErrCode(wxQueryResponseMsg.getErrCode());
|
|
@@ -242,6 +255,14 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
.msg(wxQueryResponseMsg.getErrCodeDes())
|
|
|
.cusDeclStatus(WxDict.MerchNoticeStatus.i_13.getItem())
|
|
|
.build();
|
|
|
+ wxCbPayDocService.updateWxCbPay(wxCbPayDoc);
|
|
|
+
|
|
|
+ MerchNoti noti = new MerchNoti();
|
|
|
+ noti.setCode(wxQueryResponseMsg.getErrCode());
|
|
|
+ noti.setAllPayNo(wxQueryResponseMsg.getTransactionId());
|
|
|
+ noti.setCusDeclStatus(merchNoti.getCusDeclStatus());
|
|
|
+ noti.setAllSubOrderNo(allSubOrderNo);
|
|
|
+ updateMerchNoti(noti,allSubOrderId,merchNoti);//更新商户通知
|
|
|
}
|
|
|
}
|
|
|
///返回状态码为失败
|
|
@@ -253,40 +274,19 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
.msg(wxQueryResponseMsg.getReturnMsg())
|
|
|
.cusDeclStatus(WxDict.MerchNoticeStatus.i_13.getItem())
|
|
|
.build();
|
|
|
+ wxCbPayDocService.updateWxCbPay(wxCbPayDoc);
|
|
|
+
|
|
|
+ MerchNoti noti = new MerchNoti();
|
|
|
+ noti.setCode(wxQueryResponseMsg.getErrCode());
|
|
|
+ noti.setAllPayNo(wxQueryResponseMsg.getTransactionId());
|
|
|
+ noti.setCusDeclStatus(merchNoti.getCusDeclStatus());
|
|
|
+ noti.setAllSubOrderNo(allSubOrderNo);
|
|
|
+ updateMerchNoti(noti,allSubOrderId,merchNoti);//更新商户通知
|
|
|
}
|
|
|
-
|
|
|
- wxCbPayDocService.updateWxCbPay(wxCbPayDoc);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("更新支付单证入库信息状态异常", e);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- List<MerchNoti> mchNotiList = null;
|
|
|
- try {
|
|
|
- MerchNoti noti = new MerchNoti();
|
|
|
- noti.setCode(wxQueryResponseMsg.getErrCode());
|
|
|
- noti.setAllPayNo(wxQueryResponseMsg.getTransactionId());
|
|
|
- noti.setCusDeclStatus(merchNoti.getCusDeclStatus());
|
|
|
- mchNotiList = merchNotiService.getMerchNotiByCodeAndOrderNo(noti);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("根据code查询商户通知信息异常", e);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- if(mchNotiList != null && mchNotiList.size() > 0){
|
|
|
- MerchNoti noti = mchNotiList.get(0);
|
|
|
- noti.setTstm(new Date());
|
|
|
- merchNotiService.update(noti);
|
|
|
- }else{
|
|
|
- merchNotiService.insert(merchNoti);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("操作商户通知数据异常", e);
|
|
|
- WxPayError wxPayError = createWxPayError(wxCbPayDoc, querySuccessResponseDto);
|
|
|
- wxPayError.setErrMsg("操作商户通知数据异常");
|
|
|
- errorList.add(wxPayError);
|
|
|
- }
|
|
|
});
|
|
|
//存储异常记录
|
|
|
try {
|
|
@@ -303,6 +303,18 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ private void updateMerchNoti(MerchNoti noti,String allSubOrderId,MerchNoti merchNoti){
|
|
|
+ List<MerchNoti> merchNotiList = merchNotiService.getMerchNotiByCodeAndOrderNo(noti);
|
|
|
+ if(merchNotiList != null && merchNotiList.size()>0){
|
|
|
+ MerchNoti merchNoti1 = merchNotiList.get(0);
|
|
|
+ merchNoti1.setTstm(new Date());
|
|
|
+ merchNoti1.setAllSubOrderId(allSubOrderId);
|
|
|
+ merchNotiService.update(merchNoti1);
|
|
|
+ }else{
|
|
|
+ merchNoti.setNotiSn(TablePrimaryKeyPrefix.merch_pay_noti_type + IdWorkerAide.nextId());
|
|
|
+ merchNotiService.insert(merchNoti);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 记录异常的支付单证信息
|
|
|
* @param wxCbPayDoc
|
|
@@ -341,6 +353,9 @@ public class WxCusDeclareQueryBiz extends AbstractCusDeclareBiz implements Cuspa
|
|
|
sorted.put("mch_id", wxCbPayDoc.getMchId());
|
|
|
sorted.put("out_trade_no", wxCbPayDoc.getOutTradeNo());
|
|
|
sorted.put("transaction_id", wxCbPayDoc.getTransactionId());
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isNotEmpty(wxCbPayDoc.getSubOrderNo())) {
|
|
|
+ sorted.put("sub_order_no", wxCbPayDoc.getSubOrderNo());
|
|
|
+ }
|
|
|
sorted.put("customs", wxCbPayDoc.getCustoms());
|
|
|
|
|
|
//2.生成签名
|