TRX 1 rok temu
rodzic
commit
58e8dcc720

+ 1 - 1
PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/commn/PayNotityParam.java → PaymentClient/src/main/java/com/zhongshu/payment/client/payModel/commn/PayNotifyParam.java

@@ -13,6 +13,6 @@ import lombok.NoArgsConstructor;
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
-public class PayNotityParam {
+public class PayNotifyParam {
     private String outTradeNo;
 }

+ 21 - 6
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/RechargeService.java

@@ -4,18 +4,23 @@ import ch.qos.logback.core.util.StringUtil;
 import com.github.microservice.auth.security.helper.AuthHelper;
 import com.github.microservice.core.helper.ApplicationContextHolder;
 import com.github.microservice.net.ResultContent;
+import com.github.microservice.net.ResultMessage;
 import com.wechat.pay.java.service.payments.model.Transaction;
 import com.zhongshu.card.client.model.feign.ProjectWxPayParam;
+import com.zhongshu.card.client.model.operLogs.OperationLogsAddParam;
 import com.zhongshu.card.client.model.org.OrgUserDetailParam;
 import com.zhongshu.card.client.model.org.OrganizationUserModel;
 import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
+import com.zhongshu.card.client.service.feign.OperationLogsFeignService;
 import com.zhongshu.card.client.service.feign.OrganizationFeignService;
 import com.zhongshu.card.client.service.feign.ProjectPaySettingFeignService;
+import com.zhongshu.card.client.type.LogsLevel;
+import com.zhongshu.card.client.type.MessageType;
 import com.zhongshu.payment.client.model.RechargeRecordModel;
 import com.zhongshu.payment.client.model.param.OrderParam;
 import com.zhongshu.payment.client.model.param.RechargeParam;
 import com.zhongshu.payment.client.payModel.commn.ClosePayOrderParam;
-import com.zhongshu.payment.client.payModel.commn.PayNotityParam;
+import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
 import com.zhongshu.payment.client.types.RechargeState;
 import com.zhongshu.payment.client.types.TradeType;
 import com.zhongshu.payment.client.types.WalletState;
@@ -87,6 +92,9 @@ public class RechargeService extends SuperService {
     @Autowired
     ExecuteMethodInfoDao executeMethodInfoDao;
 
+    @Autowired
+    OperationLogsFeignService logsFeignService;
+
     /**
      * 创建充值本地订单
      */
@@ -160,7 +168,7 @@ public class RechargeService extends SuperService {
         }
         ExecuteMethodInfo executeMethodInfo = executeMethodInfoDao.findTopByPaymentType(record.getPaymentType());
         if (ObjectUtils.isEmpty(executeMethodInfo)) {
-            return ResultContent.buildFail(String.format("", record.getPaymentType().getRemark()));
+            return ResultContent.buildFail(String.format(ResultMessage.SERVICE_NAME_NOT_EXIT, record.getPaymentType().getRemark()));
         }
         SuperPayService service = (SuperPayService) ApplicationContextHolder.getContext().getBean(executeMethodInfo.getBeanName());
         return service.createChannelOrder(param);
@@ -175,13 +183,20 @@ public class RechargeService extends SuperService {
     public ResultContent payNotify(HttpServletRequest request, String outTradeNo) {
         RechargeRecord record = rechargeRecordDao.findByOutTradeNo(outTradeNo);
         if (record == null) {
-            return ResultContent.buildFail("充值订单:" + outTradeNo + "不存在");
+            OperationLogsAddParam logsAddParam = initLog();
+            logsAddParam.setLevel(LogsLevel.High);
+            logsAddParam.setMessageType(MessageType.Error);
+            String msg = "充值订单:" + outTradeNo + "不存在";
+            logsAddParam.setContent(msg);
+            logsAddParam.setDataId(outTradeNo);
+            logsAddParam.setTitle("微信支付回调错误");
+            return ResultContent.buildFail(msg);
         }
-        PayNotityParam param = new PayNotityParam();
+        PayNotifyParam param = new PayNotifyParam();
         param.setOutTradeNo(outTradeNo);
         ExecuteMethodInfo executeMethodInfo = executeMethodInfoDao.findTopByPaymentType(record.getPaymentType());
         if (ObjectUtils.isEmpty(executeMethodInfo)) {
-            return ResultContent.buildFail(String.format("", record.getPaymentType().getRemark()));
+            return ResultContent.buildFail(String.format(ResultMessage.SERVICE_NAME_NOT_EXIT, record.getPaymentType().getRemark()));
         }
         SuperPayService service = (SuperPayService) ApplicationContextHolder.getContext().getBean(executeMethodInfo.getBeanName());
         return service.payNotify(request, param);
@@ -227,7 +242,7 @@ public class RechargeService extends SuperService {
         }
         ExecuteMethodInfo executeMethodInfo = executeMethodInfoDao.findTopByPaymentType(record.getPaymentType());
         if (ObjectUtils.isEmpty(executeMethodInfo)) {
-            return ResultContent.buildFail(String.format("", record.getPaymentType().getRemark()));
+            return ResultContent.buildFail(String.format(ResultMessage.SERVICE_NAME_NOT_EXIT, record.getPaymentType().getRemark()));
         }
         SuperPayService service = (SuperPayService) ApplicationContextHolder.getContext().getBean(executeMethodInfo.getBeanName());
         ResultContent resultContent = service.closePayOrder(ClosePayOrderParam.builder().outTradeNo(outTradeNo).build());

+ 11 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/base/SuperService.java

@@ -3,8 +3,11 @@ package com.zhongshu.payment.server.core.service.base;
 import com.github.microservice.auth.security.helper.AuthHelper;
 import com.zhongshu.card.client.model.base.SuperParam;
 import com.zhongshu.card.client.model.base.SuperSearch;
+import com.zhongshu.card.client.model.operLogs.OperationLogsAddParam;
 import com.zhongshu.payment.server.core.domain.base.SuperMain;
+import com.zhongshu.payment.server.core.utils.CommonUtil;
 import com.zhongshu.payment.server.core.utils.DateUtils;
+import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -23,6 +26,9 @@ public abstract class SuperService {
     @Autowired
     private AuthHelper authHelper;
 
+    @Autowired
+    private HttpServletRequest request;
+
     /**
      * 得到当前的用户ID
      *
@@ -167,4 +173,9 @@ public abstract class SuperService {
             param.setEndTime(endTime);
         }
     }
+
+    public OperationLogsAddParam initLog() {
+        return CommonUtil.initLog(request, getCurrentUserId());
+    }
+
 }

+ 13 - 5
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/SuperPayService.java

@@ -1,15 +1,16 @@
 package com.zhongshu.payment.server.core.service.pay;
 
 import com.github.microservice.auth.security.helper.AuthHelper;
-import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
-import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
-import com.zhongshu.payment.client.model.PrePayModel;
+import com.github.microservice.core.util.net.IPUtil;
+import com.github.microservice.models.type.LogServiceType;
 import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.operLogs.OperationLogsAddParam;
 import com.zhongshu.payment.client.model.WalletModel;
 import com.zhongshu.payment.client.model.param.OrderParam;
 import com.zhongshu.payment.client.model.param.WalletQueryParam;
 import com.zhongshu.payment.client.payModel.commn.ClosePayOrderParam;
-import com.zhongshu.payment.client.payModel.commn.PayNotityParam;
+import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
+import com.zhongshu.payment.server.core.utils.CommonUtil;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,11 +25,14 @@ public abstract class SuperPayService {
     @Autowired
     private AuthHelper authHelper;
 
+    @Autowired
+    private HttpServletRequest request;
+
     // 根据本地 创建渠道支付订单
     public abstract ResultContent createChannelOrder(OrderParam param);
 
     // 支付回调
-    public abstract ResultContent payNotify(HttpServletRequest request, PayNotityParam param);
+    public abstract ResultContent payNotify(HttpServletRequest request, PayNotifyParam param);
 
     // 查询付款账户信息
     public abstract ResultContent<WalletModel> getWallet(WalletQueryParam param);
@@ -47,4 +51,8 @@ public abstract class SuperPayService {
         }
         return null;
     }
+
+    public OperationLogsAddParam initLog() {
+        return CommonUtil.initLog(request, getCurrentUserId());
+    }
 }

+ 2 - 2
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionFrictionlessPayMainService.java

@@ -7,7 +7,7 @@ import com.zhongshu.payment.client.model.WalletModel;
 import com.zhongshu.payment.client.model.param.OrderParam;
 import com.zhongshu.payment.client.model.param.WalletQueryParam;
 import com.zhongshu.payment.client.payModel.commn.ClosePayOrderParam;
-import com.zhongshu.payment.client.payModel.commn.PayNotityParam;
+import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
 import com.zhongshu.payment.server.core.service.pay.SuperPayService;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
@@ -42,7 +42,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
      * @return
      */
     @Override
-    public ResultContent payNotify(HttpServletRequest request, PayNotityParam param) {
+    public ResultContent payNotify(HttpServletRequest request, PayNotifyParam param) {
         return null;
     }
 

+ 2 - 2
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/wallet/WalletMainService.java

@@ -15,7 +15,7 @@ import com.zhongshu.payment.client.model.param.GetWalletParam;
 import com.zhongshu.payment.client.model.param.OrderParam;
 import com.zhongshu.payment.client.model.param.WalletQueryParam;
 import com.zhongshu.payment.client.payModel.commn.ClosePayOrderParam;
-import com.zhongshu.payment.client.payModel.commn.PayNotityParam;
+import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
 import com.zhongshu.payment.client.types.WalletState;
 import com.zhongshu.payment.client.types.WalletType;
 import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
@@ -69,7 +69,7 @@ public class WalletMainService extends SuperPayService {
     }
 
     @Override
-    public ResultContent payNotify(HttpServletRequest request, PayNotityParam param) {
+    public ResultContent payNotify(HttpServletRequest request, PayNotifyParam param) {
         return ResultContent.buildFail("钱包不支持成功回调");
     }
 

+ 6 - 2
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/wxPaymentV3/WxPaymentMainService.java

@@ -14,6 +14,7 @@ import com.wechat.pay.java.service.payments.model.Transaction;
 import com.zhongshu.card.client.model.feign.ProjectWxPayParam;
 import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
 import com.zhongshu.card.client.model.wechat.MiniAppUserInfoVo;
+import com.zhongshu.card.client.service.feign.OperationLogsFeignService;
 import com.zhongshu.card.client.service.feign.ProjectPaySettingFeignService;
 import com.zhongshu.payment.client.annotation.PayAnnotationService;
 import com.zhongshu.payment.client.model.PrePayModel;
@@ -21,7 +22,7 @@ import com.zhongshu.payment.client.model.WalletModel;
 import com.zhongshu.payment.client.model.param.OrderParam;
 import com.zhongshu.payment.client.model.param.WalletQueryParam;
 import com.zhongshu.payment.client.payModel.commn.ClosePayOrderParam;
-import com.zhongshu.payment.client.payModel.commn.PayNotityParam;
+import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
 import com.zhongshu.payment.client.types.RechargeState;
 import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
 import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;
@@ -64,6 +65,9 @@ public class WxPaymentMainService extends SuperPayService {
     @Autowired
     WxPayNotifyService wxPayNotifyService;
 
+    @Autowired
+    OperationLogsFeignService logsFeignService;
+
     public static com.wechat.pay.java.service.payments.jsapi.JsapiService service;
 
 
@@ -123,7 +127,7 @@ public class WxPaymentMainService extends SuperPayService {
      * @param param
      * @return
      */
-    public ResultContent payNotify(HttpServletRequest request, PayNotityParam param) {
+    public ResultContent payNotify(HttpServletRequest request, PayNotifyParam param) {
         wxPayNotifyService.payNotify(request, param.getOutTradeNo());
         return ResultContent.buildSuccess();
     }

+ 17 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/utils/CommonUtil.java

@@ -1,12 +1,16 @@
 package com.zhongshu.payment.server.core.utils;
 
+import com.github.microservice.core.util.net.IPUtil;
+import com.github.microservice.models.type.LogServiceType;
 import com.google.common.collect.Lists;
 import com.google.zxing.BarcodeFormat;
 import com.google.zxing.client.j2se.MatrixToImageWriter;
 import com.google.zxing.common.BitMatrix;
 import com.google.zxing.qrcode.QRCodeWriter;
+import com.zhongshu.card.client.model.operLogs.OperationLogsAddParam;
 import com.zhongshu.card.client.utils.ITree;
 import com.zhongshu.card.client.type.Sex;
+import jakarta.servlet.http.HttpServletRequest;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import net.sourceforge.pinyin4j.PinyinHelper;
@@ -454,4 +458,17 @@ public class CommonUtil {
         return Character.toLowerCase(str.charAt(0)) + str.substring(1);
     }
 
+    public static OperationLogsAddParam initLog(HttpServletRequest request, String userId) {
+        OperationLogsAddParam param = new OperationLogsAddParam();
+        try {
+            param.setUid(userId);
+            param.setUa(request.getHeader("User-Agent"));
+            param.setIp(IPUtil.getRemoteIp(request));
+            param.setUrl(request.getRequestURI());
+            param.setLogServiceType(LogServiceType.Payment);
+        } catch (Exception e) {
+            log.error("initLog error {}", e.getMessage());
+        }
+        return param;
+    }
 }