Browse Source

feature 代码优化

xiahan 3 weeks ago
parent
commit
9b72df8851

+ 10 - 4
zhsw-wechat-common/src/main/java/com/rongwei/wechat/system/wechat/impl/PayMentServiceImpl.java

@@ -200,6 +200,7 @@ public class PayMentServiceImpl implements PayMentService {
         // }
         R error = R.error("失败");
         // dsKeys.remove("incontrol");
+        log.info("schema为:{}", dskey);
         httpServletRequest.setAttribute("schema", dskey);
         // 获取所有商户的密钥
         List<SwEnterpriseConfigInfoDo> secretKeyList = commonBusinessDao.getSecretKey(Collections.singletonList(dskey));
@@ -249,6 +250,14 @@ public class PayMentServiceImpl implements PayMentService {
         SwPaymentInitRecordDo paymentInitRecordDo = swPaymentInitRecordService.getOne(new LambdaQueryWrapper<SwPaymentInitRecordDo>()
                 .eq(BaseDo::getDeleted, "0")
                 .eq(SwPaymentInitRecordDo::getOrderno, outTradeNo), false);
+        if (paymentInitRecordDo == null) {
+            log.error("无法根据商户单号:{}获取到预下单信息", outTradeNo);
+            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error.toString());
+        }
+        if (SUCCESS.equals(paymentInitRecordDo.getState())) {
+            log.error("本次微信支付:{}已生成对应的缴费记录信息", paymentInitRecordDo.getId());
+            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error.toString());
+        }
         String state = SUCCESS;
         try {
             // 微信订单号
@@ -264,10 +273,7 @@ public class PayMentServiceImpl implements PayMentService {
             createPaymentRecordVo.setPaymentAmount(amount);
 
             log.info("根据商户订单号:{}获取到的下单信息为:{}", outTradeNo, paymentInitRecordDo);
-            String zdIds="";
-            if (paymentInitRecordDo != null) {
-                zdIds = StringUtils.isBlank(paymentInitRecordDo.getBillid()) ? null : paymentInitRecordDo.getBillid();
-            }
+            String zdIds = StringUtils.isBlank(paymentInitRecordDo.getBillid()) ? null : paymentInitRecordDo.getBillid();
             createPaymentRecordVo.setZdId(zdIds);
             createPaymentRecordVo.setUserNumber(userNum);
             createPaymentRecordVo.setOpenId(transaction.getPayer().getOpenid());