Commit 76f3c2f621126691b8faeb8f9604e171832ea712

Authored by fengliang
1 parent 3622f86a

update:支付修改

etrade-order/src/main/java/com/diligrp/etrade/order/domain/OrderWeChatPayBatch.java
1 1 package com.diligrp.etrade.order.domain;
2 2  
3 3 import jakarta.validation.Valid;
  4 +import jakarta.validation.constraints.NotBlank;
4 5 import jakarta.validation.constraints.NotEmpty;
5 6 import jakarta.validation.constraints.NotNull;
6 7 import jakarta.validation.constraints.Size;
... ... @@ -18,13 +19,12 @@ public class OrderWeChatPayBatch {
18 19 private List<String> codes;
19 20  
20 21 /** 市场自增主键 */
21   - @NotNull(message = "市场id不能为空")
22 22 private Long marketId;
23 23  
24 24 /** 付款人客户id */
25 25 @NotNull(message = "买家客户id不能为空")
26 26 private Long payerCustomerId;
27   - @NotEmpty(message = "买家客户code不能为空")
  27 + @NotBlank(message = "买家客户code不能为空")
28 28 private String payerCustomerCode;
29 29  
30 30 /** 付款常客id */
... ... @@ -43,13 +43,6 @@ public class OrderWeChatPayBatch {
43 43 @NotNull(message = "付款金额不能为空")
44 44 private BigDecimal totlePayAmount;
45 45  
46   - @NotNull(message = "openId不能为空")
47   - private String openId;
48   -
49   - private String subAppid;
50   -
51   - private String subOpenId;
52   -
53 46 @NotNull(message = "店铺不能为空")
54 47 private Long shopId;
55 48  
... ... @@ -61,6 +54,9 @@ public class OrderWeChatPayBatch {
61 54 @Valid
62 55 private OrderDeliveryDto delivery;
63 56  
  57 + @NotBlank(message = "登陆编码不能为空")
  58 + private String code;
  59 +
64 60 public String getPayType() {
65 61 return payType;
66 62 }
... ... @@ -149,30 +145,6 @@ public class OrderWeChatPayBatch {
149 145 this.payerCustomerCode = payerCustomerCode;
150 146 }
151 147  
152   - public String getOpenId() {
153   - return openId;
154   - }
155   -
156   - public void setOpenId(String openId) {
157   - this.openId = openId;
158   - }
159   -
160   - public String getSubAppid() {
161   - return subAppid;
162   - }
163   -
164   - public void setSubAppid(String subAppid) {
165   - this.subAppid = subAppid;
166   - }
167   -
168   - public String getSubOpenId() {
169   - return subOpenId;
170   - }
171   -
172   - public void setSubOpenId(String subOpenId) {
173   - this.subOpenId = subOpenId;
174   - }
175   -
176 148 public String getCustomerAbbr() {
177 149 return customerAbbr;
178 150 }
... ... @@ -204,4 +176,12 @@ public class OrderWeChatPayBatch {
204 176 public void setDelivery(OrderDeliveryDto delivery) {
205 177 this.delivery = delivery;
206 178 }
  179 +
  180 + public String getCode() {
  181 + return code;
  182 + }
  183 +
  184 + public void setCode(String code) {
  185 + this.code = code;
  186 + }
207 187 }
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderServiceImpl.java
... ... @@ -763,13 +763,12 @@ public class OrderServiceImpl implements OrderService {
763 763 }
764 764 List<String> paymentIdList = orderPaymentService.checkNotPayPaymentOrder(orderWeChatPayBatch.getCodes());
765 765 if(paymentIdList!=null&&paymentIdList.size()>=1){
766   - Message message= wxChatPayClose(paymentIdList,orderWeChatPayBatch.getMarketId(),orderWeChatPayBatch.getOpenId());
  766 + Message message= wxChatPayClose(paymentIdList,orderWeChatPayBatch.getMarketId());
767 767 if(message!=null){
768 768 return message;
769 769 }
770 770 }
771 771  
772   - List<OrderPayment> orderPaymentList = new ArrayList<>();
773 772 WeChatPayTradeDto weChatPayTradeDto = new WeChatPayTradeDto();
774 773 //效验店铺
775 774 ShopVo shop = orderGoodsService.checkShop(orderWeChatPayBatch.getShopId());
... ... @@ -778,16 +777,11 @@ public class OrderServiceImpl implements OrderService {
778 777 }
779 778 //构建微信支付参数
780 779 weChatPayTradeDto.setAmount(orderWeChatPayBatch.getTotlePayAmount().multiply(NumberTransform.ONE_HUNDERD).longValue());
781   - weChatPayTradeDto.setPayType(orderWeChatPayBatch.getPayType());
782   - weChatPayTradeDto.setType(WeChatPayType.TRADE.getCode());
783   - weChatPayTradeDto.setFees(null);
784   - weChatPayTradeDto.setAccountId(null);
785   - weChatPayTradeDto.setSerialNo(orderWeChatPayBatch.getCodes().get(0));
  780 + weChatPayTradeDto.setType(orderWeChatPayBatch.getPayType());
  781 + weChatPayTradeDto.setCode(orderWeChatPayBatch.getCode());
  782 + weChatPayTradeDto.setOutTradeNo(orderWeChatPayBatch.getCodes().get(0));
786 783 weChatPayTradeDto.setGoodsDesc(shop.getName());
787   - weChatPayTradeDto.setOpenId(orderWeChatPayBatch.getOpenId());
788   - weChatPayTradeDto.setSubMchId(shop.getWxMerchantNumber());
789 784 weChatPayTradeDto.setNotifyUrl(OrderConstant.WECHATPAY_BACK_API);
790   - weChatPayTradeDto.setMarketId(orderWeChatPayBatch.getMarketId());
791 785 weChatPayTradeDto.setDescription("电子结算微信交易");
792 786 WeChatPayTradeBackDto weChatPayTradeBackDto = orderPaymentService.WeChatPay(weChatPayTradeDto);
793 787 if(weChatPayTradeBackDto == null){
... ... @@ -810,8 +804,7 @@ public class OrderServiceImpl implements OrderService {
810 804 ,orderWeChatPayBatch.getPayerStoreCustomerId(),orderWeChatPayBatch.getPayerCustomerName(),orderWeChatPayBatch.getPayerPhone()
811 805 ,null,null,null,null,orderWeChatPayBatch.getOperateId(),orderWeChatPayBatch.getOperateName()
812 806 ,null,null,null,orderWeChatPayBatch.getCustomerAbbr(),weChatPayTradeBackDto.getPaymentId());
813   - OrderPayVo payVo = orderPaymentService.createOrderPayment(order, orderPayDto, identityType,shop);
814   - orderPaymentList.add(payVo.getOrderPayment());
  807 + orderPaymentService.createOrderPayment(order, orderPayDto, identityType,shop);
815 808 }catch (PlatformServiceException pe){
816 809 LOGGER.info("微信支付异常,支付订单号:{},异常信息{}",orderWeChatPayBatch.getCodes(),pe.getMessage());
817 810 wxChatPayCloseOnly(weChatPayTradeBackDto.getPaymentId(),orderWeChatPayBatch.getMarketId(),null);
... ... @@ -827,14 +820,12 @@ public class OrderServiceImpl implements OrderService {
827 820 //扣减库存T
828 821 orderGoodsService.deductBatch(orderList,orderWeChatPayBatch.getPayerCustomerId(),orderWeChatPayBatch.getPayerCustomerName());
829 822  
830   - //保存待支付单
831   - //orderPaymentService.saveBatch(orderPaymentList);
832 823 //返回数据,由小程序发起微信支付。
833 824 return Message.success(weChatPayTradeBackDto);
834 825 }
835 826  
836 827 @Transactional(rollbackFor = Exception.class)
837   - public Message wxChatPayClose(List<String> paymentIds, Long marketId, String openId) {
  828 + public Message wxChatPayClose(List<String> paymentIds, Long marketId) {
838 829 for(String paymentId: paymentIds){
839 830 RLock lock = redissonClient.getLock(OrderConstant.OrderLock + paymentId);
840 831 try{
... ...
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/dto/WeChatPayTradeDto.java
... ... @@ -11,22 +11,12 @@ import java.util.List;
11 11 * @Date 2024-3-25
12 12 */
13 13 public class WeChatPayTradeDto {
14   - /**
15   - * 交易类型
16   - * 当前只支持10-充值 12-缴费
17   - */
18   - @NotNull(message = "type should not be null")
19   - private Integer type;
  14 +
20 15 /**
21 16 * 支付方式-JSAPI, NATIVE等
22 17 */
23 18 @NotNull(message = "payType should not be null")
24   - private String payType;
25   - /**
26   - * 资金账号
27   - */
28   - private Long accountId;
29   -
  19 + private String type;
30 20 /**
31 21 * 微信商品描述-微信扫码支付时显示-不超过128个字符
32 22 */
... ... @@ -40,7 +30,11 @@ public class WeChatPayTradeDto {
40 30 /**
41 31 * 业务单号
42 32 */
43   - private String serialNo;
  33 + private String outTradeNo;
  34 + /**
  35 + * 小程序登陆凭证
  36 + */
  37 + private String code;
44 38 /**
45 39 * 支付结果通知URL
46 40 */
... ... @@ -50,81 +44,16 @@ public class WeChatPayTradeDto {
50 44 */
51 45 private String description;
52 46  
53   - /**
54   - * 买卖家手续费
55   - */
56   - private List<FeeDto> fees;
57   -
58   - /**
59   - * 微信用户标识-JSAPI使用
60   - */
61   - private String openId;
62   -
63   - /**
64   - * 服务商的AppID
65   - */
66   - private String subMchId;
67   -
68   - /**
69   - * 服务商模式下,服务商APPID下的openId
70   - */
71   - private String subMchIdopenId;
72   -
73   - /**
74   - * 优惠卷信息
75   - */
76   - private List<DeductFeesDto> deductFees;
77   -
78   - /**
79   - * 市场id
80   - */
81 47 private Long marketId;
82 48  
83   - /**
84   - *
85   - */
86   - private String paymentId;
87   -
88   - public String getPaymentId() {
89   - return paymentId;
90   - }
91   -
92   - public void setPaymentId(String paymentId) {
93   - this.paymentId = paymentId;
94   - }
95   -
96   - public Long getMarketId() {
97   - return marketId;
98   - }
99   -
100   - public void setMarketId(Long marketId) {
101   - this.marketId = marketId;
102   - }
103   -
104   - public Integer getType() {
  49 + public String getType() {
105 50 return type;
106 51 }
107 52  
108   - public void setType(Integer type) {
  53 + public void setType(String type) {
109 54 this.type = type;
110 55 }
111 56  
112   - public String getPayType() {
113   - return payType;
114   - }
115   -
116   - public void setPayType(String payType) {
117   - this.payType = payType;
118   - }
119   -
120   - public Long getAccountId() {
121   - return accountId;
122   - }
123   -
124   - public void setAccountId(Long accountId) {
125   - this.accountId = accountId;
126   - }
127   -
128 57 public String getGoodsDesc() {
129 58 return goodsDesc;
130 59 }
... ... @@ -141,12 +70,20 @@ public class WeChatPayTradeDto {
141 70 this.amount = amount;
142 71 }
143 72  
144   - public String getSerialNo() {
145   - return serialNo;
  73 + public String getOutTradeNo() {
  74 + return outTradeNo;
  75 + }
  76 +
  77 + public void setOutTradeNo(String outTradeNo) {
  78 + this.outTradeNo = outTradeNo;
146 79 }
147 80  
148   - public void setSerialNo(String serialNo) {
149   - this.serialNo = serialNo;
  81 + public String getCode() {
  82 + return code;
  83 + }
  84 +
  85 + public void setCode(String code) {
  86 + this.code = code;
150 87 }
151 88  
152 89 public String getNotifyUrl() {
... ... @@ -165,43 +102,11 @@ public class WeChatPayTradeDto {
165 102 this.description = description;
166 103 }
167 104  
168   - public List<FeeDto> getFees() {
169   - return fees;
170   - }
171   -
172   - public void setFees(List<FeeDto> fees) {
173   - this.fees = fees;
174   - }
175   -
176   - public String getOpenId() {
177   - return openId;
178   - }
179   -
180   - public void setOpenId(String openId) {
181   - this.openId = openId;
182   - }
183   -
184   - public String getSubMchId() {
185   - return subMchId;
186   - }
187   -
188   - public void setSubMchId(String subMchId) {
189   - this.subMchId = subMchId;
190   - }
191   -
192   - public String getSubMchIdopenId() {
193   - return subMchIdopenId;
194   - }
195   -
196   - public void setSubMchIdopenId(String subMchIdopenId) {
197   - this.subMchIdopenId = subMchIdopenId;
198   - }
199   -
200   - public List<DeductFeesDto> getDeductFees() {
201   - return deductFees;
  105 + public Long getMarketId() {
  106 + return marketId;
202 107 }
203 108  
204   - public void setDeductFees(List<DeductFeesDto> deductFees) {
205   - this.deductFees = deductFees;
  109 + public void setMarketId(Long marketId) {
  110 + this.marketId = marketId;
206 111 }
207 112 }
... ...
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/resolver/WeChatPayRpcResolver.java
... ... @@ -29,11 +29,11 @@ public class WeChatPayRpcResolver {
29 29 /** 支付系统token */
30 30 public static final String PAYMENT_TOKEN = "abcd2010";
31 31 /** 创建预支付 */
32   - public static final String PAY_STATE_PREPARE ="wechat.payment.service:prepare";
  32 + public static final String PAY_STATE_PREPARE ="hzbank.payment.service:prepay";
33 33 /** 微信支付状态查询 */
34   - public static final String PAY_STATE_CHECK ="wechat.payment.service:state";
  34 + public static final String PAY_STATE_CHECK ="hzbank.payment.service:state";
35 35 /** 微信支付关闭订单 */
36   - public static final String PAY_STATE_CLOSE ="wechat.payment.service:close";
  36 + public static final String PAY_STATE_CLOSE ="hzbank.payment.service:close";
37 37 // /** 微信支付历史交易查询 */
38 38 // public static final String PAY_STATE_INFO ="wechat.payment.service:statement";
39 39 // /** 微信支付退款 */
... ... @@ -54,9 +54,6 @@ public class WeChatPayRpcResolver {
54 54 //创建提交单
55 55 weChatPayTradeDto.setNotifyUrl(backBaseUrl+weChatPayTradeDto.getNotifyUrl());
56 56 weChatPayTradeDto.setDescription(weChatPayTradeDto.getDescription()==null?"电子交易结算":weChatPayTradeDto.getDescription());
57   - if(weChatPayTradeDto.getAccountId()==null){
58   - weChatPayTradeDto.setAccountId(1L);
59   - }
60 57 //组装headers
61 58 HttpHeaders prepareHeaders = creatHeader(weChatPayTradeDto.getMarketId().toString(),PAY_STATE_PREPARE);
62 59 Message<WeChatPayTradeBackDto> prepareJsonObject = payRpc.wechatPay(weChatPayTradeDto, prepareHeaders);
... ...