Browse Source

代码调整

baolei 6 months ago
parent
commit
3c3e34a83b
13 changed files with 276 additions and 134 deletions
  1. 1 1
      08.src/Xingxi/xingxi-miniprogram-api/src/main/resources/application-local.yml
  2. 37 23
      08.src/Xingxi/xingxi-mq-server/src/main/java/com/xingxi/mq/consumer/order/OrderCloseConsumer.java
  3. 17 0
      08.src/Xingxi/xingxi-mq-server/src/main/java/com/xingxi/mq/server/order/mapper/MqPaymentInfoMapper.java
  4. 3 0
      08.src/Xingxi/xingxi-mq-server/src/main/java/com/xingxi/mq/server/order/mapper/MqProdInventoryMapper.java
  5. 12 16
      08.src/Xingxi/xingxi-mq-server/src/main/resources/config/application-local.yml
  6. 12 5
      08.src/Xingxi/xingxi-mq-server/src/main/resources/config/application-release.yml
  7. 11 12
      08.src/Xingxi/xingxi-mq-server/src/main/resources/config/application-test.yml
  8. 0 10
      08.src/Xingxi/xingxi-mq-server/src/main/resources/config/application.yml
  9. 0 48
      08.src/Xingxi/xingxi-mq-server/src/main/resources/mapper/order/PaymentInfoMqMapper.xml
  10. 175 11
      08.src/Xingxi/xingxi-pay-utils/xingxi-unifiedpay-spring-boot-starter/src/main/java/com/xingxi/unifiedpay/open/WXPayCallbackEndpoint.java
  11. 2 2
      08.src/Xingxi/xingxi-pay-utils/xingxi-unifiedpay-spring-boot-starter/src/main/java/com/xingxi/unifiedpay/open/XingxiUnifiedpayServiceImpl.java
  12. 2 2
      08.src/Xingxi/xingxi-pay-utils/xingxi-unifiedpay-spring-boot-starter/src/main/java/com/xingxi/unifiedpay/service/UnifiedpayServiceI.java
  13. 4 4
      08.src/Xingxi/xingxi-pay-utils/xingxi-unifiedpay-spring-boot-starter/src/main/java/com/xingxi/unifiedpay/service/WXPayUnifiedpayServiceImpl.java

+ 1 - 1
08.src/Xingxi/xingxi-miniprogram-api/src/main/resources/application-local.yml

@@ -6,7 +6,7 @@ spring:
     xingxi:
       unifiedpay:
         enabled: "true"
-        callbackUrl: "https://managertest.gululuq.com/api/store/order/wxpay/callback"
+        callbackUrl: "https://managertest.gululuq.com/unifiedpay/wxpay/callback"
         wxpay:
           enabled: "true"
           app-id: "wx12e34630814e5d30"

+ 37 - 23
08.src/Xingxi/xingxi-mq-server/src/main/java/com/xingxi/mq/consumer/order/OrderCloseConsumer.java

@@ -15,27 +15,29 @@ import com.xingxi.business.Order.service.IOrderDetailService;
 import com.xingxi.business.Order.service.IOrderService;
 import com.xingxi.business.PaymentInfo.domain.PaymentInfo;
 import com.xingxi.business.PaymentInfo.service.IPaymentInfoService;
+import com.xingxi.business.ProdInventory.domain.ProdInventory;
+import com.xingxi.business.ProdInventory.domain.ProdInventoryBill;
 import com.xingxi.business.ProdInventory.mapper.ProdInventoryBillMapper;
 import com.xingxi.business.ProdInventory.mapper.ProdInventoryMapper;
 import com.xingxi.business.RefundInfo.domain.RefundInfo;
 import com.xingxi.business.RefundInfo.service.impl.RefundInfoServiceImpl;
 import com.xingxi.common.annotation.Excel;
-import com.xingxi.common.enums.EDelFlag;
-import com.xingxi.common.enums.EOrderDetailStatus;
-import com.xingxi.common.enums.EOrderStatus;
-import com.xingxi.common.enums.ETradeState;
+import com.xingxi.common.enums.*;
+import com.xingxi.common.exception.BusinessException;
 import com.xingxi.common.mq.bo.order.OrderBO;
 import com.xingxi.common.mq.constant.OrderMqKey;
 import com.xingxi.common.mq.core.AbstractRabbitConsumer;
 import com.google.common.collect.Lists;
 import com.rabbitmq.client.Channel;
 import com.xingxi.common.utils.DateUtils;
+import com.xingxi.mq.server.order.mapper.MqProdInventoryMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.amqp.core.Binding;
 import org.springframework.amqp.core.Message;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Component;
 
