mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-20 00:44:25 +08:00
🆕 #3479 【小程序】新增订单管理的配置和查询订单配置路径的接口
This commit is contained in:
parent
ab1c150feb
commit
b0daf8428e
@ -0,0 +1,40 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.order.WxMaOrderManagementGetOrderDetailPath;
|
||||
import cn.binarywang.wx.miniapp.bean.order.WxMaOrderManagementResult;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoBaseResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* @author xzh
|
||||
* @Description
|
||||
* @createTime 2025/01/16 15:20
|
||||
*/
|
||||
public interface WxMaOrderManagementService {
|
||||
|
||||
/**
|
||||
* 查询订单详情路径
|
||||
* 注意事项
|
||||
* 如果没有配置过订单详情路径,会返回成功,其中path为''。
|
||||
*
|
||||
* @return WxMaOrderManagementGetOrderDetailPath
|
||||
* @throws WxErrorException e
|
||||
*/
|
||||
WxMaOrderManagementGetOrderDetailPath getOrderDetailPath()
|
||||
throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 配置订单详情路径
|
||||
* 注意事项
|
||||
* 调用接口前需要先完成订单中心授权协议签署。
|
||||
* 请确保配置的path可正常跳转到小程序,并且path必须包含字符串“${商品订单号}”。
|
||||
*
|
||||
* @param path 订单详情路径
|
||||
* @return WxMaOrderManagementResult
|
||||
* @throws WxErrorException e
|
||||
*/
|
||||
WxMaOrderManagementResult updateOrderDetailPath(String path)
|
||||
throws WxErrorException;
|
||||
|
||||
}
|
||||
@ -550,6 +550,12 @@ public interface WxMaService extends WxService {
|
||||
* @return getWxMaOrderShippingService
|
||||
*/
|
||||
WxMaOrderShippingService getWxMaOrderShippingService();
|
||||
/**
|
||||
* 小程序订单管理服务
|
||||
*
|
||||
* @return WxMaOrderManagementService
|
||||
*/
|
||||
WxMaOrderManagementService getWxMaOrderManagementService();
|
||||
|
||||
/**
|
||||
* 小程序openApi管理
|
||||
|
||||
@ -153,6 +153,9 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
private final WxMaOrderShippingService wxMaOrderShippingService =
|
||||
new WxMaOrderShippingServiceImpl(this);
|
||||
|
||||
private final WxMaOrderManagementService wxMaOrderManagementService =
|
||||
new WxMaOrderManagementServiceImpl(this);
|
||||
|
||||
private final WxMaOpenApiService wxMaOpenApiService = new WxMaOpenApiServiceImpl(this);
|
||||
private final WxMaVodService wxMaVodService = new WxMaVodServiceImpl(this);
|
||||
private final WxMaXPayService wxMaXPayService = new WxMaXPayServiceImpl(this);
|
||||
@ -817,6 +820,16 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
return this.wxMaOrderShippingService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序订单管理服务
|
||||
*
|
||||
* @return WxMaOrderManagementService
|
||||
*/
|
||||
@Override
|
||||
public WxMaOrderManagementService getWxMaOrderManagementService() {
|
||||
return this.wxMaOrderManagementService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaOpenApiService getWxMaOpenApiService() {
|
||||
return this.wxMaOpenApiService;
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaOrderManagementService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.order.WxMaOrderManagementGetOrderDetailPath;
|
||||
import cn.binarywang.wx.miniapp.bean.order.WxMaOrderManagementResult;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoBaseResponse;
|
||||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.OrderManagement.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author xzh
|
||||
* @Description
|
||||
* @createTime 2025/01/16 15:31
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class WxMaOrderManagementServiceImpl implements WxMaOrderManagementService {
|
||||
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
/**
|
||||
* 查询订单详情路径
|
||||
* 注意事项
|
||||
* 如果没有配置过订单详情路径,会返回成功,其中path为''。
|
||||
*
|
||||
* @return WxMaOrderManagementGetOrderDetailPath
|
||||
* @throws WxErrorException e
|
||||
*/
|
||||
@Override
|
||||
public WxMaOrderManagementGetOrderDetailPath getOrderDetailPath() throws WxErrorException {
|
||||
return request(GET_ORDER_DETAIL_PATH, new Object(), WxMaOrderManagementGetOrderDetailPath.class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置订单详情路径
|
||||
* 注意事项
|
||||
* 调用接口前需要先完成订单中心授权协议签署。
|
||||
* 请确保配置的path可正常跳转到小程序,并且path必须包含字符串“${商品订单号}”。
|
||||
*
|
||||
* @param path 订单详情路径
|
||||
* @return WxMaOrderManagementResult
|
||||
* @throws WxErrorException e
|
||||
*/
|
||||
@Override
|
||||
public WxMaOrderManagementResult updateOrderDetailPath(String path) throws WxErrorException {
|
||||
JsonObject jsonObject = GsonHelper.buildJsonObject("path", path);
|
||||
return request(UPDATE_ORDER_DETAIL_PATH, jsonObject, WxMaOrderManagementResult.class);
|
||||
|
||||
}
|
||||
|
||||
private <T> T request(String url, Object request, Class<T> resultT) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(url, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, resultT);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.binarywang.wx.miniapp.bean.order;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xzh
|
||||
* @Description
|
||||
* @createTime 2025/01/16 15:27
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxMaOrderManagementGetOrderDetailPath extends WxMaOrderManagementResult {
|
||||
private static final long serialVersionUID = -5288666524298706169L;
|
||||
|
||||
/**
|
||||
* 订单详情路径
|
||||
*/
|
||||
@SerializedName("path")
|
||||
private String path;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.binarywang.wx.miniapp.bean.order;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xzh
|
||||
* @Description
|
||||
* @createTime 2025/01/16 15:27
|
||||
*/
|
||||
@Data
|
||||
public class WxMaOrderManagementResult implements Serializable {
|
||||
private static final long serialVersionUID = 1468925151935770503L;
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
@SerializedName("errcode")
|
||||
private Integer errCode;
|
||||
|
||||
/**
|
||||
* 错误原因
|
||||
*/
|
||||
@SerializedName("errmsg")
|
||||
private String errMsg;
|
||||
}
|
||||
@ -751,7 +751,7 @@ public class WxMaApiUrlConstants {
|
||||
* </pre>
|
||||
*/
|
||||
String UPLOAD_COMBINED_SHIPPING_INFO =
|
||||
"https://api.weixin.qq.com/wxa/sec/order/upload_combined_shipping_info";
|
||||
"https://api.weixin.qq.com/wxa/sec/order/upload_combined_shipping_info";
|
||||
|
||||
/**
|
||||
* 查询订单发货状态.
|
||||
@ -779,7 +779,7 @@ public class WxMaApiUrlConstants {
|
||||
* </pre>
|
||||
*/
|
||||
String NOTIFY_CONFIRM_RECEIVE =
|
||||
"https://api.weixin.qq.com/wxa/sec/order/notify_confirm_receive";
|
||||
"https://api.weixin.qq.com/wxa/sec/order/notify_confirm_receive";
|
||||
|
||||
/**
|
||||
* 消息跳转路径设置接口.
|
||||
@ -809,6 +809,35 @@ public class WxMaApiUrlConstants {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序订单管理
|
||||
*
|
||||
* <pre>
|
||||
* 文档地址: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order_center/order_center.html
|
||||
* </pre>
|
||||
*/
|
||||
public interface OrderManagement {
|
||||
|
||||
/**
|
||||
* 配置订单详情路径.
|
||||
*
|
||||
* <pre>
|
||||
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order_center/order_center.html
|
||||
* </pre>
|
||||
*/
|
||||
String UPDATE_ORDER_DETAIL_PATH = "https://api.weixin.qq.com/wxa/sec/order/update_order_detail_path";
|
||||
|
||||
/**
|
||||
* 查询订单详情路径.
|
||||
*
|
||||
* <pre>
|
||||
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order_center/order_center.html
|
||||
* </pre>
|
||||
*/
|
||||
String GET_ORDER_DETAIL_PATH = "https://api.weixin.qq.com/wxa/sec/order/get_order_detail_path";
|
||||
|
||||
}
|
||||
|
||||
public interface Vod {
|
||||
String LIST_MEDIA_URL = "https://api.weixin.qq.com/wxa/sec/vod/listmedia";
|
||||
String GET_MEDIA_URL = "https://api.weixin.qq.com/wxa/sec/vod/getmedia";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user