Forráskód Böngészése

微信支付回调

baolei 2 hónapja
szülő
commit
1c4d8a8775

+ 1 - 0
08.src/Xingxi/xingxi-miniprogram-api/src/main/java/com/xingxi/api/data/domain/MercProdResponse.java

@@ -18,6 +18,7 @@ public class MercProdResponse {
     private Long prodClassId;
 
     // 商品名称
+    private Long mercProdId;
     private Long prodId;
 
     private String prodName;

+ 1 - 0
08.src/Xingxi/xingxi-miniprogram-api/src/main/java/com/xingxi/api/service/impl/ProdApiServiceImpl.java

@@ -160,6 +160,7 @@ class ProdApiServiceImpl implements ProdServiceI {
         }
 
         rtn.setMercId(mercProd.getMercId());
+        rtn.setMercProdId(mercProd.getMercProdId());
         rtn.setProdId(mercProd.getProdId());
         rtn.setProdAttrId(mercProd.getProdAttrId());
 

+ 2 - 1
08.src/Xingxi/xingxi-miniprogram-api/src/main/resources/META-INF/sqlmap/WxApiProductMapper.xml

@@ -8,6 +8,7 @@
         <result property="mercId" column="mercId"/>
         <result property="prodClassId"    column="prodClassId"/>
         <result property="prodId"    column="prodId"/>
+        <result property="mercProdId"    column="mercProdId"/>
         <result property="prodName"    column="prodName"/>
         <result property="ipId"    column="ipId"/>
         <result property="designerId"    column="designerId"/>
@@ -18,7 +19,7 @@
     </resultMap>
 
     <select id="selectProductList" parameterType="MercProdRequest" resultMap="MercProdResponse">
-        SELECT distinct mmp.mercId,mp.prodClassId,mmp.prodId,mp.prodName,mp.Id,mp.designerId,mp.description,mp.prodStatus,mmp.delFlag,mp.ipId
+        SELECT distinct mmp.mercId,mp.prodClassId,mmp.prodId, mmp.mercProdId,mp.prodName,mp.Id,mp.designerId,mp.description,mp.prodStatus,mmp.delFlag,mp.ipId
         FROM m_merchant_prod mmp
         LEFT JOIN m_prod mp ON mmp.prodId = mp.id
         <where>

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

@@ -72,7 +72,8 @@ spring:
         min-idle: 5       # 连接池中的最小空闲连接
 mybatis:
   # 加载全局的配置文件
-  configLocation: classpath:mybatis/mybatis-config.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
 
 # 日志配置
 logging:

+ 0 - 17
08.src/Xingxi/xingxi-miniprogram-api/src/main/resources/mybatis/mybatis-config.xml

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
-<configuration>
-    <!-- 全局参数 -->
-    <settings>
-        <!-- 使全局的映射器启用或禁用缓存 -->
-        <setting name="cacheEnabled"             value="true"   />
-        <!-- 允许JDBC 支持自动生成主键 -->
-        <setting name="useGeneratedKeys"         value="true"   />
-        <!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
-        <setting name="defaultExecutorType"      value="SIMPLE" />
-		<!-- 指定 MyBatis 所用日志的具体实现 -->
-        <setting name="logImpl"                  value="SLF4J"  />
-        <!-- 使用驼峰命名法转换字段 -->
-		<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
-	</settings>
-</configuration>

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

@@ -44,14 +44,20 @@ public class WXPayCallbackEndpoint {
 
     @PostMapping("/wxpay/callback")
     public String callback(HttpServletRequest request, HttpServletResponse response) {
-        log.debug("WXPayCallback");
+        log.info("WXPayCallback");
 
         try {
 
             SignatureHeader signatureHeader = httpRequestToSignatureHeader(request);
             String s = StreamUtils.copyToString(request.getInputStream(), Charset.defaultCharset());
 
+            log.info("验签开始.s:{}", s);
+            log.info("验签开始.signatureHeader:{}", signatureHeader.toString());
+
             WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = wxPayService.parseOrderNotifyV3Result(s, signatureHeader);
+
+            log.info("验签成功.");
+
             WxPayOrderNotifyV3Result.DecryptNotifyResult decryptNotifyResult = wxPayOrderNotifyV3Result.getResult();
 
             XingxiUnifiedpayCallbackResultDTO xingxiUnifiedpayCallbackResultDTO = decryptNotifyResultToBiandanUnifiedpayCallbackResultDTO(decryptNotifyResult);
@@ -63,27 +69,30 @@ public class WXPayCallbackEndpoint {
             String outTradeNo = xingxiUnifiedpayCallbackResultDTO.getOutTradeNo();
             String callUnifiedpayComponent = xingxiUnifiedpayCallbackResultDTO.getCallUnifiedpayComponent();
 
+            log.info("outTradeNo:{}", outTradeNo);
+            log.info("tradeState:{}", tradeState);
+
             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();
-
+                log.info("orderId:{}", orderId);
                 // lock
                 Order dbOrder = xingxiUnifiedpayExtMapper.selectLockOrderByOrderId(orderId);
                 dbOrder.setUpdateTime(dbPaymentInfo.getUpdateTime());
                 dbOrder.setUpdateUser(dbPaymentInfo.getUpdateUser());
 
                 updateOrderStatus(dbOrder);
-
+                log.info("update order status success");
                 // 发送订单支付完成事件消息
                 orderPayedEvent(dbOrder);
-
+                log.info("send order orderPayedEvent");
             }
 
         } catch (Exception e) {
-            log.debug("处理微信支付回调通知失败!!!!");
+            log.info("处理微信支付回调通知失败!!!!:{}", e.getMessage());
             return "FAIL";
         }
 

+ 24 - 0
08.src/Xingxi/xingxi-system/src/main/resources/mapper/business/XingxiUnifiedpayExtMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xingxi.common.mapper.XingxiUnifiedpayExtMapper">
+
+    <select id="selectLockPaymentInfoByOutTradeNo" parameterType="String" resultType="PaymentInfo">
+        SELECT t_payment_info.* FROM t_payment_info
+        WHERE t_payment_info.delFlag = '0'
+          AND t_payment_info.outTradeNo = #{outTradeNo}
+        FOR UPDATE
+    </select>
+
+    <select id="selectLockOrderByOrderId" parameterType="Long" resultType="Order">
+        SELECT t_order.*
+        FROM t_order
+        WHERE t_order.delFlag = '0'
+          AND t_order.orderStatus = 'ORDERED'
+          AND t_order.orderId = #{orderId}
+        FOR UPDATE
+    </select>
+
+
+</mapper>