Skip to content

Commit 69a2ab9

Browse files
authored
🆕 #3720 【微信支付】实现微信押金支付的相关功能接口
1 parent 0854e4d commit 69a2ab9

15 files changed

+1468
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package com.github.binarywang.wxpay.bean.request;
2+
3+
import com.github.binarywang.wxpay.exception.WxPayException;
4+
import com.thoughtworks.xstream.annotations.XStreamAlias;
5+
import lombok.*;
6+
import me.chanjar.weixin.common.annotation.Required;
7+
8+
import java.util.Map;
9+
10+
/**
11+
* <pre>
12+
* 押金消费请求
13+
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=4">https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=4</a>
14+
* </pre>
15+
*
16+
* @author Binary Wang
17+
* created on 2024-09-24
18+
*/
19+
@Data
20+
@EqualsAndHashCode(callSuper = true)
21+
@Builder(builderMethodName = "newBuilder")
22+
@NoArgsConstructor
23+
@AllArgsConstructor
24+
@XStreamAlias("xml")
25+
public class WxDepositConsumeRequest extends BaseWxPayRequest {
26+
27+
/**
28+
* <pre>
29+
* 微信押金订单号
30+
* transaction_id
31+
* 是
32+
* String(32)
33+
* 1009660380201506130728806387
34+
* 微信押金订单号
35+
* </pre>
36+
*/
37+
@Required
38+
@XStreamAlias("transaction_id")
39+
private String transactionId;
40+
41+
/**
42+
* <pre>
43+
* 商户消费单号
44+
* out_trade_no
45+
* 是
46+
* String(32)
47+
* 20150806125346
48+
* 商户系统内部的消费单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
49+
* </pre>
50+
*/
51+
@Required
52+
@XStreamAlias("out_trade_no")
53+
private String outTradeNo;
54+
55+
/**
56+
* <pre>
57+
* 消费金额
58+
* consume_fee
59+
* 是
60+
* Int
61+
* 88
62+
* 消费金额,单位为分,不能大于押金金额
63+
* </pre>
64+
*/
65+
@Required
66+
@XStreamAlias("consume_fee")
67+
private Integer consumeFee;
68+
69+
/**
70+
* <pre>
71+
* 消费描述
72+
* consume_desc
73+
* 否
74+
* String(128)
75+
* 单车使用费
76+
* 对一笔消费的具体描述信息
77+
* </pre>
78+
*/
79+
@XStreamAlias("consume_desc")
80+
private String consumeDesc;
81+
82+
@Override
83+
protected void checkConstraints() throws WxPayException {
84+
// No additional constraints beyond @Required fields
85+
}
86+
87+
@Override
88+
protected void storeMap(Map<String, String> map) {
89+
map.put("transaction_id", transactionId);
90+
map.put("out_trade_no", outTradeNo);
91+
map.put("consume_fee", consumeFee.toString());
92+
if (consumeDesc != null) {
93+
map.put("consume_desc", consumeDesc);
94+
}
95+
}
96+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.github.binarywang.wxpay.bean.request;
2+
3+
import com.github.binarywang.wxpay.exception.WxPayException;
4+
import com.thoughtworks.xstream.annotations.XStreamAlias;
5+
import lombok.*;
6+
import me.chanjar.weixin.common.annotation.Required;
7+
8+
import java.util.Map;
9+
10+
/**
11+
* <pre>
12+
* 查询押金订单请求
13+
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=3">https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=3</a>
14+
* </pre>
15+
*
16+
* @author Binary Wang
17+
* created on 2024-09-24
18+
*/
19+
@Data
20+
@EqualsAndHashCode(callSuper = true)
21+
@Builder(builderMethodName = "newBuilder")
22+
@NoArgsConstructor
23+
@AllArgsConstructor
24+
@XStreamAlias("xml")
25+
public class WxDepositOrderQueryRequest extends BaseWxPayRequest {
26+
27+
/**
28+
* <pre>
29+
* 微信订单号
30+
* transaction_id
31+
* 否
32+
* String(32)
33+
* 1009660380201506130728806387
34+
* 微信的订单号,优先使用
35+
* </pre>
36+
*/
37+
@XStreamAlias("transaction_id")
38+
private String transactionId;
39+
40+
/**
41+
* <pre>
42+
* 商户订单号
43+
* out_trade_no
44+
* 否
45+
* String(32)
46+
* 20150806125346
47+
* 商户系统内部的订单号,当没提供transaction_id时需要传这个
48+
* </pre>
49+
*/
50+
@XStreamAlias("out_trade_no")
51+
private String outTradeNo;
52+
53+
@Override
54+
protected void checkConstraints() throws WxPayException {
55+
if (transactionId == null && outTradeNo == null) {
56+
throw new WxPayException("transaction_id 和 out_trade_no 不能同时为空");
57+
}
58+
}
59+
60+
@Override
61+
protected void storeMap(Map<String, String> map) {
62+
if (transactionId != null) {
63+
map.put("transaction_id", transactionId);
64+
}
65+
if (outTradeNo != null) {
66+
map.put("out_trade_no", outTradeNo);
67+
}
68+
}
69+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package com.github.binarywang.wxpay.bean.request;
2+
3+
import com.github.binarywang.wxpay.exception.WxPayException;
4+
import com.thoughtworks.xstream.annotations.XStreamAlias;
5+
import lombok.*;
6+
import me.chanjar.weixin.common.annotation.Required;
7+
8+
import java.util.Map;
9+
10+
/**
11+
* <pre>
12+
* 押金退款请求
13+
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=6">https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=6</a>
14+
* </pre>
15+
*
16+
* @author Binary Wang
17+
* created on 2024-09-24
18+
*/
19+
@Data
20+
@EqualsAndHashCode(callSuper = true)
21+
@Builder(builderMethodName = "newBuilder")
22+
@NoArgsConstructor
23+
@AllArgsConstructor
24+
@XStreamAlias("xml")
25+
public class WxDepositRefundRequest extends BaseWxPayRequest {
26+
27+
/**
28+
* <pre>
29+
* 微信押金订单号
30+
* transaction_id
31+
* 否
32+
* String(32)
33+
* 1009660380201506130728806387
34+
* 微信押金订单号,与out_trade_no二选一
35+
* </pre>
36+
*/
37+
@XStreamAlias("transaction_id")
38+
private String transactionId;
39+
40+
/**
41+
* <pre>
42+
* 商户押金订单号
43+
* out_trade_no
44+
* 否
45+
* String(32)
46+
* 20150806125346
47+
* 商户系统内部的押金订单号,与transaction_id二选一
48+
* </pre>
49+
*/
50+
@XStreamAlias("out_trade_no")
51+
private String outTradeNo;
52+
53+
/**
54+
* <pre>
55+
* 商户退款单号
56+
* out_refund_no
57+
* 是
58+
* String(32)
59+
* 1217752501201407033233368018
60+
* 商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔
61+
* </pre>
62+
*/
63+
@Required
64+
@XStreamAlias("out_refund_no")
65+
private String outRefundNo;
66+
67+
/**
68+
* <pre>
69+
* 退款金额
70+
* refund_fee
71+
* 是
72+
* Int
73+
* 100
74+
* 退款总金额,订单总金额,单位为分,只能为整数
75+
* </pre>
76+
*/
77+
@Required
78+
@XStreamAlias("refund_fee")
79+
private Integer refundFee;
80+
81+
/**
82+
* <pre>
83+
* 退款原因
84+
* refund_desc
85+
* 否
86+
* String(80)
87+
* 商品已售完
88+
* 若商户传入,会在下发给用户的退款消息中体现退款原因
89+
* </pre>
90+
*/
91+
@XStreamAlias("refund_desc")
92+
private String refundDesc;
93+
94+
@Override
95+
protected void checkConstraints() throws WxPayException {
96+
if (transactionId == null && outTradeNo == null) {
97+
throw new WxPayException("transaction_id 和 out_trade_no 不能同时为空");
98+
}
99+
}
100+
101+
@Override
102+
protected void storeMap(Map<String, String> map) {
103+
if (transactionId != null) {
104+
map.put("transaction_id", transactionId);
105+
}
106+
if (outTradeNo != null) {
107+
map.put("out_trade_no", outTradeNo);
108+
}
109+
map.put("out_refund_no", outRefundNo);
110+
map.put("refund_fee", refundFee.toString());
111+
if (refundDesc != null) {
112+
map.put("refund_desc", refundDesc);
113+
}
114+
}
115+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package com.github.binarywang.wxpay.bean.request;
2+
3+
import com.github.binarywang.wxpay.exception.WxPayException;
4+
import com.thoughtworks.xstream.annotations.XStreamAlias;
5+
import lombok.*;
6+
import me.chanjar.weixin.common.annotation.Required;
7+
8+
import java.util.Map;
9+
10+
/**
11+
* <pre>
12+
* 押金撤销请求
13+
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=5">https://pay.weixin.qq.com/wiki/doc/api/deposit_sl.php?chapter=27_7&index=5</a>
14+
* </pre>
15+
*
16+
* @author Binary Wang
17+
* created on 2024-09-24
18+
*/
19+
@Data
20+
@EqualsAndHashCode(callSuper = true)
21+
@Builder(builderMethodName = "newBuilder")
22+
@NoArgsConstructor
23+
@AllArgsConstructor
24+
@XStreamAlias("xml")
25+
public class WxDepositUnfreezeRequest extends BaseWxPayRequest {
26+
27+
/**
28+
* <pre>
29+
* 微信押金订单号
30+
* transaction_id
31+
* 是
32+
* String(32)
33+
* 1009660380201506130728806387
34+
* 微信押金订单号
35+
* </pre>
36+
*/
37+
@Required
38+
@XStreamAlias("transaction_id")
39+
private String transactionId;
40+
41+
/**
42+
* <pre>
43+
* 商户撤销单号
44+
* out_trade_no
45+
* 是
46+
* String(32)
47+
* 20150806125346
48+
* 商户系统内部的撤销单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一
49+
* </pre>
50+
*/
51+
@Required
52+
@XStreamAlias("out_trade_no")
53+
private String outTradeNo;
54+
55+
/**
56+
* <pre>
57+
* 撤销金额
58+
* unfreeze_fee
59+
* 是
60+
* Int
61+
* 99
62+
* 撤销金额,单位为分,不能大于剩余押金金额
63+
* </pre>
64+
*/
65+
@Required
66+
@XStreamAlias("unfreeze_fee")
67+
private Integer unfreezeFee;
68+
69+
/**
70+
* <pre>
71+
* 撤销原因
72+
* unfreeze_desc
73+
* 否
74+
* String(128)
75+
* 用户主动取消
76+
* 对一笔撤销的具体原因描述
77+
* </pre>
78+
*/
79+
@XStreamAlias("unfreeze_desc")
80+
private String unfreezeDesc;
81+
82+
@Override
83+
protected void checkConstraints() throws WxPayException {
84+
// No additional constraints beyond @Required fields
85+
}
86+
87+
@Override
88+
protected void storeMap(Map<String, String> map) {
89+
map.put("transaction_id", transactionId);
90+
map.put("out_trade_no", outTradeNo);
91+
map.put("unfreeze_fee", unfreezeFee.toString());
92+
if (unfreezeDesc != null) {
93+
map.put("unfreeze_desc", unfreezeDesc);
94+
}
95+
}
96+
}

0 commit comments

Comments
 (0)