Browse Source

支付接口记录日志

liweifan 3 years ago
parent
commit
fad78e1bcd

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderPaymentServiceImpl.java

@@ -103,6 +103,7 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
 
             try {
                 BaseResult<ClosePayment> responseResult = paymentClient.closePayment(param);
+                log.info("关单返回: {}", JSONObject.toJSONString(responseResult));
                 if (!responseResult.getStatus()) {
                     orderPayment.setCloseStatus(TradeStatusEnum.failed);
                     orderPayment.setCloseFailMsg(responseResult.getMsg());
@@ -167,6 +168,7 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
 
         //付款请求
         BaseResult<Payment> paymentResBaseResult = paymentClient.executePayment(payment);
+        log.info("关单返回: {}", JSONObject.toJSONString(paymentResBaseResult));
         if (paymentResBaseResult.getStatus()) {
             orderPayRes.setPay_amt(detail.getActualPrice().setScale(2, RoundingMode.HALF_UP).toString());
             String pay_info = paymentResBaseResult.getData().getPayInfo();

+ 6 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderRefundServiceImpl.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -32,6 +33,8 @@ import com.yonge.toolset.payment.base.model.callback.PaymentCallBack;
 import com.yonge.toolset.payment.base.model.callback.RefundPaymentCallBack;
 import com.yonge.toolset.payment.core.service.PaymentClient;
 import com.yonge.toolset.utils.string.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -45,6 +48,8 @@ import java.util.stream.Collectors;
 
 @Service
 public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao, UserOrderRefund> implements UserOrderRefundService {
+    private final static Logger log = LoggerFactory.getLogger(UserOrderRefundServiceImpl.class);
+
     @Autowired
     private UserOrderService orderService;
     @Autowired
@@ -306,7 +311,7 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
         refundBill.setReason(orderRefund.getReason());
 
         BaseResult<RefundBill> refundBillBaseResult = paymentClient.refundPayment(refundBill);
-
+        log.info("退款返回: {} ", JSONObject.toJSONString(refundBillBaseResult));
         //入退款单表
         UserOrderRefundBill orderRefundBill = new UserOrderRefundBill();
         orderRefundBill.setRefundId(orderRefund.getId());
@@ -320,8 +325,6 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
             orderRefundBill.setPayFailMsg(refundBillBaseResult.getMsg());
         }
         refundBillService.save(orderRefundBill);
-
-
         return HttpResponseResult.succeed(orderRefundBill);
     }
 

+ 6 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/OriginalAliAppTemplate.java

@@ -90,6 +90,8 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
         request.setBizContent(bizContent.toString());
         try {
             AlipayTradeAppPayResponse response = getAlipayClient(payment.getPaymentClient()).sdkExecute(request);
+            log.info("支付返回:{}", JSONObject.toJSONString(response));
+
             if (response.isSuccess()) {
                 payment.setId(response.getTradeNo());
                 payment.setPayInfo(response.getBody());
@@ -117,6 +119,7 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
         request.setBizContent(bizContent.toString());
         try {
             AlipayTradeQueryResponse response = getAlipayClient(payment.getPaymentClient()).execute(request);
+            log.info("查询返回:{}", JSONObject.toJSONString(response));
 
             if (response.isSuccess()) {
                 payment.setPayAmt(response.getPayAmount());
@@ -158,6 +161,8 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
         request.setBizContent(bizContent.toString());
         try {
             AlipayTradeCloseResponse response = getAlipayClient(closePayment.getPaymentClient()).execute(request);
+            log.info("关单返回:{}", JSONObject.toJSONString(response));
+
             closePayment.setStatus(TradeStatusEnum.succeeded);
             if (response.isSuccess()) {
                 return BaseResult.succeed(closePayment);
@@ -187,6 +192,7 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
         request.setBizContent(bizContent.toString());
         try {
             AlipayTradeRefundResponse response = getAlipayClient(refundBill.getPaymentClient()).execute(request);
+            log.info("退款返回:{}", JSONObject.toJSONString(response));
 
             if (response.isSuccess()) {
                 //获取交易状态

+ 3 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/wx/OriginalWxAppTemplate.java

@@ -92,6 +92,7 @@ public class OriginalWxAppTemplate implements PaymentTemplate {
         try {
             Object orderV3 = getWxPayService(payment.getPaymentClient())
                     .createOrderV3(TradeTypeEnum.APP, request);
+            log.info("支付返回:{}", JSONObject.toJSONString(orderV3));
             Map<String, String> stringStringMap = SignUtils.xmlBean2Map(orderV3);
             String msg = buildMessage(
                     APP_ID,
@@ -133,6 +134,7 @@ public class OriginalWxAppTemplate implements PaymentTemplate {
         try {
             WxPayOrderQueryV3Result res = getWxPayService(payment.getPaymentClient())
                     .queryOrderV3(param);
+            log.info("查询返回:{}", JSONObject.toJSONString(res));
 
             payment.setId(res.getTransactionId());
             String tradeState = res.getTradeState();
@@ -208,6 +210,7 @@ public class OriginalWxAppTemplate implements PaymentTemplate {
         try {
             WxPayRefundV3Result res = getWxPayService(refundBill.getPaymentClient())
                     .refundV3(param);
+            log.info("退款返回:{}", JSONObject.toJSONString(res));
 
             String refund_id = res.getRefundId();
             refundBill.setId(refund_id);

+ 19 - 4
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/wx/config/WxpayConfiguration.java

@@ -9,6 +9,7 @@ import com.yonge.toolset.payment.core.service.SysConfigPaymentService;
 import com.yonge.toolset.payment.original.wx.constant.WxpayConstant;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
@@ -23,6 +24,8 @@ import java.security.PrivateKey;
 public class WxpayConfiguration {
     @Autowired
     private SysConfigPaymentService configPaymentService;
+    @Value("${spring.profiles.active}")
+    private String profile;
 
     @Bean(name = "studentWxService")
     public WxPayService studentWxService() {
@@ -44,8 +47,14 @@ public class WxpayConfiguration {
         payConfig.setMchKey(merchantPrivateKey);
         payConfig.setCertSerialNo(merchantSerialNumber);
         payConfig.setApiV3Key(apiV3Key);
-        payConfig.setPrivateCertPath(privateCertPath);
-        payConfig.setPrivateKeyPath(privateKeyPath);
+        if("local".equals(profile)){
+            payConfig.setPrivateCertPath("D:\\env\\license\\wxpay\\apiclient_cert.pem");
+            payConfig.setPrivateKeyPath("D:\\env\\license\\wxpay\\apiclient_key.pem");
+        }else{
+            payConfig.setPrivateCertPath(privateCertPath);
+            payConfig.setPrivateKeyPath(privateKeyPath);
+        }
+
         // 可以指定是否使用沙箱环境
         payConfig.setUseSandboxEnv(false);
 
@@ -75,8 +84,14 @@ public class WxpayConfiguration {
         payConfig.setMchKey(merchantPrivateKey);
         payConfig.setCertSerialNo(merchantSerialNumber);
         payConfig.setApiV3Key(apiV3Key);
-        payConfig.setPrivateCertPath(privateCertPath);
-        payConfig.setPrivateKeyPath(privateKeyPath);
+
+        if("local".equals(profile)){
+            payConfig.setPrivateCertPath("D:\\env\\license\\wxpay\\apiclient_cert.pem");
+            payConfig.setPrivateKeyPath("D:\\env\\license\\wxpay\\apiclient_key.pem");
+        }else{
+            payConfig.setPrivateCertPath(privateCertPath);
+            payConfig.setPrivateKeyPath(privateKeyPath);
+        }
         // 可以指定是否使用沙箱环境
         payConfig.setUseSandboxEnv(false);