@@ -61,6 +63,10 @@ public class OrderCloseConsumer extends AbstractRabbitConsumer {
     private ProdInventoryBillMapper prodInventoryBillMapper;
     @Autowired
     private ProdInventoryMapper prodInventoryMapper;
+    @Autowired
+    private MqProdInventoryMapper mqProdInventoryMapper;
+
+
 
     @Autowired
     private WxPayService wxPayService;
@@ -68,6 +74,9 @@ public class OrderCloseConsumer extends AbstractRabbitConsumer {
     @Autowired
     private RefundInfoServiceImpl refundInfoServiceImpl;
 
+//    @Value("${wx.pay.refundcallbackUrl}")
+//    private String notifyUrl;
+
     @Bean(OrderMqKey.EDIT_QUEUE_DELAY_FOR_UNPAID)
     @Override
     protected List<Binding> getBindingList() {
@@ -149,8 +158,7 @@ public class OrderCloseConsumer extends AbstractRabbitConsumer {
                 refundInfo.setOutTradeNo(orgOrder.getOrderNo());
                 refundInfo.setOutRefundNo(outRefundNo);
                 refundInfo.setReason(orderBO.getOrderNo() + "退款");
-                // TODO
-                refundInfo.setNotifyUrl("");
+//                refundInfo.setNotifyUrl(notifyUrl);
                 refundInfo.setAmountRefund(new BigDecimal(refundV3Result.getAmount().getRefund()));
                 refundInfo.setAmountTotal(new BigDecimal(refundV3Result.getAmount().getTotal()));
                 refundInfo.setRefundId(refundV3Result.getRefundId());
@@ -171,7 +179,6 @@ public class OrderCloseConsumer extends AbstractRabbitConsumer {
 
             }
 
-
             return true;
         }
 
@@ -189,6 +196,7 @@ public class OrderCloseConsumer extends AbstractRabbitConsumer {
         sod.setOrderId(order.getOrderId());
         List<OrderDetail> orderDetails = orderDetailService.selectOrderDetailList(sod);
         for (OrderDetail od : orderDetails) {
+
             //将订单明细设为已取消
             OrderDetail updateDetail = new OrderDetail();
             updateDetail.setOrderDetailId(od.getOrderDetailId());
@@ -198,22 +206,28 @@ public class OrderCloseConsumer extends AbstractRabbitConsumer {
             orderDetailService.updateOrderDetail(updateDetail);
 
             //减少锁库,恢复库存
-//            ProdStockVo sps = new ProdStockVo();
-//            sps.setProdId(od.getProdId());
-//            sps.setPprId(od.getPprId());
-//            sps.setVendorId(od.getVendorId());
-//
-//            ProdStockVo ps = prodInventoryMapper.selectProdStockVoByUnionId(sps);
-//            sps.setStockId(ps.getStockId());
-//            sps.setAvailQty(od.getBuyQty());
-//            sps.setOrderId(orgOrder.getOrderId());
-//            sps.setOrderNo(orgOrder.getOrderNo());
-//            sps.setBillType(EStockBillType.IN.getVal());
-//            sps.setBillKind(EStockBillKind.IN_CANCEL.getVal());
-//            sps.setUpdateUser(opName);
-//            sps.setUpdateTime(nowDate);
-//            prodStockVoService.updateProdStockQty(sps);
-//            prodInventoryMapper.
+            ProdInventory prodInventory = mqProdInventoryMapper.selectProdInventoryLock(od.getProdId(), od.getProdAttrId(), orgOrder.getSellerId());
+
+            prodInventory.setAvailQty(od.getQuantity());
+            prodInventory.setUpdateTime(nowDate);
+            prodInventory.setUpdateUser(opName);
+            int cnt = mqProdInventoryMapper.updatePlusProdStock(prodInventory);
+
+            ProdInventoryBill inventoryBill = new ProdInventoryBill();
+            inventoryBill.setBillTime(nowDate);
+            inventoryBill.setBillType(EInventoryBillType.LOCK.getVal());
+            inventoryBill.setQuantity(od.getQuantity());
+            inventoryBill.setInventoryId(prodInventory.getProdInventoryId());
+            inventoryBill.setOrderId(order.getOrderId());
+            inventoryBill.setOrderNo(orgOrder.getOrderNo());
+            inventoryBill.setDelFlag(EDelFlag.NO.getVal());
+            inventoryBill.setCreateUser(opName);
+            inventoryBill.setCreateTime(nowDate);
+            inventoryBill.setUpdateUser(opName);
+            inventoryBill.setUpdateTime(nowDate);
+
+            cnt = prodInventoryBillMapper.insertProdInventoryBill(inventoryBill);
+
         }
 
         // 关闭支付信息

+ 17 - 0
08.src/Xingxi/xingxi-mq-server/src/main/java/com/xingxi/mq/server/order/mapper/MqPaymentInfoMapper.java

@@ -0,0 +1,17 @@
+package com.xingxi.mq.server.order.mapper;
+
+import com.xingxi.business.PaymentInfo.domain.PaymentInfo;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 队列 库存Mapper接口
+ *
+ * @author xingxi
+ * @date 2025-05-11
+ */
+@Repository
+public interface MqPaymentInfoMapper {
+
+    public int updateOrderStatusByOrderId(PaymentInfo paymentInfo);
+
+}

+ 3 - 0
08.src/Xingxi/xingxi-mq-server/src/main/java/com/xingxi/mq/server/order/mapper/MqProdInventoryMapper.java

@@ -2,6 +2,7 @@ package com.xingxi.mq.server.order.mapper;
 
 import com.xingxi.business.ProdInventory.domain.ProdInventory;
 import com.xingxi.mq.entity.OrderDetail;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 /**
@@ -13,6 +14,8 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface MqProdInventoryMapper {
 
+    ProdInventory selectProdInventoryLock(@Param("prodId") Long prodId, @Param("prodAttrId") Long prodAttrId, @Param("mercId") Long mercId);
+
     /**
      * 减少库存数量
      *

+ 12 - 16
08.src/Xingxi/xingxi-mq-server/src/main/resources/config/application-local.yml

@@ -87,19 +87,15 @@ logging:
     "cn.com.xingxi": debug
     org.springframework: warn
     org.apache.http: info
-shdzfp:
-  requestUrl: "http://fw2test.shdzfp.com:15002/sajt-shdzfp-sl-http/SvrServlet"
-  key: "9oyKs7cVo1yYzkuisP9bhA=="
-  userName: "P1000001"
-  authorizationCode: "NH873FG4KW"
-#  requestUrl: "http://fw11.shdzfp.com:9012/sajt-shdzfp-sl-http/SvrServlet"
-#  key: "Bdv7AsnjlZznEka94pZLVw=="
-#  userName: "11111111"
-#  authorizationCode: "88888888"
-# https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/sendMessage.html
-# 消息推送 TODO
-wechat:
-  appId: wxe53a2bd91cc5b4c2
-  appSecret: 4a38f1d5a566433ccc9d9243a1e9b2a1
-  mpAppId: wx1b4a36bcb96e3cfe
-  mpAppSecret: 0d2bcd4be48a244dc4d7dcf84f0710b3
+
+wx:
+  miniapp:
+    appid: "wx12e34630814e5d30"
+    secret: "fc06d584d8544a00f0ff9df65a30af02"
+  pay:
+    mch-id: "1709337210"
+    apiv3-key: "mF9oH1oV9wY3gL8iW3kU4fJ7fE1dW4vK"
+    cert-serial-no: 4FBE124DE5AAD53E1FF52E740131A6072FE692F1
+    private-key-path: "classpath:META-INF/apiclient_key.pem"
+    private-cert-path: "classpath:META-INF/apiclient_cert.pem"
+    refundcallbackUrl: "https://managertest.gululuq.com/unifiedpay/wxpay/refund/callback"

+ 12 - 5
08.src/Xingxi/xingxi-mq-server/src/main/resources/config/application-release.yml

@@ -88,8 +88,15 @@ logging:
     cn.com.xingxi: info
     org.springframework: info
     org.apache.http: info
-shdzfp:
-  requestUrl: "http://fw2test.shdzfp.com:15002/sajt-shdzfp-sl-http/SvrServlet"
-  key: "9oyKs7cVo1yYzkuisP9bhA=="
-  userName: "P1000001"
-  authorizationCode: "NH873FG4KW"
+
+wx:
+  miniapp:
+    appid: "wx12e34630814e5d30"
+    secret: "fc06d584d8544a00f0ff9df65a30af02"
+  pay:
+    mch-id: "1709337210"
+    apiv3-key: "mF9oH1oV9wY3gL8iW3kU4fJ7fE1dW4vK"
+    cert-serial-no: 4FBE124DE5AAD53E1FF52E740131A6072FE692F1
+    private-key-path: "classpath:META-INF/apiclient_key.pem"
+    private-cert-path: "classpath:META-INF/apiclient_cert.pem"
+    refundcallbackUrl: "https://managertest.gululuq.com/unifiedpay/wxpay/refund/callback"

+ 11 - 12
08.src/Xingxi/xingxi-mq-server/src/main/resources/config/application-test.yml

@@ -86,16 +86,15 @@ logging:
     "cn.com.xingxi": debug
     org.springframework: warn
     org.apache.http: info
-shdzfp:
-  requestUrl: "http://fw2test.shdzfp.com:15002/sajt-shdzfp-sl-http/SvrServlet"
-  key: "9oyKs7cVo1yYzkuisP9bhA=="
-  userName: "P1000001"
-  authorizationCode: "NH873FG4KW"
 
-# https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/sendMessage.html
-# 消息推送 TODO
-wechat:
-  appId: wxe53a2bd91cc5b4c2
-  appSecret: 4a38f1d5a566433ccc9d9243a1e9b2a1
-  mpAppId: wx1b4a36bcb96e3cfe
-  mpAppSecret: 0d2bcd4be48a244dc4d7dcf84f0710b3
+wx:
+  miniapp:
+    appid: "wx12e34630814e5d30"
+    secret: "fc06d584d8544a00f0ff9df65a30af02"
+  pay:
+    mch-id: "1709337210"
+    apiv3-key: "mF9oH1oV9wY3gL8iW3kU4fJ7fE1dW4vK"
+    cert-serial-no: 4FBE124DE5AAD53E1FF52E740131A6072FE692F1
+    private-key-path: "classpath:META-INF/apiclient_key.pem"
+    private-cert-path: "classpath:META-INF/apiclient_cert.pem"
+    refundcallbackUrl: "https://managertest.gululuq.com/unifiedpay/wxpay/refund/callback"

+ 0 - 10
08.src/Xingxi/xingxi-mq-server/src/main/resources/config/application.yml

@@ -47,16 +47,6 @@ idworkcfg:
   # 数据中心标识位数
   dataCenterId: 4
 
-wx:
-  miniapp:
-    appid: "wx749421f425650fb2"
-    secret: "bf0d4499b7da9f9605f74ca5daa12a90"
-  pay:
-    mch-id: "1514166051"
-    apiv3-key: "Rongxi88888888888888888888888888"
-    private-key-path: "classpath:META-INF/apiclient_key.pem"
-    private-cert-path: "classpath:META-INF/apiclient_cert.p12"
-
 aliyun:
   oss:
     endPoint: oss-cn-beijing.aliyuncs.com

+ 0 - 48
08.src/Xingxi/xingxi-mq-server/src/main/resources/mapper/order/PaymentInfoMqMapper.xml

@@ -3,54 +3,6 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.xingxi.mq.server.order.mapper.PaymentInfoMqMapper">
-    
-    <resultMap type="PaymentInfo" id="PaymentInfoResult">
-        <result property="payId"    column="payId"    />
-        <result property="orderId"    column="orderId"    />
-        <result property="orderNo"    column="orderNo"    />
-        <result property="orderStatus"    column="orderStatus"    />
-        <result property="payTime"    column="payTime"    />
-        <result property="payKind"    column="payKind"    />
-        <result property="sellerId"    column="sellerId"    />
-        <result property="combineAppid"    column="combineAppid"    />
-        <result property="combineMchid"    column="combineMchid"    />
-        <result property="deviceId"    column="deviceId"    />
-        <result property="payerClientIp"    column="payerClientIp"    />
-        <result property="mchid"    column="mchid"    />
-        <result property="outTradeNo"    column="outTradeNo"    />
-        <result property="subMchid"    column="subMchid"    />
-        <result property="subAttach"    column="subAttach"    />
-        <result property="subDescription"    column="subDescription"    />
-        <result property="payAmount"    column="payAmount"    />
-        <result property="subCurrency"    column="subCurrency"    />
-        <result property="profitSharing"    column="profitSharing"    />
-        <result property="wxOpenId"    column="wxOpenId"    />
-        <result property="notifyUrl"    column="notifyUrl"    />
-        <result property="stateCode"    column="stateCode"    />
-        <result property="prepayId"    column="prepayId"    />
-        <result property="tradeType"    column="tradeType"    />
-        <result property="tradeState"    column="tradeState"    />
-        <result property="bankType"    column="bankType"    />
-        <result property="successTime"    column="successTime"    />
-        <result property="transactionId"    column="transactionId"    />
-        <result property="wxOrderId"    column="wxOrderId"    />
-        <result property="wxOrderStatus"    column="wxOrderStatus"    />
-        <result property="delFlag"    column="delFlag"    />
-        <result property="createUser"    column="createUser"    />
-        <result property="createTime"    column="createTime"    />
-        <result property="updateUser"    column="updateUser"    />
-        <result property="updateTime"    column="updateTime"    />
-    </resultMap>
-
-
-    <sql id="selectPaymentInfoVo">
-        select
-            payId, orderId, orderNo, orderStatus, payTime, payKind, sellerId, combineAppid, combineMchid, deviceId,
-            payerClientIp, mchid, outTradeNo, subMchid, subAttach, subDescription, payAmount, subCurrency,
-            profitSharing, wxOpenId, notifyUrl, stateCode, prepayId, tradeType, tradeState, bankType, successTime,
-            transactionId, wxOrderId, wxOrderStatus, delFlag, createUser, createTime, updateUser, updateTime
-        from t_payment_info
-    </sql>
 
     <update id="updateOrderStatusByOrderId" parameterType="PaymentInfo">
         update t_payment_info

+ 175 - 11
08.src/Xingxi/xingxi-pay-utils/xingxi-unifiedpay-spring-boot-starter/src/main/java/com/xingxi/unifiedpay/open/WXPayCallbackEndpoint.java

@@ -1,17 +1,34 @@
 package com.xingxi.unifiedpay.open;
 
+import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
+import com.github.binarywang.wxpay.service.WxPayService;
+import com.xingxi.business.Order.domain.Order;
+import com.xingxi.business.Order.domain.OrderDetail;
+import com.xingxi.business.PaymentInfo.domain.PaymentInfo;
+import com.xingxi.common.enums.EOrderDetailStatus;
+import com.xingxi.common.enums.EOrderStatus;
+import com.xingxi.common.mapper.XingxiUnifiedpayExtMapper;
+import com.xingxi.common.mq.bo.order.OrderBO;
+import com.xingxi.common.mq.publisher.order.OrderPayedMqPublisher;
+import com.xingxi.common.service.XingxiUnifiedpayCallbackDTO;
 import com.xingxi.unifiedpay.bean.BiandanUnifiedpayCallbackRequest;
 import com.xingxi.unifiedpay.bean.BiandanUnifiedpayCallbackResponse;
+import com.xingxi.unifiedpay.domain.XingxiUnifiedpayCallbackResultDTO;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.util.StreamUtils;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.nio.charset.Charset;
+import java.util.Date;
+import java.util.List;
 
 @Slf4j
 @RequiredArgsConstructor
@@ -19,25 +36,172 @@ import javax.servlet.http.HttpServletResponse;
 @RequestMapping("/unifiedpay")
 @ConditionalOnBean({XingxiUnifiedpayServiceI.class})
 public class WXPayCallbackEndpoint {
+
     private final XingxiUnifiedpayServiceI unifiedpayServiceI;
+    private final WxPayService wxPayService;
+    private final XingxiUnifiedpayExtMapper xingxiUnifiedpayExtMapper;
+    private final OrderPayedMqPublisher orderPayedMqPublisher;
+
+    @PostMapping("/wxpay/callback")
+    public String callback(HttpServletRequest request, HttpServletResponse response) {
+        log.debug("WXPayCallback");
 
+        try {
 
-    @PostMapping("/{mercId}/callback")
-    public String callback(@PathVariable("mercId") Long mercId, HttpServletRequest request, HttpServletResponse response) {
-        log.debug("MercId[" + mercId + "]WXPayCallback");
+            SignatureHeader signatureHeader = httpRequestToSignatureHeader(request);
+            String s = StreamUtils.copyToString(request.getInputStream(), Charset.defaultCharset());
 
-        BiandanUnifiedpayCallbackRequest callbackRequest = new BiandanUnifiedpayCallbackRequest();
-        callbackRequest.setHttpServletRequest(request);
-        callbackRequest.setSellerId(mercId);
+            WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = wxPayService.parseOrderNotifyV3Result(s, signatureHeader);
+            WxPayOrderNotifyV3Result.DecryptNotifyResult decryptNotifyResult = wxPayOrderNotifyV3Result.getResult();
+
+            XingxiUnifiedpayCallbackResultDTO xingxiUnifiedpayCallbackResultDTO = decryptNotifyResultToBiandanUnifiedpayCallbackResultDTO(decryptNotifyResult);
+
+            XingxiUnifiedpayCallbackDTO xingxiUnifiedpayCallbackDTO = new XingxiUnifiedpayCallbackDTO();
+            BeanUtils.copyProperties(xingxiUnifiedpayCallbackResultDTO, xingxiUnifiedpayCallbackDTO);
+
+            String tradeState = xingxiUnifiedpayCallbackResultDTO.getTradeState();
+            String outTradeNo = xingxiUnifiedpayCallbackResultDTO.getOutTradeNo();
+            String callUnifiedpayComponent = xingxiUnifiedpayCallbackResultDTO.getCallUnifiedpayComponent();
+
+            PaymentInfo dbPaymentInfo = xingxiUnifiedpayExtMapper.selectLockPaymentInfoByOutTradeNo(outTradeNo);
+            if (dbPaymentInfo != null && "SUCCESS".equals(tradeState)) {
+                dbPaymentInfo.setUpdateUser(callUnifiedpayComponent);
+                dbPaymentInfo.setUpdateTime(new Date());
+                updatePaymentInfo(dbPaymentInfo, xingxiUnifiedpayCallbackDTO);
+                Long orderId = dbPaymentInfo.getOrderId();
+
+                // lock
+                Order dbOrder = xingxiUnifiedpayExtMapper.selectLockOrderByOrderId(orderId);
+                dbOrder.setUpdateTime(dbPaymentInfo.getUpdateTime());
+                dbOrder.setUpdateUser(dbPaymentInfo.getUpdateUser());
+
+                updateOrderStatus(dbOrder);
+
+                // 发送订单支付完成事件消息
+                orderPayedEvent(dbOrder);
+
+            }
 
-        try {
-            BiandanUnifiedpayCallbackResponse callbackResponse = unifiedpayServiceI.getResponse(callbackRequest);
         } catch (Exception e) {
-            e.printStackTrace();
-            log.debug("商户[" + mercId + "]处理微信支付回调通知失败!!!!");
+            log.debug("处理微信支付回调通知失败!!!!");
             return "FAIL";
         }
 
         return "SUCCESS";
     }
+
+    private void updatePaymentInfo(PaymentInfo dbPaymentInfo, XingxiUnifiedpayCallbackDTO biandanUnifiedpayCallbackDTO) {
+        String tradeState = biandanUnifiedpayCallbackDTO.getTradeState();
+        String tradeType = biandanUnifiedpayCallbackDTO.getTradeType();
+        String bankType = biandanUnifiedpayCallbackDTO.getBankType();
+        String transactionId = biandanUnifiedpayCallbackDTO.getTransactionId();
+        String callUnifiedpayComponent = biandanUnifiedpayCallbackDTO.getCallUnifiedpayComponent();
+
+        PaymentInfo updatePaymentInfo = new PaymentInfo();
+        updatePaymentInfo.setPayId(dbPaymentInfo.getPayId());
+        updatePaymentInfo.setTradeType(tradeType);
+        updatePaymentInfo.setTradeState(tradeState);
+        updatePaymentInfo.setTransactionId(transactionId);
+        updatePaymentInfo.setSuccessTime(new Date());
+        updatePaymentInfo.setPayTime(updatePaymentInfo.getSuccessTime());
+        updatePaymentInfo.setBankType(bankType);
+        updatePaymentInfo.setUpdateUser(callUnifiedpayComponent);
+        updatePaymentInfo.setUpdateTime(dbPaymentInfo.getUpdateTime());
+        xingxiUnifiedpayExtMapper.updatePaymentInfo(updatePaymentInfo);
+    }
+
+    private SignatureHeader httpRequestToSignatureHeader(HttpServletRequest request){
+
+        String serial = request.getHeader("Wechatpay-Serial");
+        String signature = request.getHeader("Wechatpay-Signature");
+        String timestamp = request.getHeader("Wechatpay-Timestamp");
+        String nonceStr = request.getHeader("Wechatpay-Nonce");
+        SignatureHeader signatureHeader = new SignatureHeader();
+        signatureHeader.setSerial(serial);
+        signatureHeader.setSignature(signature);
+        signatureHeader.setNonce(nonceStr);
+        signatureHeader.setTimeStamp(timestamp);
+        return signatureHeader;
+
+    }
+
+    private XingxiUnifiedpayCallbackResultDTO decryptNotifyResultToBiandanUnifiedpayCallbackResultDTO(WxPayOrderNotifyV3Result.DecryptNotifyResult decryptNotifyResult) {
+        String tradeState = decryptNotifyResult.getTradeState();
+        String outTradeNo = decryptNotifyResult.getOutTradeNo();
+        String successTimeString = decryptNotifyResult.getSuccessTime();
+        String tradeType = decryptNotifyResult.getTradeType();
+        String bankType = decryptNotifyResult.getBankType();
+        String attach = decryptNotifyResult.getAttach();
+        String transactionId = decryptNotifyResult.getTransactionId();
+
+        XingxiUnifiedpayCallbackResultDTO biandanUnifiedpayCallbackResultDTO = new XingxiUnifiedpayCallbackResultDTO();
+        biandanUnifiedpayCallbackResultDTO.setTradeState(tradeState);
+        biandanUnifiedpayCallbackResultDTO.setOutTradeNo(outTradeNo);
+        biandanUnifiedpayCallbackResultDTO.setSuccessTimeString(successTimeString);
+        biandanUnifiedpayCallbackResultDTO.setTradeType(tradeType);
+        biandanUnifiedpayCallbackResultDTO.setBankType(bankType);
+        biandanUnifiedpayCallbackResultDTO.setAttach(attach);
+        biandanUnifiedpayCallbackResultDTO.setTransactionId(transactionId);
+        biandanUnifiedpayCallbackResultDTO.setCallUnifiedpayComponent("WXPayCallback");
+
+        biandanUnifiedpayCallbackResultDTO.setOriginalObj(decryptNotifyResult);
+        return biandanUnifiedpayCallbackResultDTO;
+
+    }
+
+    private void updateOrderStatus(Order dbOrder) {
+        Order updateOrderStatus = new Order();
+        updateOrderStatus.setOrderId(dbOrder.getOrderId());
+        updateOrderStatus.setOrderStatus(EOrderStatus.PAYED.getVal());
+        updateOrderStatus.setUpdateUser(dbOrder.getUpdateUser());
+        updateOrderStatus.setUpdateTime(dbOrder.getUpdateTime());
+        xingxiUnifiedpayExtMapper.updateOrder(updateOrderStatus);
+
+        OrderDetail queryOrderDetail = new OrderDetail();
+        queryOrderDetail.setOrderId(dbOrder.getOrderId());
+        List<OrderDetail> orderDetails = xingxiUnifiedpayExtMapper.selectOrderDetailList(queryOrderDetail);
+        for (OrderDetail dbOrderDetail : orderDetails) {
+            OrderDetail updateOrderDetailStatus = new OrderDetail();
+            updateOrderDetailStatus.setOrderDetailId(dbOrderDetail.getOrderDetailId());
+            updateOrderDetailStatus.setOrderDetailStatus(EOrderDetailStatus.APPROVED.getVal());
+            updateOrderDetailStatus.setUpdateUser(dbOrder.getUpdateUser());
+            updateOrderDetailStatus.setUpdateTime(dbOrder.getUpdateTime());
+            xingxiUnifiedpayExtMapper.updateOrderDetail(updateOrderDetailStatus);
+        }
+    }
+
+    private void orderPayedEvent(Order orderDTO) {
+        // EDIT_ROUTE_FOR_PAYED
+        // EDIT_EXCHANGE
+        OrderBO orderBO = new OrderBO();
+        orderBO.setOrderId(orderDTO.getOrderId());
+        orderBO.setOrderNo(orderDTO.getOrderNo());
+        orderPayedMqPublisher.sendMessage(orderBO);
+    }
+//
+//    @PostMapping("/wxpay/refund/callback")
+//    public String refund(HttpServletRequest request, HttpServletResponse response) {
+//        log.debug("WXPayRefundCallback");
+//
+//        try {
+//            SignatureHeader signatureHeader = httpRequestToSignatureHeader(request);
+//            String s = StreamUtils.copyToString(request.getInputStream(), Charset.defaultCharset());
+//
+//            WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = wxPayService.parseOrderNotifyV3Result(s, signatureHeader);
+//            WxPayOrderNotifyV3Result.DecryptNotifyResult decryptNotifyResult = wxPayOrderNotifyV3Result.getResult();
+//
+//            XingxiUnifiedpayCallbackResultDTO xingxiUnifiedpayCallbackResultDTO = decryptNotifyResultToBiandanUnifiedpayCallbackResultDTO(decryptNotifyResult);
+//
+//
+//
+//
+//
+//        } catch (Exception e) {
+//
+//            log.debug("处理微信支付回调通知失败!!!!" + e.getMessage());
+//            return "FAIL";
+//        }
+//
+//        return "SUCCESS";
+//    }
 }

+ 2 - 2
08.src/Xingxi/xingxi-pay-utils/xingxi-unifiedpay-spring-boot-starter/src/main/java/com/xingxi/unifiedpay/open/XingxiUnifiedpayServiceImpl.java

@@ -28,7 +28,7 @@ class XingxiUnifiedpayServiceImpl implements XingxiUnifiedpayServiceI {
     public <T extends BaseBiandanUnifiedpayResponse> T getResponse(BaseBiandanUnifiedpayRequest<T> request) throws Exception {
         Long sellerId = request.getSellerId();
         MercUnifiedpayDTO mercUnifiedpayDTO = getMercUnifiedpayDTOByMercId(sellerId);
-        String unifiedPayMethod = mercUnifiedpayDTO.getUnifiedPayMethod();
+        String unifiedPayMethod = "WXPay";
 
         Object unifiedpayServiceI = null;
 
@@ -40,7 +40,7 @@ class XingxiUnifiedpayServiceImpl implements XingxiUnifiedpayServiceI {
         }
 
         String callMethod = request.getCallMethod();
-        Method invokeMethod = ReflectionUtils.findMethod(unifiedpayServiceI.getClass(), callMethod, MercUnifiedpayDTO.class, request.getClass());
+        Method invokeMethod = ReflectionUtils.findMethod(unifiedpayServiceI.getClass(), callMethod, request.getClass());
         if (ObjectUtils.isEmpty(invokeMethod)) {
             log.debug("接口[" + callMethod + "]不支持");
             throw new RuntimeException("接口不支持");

+ 2 - 2
08.src/Xingxi/xingxi-pay-utils/xingxi-unifiedpay-spring-boot-starter/src/main/java/com/xingxi/unifiedpay/service/UnifiedpayServiceI.java

@@ -12,9 +12,9 @@ interface UnifiedpayServiceI {
 
     BiandanUnifiedpayContinue2payResponse continue2pay(MercUnifiedpayDTO mercUnifiedpayDTO, BiandanUnifiedpayContinue2payRequest request) throws Exception;
 
-    BiandanUnifiedpayCallbackResponse callback(MercUnifiedpayDTO mercUnifiedpayDTO, BiandanUnifiedpayCallbackRequest request) throws Exception;
+    BiandanUnifiedpayCallbackResponse callback(BiandanUnifiedpayCallbackRequest request) throws Exception;
 
-    BiandanUnifiedpayRefundResponse refund(MercUnifiedpayDTO mercUnifiedpayDTO, BiandanUnifiedpayRefundRequest request) throws Exception;
+    BiandanUnifiedpayRefundResponse refund(BiandanUnifiedpayRefundRequest request) throws Exception;
 
     BiandanUnifiedpayQueryRefundResponse queryRefund(MercUnifiedpayDTO mercUnifiedpayDTO, BiandanUnifiedpayQueryRefundRequest request) throws Exception;
 

+ 4 - 4
08.src/Xingxi/xingxi-pay-utils/xingxi-unifiedpay-spring-boot-starter/src/main/java/com/xingxi/unifiedpay/service/WXPayUnifiedpayServiceImpl.java

@@ -88,13 +88,13 @@ class WXPayUnifiedpayServiceImpl implements UnifiedpayServiceI {
 
 
     @Override
-    public BiandanUnifiedpayCallbackResponse callback(MercUnifiedpayDTO mercUnifiedpayDTO, BiandanUnifiedpayCallbackRequest request) throws Exception {
+    public BiandanUnifiedpayCallbackResponse callback(BiandanUnifiedpayCallbackRequest request) throws Exception {
 
         HttpServletRequest httpServletRequest = request.getHttpServletRequest();
         SignatureHeader signatureHeader = httpRequestToSignatureHeader(httpServletRequest);
         String s = StreamUtils.copyToString(httpServletRequest.getInputStream(), Charset.defaultCharset());
 
-        WxPayService wxPayService = this.switchoverTo(mercUnifiedpayDTO);
+//        WxPayService wxPayService = this.switchoverTo(mercUnifiedpayDTO);
         WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = wxPayService.parseOrderNotifyV3Result(s, signatureHeader);
         WxPayOrderNotifyV3Result.DecryptNotifyResult decryptNotifyResult = wxPayOrderNotifyV3Result.getResult();
 
@@ -107,7 +107,7 @@ class WXPayUnifiedpayServiceImpl implements UnifiedpayServiceI {
 
 
     @Override
-    public BiandanUnifiedpayRefundResponse refund(MercUnifiedpayDTO mercUnifiedpayDTO, BiandanUnifiedpayRefundRequest request) throws Exception {
+    public BiandanUnifiedpayRefundResponse refund(BiandanUnifiedpayRefundRequest request) throws Exception {
 
         String transactionId = request.getTransactionId();
         String outRefundNo = request.getOutRefundNo();
@@ -115,7 +115,7 @@ class WXPayUnifiedpayServiceImpl implements UnifiedpayServiceI {
         Integer refundAmt = request.getRefundAmt();
         Integer orderOriginalTotalAmt = request.getOrderOriginalTotalAmt();
 
-        WxPayService wxPayService = this.switchoverTo(mercUnifiedpayDTO);
+//        WxPayService wxPayService = this.switchoverTo(mercUnifiedpayDTO);
         WxPayConfig wxPayConfig = wxPayService.getConfig();
 
         WxPayRefundV3Request wxPayRefundV3Request = new WxPayRefundV3Request();