Skip to content

Commit b6b80a2

Browse files
authored
🆕 #3083 【小程序】增加发货信息管理相关接口,【开放平台】增加第三方平台的购物订单管理等接口
1 parent 4423b3d commit b6b80a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2161
-12
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package cn.binarywang.wx.miniapp.api;
2+
3+
import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*;
4+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoBaseResponse;
5+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetListResponse;
6+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetResponse;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingIsTradeManagedResponse;
8+
import me.chanjar.weixin.common.error.WxErrorException;
9+
10+
/**
11+
* @author xzh
12+
* created on 2023/5/17 16:49
13+
*/
14+
public interface WxMaOrderShippingService {
15+
/**
16+
* 查询小程序是否已开通发货信息管理服务
17+
*
18+
* @param appId 待查询小程序的 appid,非服务商调用时仅能查询本账号
19+
* @return WxMaOrderShippingInfoBaseResponse
20+
* @throws WxErrorException e
21+
*/
22+
WxMaOrderShippingIsTradeManagedResponse isTradeManaged(String appId)
23+
throws WxErrorException;
24+
25+
/**
26+
* 发货信息录入接口
27+
*
28+
* @param request 请求
29+
* @return WxMaOrderShippingInfoBaseResponse
30+
* @throws WxErrorException e
31+
*/
32+
WxMaOrderShippingInfoBaseResponse upload(WxMaOrderShippingInfoUploadRequest request)
33+
throws WxErrorException;
34+
35+
36+
/**
37+
* 发货信息合单录入接口
38+
*
39+
* @param request 请求
40+
* @return WxMaOrderShippingInfoBaseResponse
41+
* @throws WxErrorException e
42+
*/
43+
WxMaOrderShippingInfoBaseResponse upload(WxMaOrderCombinedShippingInfoUploadRequest request)
44+
throws WxErrorException;
45+
46+
/**
47+
* 查询订单发货状态
48+
* 你可以通过交易单号或商户号+商户单号来查询该支付单的发货状态。
49+
*
50+
* @param request 请求
51+
* @return WxMaOrderShippingInfoGetResponse
52+
* @throws WxErrorException e
53+
*/
54+
WxMaOrderShippingInfoGetResponse get(WxMaOrderShippingInfoGetRequest request)
55+
throws WxErrorException;
56+
57+
/**
58+
* 查询订单列表
59+
* 你可以通过支付时间、支付者openid或订单状态来查询订单列表。
60+
*
61+
* @param request 请求
62+
* @return WxMaOrderShippingInfoGetListResponse
63+
* @throws WxErrorException e
64+
*/
65+
WxMaOrderShippingInfoGetListResponse getList(WxMaOrderShippingInfoGetListRequest request)
66+
throws WxErrorException;
67+
68+
/**
69+
* 确认收货提醒接口
70+
* 如你已经从你的快递物流服务方获知到用户已经签收相关商品,可以通过该接口提醒用户及时确认收货,以提高资金结算效率,每个订单仅可调用一次。
71+
*
72+
* @param request 请求
73+
* @return WxMaOrderShippingInfoBaseResponse
74+
* @throws WxErrorException e
75+
*/
76+
WxMaOrderShippingInfoBaseResponse notifyConfirmReceive(WxMaOrderShippingInfoNotifyConfirmRequest request)
77+
throws WxErrorException;
78+
79+
/**
80+
* 消息跳转路径设置接口
81+
* 如你已经在小程序内接入平台提供的确认收货组件,可以通过该接口设置发货消息及确认收货消息的跳转动作,用户点击发货消息时会直接进入你的小程序订单列表页面或详情页面进行确认收货,进一步优化用户体验。
82+
*
83+
* @param path 商户自定义跳转路径
84+
* @return WxMaOrderShippingInfoBaseResponse
85+
* @throws WxErrorException e
86+
*/
87+
WxMaOrderShippingInfoBaseResponse setMsgJumpPath(String path)
88+
throws WxErrorException;
89+
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,36 +496,49 @@ public interface WxMaService extends WxService {
496496

497497
/**
498498
* 分享人接口
499+
*
499500
* @return WxMaShopSharerService
500501
*/
501502
WxMaShopSharerService getShopSharerService();
502503

503504
/**
504505
* 标准交易组件接口
506+
*
505507
* @return WxMaProductService
506508
*/
507509
WxMaProductService getProductService();
508510

509511
/**
510512
* 小商店-标准交易组件-订单服务
513+
*
511514
* @return getProductOrderService
512515
*/
513516
WxMaProductOrderService getProductOrderService();
514517

515518
/**
516519
* 小商店-标准交易组件-优惠券
520+
*
517521
* @return getWxMaShopCouponService
518522
*/
519523
WxMaShopCouponService getWxMaShopCouponService();
520524

521525
/**
522526
* 小程序支付管理-订单支付
527+
*
523528
* @return getWxMaShopPayService
524529
*/
525530
WxMaShopPayService getWxMaShopPayService();
526531

532+
/**
533+
* 小程序发货信息管理服务
534+
*
535+
* @return getWxMaOrderShippingService
536+
*/
537+
WxMaOrderShippingService getWxMaOrderShippingService();
538+
527539
/**
528540
* 小程序openApi管理
541+
*
529542
* @return getWxMaOpenApiService
530543
*/
531544
WxMaOpenApiService getWxMaOpenApiService();

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
8585
private final WxMaProductOrderService productOrderService = new WxMaProductOrderServiceImpl(this);
8686
private final WxMaShopCouponService wxMaShopCouponService = new WxMaShopCouponServiceImpl(this);
8787
private final WxMaShopPayService wxMaShopPayService = new WxMaShopPayServiceImpl(this);
88+
89+
private final WxMaOrderShippingService wxMaOrderShippingService = new WxMaOrderShippingServiceImpl(this);
90+
8891
private final WxMaOpenApiService wxMaOpenApiService = new WxMaOpenApiServiceImpl(this);
92+
8993
private Map<String, WxMaConfig> configMap;
9094
private int retrySleepMillis = 1000;
9195
private int maxRetryTimes = 5;
@@ -602,24 +606,34 @@ public WxMaReimburseInvoiceService getReimburseInvoiceService() {
602606
}
603607

604608
@Override
605-
public WxMaDeviceSubscribeService getDeviceSubscribeService(){ return this.deviceSubscribeService; }
609+
public WxMaDeviceSubscribeService getDeviceSubscribeService() {
610+
return this.deviceSubscribeService;
611+
}
606612

607613
@Override
608-
public WxMaMarketingService getMarketingService() {return this.marketingService; }
614+
public WxMaMarketingService getMarketingService() {
615+
return this.marketingService;
616+
}
609617

610618
@Override
611619
public WxMaImmediateDeliveryService getWxMaImmediateDeliveryService() {
612620
return this.immediateDeliveryService;
613621
}
614622

615623
@Override
616-
public WxMaSafetyRiskControlService getSafetyRiskControlService(){ return this.safetyRiskControlService; }
624+
public WxMaSafetyRiskControlService getSafetyRiskControlService() {
625+
return this.safetyRiskControlService;
626+
}
617627

618628
@Override
619-
public WxMaShopSharerService getShopSharerService() {return this.shopSharerService; }
629+
public WxMaShopSharerService getShopSharerService() {
630+
return this.shopSharerService;
631+
}
620632

621633
@Override
622-
public WxMaProductService getProductService() { return this.productService; }
634+
public WxMaProductService getProductService() {
635+
return this.productService;
636+
}
623637

624638
@Override
625639
public WxMaProductOrderService getProductOrderService() {
@@ -636,6 +650,16 @@ public WxMaShopPayService getWxMaShopPayService() {
636650
return this.wxMaShopPayService;
637651
}
638652

653+
/**
654+
* 小程序发货信息管理服务
655+
*
656+
* @return getWxMaOrderShippingService
657+
*/
658+
@Override
659+
public WxMaOrderShippingService getWxMaOrderShippingService() {
660+
return this.wxMaOrderShippingService;
661+
}
662+
639663
@Override
640664
public WxMaOpenApiService getWxMaOpenApiService() {
641665
return this.wxMaOpenApiService;
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package cn.binarywang.wx.miniapp.api.impl;
2+
3+
import cn.binarywang.wx.miniapp.api.WxMaOrderShippingService;
4+
import cn.binarywang.wx.miniapp.api.WxMaService;
5+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaOrderShippingIsTradeManagedRequest;
6+
import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoBaseResponse;
8+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetListResponse;
9+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetResponse;
10+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingIsTradeManagedResponse;
11+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
12+
import com.google.gson.JsonObject;
13+
import lombok.RequiredArgsConstructor;
14+
import lombok.extern.slf4j.Slf4j;
15+
import me.chanjar.weixin.common.api.WxConsts;
16+
import me.chanjar.weixin.common.enums.WxType;
17+
import me.chanjar.weixin.common.error.WxError;
18+
import me.chanjar.weixin.common.error.WxErrorException;
19+
import me.chanjar.weixin.common.util.json.GsonHelper;
20+
import me.chanjar.weixin.common.util.json.GsonParser;
21+
22+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.OrderShipping.*;
23+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.GET_CATEGORY;
24+
25+
26+
/**
27+
* @author xzh
28+
* created on 2023/5/17 17:44
29+
*/
30+
@Slf4j
31+
@RequiredArgsConstructor
32+
public class WxMaOrderShippingServiceImpl implements WxMaOrderShippingService {
33+
34+
private final WxMaService wxMaService;
35+
36+
/**
37+
* 查询小程序是否已开通发货信息管理服务
38+
*
39+
* @param appId 待查询小程序的 appid,非服务商调用时仅能查询本账号
40+
* @return WxMaOrderShippingInfoBaseResponse
41+
* @throws WxErrorException e
42+
*/
43+
@Override
44+
public WxMaOrderShippingIsTradeManagedResponse isTradeManaged(String appId) throws WxErrorException {
45+
WxMaOrderShippingIsTradeManagedRequest request = WxMaOrderShippingIsTradeManagedRequest.builder().appId(appId).build();
46+
return request(IS_TRADE_MANAGED, request, WxMaOrderShippingIsTradeManagedResponse.class);
47+
}
48+
49+
/**
50+
* 发货信息录入接口
51+
*
52+
* @param request 请求
53+
* @return WxMaOrderShippingInfoBaseResponse
54+
* @throws WxErrorException e
55+
*/
56+
@Override
57+
public WxMaOrderShippingInfoBaseResponse upload(WxMaOrderShippingInfoUploadRequest request) throws WxErrorException {
58+
return request(UPLOAD_SHIPPING_INFO, request, WxMaOrderShippingInfoBaseResponse.class);
59+
}
60+
61+
/**
62+
* 发货信息合单录入接口
63+
*
64+
* @param request 请求
65+
* @return WxMaOrderShippingInfoBaseResponse
66+
* @throws WxErrorException e
67+
*/
68+
@Override
69+
public WxMaOrderShippingInfoBaseResponse upload(WxMaOrderCombinedShippingInfoUploadRequest request) throws WxErrorException {
70+
return request(UPLOAD_COMBINED_SHIPPING_INFO, request, WxMaOrderShippingInfoBaseResponse.class);
71+
}
72+
73+
/**
74+
* 查询订单发货状态
75+
* 你可以通过交易单号或商户号+商户单号来查询该支付单的发货状态。
76+
*
77+
* @param request 请求
78+
* @return WxMaOrderShippingInfoGetResponse
79+
* @throws WxErrorException e
80+
*/
81+
@Override
82+
public WxMaOrderShippingInfoGetResponse get(WxMaOrderShippingInfoGetRequest request) throws WxErrorException {
83+
return request(GET_SHIPPING_INFO, request, WxMaOrderShippingInfoGetResponse.class);
84+
}
85+
86+
/**
87+
* 查询订单列表
88+
* 你可以通过支付时间、支付者openid或订单状态来查询订单列表。
89+
*
90+
* @param request 请求
91+
* @return WxMaOrderShippingInfoGetListResponse
92+
* @throws WxErrorException e
93+
*/
94+
@Override
95+
public WxMaOrderShippingInfoGetListResponse getList(WxMaOrderShippingInfoGetListRequest request) throws WxErrorException {
96+
return request(GET_SHIPPING_INFO_LIST, request, WxMaOrderShippingInfoGetListResponse.class);
97+
}
98+
99+
/**
100+
* 确认收货提醒接口
101+
* 如你已经从你的快递物流服务方获知到用户已经签收相关商品,可以通过该接口提醒用户及时确认收货,以提高资金结算效率,每个订单仅可调用一次。
102+
*
103+
* @param request 请求
104+
* @return WxMaOrderShippingInfoBaseResponse
105+
* @throws WxErrorException e
106+
*/
107+
@Override
108+
public WxMaOrderShippingInfoBaseResponse notifyConfirmReceive(WxMaOrderShippingInfoNotifyConfirmRequest request) throws WxErrorException {
109+
return request(NOTIFY_CONFIRM_RECEIVE, request, WxMaOrderShippingInfoBaseResponse.class);
110+
}
111+
112+
/**
113+
* 消息跳转路径设置接口
114+
* 如你已经在小程序内接入平台提供的确认收货组件,可以通过该接口设置发货消息及确认收货消息的跳转动作,用户点击发货消息时会直接进入你的小程序订单列表页面或详情页面进行确认收货,进一步优化用户体验。
115+
*
116+
* @param path 商户自定义跳转路径
117+
* @return WxMaOrderShippingInfoBaseResponse
118+
* @throws WxErrorException e
119+
*/
120+
@Override
121+
public WxMaOrderShippingInfoBaseResponse setMsgJumpPath(String path) throws WxErrorException {
122+
JsonObject jsonObject = GsonHelper.buildJsonObject("path", path);
123+
return request(SET_MSG_JUMP_PATH, jsonObject, WxMaOrderShippingInfoBaseResponse.class);
124+
}
125+
126+
private <T> T request(String url, Object request, Class<T> resultT) throws WxErrorException {
127+
String responseContent = this.wxMaService.post(url, request);
128+
JsonObject jsonObject = GsonParser.parse(responseContent);
129+
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
130+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
131+
}
132+
return WxMaGsonBuilder.create().fromJson(responseContent, resultT);
133+
}
134+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
import java.util.List;
11+
12+
/**
13+
* @author xzh
14+
* created on 2023/5/17 17:01
15+
*/
16+
@Data
17+
@Builder
18+
@NoArgsConstructor
19+
@AllArgsConstructor
20+
public class WxMaOrderShippingIsTradeManagedRequest implements Serializable {
21+
22+
private static final long serialVersionUID = -5735132900385013330L;
23+
/**
24+
* 必填
25+
* 待查询小程序的 appid,非服务商调用时仅能查询本账号
26+
*/
27+
@SerializedName("appid")
28+
private String appId;
29+
30+
}

0 commit comments

Comments
 (0)