Skip to content

Commit e785b1f

Browse files
authored
🆕 #2258 【小程序】增加自定义组件之物流和售后相关接口
1 parent 3f42a16 commit e785b1f

16 files changed

Lines changed: 681 additions & 14 deletions

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,20 @@ public interface WxMaService extends WxService {
377377
*/
378378
WxImgProcService getImgProcService();
379379

380-
// /**
381-
// * 返回小程序交易组件-售后服务接口
382-
// * @return
383-
// */
384-
// WxMaShopAfterSaleService getShopAfterSaleService();
385-
//
386-
//
387-
// /**
388-
// * 返回小程序交易组件-物流服务接口
389-
// * @return
390-
// */
391-
// WxMaShopDeliveryService getShopDeliveryService();
380+
/**
381+
* 返回小程序交易组件-售后服务接口
382+
*
383+
* @return
384+
*/
385+
WxMaShopAfterSaleService getShopAfterSaleService();
386+
387+
388+
/**
389+
* 返回小程序交易组件-物流服务接口
390+
*
391+
* @return
392+
*/
393+
WxMaShopDeliveryService getShopDeliveryService();
392394

393395

394396
/**
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
11
package cn.binarywang.wx.miniapp.api;
22

3+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest;
4+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleGetRequest;
5+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest;
6+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
8+
import me.chanjar.weixin.common.error.WxErrorException;
9+
310
/**
411
* 小程序交易组件-售后服务
512
*
613
* @author boris
14+
* @author liming1019
715
*/
816
public interface WxMaShopAfterSaleService {
17+
/**
18+
* 创建售后
19+
*
20+
* @param request
21+
* @return WxMaShopBaseResponse
22+
* @throws WxErrorException
23+
*/
24+
WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException;
25+
26+
/**
27+
* 获取订单下售后单
28+
*
29+
* @param request
30+
* @return WxMaShopAfterSaleGetResponse
31+
* @throws WxErrorException
32+
*/
33+
WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) throws WxErrorException;
34+
35+
/**
36+
* 更新售后
37+
*
38+
* @param request
39+
* @return WxMaShopBaseResponse
40+
* @throws WxErrorException
41+
*/
42+
WxMaShopBaseResponse update(WxMaShopAfterSaleUpdateRequest request) throws WxErrorException;
943

1044
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
11
package cn.binarywang.wx.miniapp.api;
22

3+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliveryRecieveRequest;
4+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliverySendRequest;
5+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
6+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopDeliveryGetCompanyListResponse;
7+
import me.chanjar.weixin.common.error.WxErrorException;
8+
39
/**
410
* 小程序交易组件-物流发货服务
511
*
612
* @author boris
13+
* @author liming1019
714
*/
815
public interface WxMaShopDeliveryService {
16+
/**
17+
* 获取快递公司列表
18+
*
19+
* @return WxMaShopDeliveryGetCompanyListResponse
20+
* @throws WxErrorException
21+
*/
22+
WxMaShopDeliveryGetCompanyListResponse getCompanyList() throws WxErrorException;
23+
24+
/**
25+
* 订单发货
26+
*
27+
* @param request
28+
* @return WxMaShopBaseResponse
29+
* @throws WxErrorException
30+
*/
31+
WxMaShopBaseResponse send(WxMaShopDeliverySendRequest request) throws WxErrorException;
32+
33+
/**
34+
* 订单确认收货
35+
*
36+
* @param request
37+
* @return WxMaShopBaseResponse
38+
* @throws WxErrorException
39+
*/
40+
WxMaShopBaseResponse receive(WxMaShopDeliveryRecieveRequest request) throws WxErrorException;
941

1042
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
7070
private final WxMaShopCatService shopCatService = new WxMaShopCatServiceImpl(this);
7171
private final WxMaShopImgService shopImgService = new WxMaShopImgServiceImpl(this);
7272
private final WxMaShopAuditService shopAuditService = new WxMaShopAuditServiceImpl(this);
73+
private final WxMaShopAfterSaleService shopAfterSaleService = new WxMaShopAfterSaleServiceImpl(this);
74+
private final WxMaShopDeliveryService shopDeliveryService = new WxMaShopDeliveryServiceImpl(this);
7375
private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
7476
private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
7577
private Map<String, WxMaConfig> configMap;
@@ -546,6 +548,16 @@ public WxMaShopAuditService getShopAuditService() {
546548
return this.shopAuditService;
547549
}
548550

551+
@Override
552+
public WxMaShopAfterSaleService getShopAfterSaleService() {
553+
return this.shopAfterSaleService;
554+
}
555+
556+
@Override
557+
public WxMaShopDeliveryService getShopDeliveryService() {
558+
return this.shopDeliveryService;
559+
}
560+
549561
@Override
550562
public WxMaLinkService getLinkService() {
551563
return this.linkService;

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

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,81 @@
22

33
import cn.binarywang.wx.miniapp.api.WxMaService;
44
import cn.binarywang.wx.miniapp.api.WxMaShopAfterSaleService;
5+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest;
6+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleGetRequest;
7+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest;
8+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse;
9+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
10+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
11+
import com.google.gson.JsonObject;
512
import lombok.RequiredArgsConstructor;
613
import lombok.extern.slf4j.Slf4j;
14+
import me.chanjar.weixin.common.enums.WxType;
15+
import me.chanjar.weixin.common.error.WxError;
16+
import me.chanjar.weixin.common.error.WxErrorException;
17+
import me.chanjar.weixin.common.util.json.GsonParser;
18+
19+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Aftersale.*;
20+
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
721

822
/**
923
* @author boris
24+
* @author liming1019
1025
*/
1126
@RequiredArgsConstructor
1227
@Slf4j
1328
public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
14-
private final WxMaService service;
29+
private final WxMaService wxMaService;
1530

1631

32+
/**
33+
* 创建售后
34+
*
35+
* @param request
36+
* @return WxMaShopBaseResponse
37+
* @throws WxErrorException
38+
*/
39+
@Override
40+
public WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException {
41+
String responseContent = this.wxMaService.post(AFTERSALE_ADD, request);
42+
JsonObject jsonObject = GsonParser.parse(responseContent);
43+
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
44+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
45+
}
46+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
47+
}
1748

49+
/**
50+
* 获取订单下售后单
51+
*
52+
* @param request
53+
* @return WxMaShopAfterSaleGetResponse
54+
* @throws WxErrorException
55+
*/
56+
@Override
57+
public WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) throws WxErrorException {
58+
String responseContent = this.wxMaService.post(AFTERSALE_GET, request);
59+
JsonObject jsonObject = GsonParser.parse(responseContent);
60+
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
61+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
62+
}
63+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAfterSaleGetResponse.class);
64+
}
1865

