Skip to content

Commit ebc31ce

Browse files
author
xzh
committed
添加第三方平台购物订单管理相关
1 parent 7198a58 commit ebc31ce

24 files changed

+1236
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package cn.binarywang.wx.miniapp.api;
2+
3+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaOrderShippingIsTradeManagedRequest;
4+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaOrderShippingUploadRequest;
5+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingBaseResponse;
6+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingIsTradeManagedResponse;
7+
import me.chanjar.weixin.common.error.WxErrorException;
8+
9+
/**
10+
* @author xzh
11+
* created on 2023/5/17 16:49
12+
*/
13+
public interface WxMaOrderShippingService {
14+
/**
15+
* 查询小程序是否已开通发货信息管理服务
16+
*
17+
* @param appId 待查询小程序的 appid,非服务商调用时仅能查询本账号
18+
* @return WxMaOrderShippingBaseResponse
19+
* @throws WxErrorException
20+
*/
21+
WxMaOrderShippingIsTradeManagedResponse isTradeManaged(String appId)
22+
throws WxErrorException;
23+
24+
/**
25+
* 发货信息录入接口
26+
*
27+
* @param request 请求
28+
* @return WxMaOrderShippingBaseResponse
29+
* @throws WxErrorException
30+
*/
31+
WxMaOrderShippingBaseResponse upload(WxMaOrderShippingUploadRequest request)
32+
throws WxErrorException;
33+
}

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

+6
Original file line numberDiff line numberDiff line change
@@ -521,4 +521,10 @@ public interface WxMaService extends WxService {
521521
* @return getWxMaShopPayService
522522
*/
523523
WxMaShopPayService getWxMaShopPayService();
524+
525+
/**
526+
* 小程序发货信息管理服务
527+
* @return getWxMaOrderShippingService
528+
*/
529+
WxMaOrderShippingService getWxMaOrderShippingService();
524530
}

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

+26-5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
8484
private final WxMaProductOrderService productOrderService = new WxMaProductOrderServiceImpl(this);
8585
private final WxMaShopCouponService wxMaShopCouponService = new WxMaShopCouponServiceImpl(this);
8686
private final WxMaShopPayService wxMaShopPayService = new WxMaShopPayServiceImpl(this);
87+
private final WxMaOrderShippingService wxMaOrderShippingService = new WxMaOrderShippingServiceImpl(this);
8788
private Map<String, WxMaConfig> configMap;
8889
private int retrySleepMillis = 1000;
8990
private int maxRetryTimes = 5;
@@ -584,24 +585,34 @@ public WxMaReimburseInvoiceService getReimburseInvoiceService() {
584585
}
585586

586587
@Override
587-
public WxMaDeviceSubscribeService getDeviceSubscribeService(){ return this.deviceSubscribeService; }
588+
public WxMaDeviceSubscribeService getDeviceSubscribeService() {
589+
return this.deviceSubscribeService;
590+
}
588591

589592
@Override
590-
public WxMaMarketingService getMarketingService() {return this.marketingService; }
593+
public WxMaMarketingService getMarketingService() {
594+
return this.marketingService;
595+
}
591596

592597
@Override
593598
public WxMaImmediateDeliveryService getWxMaImmediateDeliveryService() {
594599
return this.immediateDeliveryService;
595600
}
596601

597602
@Override
598-
public WxMaSafetyRiskControlService getSafetyRiskControlService(){ return this.safetyRiskControlService; }
603+
public WxMaSafetyRiskControlService getSafetyRiskControlService() {
604+
return this.safetyRiskControlService;
605+
}
599606

600607
@Override
601-
public WxMaShopSharerService getShopSharerService() {return this.shopSharerService; }
608+
public WxMaShopSharerService getShopSharerService() {
609+
return this.shopSharerService;
610+
}
602611

603612
@Override
604-
public WxMaProductService getProductService() { return this.productService; }
613+
public WxMaProductService getProductService() {
614+
return this.productService;
615+
}
605616

