Quellcode durchsuchen

Merge branch 'master' of http://git.izouma.com/xiongzhu/pms

xuqiang vor 4 Jahren
Ursprung
Commit
ffb818961e

+ 31 - 39
src/main/java/com/izouma/zhumj/service/UserMoneyWithdrawApplyService.java

@@ -1,14 +1,6 @@
 package com.izouma.zhumj.service;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import com.alipay.api.AlipayApiException;
-import com.alipay.api.AlipayClient;
-import com.alipay.api.domain.AlipayFundTransPayModel;
-import com.alipay.api.domain.AlipayFundTransUniTransferModel;
-import com.alipay.api.domain.Participant;
-import com.alipay.api.request.AlipayFundTransUniTransferRequest;
-import com.alipay.api.response.AlipayFundTransUniTransferResponse;
+
 import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
 import com.github.binarywang.wxpay.bean.entpay.EntPayResult;
 import com.github.binarywang.wxpay.exception.WxPayException;
@@ -43,7 +35,7 @@ public class UserMoneyWithdrawApplyService {
     private WxPayService               wxPayService;
     private CheckinInfoRepo            checkinInfoRepo;
     private MemberRepo                 memberRepo;
-    private AlipayClient               alipayClient;
+//    private AlipayClient               alipayClient;
 
     public UserMoneyWithdrawApply apply(Long userId, WithdrawMethod method, String account, String name) {
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
@@ -129,35 +121,35 @@ public class UserMoneyWithdrawApplyService {
                     throw new BusinessException(e.getMessage());
                 }
                 break;
-            case ALIPAY:
-                AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
-                AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
-                model.setOutBizNo(apply.getTradeNo());
-                model.setTransAmount(apply.getAmount().toString());
-                model.setProductCode("TRANS_ACCOUNT_NO_PWD");
-                model.setBizScene("DIRECT_TRANSFER");
-                Participant participant = new Participant();
-                participant.setIdentity(apply.getAccount());
-                participant.setIdentityType("ALIPAY_LOGON_ID");
-                participant.setName(apply.getName());
-                model.setPayeeInfo(participant);
-                request.setBizModel(model);
-
-                AlipayFundTransUniTransferResponse response = null;
-                try {
-                    response = alipayClient.certificateExecute(request);
-                    log.info("支付宝转账返回 \n{}", JSON.parseObject(response.getBody())
-                            .toString(SerializerFeature.PrettyFormat));
-                    if (!(response.isSuccess() && "10000".equals(response.getCode()))) {
-                        throw new BusinessException(String
-                                .format("%s %s %s %s", response.getCode(), response.getMsg(),
-                                        response.getSubCode(), response.getSubMsg()));
-                    }
-                } catch (AlipayApiException e) {
-                    log.error("余额提现失败", e);
-                    throw new BusinessException(e.getMessage());
-                }
-                break;
+//            case ALIPAY:
+//                AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
+//                AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
+//                model.setOutBizNo(apply.getTradeNo());
+//                model.setTransAmount(apply.getAmount().toString());
+//                model.setProductCode("TRANS_ACCOUNT_NO_PWD");
+//                model.setBizScene("DIRECT_TRANSFER");
+//                Participant participant = new Participant();
+//                participant.setIdentity(apply.getAccount());
+//                participant.setIdentityType("ALIPAY_LOGON_ID");
+//                participant.setName(apply.getName());
+//                model.setPayeeInfo(participant);
+//                request.setBizModel(model);
+//
+//                AlipayFundTransUniTransferResponse response = null;
+//                try {
+//                    response = alipayClient.certificateExecute(request);
+//                    log.info("支付宝转账返回 \n{}", JSON.parseObject(response.getBody())
+//                            .toString(SerializerFeature.PrettyFormat));
+//                    if (!(response.isSuccess() && "10000".equals(response.getCode()))) {
+//                        throw new BusinessException(String
+//                                .format("%s %s %s %s", response.getCode(), response.getMsg(),
+//                                        response.getSubCode(), response.getSubMsg()));
+//                    }
+//                } catch (AlipayApiException e) {
+//                    log.error("余额提现失败", e);
+//                    throw new BusinessException(e.getMessage());
+//                }
+//                break;
             default:
                 throw new BusinessException("不支持此提现方式");
         }

+ 60 - 61
src/main/java/com/izouma/zhumj/service/client/ClientRoomInfoService.java

@@ -3,7 +3,6 @@ package com.izouma.zhumj.service.client;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alipay.api.AlipayApiException;
-import com.alipay.api.AlipayClient;
 import com.alipay.api.domain.AlipayTradeAppPayModel;
 import com.alipay.api.request.AlipayTradeAppPayRequest;
 import com.alipay.api.request.AlipayTradeWapPayRequest;
@@ -59,13 +58,13 @@ public class ClientRoomInfoService {
     private final FeeTypeRepo         feeTypeRepo;
     private final UserMoneyRecordRepo userMoneyRecordRepo;
     private final MemberRepo          memberRepo;
-    private final AlipayClient        alipayClient;
+//    private final AlipayClient        alipayClient;
 
     public ClientRoomInfoService(UserRepo userRepo, CheckinInfoRepo checkinInfoRepo, WxPayService wxPayService,
                                  WxMpService wxMpService, Environment environment, PersonalFeeRepo personalFeeRepo,
                                  PersonalFeeTypeRepo personalFeeTypeRepo, ContractRepo contractRepo,
                                  RoomFeeRepo roomFeeRepo, FeeTypeRepo feeTypeRepo, UserMoneyRecordRepo userMoneyRecordRepo,
-                                 MemberRepo memberRepo, AlipayClient alipayClient) {
+                                 MemberRepo memberRepo) {
         this.userRepo = userRepo;
         this.checkinInfoRepo = checkinInfoRepo;
         this.wxPayService = wxPayService;
@@ -75,7 +74,7 @@ public class ClientRoomInfoService {
         this.feeTypeRepo = feeTypeRepo;
         this.userMoneyRecordRepo = userMoneyRecordRepo;
         this.memberRepo = memberRepo;
-        this.alipayClient = alipayClient;
+//        this.alipayClient = alipayClient;
     }
 
     public ClientRoomInfoDTO getClientRoomInfoDTO(Long userId) {
@@ -173,34 +172,34 @@ public class ClientRoomInfoService {
                         .add(Constants.ATTACH_AMOUNT, checkinInfo.getDepositAmount())
                         .build());
                 return wxPayService.createOrder(request);
-            case ALIPAY:
-                AlipayTradeAppPayRequest alipayRequest = new AlipayTradeAppPayRequest();
-                AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
-                model.setOutTradeNo(UUID.randomUUID().toString());
-                model.setSubject(body);
-                model.setTotalAmount(checkinInfo.getDepositAmount().toString());
-                model.setDisablePayChannels("pcredit,creditCard");
-                model.setProductCode("QUICK_MSECURITY_PAY");
-                model.setBody(new JsonUtils.Builder()
-                        .add(Constants.ATTACH_TYPE, "deposit")
-                        .add(Constants.ATTACH_CHECKIN_ID, checkinInfoId)
-                        .add(Constants.ATTACH_USER_ID, userId)
-                        .add(Constants.ATTACH_AMOUNT, checkinInfo.getDepositAmount())
-                        .build());
-                if (Arrays.stream(environment.getActiveProfiles()).noneMatch(s -> s.equals("prod"))) {
-                    // 测试环境设为1分
+//            case ALIPAY:
+//                AlipayTradeAppPayRequest alipayRequest = new AlipayTradeAppPayRequest();
+//                AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+//                model.setOutTradeNo(UUID.randomUUID().toString());
+//                model.setSubject(body);
+//                model.setTotalAmount(checkinInfo.getDepositAmount().toString());
+//                model.setDisablePayChannels("pcredit,creditCard");
+//                model.setProductCode("QUICK_MSECURITY_PAY");
+//                model.setBody(new JsonUtils.Builder()
+//                        .add(Constants.ATTACH_TYPE, "deposit")
+//                        .add(Constants.ATTACH_CHECKIN_ID, checkinInfoId)
+//                        .add(Constants.ATTACH_USER_ID, userId)
+//                        .add(Constants.ATTACH_AMOUNT, checkinInfo.getDepositAmount())
+//                        .build());
+//                if (Arrays.stream(environment.getActiveProfiles()).noneMatch(s -> s.equals("prod"))) {
+//                    // 测试环境设为1分
 //                    model.setTotalAmount("0.01");
-                }
-
-                alipayRequest.setNotifyUrl(aliNotifyUrl);
-                alipayRequest.setBizModel(model);
-
-                AlipayTradeAppPayResponse response = alipayClient.sdkExecute(alipayRequest);
-                if (response.isSuccess()) {
-                    return response.getBody();
-                } else {
-                    throw new BusinessException("支付宝下单失败");
-                }
+//                }
+//
+//                alipayRequest.setNotifyUrl(aliNotifyUrl);
+//                alipayRequest.setBizModel(model);
+//
+//                AlipayTradeAppPayResponse response = alipayClient.sdkExecute(alipayRequest);
+//                if (response.isSuccess()) {
+//                    return response.getBody();
+//                } else {
+//                    throw new BusinessException("支付宝下单失败");
+//                }
             default:
                 throw new BusinessException("不支持此支付方式");
         }
@@ -269,36 +268,36 @@ public class ClientRoomInfoService {
                     // request.setTotalFee(1);
                 }
                 return wxPayService.createOrder(request);
-            case ALIPAY:
-                AlipayTradeAppPayRequest alipayRequest = new AlipayTradeAppPayRequest();
-                AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
-                model.setOutTradeNo(UUID.randomUUID().toString());
-                model.setSubject(body);
-                model.setTotalAmount(amount.toString());
-                model.setDisablePayChannels("pcredit,creditCard");
-                model.setProductCode("QUICK_MSECURITY_PAY");
-                model.setBody(new JsonUtils.Builder()
-                        .add(Constants.ATTACH_TYPE, "recharge")
-                        .add(Constants.ATTACH_RECHARGE_TYPE, type.name())
-                        .add(Constants.ATTACH_CHECKIN_ID, checkinInfo.getId())
-                        .add(Constants.ATTACH_USER_ID, userId)
-                        .add(Constants.ATTACH_AMOUNT, amount)
-                        .add(Constants.ATTACH_REMARK, "")
-                        .build());
-                if (Arrays.stream(environment.getActiveProfiles()).noneMatch(s -> s.equals("prod"))) {
-                    // 测试环境设为1分
-//                    model.setTotalAmount("0.01");
-                }
-
-                alipayRequest.setNotifyUrl(aliNotifyUrl);
-                alipayRequest.setBizModel(model);
-
-                AlipayTradeAppPayResponse response = alipayClient.sdkExecute(alipayRequest);
-                if (response.isSuccess()) {
-                    return response.getBody();
-                } else {
-                    throw new BusinessException("支付宝下单失败");
-                }
+//            case ALIPAY:
+//                AlipayTradeAppPayRequest alipayRequest = new AlipayTradeAppPayRequest();
+//                AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+//                model.setOutTradeNo(UUID.randomUUID().toString());
+//                model.setSubject(body);
+//                model.setTotalAmount(amount.toString());
+//                model.setDisablePayChannels("pcredit,creditCard");
+//                model.setProductCode("QUICK_MSECURITY_PAY");
+//                model.setBody(new JsonUtils.Builder()
+//                        .add(Constants.ATTACH_TYPE, "recharge")
+//                        .add(Constants.ATTACH_RECHARGE_TYPE, type.name())
+//                        .add(Constants.ATTACH_CHECKIN_ID, checkinInfo.getId())
+//                        .add(Constants.ATTACH_USER_ID, userId)
+//                        .add(Constants.ATTACH_AMOUNT, amount)
+//                        .add(Constants.ATTACH_REMARK, "")
+//                        .build());
+//                if (Arrays.stream(environment.getActiveProfiles()).noneMatch(s -> s.equals("prod"))) {
+//                    // 测试环境设为1分
+////                    model.setTotalAmount("0.01");
+//                }
+//
+//                alipayRequest.setNotifyUrl(aliNotifyUrl);
+//                alipayRequest.setBizModel(model);
+//
+//                AlipayTradeAppPayResponse response = alipayClient.sdkExecute(alipayRequest);
+//                if (response.isSuccess()) {
+//                    return response.getBody();
+//                } else {
+//                    throw new BusinessException("支付宝下单失败");
+//                }
             default:
                 throw new BusinessException("不支持此支付方式");
         }

+ 29 - 36
src/main/java/com/izouma/zhumj/service/client/DepositRefundApplyService.java

@@ -1,12 +1,5 @@
 package com.izouma.zhumj.service.client;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import com.alipay.api.AlipayApiException;
-import com.alipay.api.AlipayClient;
-import com.alipay.api.domain.AlipayTradeRefundModel;
-import com.alipay.api.request.AlipayTradeRefundRequest;
-import com.alipay.api.response.AlipayTradeRefundResponse;
 import com.github.binarywang.wxpay.bean.entpay.EntPayBankRequest;
 import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
 import com.github.binarywang.wxpay.bean.entpay.EntPayResult;
@@ -63,8 +56,8 @@ public class DepositRefundApplyService {
     private UserRepo               userRepo;
     @Autowired
     private MemberRepo             memberRepo;
-    @Autowired
-    private AlipayClient           alipayClient;
+//    @Autowired
+//    private AlipayClient           alipayClient;
 
     public Page<DepositRefundApply> getDepositRefundApply(Long storeId, String search, DepositRefundStatus status, DepositRefundType depositRefundType, Pageable pageable) {
         return depositRefundApplyRepo
@@ -253,33 +246,33 @@ public class DepositRefundApplyService {
                 }
                 depositRecordRepo.save(apply.getCheckinInfo().getDepositRecord());
                 return;
-            case ALIPAY:
-                AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
-                AlipayTradeRefundModel model = new AlipayTradeRefundModel();
-                model.setTradeNo(checkinInfo.getDepositRecord().getTransactionId());
-                model.setRefundAmount(apply.getAmount().toString());
-                request.setBizModel(model);
-                AlipayTradeRefundResponse response = null;
-                try {
-                    response = alipayClient.execute(request);
-                    log.info("支付宝退款返回 \n{}", JSON.parseObject(response.getBody())
-                            .toString(SerializerFeature.PrettyFormat));
-                    if (response.isSuccess() && "10000".equals(response.getCode())) {
-                        apply.setStatus(DepositRefundStatus.SUCCESS);
-                        apply.setRefundTime(LocalDateTime.now());
-                        depositRefundApplyRepo.save(apply);
-                        checkinInfo.setDepositStatus(DepositStatus.REFUNDED);
-                    } else {
-                        throw new BusinessException(String
-                                .format("%s %s %s %s", response.getCode(), response.getMsg(),
-                                        response.getSubCode(), response.getSubMsg()));
-                    }
-                } catch (AlipayApiException e) {
-                    e.printStackTrace();
-                    log.error("支付宝退款失败", e);
-                    throw new BusinessException(e.getMessage());
-                }
-                break;
+//            case ALIPAY:
+//                AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
+//                AlipayTradeRefundModel model = new AlipayTradeRefundModel();
+//                model.setTradeNo(checkinInfo.getDepositRecord().getTransactionId());
+//                model.setRefundAmount(apply.getAmount().toString());
+//                request.setBizModel(model);
+//                AlipayTradeRefundResponse response = null;
+//                try {
+//                    response = alipayClient.execute(request);
+//                    log.info("支付宝退款返回 \n{}", JSON.parseObject(response.getBody())
+//                            .toString(SerializerFeature.PrettyFormat));
+//                    if (response.isSuccess() && "10000".equals(response.getCode())) {
+//                        apply.setStatus(DepositRefundStatus.SUCCESS);
+//                        apply.setRefundTime(LocalDateTime.now());
+//                        depositRefundApplyRepo.save(apply);
+//                        checkinInfo.setDepositStatus(DepositStatus.REFUNDED);
+//                    } else {
+//                        throw new BusinessException(String
+//                                .format("%s %s %s %s", response.getCode(), response.getMsg(),
+//                                        response.getSubCode(), response.getSubMsg()));
+//                    }
+//                } catch (AlipayApiException e) {
+//                    e.printStackTrace();
+//                    log.error("支付宝退款失败", e);
+//                    throw new BusinessException(e.getMessage());
+//                }
+//                break;
         }
     }
 

+ 45 - 52
src/main/java/com/izouma/zhumj/web/AlipayController.java

@@ -1,13 +1,6 @@
 package com.izouma.zhumj.web;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.alipay.api.AlipayApiException;
-import com.alipay.api.AlipayClient;
-import com.alipay.api.internal.util.AlipaySignature;
-import com.izouma.zhumj.config.AlipayProperties;
-import com.izouma.zhumj.service.CheckinInfoService;
-import com.izouma.zhumj.service.RechargeRecordService;
+
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.MapUtils;
@@ -29,48 +22,48 @@ import static com.alibaba.fastjson.serializer.SerializerFeature.PrettyFormat;
 @Slf4j
 @AllArgsConstructor
 public class AlipayController {
-    private AlipayClient          alipayClient;
-    private AlipayProperties      alipayProperties;
-    private CheckinInfoService    checkinInfoService;
-    private RechargeRecordService rechargeRecordService;
-
-    @PostMapping("/payNotify")
-    @ResponseBody
-    public String notify(HttpServletRequest request) throws AlipayApiException {
-        Map<String, String> params = new HashMap<>();
-        Set<Map.Entry<String, String[]>> entrySet = request.getParameterMap().entrySet();
-        for (Map.Entry<String, String[]> entry : entrySet) {
-            String name = entry.getKey();
-            String[] values = entry.getValue();
-            int valLen = values.length;
-
-            if (valLen == 1) {
-                params.put(name, values[0]);
-            } else if (valLen > 1) {
-                StringBuilder sb = new StringBuilder();
-                for (String val : values) {
-                    sb.append(",").append(val);
-                }
-                params.put(name, sb.toString().substring(1));
-            } else {
-                params.put(name, "");
-            }
-        }
-        log.info("支付宝回调 {}", JSON.toJSONString(params, PrettyFormat));
-        AlipaySignature.rsaCheckV1(params, alipayProperties.getAliPublicKey(), "UTF-8", "RSA2");
-        if (MapUtils.getString(params, "trade_status").equals("TRADE_SUCCESS")) {
-            JSONObject body = JSON.parseObject(params.get("body"));
-            String type = body.getString("type");
-            switch (type) {
-                case "deposit":
-                    checkinInfoService.handleDepositNotify(params, body);
-                    break;
-                case "recharge":
-                    rechargeRecordService.handleRechargeNotify(params, body);
-                    break;
-            }
-            return "success";
-        }
-        return "error";
-    }
+//    private AlipayClient          alipayClient;
+//    private AlipayProperties      alipayProperties;
+//    private CheckinInfoService    checkinInfoService;
+//    private RechargeRecordService rechargeRecordService;
+//
+//    @PostMapping("/payNotify")
+//    @ResponseBody
+//    public String notify(HttpServletRequest request) throws AlipayApiException {
+//        Map<String, String> params = new HashMap<>();
+//        Set<Map.Entry<String, String[]>> entrySet = request.getParameterMap().entrySet();
+//        for (Map.Entry<String, String[]> entry : entrySet) {
+//            String name = entry.getKey();
+//            String[] values = entry.getValue();
+//            int valLen = values.length;
+//
+//            if (valLen == 1) {
+//                params.put(name, values[0]);
+//            } else if (valLen > 1) {
+//                StringBuilder sb = new StringBuilder();
+//                for (String val : values) {
+//                    sb.append(",").append(val);
+//                }
+//                params.put(name, sb.toString().substring(1));
+//            } else {
+//                params.put(name, "");
+//            }
+//        }
+//        log.info("支付宝回调 {}", JSON.toJSONString(params, PrettyFormat));
+//        AlipaySignature.rsaCheckV1(params, alipayProperties.getAliPublicKey(), "UTF-8", "RSA2");
+//        if (MapUtils.getString(params, "trade_status").equals("TRADE_SUCCESS")) {
+//            JSONObject body = JSON.parseObject(params.get("body"));
+//            String type = body.getString("type");
+//            switch (type) {
+//                case "deposit":
+//                    checkinInfoService.handleDepositNotify(params, body);
+//                    break;
+//                case "recharge":
+//                    rechargeRecordService.handleRechargeNotify(params, body);
+//                    break;
+//            }
+//            return "success";
+//        }
+//        return "error";
+//    }
 }

+ 4 - 4
src/main/resources/application.yaml

@@ -178,7 +178,7 @@ generic:
   server-address: https://pms.izouma.com
 #  mp-address: https://zmjpms.com/mp
 alipay:
-  appCertPath: /var/www/zmj/cert/appCertPublicKey_2021002120645023.crt
-  aliPubCertPath: /var/www/zmj/cert/alipayCertPublicKey_RSA2.crt
-  rootCertPath: /var/www/zmj/cert/alipayRootCert.crt
-  notifyUrl: https://zmjpms.com/alipay/payNotify
+#  appCertPath: /var/www/zmj/cert/appCertPublicKey_2021002120645023.crt
+#  aliPubCertPath: /var/www/zmj/cert/alipayCertPublicKey_RSA2.crt
+#  rootCertPath: /var/www/zmj/cert/alipayRootCert.crt
+#  notifyUrl: https://zmjpms.com/alipay/payNotify