mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-02 20:02:37 +08:00
🆕 #2807 【小程序】增加支付管理获取订单详情和申请退款的接口
This commit is contained in:
commit
a435ee5a01
@ -1,7 +1,10 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayOrderRefundRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
@ -19,6 +22,25 @@ public interface WxMaShopPayService {
|
||||
* @return 创建订单结果
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxMaShopPayCreateOrderResponse createOrder(WxMaShopPayCreateOrderRequest request)
|
||||
throws WxErrorException;
|
||||
WxMaShopPayCreateOrderResponse createOrder(WxMaShopPayCreateOrderRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 查询订单详情
|
||||
* 文档地址:<a href="https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/order/get_order_detail.html">文档地址</a>
|
||||
*
|
||||
* @param trade_no
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopPayGetOrderResponse getOrder(String trade_no) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
* 文档地址:<a href="https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/order/refunds_order.html">文档地址</a>
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopBaseResponse refundOrder(WxMaShopPayOrderRefundRequest request) throws WxErrorException;
|
||||
}
|
||||
|
@ -3,13 +3,16 @@ package cn.binarywang.wx.miniapp.api.impl;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShopPayService;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayOrderRefundRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Pay.CREATE_ORDER;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Pay.*;
|
||||
|
||||
/**
|
||||
* 小程序支付管理订单相关接口
|
||||
@ -26,4 +29,16 @@ public class WxMaShopPayServiceImpl implements WxMaShopPayService {
|
||||
String response = this.wxMaService.post(CREATE_ORDER, request);
|
||||
return WxGsonBuilder.create().fromJson(response, WxMaShopPayCreateOrderResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopPayGetOrderResponse getOrder(String tradeNo) throws WxErrorException {
|
||||
String response = this.wxMaService.post(GET_ORDER, tradeNo);
|
||||
return WxGsonBuilder.create().fromJson(response, WxMaShopPayGetOrderResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse refundOrder(WxMaShopPayOrderRefundRequest request) throws WxErrorException {
|
||||
String response = this.wxMaService.post(REFUND_ORDER, request);
|
||||
return WxGsonBuilder.create().fromJson(response, WxMaShopBaseResponse.class);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package cn.binarywang.wx.miniapp.bean.shop.request;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
* created on 2022/8/31
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxMaShopPayOrderRefundRequest implements Serializable {
|
||||
private static final long serialVersionUID = -5850024411710741165L;
|
||||
|
||||
@SerializedName("openid")
|
||||
private String openid;
|
||||
@SerializedName("mchid")
|
||||
private String mchid;
|
||||
@SerializedName("trade_no")
|
||||
private String tradeNo;
|
||||
@SerializedName("transaction_id")
|
||||
private String transactionId;
|
||||
@SerializedName("refund_no")
|
||||
private String refundNo;
|
||||
@SerializedName("total_amount")
|
||||
private int totalAmount;
|
||||
@SerializedName("refund_amount")
|
||||
private int refundAmount;
|
||||
}
|
||||
|
@ -0,0 +1,102 @@
|
||||
package cn.binarywang.wx.miniapp.bean.shop.response;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
* created on 2022/8/31
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxMaShopPayGetOrderResponse extends WxMaShopBaseResponse implements Serializable {
|
||||
private static final long serialVersionUID = -3329915987130142268L;
|
||||
|
||||
@SerializedName("order")
|
||||
private OrderBean order;
|
||||
|
||||
@Data
|
||||
public static class OrderBean implements Serializable {
|
||||
@SerializedName("trade_no")
|
||||
private String tradeNo;
|
||||
@SerializedName("transaction_id")
|
||||
private String transactionId;
|
||||
@SerializedName("combine_trade_no")
|
||||
private String combineTradeNo;
|
||||
@SerializedName("mchid")
|
||||
private String mchid;
|
||||
@SerializedName("create_time")
|
||||
private int createTime;
|
||||
@SerializedName("update_time")
|
||||
private int updateTime;
|
||||
@SerializedName("pay_time")
|
||||
private int payTime;
|
||||
@SerializedName("expire_time")
|
||||
private int expireTime;
|
||||
@SerializedName("amount")
|
||||
private int amount;
|
||||
@SerializedName("description")
|
||||
private String description;
|
||||
@SerializedName("profit_sharing_delay")
|
||||
private int profitSharingDelay;
|
||||
@SerializedName("profit_sharing_frozen")
|
||||
private int profitSharingFrozen;
|
||||
@SerializedName("refund_list")
|
||||
private List<RefundListBean> refundList;
|
||||
@SerializedName("profit_sharing_list")
|
||||
private List<ProfitSharingListBean> profitSharingList;
|
||||
|
||||
@Data
|
||||
public static class RefundListBean implements Serializable {
|
||||
@SerializedName("amount")
|
||||
private int amount;
|
||||
@SerializedName("create_time")
|
||||
private int createTime;
|
||||
@SerializedName("finish_time")
|
||||
private int finishTime;
|
||||
@SerializedName("result")
|
||||
private String result;
|
||||
@SerializedName("refund_id")
|
||||
private String refundId;
|
||||
@SerializedName("refund_no")
|
||||
private String refundNo;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ProfitSharingListBean implements Serializable {
|
||||
/**
|
||||
* mchid : 1623426221
|
||||
* amount : 1
|
||||
* create_time : 1648880985
|
||||
* finish_time : 1648881016
|
||||
* result : SUCCESS
|
||||
* profit_sharing_id : 30002107912022040228952584675
|
||||
* profit_sharing_no : 512341
|
||||
*/
|
||||
|
||||
@SerializedName("mchid")
|
||||
private String mchid;
|
||||
@SerializedName("amount")
|
||||
private int amount;
|
||||
@SerializedName("create_time")
|
||||
private int createTime;
|
||||
@SerializedName("finish_time")
|
||||
private int finishTime;
|
||||
@SerializedName("result")
|
||||
private String result;
|
||||
@SerializedName("profit_sharing_id")
|
||||
private String profitSharingId;
|
||||
@SerializedName("profit_sharing_no")
|
||||
private String profitSharingNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -541,6 +541,8 @@ public class WxMaApiUrlConstants {
|
||||
|
||||
interface Pay {
|
||||
String CREATE_ORDER = "https://api.weixin.qq.com/shop/pay/createorder";
|
||||
String GET_ORDER = "https://api.weixin.qq.com/shop/pay/getorder";
|
||||
String REFUND_ORDER = "https://api.weixin.qq.com/shop/pay/refundorder";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user