66+
/**
67+
* 更新售后
68+
*
69+
* @param request
70+
* @return
71+
* @throws WxErrorException
72+
*/
73+
@Override
74+
public WxMaShopBaseResponse update(WxMaShopAfterSaleUpdateRequest request) throws WxErrorException {
75+
String responseContent = this.wxMaService.post(AFTERSALE_UPDATE, request);
76+
JsonObject jsonObject = GsonParser.parse(responseContent);
77+
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
78+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
79+
}
80+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
81+
}
1982
}

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

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,78 @@
22

33
import cn.binarywang.wx.miniapp.api.WxMaService;
44
import cn.binarywang.wx.miniapp.api.WxMaShopDeliveryService;
5+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliveryRecieveRequest;
6+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliverySendRequest;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
8+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopDeliveryGetCompanyListResponse;
9+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
10+
import com.google.gson.JsonObject;
511
import lombok.RequiredArgsConstructor;
612
import lombok.extern.slf4j.Slf4j;
13+
import me.chanjar.weixin.common.enums.WxType;
14+
import me.chanjar.weixin.common.error.WxError;
15+
import me.chanjar.weixin.common.error.WxErrorException;
16+
import me.chanjar.weixin.common.util.json.GsonParser;
17+
18+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Delivery.*;
19+
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
720

