Skip to content

Commit a435ee5

Browse files
authored
🆕 #2807 【小程序】增加支付管理获取订单详情和申请退款的接口
2 parents 7a200c0 + 81bb1f3 commit a435ee5

File tree

5 files changed

+181
-3
lines changed

5 files changed

+181
-3
lines changed

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopPayService.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package cn.binarywang.wx.miniapp.api;
22

33
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest;
4+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayOrderRefundRequest;
5+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
46
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse;
58
import me.chanjar.weixin.common.error.WxErrorException;
69

710
/**
@@ -19,6 +22,25 @@ public interface WxMaShopPayService {
1922
* @return 创建订单结果
2023
* @throws WxErrorException .
2124
*/
22-
WxMaShopPayCreateOrderResponse createOrder(WxMaShopPayCreateOrderRequest request)
23-
throws WxErrorException;
25+
WxMaShopPayCreateOrderResponse createOrder(WxMaShopPayCreateOrderRequest request) throws WxErrorException;
26+
27+
/**
28+
* 查询订单详情
29+
* 文档地址:<a href="https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/order/get_order_detail.html">文档地址</a>
30+
*
31+
* @param trade_no
32+
* @return
33+
* @throws WxErrorException
34+
*/
35+
WxMaShopPayGetOrderResponse getOrder(String trade_no) throws WxErrorException;
36+
37+
/**
38+
* 订单退款
39+
* 文档地址:<a href="https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/order/refunds_order.html">文档地址</a>
40+
*
41+
* @param request
42+
* @return
43+
* @throws WxErrorException
44+
*/
45+
WxMaShopBaseResponse refundOrder(WxMaShopPayOrderRefundRequest request) throws WxErrorException;
2446
}

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopPayServiceImpl.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
import cn.binarywang.wx.miniapp.api.WxMaService;
44
import cn.binarywang.wx.miniapp.api.WxMaShopPayService;
55
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest;
6+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayOrderRefundRequest;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
68
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse;
9+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse;
710
import lombok.RequiredArgsConstructor;
811
import lombok.extern.slf4j.Slf4j;
912
import me.chanjar.weixin.common.error.WxErrorException;
1013
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
1114

12-
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Pay.CREATE_ORDER;
15+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Pay.*;
1316

