TRX 1 年之前
父節點
當前提交
33bc8635b8
共有 14 個文件被更改,包括 38 次插入165 次删除
  1. 2 3
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/wxPaymentV3/WechatNotifyController.java
  2. 5 5
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/wxPaymentV3/WechatPayV3Controller.java
  3. 7 4
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/RechargeService.java
  4. 1 1
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/TransferService.java
  5. 1 3
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/SuperPayService.java
  6. 0 122
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/WeChatPayService.java
  7. 2 3
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionFrictionlessPayMainService.java
  8. 1 1
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionRequestService.java
  9. 4 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/package-info.java
  10. 2 2
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/wxPaymentV3/WxPayNotifyService.java
  11. 6 15
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/wxPaymentV3/WxPaymentMainService.java
  12. 5 2
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/wxPaymentV3/WxTransferBatchService.java
  13. 0 4
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/unionFrictionlessPay/package-info.java
  14. 2 0
      PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/wallet/WalletService.java

+ 2 - 3
PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/wxPaymentV3/WechatNotifyController.java

@@ -1,6 +1,6 @@
 package com.zhongshu.payment.server.core.controller.wxPaymentV3;
 
-import com.zhongshu.payment.server.core.service.wxPaymentV3.WxPayNotifyService;
+import com.zhongshu.payment.server.core.service.pay.impl.wxPaymentV3.WxPayNotifyService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.servlet.http.HttpServletRequest;
@@ -25,10 +25,9 @@ public class WechatNotifyController {
     @Autowired
     WxPayNotifyService wxPayNotifyService;
 
-
     @Operation(summary = "支付通知回调")
     @PostMapping(value = "payNotify/{outTradeNo}", consumes = MediaType.APPLICATION_JSON_VALUE)
-    public void payNotify(HttpServletRequest request, @PathVariable(name = "outTradeNo") String outTradeNo){
+    public void payNotify(HttpServletRequest request, @PathVariable(name = "outTradeNo") String outTradeNo) {
         log.info("收到微信支付通知 appid:{}", outTradeNo);
         wxPayNotifyService.payNotify(request, outTradeNo);
     }

+ 5 - 5
PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/wxPaymentV3/WechatPayV3Controller.java

@@ -5,7 +5,7 @@ import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.service.feign.ProjectPaySettingFeignService;
 import com.zhongshu.payment.server.core.dataConfig.WxV3PayConfig;
-import com.zhongshu.payment.server.core.service.wxPaymentV3.WxPaymentService;
+import com.zhongshu.payment.server.core.service.pay.impl.wxPaymentV3.WxPaymentMainService;
 import io.swagger.v3.oas.annotations.Hidden;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.*;
 public class WechatPayV3Controller {
 
     @Autowired
-    WxPaymentService wxPaymentService;
+    WxPaymentMainService wxPaymentService;
 
     @Autowired
     ProjectPaySettingFeignService projectPaySettingService;
@@ -38,7 +38,7 @@ public class WechatPayV3Controller {
         ProjectWxPayParam param = new ProjectWxPayParam();
         param.setAppId(WxV3PayConfig.APP_ID);
         ResultContent<WxPayConfigModel> resultContent = projectPaySettingService.getProjectWxPayConfig(param);
-        if (resultContent.isSuccess()){
+        if (resultContent.isSuccess()) {
             Log.info(resultContent.getContent());
         }
         return ResultContent.buildSuccess();
@@ -51,8 +51,8 @@ public class WechatPayV3Controller {
 //    }
 
     @Operation(summary = "获取openid")
-    @GetMapping (value = "getOpenid")
-    public Object transactions(@Parameter(name = "jscode")@RequestParam(name = "jscode") String jscode){
+    @GetMapping(value = "getOpenid")
+    public Object transactions(@Parameter(name = "jscode") @RequestParam(name = "jscode") String jscode) {
         return wxPaymentService.getOpenid(jscode);
     }
 }

+ 7 - 4
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/RechargeService.java

@@ -2,6 +2,7 @@ package com.zhongshu.payment.server.core.service;
 
 import ch.qos.logback.core.util.StringUtil;
 import com.github.microservice.auth.security.helper.AuthHelper;
+import com.github.microservice.net.ResultContent;
 import com.wechat.pay.java.service.payments.jsapi.model.Amount;
 import com.wechat.pay.java.service.payments.jsapi.model.Payer;
 import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
@@ -17,8 +18,10 @@ import com.zhongshu.payment.client.model.PrePayModel;
 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.github.microservice.net.ResultContent;
-import com.zhongshu.payment.client.types.*;
+import com.zhongshu.payment.client.types.RechargeState;
+import com.zhongshu.payment.client.types.TradeType;
+import com.zhongshu.payment.client.types.WalletState;
+import com.zhongshu.payment.client.types.WalletType;
 import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
 import com.zhongshu.payment.server.core.dao.WalletDao;
 import com.zhongshu.payment.server.core.dao.WxPayConfigDao;
@@ -26,7 +29,7 @@ import com.zhongshu.payment.server.core.dataConfig.TimeConfig;
 import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;
 import com.zhongshu.payment.server.core.domain.wallet.Wallet;
 import com.zhongshu.payment.server.core.service.impl.WalletFeignServiceImpl;
-import com.zhongshu.payment.server.core.service.wxPaymentV3.WxPaymentService;
+import com.zhongshu.payment.server.core.service.pay.impl.wxPaymentV3.WxPaymentMainService;
 import com.zhongshu.payment.server.core.utils.CommonUtil;
 import com.zhongshu.payment.server.core.utils.DateUtils;
 import com.zhongshu.payment.server.core.utils.wx.WechatCUtil;
@@ -55,7 +58,7 @@ public class RechargeService {
     AuthHelper authHelper;
 
     @Autowired
-    WxPaymentService wxPaymentService;
+    WxPaymentMainService wxPaymentService;
 
     @Autowired
     WechatCUtil wechatCUtil;

+ 1 - 1
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/TransferService.java

@@ -23,7 +23,7 @@ import com.zhongshu.payment.server.core.dao.WalletDao;
 import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;
 import com.zhongshu.payment.server.core.domain.wallet.Wallet;
 import com.zhongshu.payment.server.core.service.impl.WalletFeignServiceImpl;
-import com.zhongshu.payment.server.core.service.wxPaymentV3.WxTransferBatchService;
+import com.zhongshu.payment.server.core.service.pay.impl.wxPaymentV3.WxTransferBatchService;
 import com.zhongshu.payment.server.core.utils.CommonUtil;
 import io.netty.util.internal.StringUtil;
 import org.springframework.beans.BeanUtils;

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

@@ -10,8 +10,6 @@ import com.github.microservice.net.ResultContent;
  * @date 2024/8/15
  */
 public abstract class SuperPayService {
-
-    // 渠道支付下单
-    public abstract ResultContent<PrePayModel> createOrder(PrepayRequest request, WxPayConfigModel configModel);
+    
 
 }

+ 0 - 122
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/WeChatPayService.java

@@ -1,122 +0,0 @@
-package com.zhongshu.payment.server.core.service.pay.impl;
-
-import com.github.microservice.models.type.PaymentType;
-import com.wechat.pay.java.core.Config;
-import com.wechat.pay.java.core.RSAAutoCertificateConfig;
-import com.wechat.pay.java.core.exception.HttpException;
-import com.wechat.pay.java.core.exception.MalformedMessageException;
-import com.wechat.pay.java.core.exception.ServiceException;
-import com.wechat.pay.java.core.util.NonceUtil;
-import com.wechat.pay.java.core.util.PemUtil;
-import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
-import com.wechat.pay.java.service.payments.jsapi.model.PrepayResponse;
-import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
-import com.zhongshu.payment.client.annotation.PayAnnotationService;
-import com.zhongshu.payment.client.model.PrePayModel;
-import com.github.microservice.net.ResultContent;
-import com.zhongshu.payment.server.core.service.pay.SuperPayService;
-import lombok.SneakyThrows;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import java.io.UnsupportedEncodingException;
-import java.security.PrivateKey;
-import java.security.Signature;
-import java.util.Base64;
-
-/**
- * @author TRX
- * @date 2024/8/21
- */
-@Slf4j
-@Component
-@PayAnnotationService(paymentType = PaymentType.WeChat, remark = "微信支付方式")
-public class WeChatPayService extends SuperPayService {
-
-    public static com.wechat.pay.java.service.payments.jsapi.JsapiService service;
-
-    // 初始化商户配置
-    public static Config RSAAutoCertificateConfig(String mchId, String privateKeyPath, String mchSerialNo, String apiV3Key) {
-        return new RSAAutoCertificateConfig.Builder()
-                .merchantId(mchId)
-                // 使用 com.wechat.pay.java.core.util 中的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
-                .privateKeyFromPath(privateKeyPath)
-                .merchantSerialNumber(mchSerialNo)
-                .apiV3Key(apiV3Key)
-                .build();
-    }
-
-    /**
-     * 支付下单
-     *
-     * @param request
-     * @param configModel
-     * @return
-     */
-    @Override
-    public ResultContent<PrePayModel> createOrder(PrepayRequest request, WxPayConfigModel configModel) {
-        String privateKeyPath = configModel.getPrivateKeyPath();
-        if (configModel.getPrivateKeyType().equals("local")) {
-            privateKeyPath = Thread.currentThread().getContextClassLoader().getResource("").getPath() + configModel.getPrivateKeyPath();
-        }
-
-        // 初始化商户配置
-        Config config = RSAAutoCertificateConfig(configModel.getMchId(), privateKeyPath, configModel.getMchSerialNo(), configModel.getApiV3Key());
-        // 初始化服务
-        service = new com.wechat.pay.java.service.payments.jsapi.JsapiService.Builder().config(config).build();
-        // ... 调用接口
-        try {
-            // 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
-            request.setAppid(configModel.getAppId());
-            request.setMchid(configModel.getMchId());
-            request.setNotifyUrl("https://api.dev.qk.zonelife.cn/paymentserver/wechat/v3/notify/payNotify/" + request.getOutTradeNo());
-//            request.setNotifyUrl(configModel.getNotifyUrl());
-            // 调用接口
-            PrepayResponse response = service.prepay(request);
-
-            PrePayModel prePayModel = new PrePayModel();
-            prePayModel.setNonceStr(NonceUtil.createNonce(10));
-            prePayModel.setPackAge("prepay_id=" + response.getPrepayId());
-            prePayModel.setSignType("RSA");
-            long timeStamp = System.currentTimeMillis() / 1000;
-            prePayModel.setTimeStamp(Long.toString(timeStamp));
-
-            String sign = buildMessage(configModel.getAppId(), timeStamp, prePayModel.getNonceStr(), prePayModel.getPackAge());
-            String signature = sign(privateKeyPath, sign.getBytes("utf-8"));
-            prePayModel.setPaySign(signature);
-            return ResultContent.buildContent(prePayModel);
-        } catch (HttpException e) { // 发送HTTP请求失败
-            // 调用e.getHttpRequest()获取请求打印日志或上报监控,更多方法见HttpException定义
-            log.info("请求失败1:{}", e.getHttpRequest());
-            return ResultContent.buildFail("发送HTTP请求失败");
-        } catch (ServiceException e) { // 服务返回状态小于200或大于等于300,例如500
-            // 调用e.getResponseBody()获取返回体打印日志或上报监控,更多方法见ServiceException定义
-            log.info("请求失败2:{}", e.getResponseBody());
-            return ResultContent.buildFail(e.getErrorMessage());
-        } catch (MalformedMessageException e) { // 服务返回成功,返回体类型不合法,或者解析返回体失败
-            // 调用e.getMessage()获取信息打印日志或上报监控,更多方法见MalformedMessageException定义
-            log.info("请求失败3:{}", e.getMessage());
-            return ResultContent.buildFail("服务返回成功,返回体类型不合法,或者解析返回体失败");
-        } catch (UnsupportedEncodingException e) {
-            log.info("请求失败4:{}", e.getMessage());
-            return ResultContent.buildFail("编码错误");
-        }
-    }
-
-    @SneakyThrows
-    public String sign(String privateKeyPath, byte[] message) {
-        Signature sign = Signature.getInstance("SHA256withRSA");
-        PrivateKey privateKey = PemUtil.loadPrivateKeyFromPath(privateKeyPath);
-        sign.initSign(privateKey);
-        sign.update(message);
-        return Base64.getEncoder().encodeToString(sign.sign());
-    }
-
-    private String buildMessage(String appid, long timestamp, String nonceStr, String prepayId) {
-        return appid + "\n"
-                + timestamp + "\n"
-                + nonceStr + "\n"
-                + prepayId + "\n";
-    }
-
-}

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

@@ -1,6 +1,5 @@
-package com.zhongshu.payment.server.core.service.unionFrictionlessPay;
+package com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay;
 
-import com.github.microservice.core.util.JsonUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
@@ -12,7 +11,7 @@ import org.springframework.stereotype.Service;
  */
 @Slf4j
 @Service
-public class UnionFrictionlessPayService {
+public class UnionFrictionlessPayMainService {
 
 
 }

+ 1 - 1
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/unionFrictionlessPay/UnionRequestService.java → PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/UnionRequestService.java

@@ -1,4 +1,4 @@
-package com.zhongshu.payment.server.core.service.unionFrictionlessPay;
+package com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay;
 
 import cn.hutool.core.bean.BeanUtil;
 import com.github.microservice.core.util.net.apache.HttpClientUtil;

+ 4 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/unionFrictionlessPay/package-info.java

@@ -0,0 +1,4 @@
+package com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay;
+/**
+ * 银联无感支付
+ */

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

@@ -1,6 +1,7 @@
-package com.zhongshu.payment.server.core.service.wxPaymentV3;
+package com.zhongshu.payment.server.core.service.pay.impl.wxPaymentV3;
 
 import com.github.microservice.core.util.JsonUtil;
+import com.github.microservice.net.ResultContent;
 import com.wechat.pay.java.core.RSAAutoCertificateConfig;
 import com.wechat.pay.java.core.notification.NotificationConfig;
 import com.wechat.pay.java.core.notification.NotificationParser;
@@ -12,7 +13,6 @@ import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
 import com.zhongshu.card.client.service.feign.MqttFeignService;
 import com.zhongshu.card.client.service.feign.ProjectPaySettingFeignService;
 import com.zhongshu.payment.client.model.param.AmountUpdateParam;
-import com.github.microservice.net.ResultContent;
 import com.zhongshu.payment.client.types.RechargeState;
 import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
 import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;

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

@@ -1,5 +1,6 @@
-package com.zhongshu.payment.server.core.service.wxPaymentV3;
+package com.zhongshu.payment.server.core.service.pay.impl.wxPaymentV3;
 
+import com.github.microservice.net.ResultContent;
 import com.wechat.pay.java.core.Config;
 import com.wechat.pay.java.core.RSAAutoCertificateConfig;
 import com.wechat.pay.java.core.exception.HttpException;
@@ -11,9 +12,8 @@ import com.wechat.pay.java.service.payments.jsapi.model.*;
 import com.wechat.pay.java.service.payments.model.Transaction;
 import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
 import com.zhongshu.card.client.model.wechat.MiniAppUserInfoVo;
-import com.github.microservice.net.ResultContent;
 import com.zhongshu.payment.client.model.PrePayModel;
-import com.zhongshu.payment.server.core.service.base.SuperService;
+import com.zhongshu.payment.server.core.service.pay.SuperPayService;
 import com.zhongshu.payment.server.core.utils.wx.WechatCUtil;
 import io.netty.util.internal.StringUtil;
 import lombok.SneakyThrows;
@@ -28,12 +28,14 @@ import java.util.Base64;
 
 
 /**
+ * 微信支付
+ *
  * @author TRX
  * @date 2024/7/22
  */
 @Slf4j
 @Service
-public class WxPaymentService extends SuperService {
+public class WxPaymentMainService extends SuperPayService {
 
     @Autowired
     WechatCUtil wechatCUtil;
@@ -62,17 +64,6 @@ public class WxPaymentService extends SuperService {
         return ResultContent.buildContent(miniAppUserInfo);
     }
 
-    @SneakyThrows
-    public String getOpenId(String jscode) {
-        MiniAppUserInfoVo miniAppUserInfo = wechatCUtil.getMiniAppUserInfo(jscode);
-        if (miniAppUserInfo == null || StringUtil.isNullOrEmpty(miniAppUserInfo.getOpenid())) {
-            log.info("无法获取用户信息");
-            return null;
-        }
-        log.info("用户openid:{}", miniAppUserInfo.getOpenid());
-        return miniAppUserInfo.getOpenid();
-    }
-
 //    public ResultContent<PrePayModel> testPrepay(WxPrepayParam param){
 //
 //

+ 5 - 2
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/wxPaymentV3/WxTransferBatchService.java → PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/pay/impl/wxPaymentV3/WxTransferBatchService.java

@@ -1,9 +1,12 @@
-package com.zhongshu.payment.server.core.service.wxPaymentV3;
+package com.zhongshu.payment.server.core.service.pay.impl.wxPaymentV3;
 
 import com.wechat.pay.java.core.Config;
 import com.wechat.pay.java.core.RSAAutoCertificateConfig;
 import com.wechat.pay.java.service.transferbatch.TransferBatchService;
-import com.wechat.pay.java.service.transferbatch.model.*;
+import com.wechat.pay.java.service.transferbatch.model.GetTransferDetailByOutNoRequest;
+import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferRequest;
+import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferResponse;
+import com.wechat.pay.java.service.transferbatch.model.TransferDetailEntity;
 import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;

+ 0 - 4
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/unionFrictionlessPay/package-info.java

@@ -1,4 +0,0 @@
-package com.zhongshu.payment.server.core.service.unionFrictionlessPay;
-/**
- * 银联无感支付
- */

+ 2 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/wallet/WalletService.java

@@ -23,6 +23,8 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 
 /**
+ * 钱包信息
+ *
  * @author wjf
  * @date 2024/7/24
  */