From b3942f278045cf74410d81a62ded4696f22d170d Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期六, 26 八月 2023 13:08:14 +0800
Subject: [PATCH] Merge branch 'master' of ssh://120.76.84.145:20202/java/HongRuiTang into master

---
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java |   48 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java
index 07a4a0f..5af01c2 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java
@@ -1,9 +1,35 @@
 package com.ruoyi.order.controller.miniapp;
 
+import com.github.binarywang.wxpay.bean.ecommerce.*;
+import com.github.binarywang.wxpay.bean.notify.WxPayNotifyV3Response;
+import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingNotifyData;
+import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingNotifyResult;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.ProfitSharingV3Service;
+import com.github.binarywang.wxpay.service.WxPayService;
+import com.github.binarywang.wxpay.v3.auth.Verifier;
+import com.github.binarywang.wxpay.v3.util.AesUtils;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
 import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.order.domain.vo.ProfitSharingNotifyNewResult;
+import com.ruoyi.order.enums.WxPayNotifyEventTypeEnum;
+import com.ruoyi.order.service.account.BackMessageService;
+import com.ruoyi.order.service.order.OrderService;
 import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.GeneralSecurityException;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * @program: ruoyi
@@ -14,9 +40,10 @@
 @Api(value = "微信通知控制", tags = "微信通知控制", description = "微信通知控制")
 @RestController
 @RequestMapping("/app/notify")
+@Log4j2
 public class NotifyController extends BaseController {
 
-    /*public static final String WECHAT_PAY_SERIAL = "Wechatpay-Serial";
+    public static final String WECHAT_PAY_SERIAL = "Wechatpay-Serial";
     public static final String WECHAT_PAY_SIGNATURE = "Wechatpay-Signature";
     public static final String WECHAT_PAY_TIMESTAMP = "Wechatpay-Timestamp";
     public static final String WECHAT_PAY_NONCE = "Wechatpay-Nonce";
@@ -26,7 +53,7 @@
     @Resource
     private OrderService orderService;
 
-    @Autowired
+    @Resource
     private WxPayService wxService;
     @Resource
     private BackMessageService backMessageService;
@@ -37,6 +64,8 @@
 
         // 获取请求头
         SignatureHeader signatureHeader = getSignatureHeader(response);
+
+        log.info("微信支付/退款通知:  {}", notifyData);
 
         NotifyResponse responseData = GSON.fromJson(notifyData, NotifyResponse.class);
         String eventType = responseData.getEventType();
@@ -63,7 +92,6 @@
         // 保存支付/退款回调信息
         backMessageService.saveBackMessage(resultType, resultMessage);
 
-
         return WxPayNotifyV3Response.success("成功");
     }
 
@@ -72,6 +100,7 @@
     public String profitSharingNotify(@RequestBody String notifyData, HttpServletRequest request, HttpServletResponse response) throws WxPayException {
         ProfitSharingV3Service sharingV3Service = wxService.getProfitSharingV3Service();
         // ProfitSharingNotifyResult
+        log.info("微信分账通知:  {}", notifyData);
 
         // 获取请求头
         SignatureHeader signatureHeader = getSignatureHeader(response);
@@ -143,6 +172,13 @@
         signatureHeader.setSigned(response.getHeader(WECHAT_PAY_SIGNATURE));
         signatureHeader.setNonce(response.getHeader(WECHAT_PAY_NONCE));
         signatureHeader.setTimeStamp(response.getHeader(WECHAT_PAY_TIMESTAMP));
+
+        log.info("timeStamp:{}   nonce : {}   signed:{}  serialNo:{}",
+                signatureHeader.getTimeStamp(),
+                signatureHeader.getNonce(),
+                signatureHeader.getSigned(),
+                signatureHeader.getSerialNo());
+
         return signatureHeader;
-    }*/
+    }
 }

--
Gitblit v1.7.1