606617
@Override
607618
public WxMaProductOrderService getProductOrderService() {
@@ -617,4 +628,14 @@ public WxMaShopCouponService getWxMaShopCouponService() {
617628
public WxMaShopPayService getWxMaShopPayService() {
618629
return this.wxMaShopPayService;
619630
}
631+
632+
/**
633+
* 小程序发货信息管理服务
634+
*
635+
* @return getWxMaOrderShippingService
636+
*/
637+
@Override
638+
public WxMaOrderShippingService getWxMaOrderShippingService() {
639+
return this.wxMaOrderShippingService;
640+
}
620641
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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.WxMaOrderShippingUploadRequest;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingBaseResponse;
8+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingIsTradeManagedResponse;
9+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
10+
import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants;
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.enums.WxType;
16+
import me.chanjar.weixin.common.error.WxError;
17+
import me.chanjar.weixin.common.error.WxErrorException;
18+
import me.chanjar.weixin.common.util.json.GsonParser;
19+
20+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.OrderShipping.IS_TRADE_MANAGED;
21+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.OrderShipping.UPLOAD_SHIPPING_INFO;
22+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Delivery.DELIVERY_SEND;
23+
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
24+
25+
/**
26+
* @author xzh
27+
* created on 2023/5/17 17:44
28+
*/
29+
@Slf4j
30+
@RequiredArgsConstructor
31+
public class WxMaOrderShippingServiceImpl implements WxMaOrderShippingService {
32+
33+
private final WxMaService wxMaService;
34+
35+
/**
36+
* 查询小程序是否已开通发货信息管理服务
37+
*
38+
* @param appId 待查询小程序的 appid,非服务商调用时仅能查询本账号
39+
* @return WxMaOrderShippingBaseResponse
40+
* @throws WxErrorException
41+
*/
42+
@Override
43+
public WxMaOrderShippingIsTradeManagedResponse isTradeManaged(String appId) throws WxErrorException {
44+
WxMaOrderShippingIsTradeManagedRequest request = WxMaOrderShippingIsTradeManagedRequest.builder().appId(appId).build();
45+
return request(IS_TRADE_MANAGED, request, WxMaOrderShippingIsTradeManagedResponse.class);
46+
}
47+
48+
/**
49+
* 发货信息录入接口
50+
*
51+
* @param request 请求
52+
* @return WxMaOrderShippingBaseResponse
53+
* @throws WxErrorException
54+
*/
55+
@Override
56+
public WxMaOrderShippingBaseResponse upload(WxMaOrderShippingUploadRequest request) throws WxErrorException {
57+
return request(UPLOAD_SHIPPING_INFO, request, WxMaOrderShippingBaseResponse.class);
58+
}
59+
60+
private <T> T request(String url, Object request, Class<T> resultT) throws WxErrorException {
61+
String responseContent = this.wxMaService.post(url, request);
62+
JsonObject jsonObject = GsonParser.parse(responseContent);
63+
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
64+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
65+
}
66+
return WxMaGsonBuilder.create().fromJson(responseContent, resultT);
67+
}
68+
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
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 WxMaOrderShippingUploadRequest implements Serializable {
21+
private static final long serialVersionUID = -334322216049787167L;
22+
23+
24+
/**
25+
* 必填
26+
* 订单,需要上传物流信息的订单
27+
*/
28+
@SerializedName("order_key")
29+
private OrderKeyBean orderKey;
30+
31+
/**
32+
* 必填
33+
* 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
34+
*/
35+
@SerializedName("logistics_type")
36+
private int logisticsType;
37+
38+
/**
39+
* 必填
40+
* 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货)
41+
* 示例值: UNIFIED_DELIVERY
42+
*/
43+
@SerializedName("delivery_mode")
44+
private int deliveryMode;
45+
46+
/**
47+
* 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。
48+
* 示例值: true/false
49+
*/
50+
@SerializedName("is_all_delivered")
51+
private Boolean isAllDelivered;
52+
53+
/**
54+
* 必填
55+
* 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式,多重性: [1, 10]
56+
*/
57+
@SerializedName("shipping_list")
58+
private List<ShippingListBean> shippingList;
59+
60+
/**
61+
* 必填
62+
* 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00
63+
*/
64+
@SerializedName("upload_time")
65+
private String uploadTime;
66+
67+
/**
68+
* 必填
69+
* 支付者,支付者信息
70+
*/
71+
@SerializedName("payer")
72+
private PayerBean payer;
73+
74+
75+
@Data
76+
@Builder
77+
@NoArgsConstructor
78+
@AllArgsConstructor
79+
public static class OrderKeyBean implements Serializable {
80+
private static final long serialVersionUID = -6322907878214196106L;
81+
82+
/**
83+
* 必填
84+
* 订单单号类型,用于确认需要上传详情的订单。枚举值1,使用下单商户号和商户侧单号;枚举值2,使用微信支付单号。
85+
*/
86+
@SerializedName("order_number_type")
87+
private int orderNumberType;
88+
/**
89+
* 原支付交易对应的微信订单号
90+
*/
91+
@SerializedName("transaction_id")
92+
private String transactionId;
93+
/**
94+
* 支付下单商户的商户号,由微信支付生成并下发。
95+
*/
96+
@SerializedName("mchid")
97+
private String mchId;
98+
/**
99+
* 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
100+
*/
101+
@SerializedName("out_trade_no")
102+
private String outTradeNo;
103+
}
104+
105+
106+
@Data
107+
@Builder
108+
@NoArgsConstructor
109+
@AllArgsConstructor
110+
public static class ShippingListBean implements Serializable {
111+
private static final long serialVersionUID = -6554762808990702774L;
112+
113+
/**
114+
* 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128]
115+
*/
116+
@SerializedName("tracking_no")
117+
private String trackingNo;
118+
/**
119+
* 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128]
120+
*/
121+
@SerializedName("express_company")
122+
private String expressCompany;
123+
/**
124+
* 必填
125+
* 商品信息,例如:微信红包抱枕*1个,限120个字以内
126+
*/
127+
@SerializedName("item_desc")
128+
private String itemDesc;
129+
/**
130+
* 联系方式,当发货的物流公司为顺丰时,联系方式为必填,收件人或寄件人联系方式二选一
131+
*/
132+
@SerializedName("contact")
133+
private ContactBean contact;
134+
}
135+
136+
137+
@Data
138+
@Builder
139+
@NoArgsConstructor
140+
@AllArgsConstructor
141+
public static class ContactBean implements Serializable {
142+
private static final long serialVersionUID = 3388264169113920140L;
143+
144+
/**
145+
* 寄件人联系方式,寄件人联系方式,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024
146+
*/
147+
@SerializedName("consignor_contact")
148+
private String consignorContact;
149+
/**
150+
* 收件人联系方式,收件人联系方式为,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024
151+
*/
152+
@SerializedName("receiver_contact")
153+
private String receiverContact;
154+
}
155+
156+
@Data
157+
@Builder
158+
@NoArgsConstructor
159+
@AllArgsConstructor
160+
public static class PayerBean implements Serializable {
161+
162+
private static final long serialVersionUID = 6628077253606871512L;
163+
/**
164+
* 必填
165+
* 用户标识,用户在小程序appid下的唯一标识。 下单前需获取到用户的Openid 示例值: oUpF8uMuAJO_M2pxb1Q9zNjWeS6o 字符字节限制: [1, 128]
166+
*/
167+
@SerializedName("openid")
168+
private String openid;
169+
}
170+
}

0 commit comments

Comments
 (0)