821
/**
922
* @author boris
23+
* @author liming1019
1024
*/
1125
@RequiredArgsConstructor
1226
@Slf4j
1327
public class WxMaShopDeliveryServiceImpl implements WxMaShopDeliveryService {
14-
private final WxMaService service;
28+
private final WxMaService wxMaService;
29+
30+
/**
31+
* 获取快递公司列表
32+
*
33+
* @return WxMaShopDeliveryGetCompanyListResponse
34+
* @throws WxErrorException
35+
*/
36+
@Override
37+
public WxMaShopDeliveryGetCompanyListResponse getCompanyList() throws WxErrorException {
38+
String responseContent = this.wxMaService.post(GET_COMPANY_LIST, new JsonObject());
39+
JsonObject jsonObject = GsonParser.parse(responseContent);
40+
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
41+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
42+
}
43+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopDeliveryGetCompanyListResponse.class);
44+
}
45+
46+
/**
47+
* 订单发货
48+
*
49+
* @param request
50+
* @return WxMaShopBaseResponse
51+
* @throws WxErrorException
52+
*/
53+
@Override
54+
public WxMaShopBaseResponse send(WxMaShopDeliverySendRequest request) throws WxErrorException {
55+
String responseContent = this.wxMaService.post(DELIVERY_SEND, request);
56+
JsonObject jsonObject = GsonParser.parse(responseContent);
57+
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
58+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
59+
}
60+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
61+
}
1562

63+
/**
64+
* 订单确认收货
65+
*
66+
* @param request
67+
* @return WxMaShopBaseResponse
68+
* @throws WxErrorException
69+
*/
70+
@Override
71+
public WxMaShopBaseResponse receive(WxMaShopDeliveryRecieveRequest request) throws WxErrorException {
72+
String responseContent = this.wxMaService.post(DELIVERY_RECEIVE, request);
73+
JsonObject jsonObject = GsonParser.parse(responseContent);
74+
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
75+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
76+
}
77+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
78+
}
1679
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package cn.binarywang.wx.miniapp.bean.shop.request;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
7+
import java.io.Serializable;
8+
import java.util.List;
9+
10+
/**
11+
* @author liming1019
12+
* @date 2021/8/12
13+
*/
14+
@Data
15+
@Builder
16+
public class WxMaShopAfterSaleAddRequest implements Serializable {
17+
private static final long serialVersionUID = 6652525413062887786L;
18+
19+
/**
20+
* out_order_id : xxxxx
21+
* out_aftersale_id : xxxxxx
22+
* openid : oTVP50O53a7jgmawAmxKukNlq3XI
23+
* type : 1
24+
* create_time : 2020-12-01 00:00:00
25+
* status : 1
26+
* finish_all_aftersale : 0
27+
* path : /pages/aftersale.html?out_aftersale_id=xxxxx
28+
* refund : 100
29+
* product_infos : [{"out_product_id":"234245","out_sku_id":"23424","product_cnt":5}]
30+
*/
31+
32+
@SerializedName("out_order_id")
33+
private String outOrderId;
34+
@SerializedName("out_aftersale_id")
35+
private String outAftersaleId;
36+
@SerializedName("openid")
37+
private String openid;
38+
@SerializedName("type")
39+
private Integer type;
40+
@SerializedName("create_time")
41+
private String createTime;
42+
@SerializedName("status")
43+
private Integer status;
44+
@SerializedName("finish_all_aftersale")
45+
private Integer finishAllAftersale;
46+
@SerializedName("path")
47+
private String path;
48+
@SerializedName("refund")
49+
private Long refund;
50+
@SerializedName("product_infos")
51+
private List<ProductInfosBean> productInfos;
52+
53+
@Data
54+
@Builder
55+
public static class ProductInfosBean implements Serializable {
56+
/**
57+
* out_product_id : 234245
58+
* out_sku_id : 23424
59+
* product_cnt : 5
60+
*/
61+
62+
@SerializedName("out_product_id")
63+
private String outProductId;
64+
@SerializedName("out_sku_id")
65+
private String outSkuId;
66+
@SerializedName("product_cnt")
67+
private Integer productCnt;
68+
}
69+
}

0 commit comments

Comments
 (0)