1417
/**
1518
* 小程序支付管理订单相关接口
@@ -26,4 +29,16 @@ public WxMaShopPayCreateOrderResponse createOrder(WxMaShopPayCreateOrderRequest
2629
String response = this.wxMaService.post(CREATE_ORDER, request);
2730
return WxGsonBuilder.create().fromJson(response, WxMaShopPayCreateOrderResponse.class);
2831
}
32+
33+
@Override
34+
public WxMaShopPayGetOrderResponse getOrder(String tradeNo) throws WxErrorException {
35+
String response = this.wxMaService.post(GET_ORDER, tradeNo);
36+
return WxGsonBuilder.create().fromJson(response, WxMaShopPayGetOrderResponse.class);
37+
}
38+
39+
@Override
40+
public WxMaShopBaseResponse refundOrder(WxMaShopPayOrderRefundRequest request) throws WxErrorException {
41+
String response = this.wxMaService.post(REFUND_ORDER, request);
42+
return WxGsonBuilder.create().fromJson(response, WxMaShopBaseResponse.class);
43+
}
2944
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package cn.binarywang.wx.miniapp.bean.shop.request;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
import java.io.Serializable;
10+
11+
/**
12+
* @author liming1019
13+
* created on 2022/8/31
14+
*/
15+
@Data
16+
@Builder
17+
@NoArgsConstructor
18+
@AllArgsConstructor
19+
public class WxMaShopPayOrderRefundRequest implements Serializable {
20+
private static final long serialVersionUID = -5850024411710741165L;
21+
22+
@SerializedName("openid")
23+
private String openid;
24+
@SerializedName("mchid")
25+
private String mchid;
26+
@SerializedName("trade_no")
27+
private String tradeNo;
28+
@SerializedName("transaction_id")
29+
private String transactionId;
30+
@SerializedName("refund_no")
31+
private String refundNo;
32+
@SerializedName("total_amount")
33+
private int totalAmount;
34+
@SerializedName("refund_amount")
35+
private int refundAmount;
36+
}
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package cn.binarywang.wx.miniapp.bean.shop.response;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
import java.io.Serializable;
10+
import java.util.List;
11+
12+
/**
13+
* @author liming1019
14+
* created on 2022/8/31
15+
*/
16+
@Data
17+
@Builder
18+
@NoArgsConstructor
19+
@AllArgsConstructor
20+
public class WxMaShopPayGetOrderResponse extends WxMaShopBaseResponse implements Serializable {
21+
private static final long serialVersionUID = -3329915987130142268L;
22+
23+
@SerializedName("order")
24+
private OrderBean order;
25+
26+
@Data
27+
public static class OrderBean implements Serializable {
28+
@SerializedName("trade_no")
29+
private String tradeNo;
30+
@SerializedName("transaction_id")
31+
private String transactionId;
32+
@SerializedName("combine_trade_no")
33+
private String combineTradeNo;
34+
@SerializedName("mchid")
35+
private String mchid;
36+
@SerializedName("create_time")
37+
private int createTime;
38+
@SerializedName("update_time")
39+
private int updateTime;
40+
@SerializedName("pay_time")
41+
private int payTime;
42+
@SerializedName("expire_time")
43+
private int expireTime;
44+
@SerializedName("amount")
45+
private int amount;
46+
@SerializedName("description")
47+
private String description;
48+
@SerializedName("profit_sharing_delay")
49+
private int profitSharingDelay;
50+
@SerializedName("profit_sharing_frozen")
51+
private int profitSharingFrozen;
52+
@SerializedName("refund_list")
53+
private List<RefundListBean> refundList;
54+
@SerializedName("profit_sharing_list")
55+
private List<ProfitSharingListBean> profitSharingList;
56+
57+
@Data
58+
public static class RefundListBean implements Serializable {
59+
@SerializedName("amount")
60+
private int amount;
61+
@SerializedName("create_time")
62+
private int createTime;
63+
@SerializedName("finish_time")
64+
private int finishTime;
65+
@SerializedName("result")
66+
private String result;
67+
@SerializedName("refund_id")
68+
private String refundId;
69+
@SerializedName("refund_no")
70+
private String refundNo;
71+
}
72+
73+
@Data
74+
public static class ProfitSharingListBean implements Serializable {
75+
/**
76+
* mchid : 1623426221
77+
* amount : 1
78+
* create_time : 1648880985
79+
* finish_time : 1648881016
80+
* result : SUCCESS
81+
* profit_sharing_id : 30002107912022040228952584675
82+
* profit_sharing_no : 512341
83+
*/
84+
85+
@SerializedName("mchid")
86+
private String mchid;
87+
@SerializedName("amount")
88+
private int amount;
89+
@SerializedName("create_time")
90+
private int createTime;
91+
@SerializedName("finish_time")
92+
private int finishTime;
93+
@SerializedName("result")
94+
private String result;
95+
@SerializedName("profit_sharing_id")
96+
private String profitSharingId;
97+
@SerializedName("profit_sharing_no")
98+
private String profitSharingNo;
99+
}
100+
}
101+
}
102+

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java

+2
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ interface Coupon {
541541

542542
interface Pay {
543543
String CREATE_ORDER = "https://api.weixin.qq.com/shop/pay/createorder";
544+
String GET_ORDER = "https://api.weixin.qq.com/shop/pay/getorder";
545+
String REFUND_ORDER = "https://api.weixin.qq.com/shop/pay/refundorder";
544546
}
545547
}
546548

0 commit comments

Comments
 (0)