From e785b1f9a72fd248923d044535a129a312743133 Mon Sep 17 00:00:00 2001 From: liming1019 Date: Fri, 13 Aug 2021 17:55:35 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20#2258=20=E3=80=90=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E3=80=91=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=B9=8B=E7=89=A9=E6=B5=81=E5=92=8C=E5=94=AE?= =?UTF-8?q?=E5=90=8E=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wx/miniapp/api/WxMaService.java | 26 ++++--- .../miniapp/api/WxMaShopAfterSaleService.java | 34 +++++++++ .../miniapp/api/WxMaShopDeliveryService.java | 32 ++++++++ .../miniapp/api/impl/BaseWxMaServiceImpl.java | 12 +++ .../impl/WxMaShopAfterSaleServiceImpl.java | 65 +++++++++++++++- .../api/impl/WxMaShopDeliveryServiceImpl.java | 65 +++++++++++++++- .../request/WxMaShopAfterSaleAddRequest.java | 69 +++++++++++++++++ .../request/WxMaShopAfterSaleGetRequest.java | 30 ++++++++ .../WxMaShopAfterSaleUpdateRequest.java | 36 +++++++++ .../WxMaShopDeliveryRecieveRequest.java | 30 ++++++++ .../request/WxMaShopDeliverySendRequest.java | 51 +++++++++++++ .../WxMaShopAfterSaleGetResponse.java | 67 +++++++++++++++++ ...xMaShopDeliveryGetCompanyListResponse.java | 30 ++++++++ .../miniapp/constant/WxMaApiUrlConstants.java | 12 +++ .../WxMaShopAfterSaleServiceImplTest.java | 75 +++++++++++++++++++ .../impl/WxMaShopDeliveryServiceImplTest.java | 61 +++++++++++++++ 16 files changed, 681 insertions(+), 14 deletions(-) create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleGetResponse.java create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopDeliveryGetCompanyListResponse.java create mode 100644 weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImplTest.java create mode 100644 weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImplTest.java diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java index 484968f3d..a182c245c 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java @@ -377,18 +377,20 @@ public interface WxMaService extends WxService { */ WxImgProcService getImgProcService(); -// /** -// * 返回小程序交易组件-售后服务接口 -// * @return -// */ -// WxMaShopAfterSaleService getShopAfterSaleService(); -// -// -// /** -// * 返回小程序交易组件-物流服务接口 -// * @return -// */ -// WxMaShopDeliveryService getShopDeliveryService(); + /** + * 返回小程序交易组件-售后服务接口 + * + * @return + */ + WxMaShopAfterSaleService getShopAfterSaleService(); + + + /** + * 返回小程序交易组件-物流服务接口 + * + * @return + */ + WxMaShopDeliveryService getShopDeliveryService(); /** diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAfterSaleService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAfterSaleService.java index 6e9878c9f..97b8aa56d 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAfterSaleService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAfterSaleService.java @@ -1,10 +1,44 @@ package cn.binarywang.wx.miniapp.api; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleGetRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import me.chanjar.weixin.common.error.WxErrorException; + /** * 小程序交易组件-售后服务 * * @author boris + * @author liming1019 */ public interface WxMaShopAfterSaleService { + /** + * 创建售后 + * + * @param request + * @return WxMaShopBaseResponse + * @throws WxErrorException + */ + WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException; + + /** + * 获取订单下售后单 + * + * @param request + * @return WxMaShopAfterSaleGetResponse + * @throws WxErrorException + */ + WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) throws WxErrorException; + + /** + * 更新售后 + * + * @param request + * @return WxMaShopBaseResponse + * @throws WxErrorException + */ + WxMaShopBaseResponse update(WxMaShopAfterSaleUpdateRequest request) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopDeliveryService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopDeliveryService.java index 2a3a11986..d6aadbebc 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopDeliveryService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopDeliveryService.java @@ -1,10 +1,42 @@ package cn.binarywang.wx.miniapp.api; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliveryRecieveRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliverySendRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopDeliveryGetCompanyListResponse; +import me.chanjar.weixin.common.error.WxErrorException; + /** * 小程序交易组件-物流发货服务 * * @author boris + * @author liming1019 */ public interface WxMaShopDeliveryService { + /** + * 获取快递公司列表 + * + * @return WxMaShopDeliveryGetCompanyListResponse + * @throws WxErrorException + */ + WxMaShopDeliveryGetCompanyListResponse getCompanyList() throws WxErrorException; + + /** + * 订单发货 + * + * @param request + * @return WxMaShopBaseResponse + * @throws WxErrorException + */ + WxMaShopBaseResponse send(WxMaShopDeliverySendRequest request) throws WxErrorException; + + /** + * 订单确认收货 + * + * @param request + * @return WxMaShopBaseResponse + * @throws WxErrorException + */ + WxMaShopBaseResponse receive(WxMaShopDeliveryRecieveRequest request) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java index fe841a57a..096eedd5b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java @@ -70,6 +70,8 @@ public abstract class BaseWxMaServiceImpl implements WxMaService, RequestH private final WxMaShopCatService shopCatService = new WxMaShopCatServiceImpl(this); private final WxMaShopImgService shopImgService = new WxMaShopImgServiceImpl(this); private final WxMaShopAuditService shopAuditService = new WxMaShopAuditServiceImpl(this); + private final WxMaShopAfterSaleService shopAfterSaleService = new WxMaShopAfterSaleServiceImpl(this); + private final WxMaShopDeliveryService shopDeliveryService = new WxMaShopDeliveryServiceImpl(this); private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this); private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this); private Map configMap; @@ -546,6 +548,16 @@ public abstract class BaseWxMaServiceImpl implements WxMaService, RequestH return this.shopAuditService; } + @Override + public WxMaShopAfterSaleService getShopAfterSaleService() { + return this.shopAfterSaleService; + } + + @Override + public WxMaShopDeliveryService getShopDeliveryService() { + return this.shopDeliveryService; + } + @Override public WxMaLinkService getLinkService() { return this.linkService; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImpl.java index 85fdb90b6..9fd24350a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImpl.java @@ -2,18 +2,81 @@ package cn.binarywang.wx.miniapp.api.impl; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaShopAfterSaleService; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleGetRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +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.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; + +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Aftersale.*; +import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE; /** * @author boris + * @author liming1019 */ @RequiredArgsConstructor @Slf4j public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService { - private final WxMaService service; + private final WxMaService wxMaService; + /** + * 创建售后 + * + * @param request + * @return WxMaShopBaseResponse + * @throws WxErrorException + */ + @Override + public WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(AFTERSALE_ADD, request); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get(ERRCODE).getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class); + } + /** + * 获取订单下售后单 + * + * @param request + * @return WxMaShopAfterSaleGetResponse + * @throws WxErrorException + */ + @Override + public WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(AFTERSALE_GET, request); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get(ERRCODE).getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAfterSaleGetResponse.class); + } + /** + * 更新售后 + * + * @param request + * @return + * @throws WxErrorException + */ + @Override + public WxMaShopBaseResponse update(WxMaShopAfterSaleUpdateRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(AFTERSALE_UPDATE, request); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get(ERRCODE).getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class); + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImpl.java index 9b6a093eb..8fd9d63f9 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImpl.java @@ -2,15 +2,78 @@ package cn.binarywang.wx.miniapp.api.impl; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaShopDeliveryService; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliveryRecieveRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliverySendRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopDeliveryGetCompanyListResponse; +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.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; + +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Delivery.*; +import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE; /** * @author boris + * @author liming1019 */ @RequiredArgsConstructor @Slf4j public class WxMaShopDeliveryServiceImpl implements WxMaShopDeliveryService { - private final WxMaService service; + private final WxMaService wxMaService; + /** + * 获取快递公司列表 + * + * @return WxMaShopDeliveryGetCompanyListResponse + * @throws WxErrorException + */ + @Override + public WxMaShopDeliveryGetCompanyListResponse getCompanyList() throws WxErrorException { + String responseContent = this.wxMaService.post(GET_COMPANY_LIST, new JsonObject()); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get(ERRCODE).getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopDeliveryGetCompanyListResponse.class); + } + + /** + * 订单发货 + * + * @param request + * @return WxMaShopBaseResponse + * @throws WxErrorException + */ + @Override + public WxMaShopBaseResponse send(WxMaShopDeliverySendRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(DELIVERY_SEND, request); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get(ERRCODE).getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class); + } + + /** + * 订单确认收货 + * + * @param request + * @return WxMaShopBaseResponse + * @throws WxErrorException + */ + @Override + public WxMaShopBaseResponse receive(WxMaShopDeliveryRecieveRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(DELIVERY_RECEIVE, request); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get(ERRCODE).getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class); + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java new file mode 100644 index 000000000..9f9c13e98 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java @@ -0,0 +1,69 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author liming1019 + * @date 2021/8/12 + */ +@Data +@Builder +public class WxMaShopAfterSaleAddRequest implements Serializable { + private static final long serialVersionUID = 6652525413062887786L; + + /** + * out_order_id : xxxxx + * out_aftersale_id : xxxxxx + * openid : oTVP50O53a7jgmawAmxKukNlq3XI + * type : 1 + * create_time : 2020-12-01 00:00:00 + * status : 1 + * finish_all_aftersale : 0 + * path : /pages/aftersale.html?out_aftersale_id=xxxxx + * refund : 100 + * product_infos : [{"out_product_id":"234245","out_sku_id":"23424","product_cnt":5}] + */ + + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("openid") + private String openid; + @SerializedName("type") + private Integer type; + @SerializedName("create_time") + private String createTime; + @SerializedName("status") + private Integer status; + @SerializedName("finish_all_aftersale") + private Integer finishAllAftersale; + @SerializedName("path") + private String path; + @SerializedName("refund") + private Long refund; + @SerializedName("product_infos") + private List productInfos; + + @Data + @Builder + public static class ProductInfosBean implements Serializable { + /** + * out_product_id : 234245 + * out_sku_id : 23424 + * product_cnt : 5 + */ + + @SerializedName("out_product_id") + private String outProductId; + @SerializedName("out_sku_id") + private String outSkuId; + @SerializedName("product_cnt") + private Integer productCnt; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java new file mode 100644 index 000000000..31afee26c --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author liming1019 + * @date 2021/8/12 + */ +@Data +@Builder +public class WxMaShopAfterSaleGetRequest implements Serializable { + private static final long serialVersionUID = -1275475147400719521L; + + /** + * order_id : 32434234 + * out_order_id : xxxxx + * openid : oTVP50O53a7jgmawAmxKukNlq3XI + */ + + @SerializedName("order_id") + private Long orderId; + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("openid") + private String openid; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java new file mode 100644 index 000000000..8bbeadb1a --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java @@ -0,0 +1,36 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author liming1019 + * @date 2021/8/12 + */ +@Data +@Builder +public class WxMaShopAfterSaleUpdateRequest implements Serializable { + private static final long serialVersionUID = 2712027510252221370L; + + /** + * out_order_id : xxxxx + * openid : oTVP50O53a7jgmawAmxKukNlq3XI + * out_aftersale_id : xxxxxx + * status : 1 + * finish_all_aftersale : 0 + */ + + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("openid") + private String openid; + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("status") + private Integer status; + @SerializedName("finish_all_aftersale") + private Integer finishAllAftersale; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java new file mode 100644 index 000000000..50ef7a63e --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author liming1019 + * @date 2021/8/12 + */ +@Data +@Builder +public class WxMaShopDeliveryRecieveRequest implements Serializable { + private static final long serialVersionUID = 1540854758624081221L; + + /** + * order_id : 123456 + * out_order_id : xxxxx + * openid : oTVP50O53a7jgmawAmxKukNlq3XI + */ + + @SerializedName("order_id") + private Long orderId; + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("openid") + private String openid; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java new file mode 100644 index 000000000..6636b6405 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java @@ -0,0 +1,51 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author liming1019 + * @date 2021/8/12 + */ +@Data +@Builder +public class WxMaShopDeliverySendRequest implements Serializable { + private static final long serialVersionUID = -4034672301224469057L; + + /** + * order_id : 123456 + * out_order_id : xxxxx + * openid : oTVP50O53a7jgmawAmxKukNlq3XI + * finish_all_delivery : 0 + * delivery_list : [{"delivery_id":"SF","waybill_id":"23424324253"}] + */ + + @SerializedName("order_id") + private Long orderId; + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("openid") + private String openid; + @SerializedName("finish_all_delivery") + private Integer finishAllDelivery; + @SerializedName("delivery_list") + private List deliveryList; + + @Data + @Builder + public static class DeliveryListBean implements Serializable { + /** + * delivery_id : SF + * waybill_id : 23424324253 + */ + + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("waybill_id") + private String waybillId; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleGetResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleGetResponse.java new file mode 100644 index 000000000..ac8f68db6 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopAfterSaleGetResponse.java @@ -0,0 +1,67 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +public class WxMaShopAfterSaleGetResponse extends WxMaShopBaseResponse implements Serializable { + private static final long serialVersionUID = 213666907103837748L; + + @SerializedName("aftersale_infos") + private List aftersaleInfos; + + @Data + public static class AftersaleInfosBean implements Serializable { + /** + * out_order_id : xxxxx + * out_aftersale_id : xxxxxx + * openid : oTVP50O53a7jgmawAmxKukNlq3XI + * type : 1 + * create_time : 2020-12-01 00:00:00 + * path : /pages/order.html?out_order_id=xxxxx + * status : 1 + * refund : 100 + * product_infos : [{"out_product_id":"234245","out_sku_id":"23424","product_cnt":5}] + */ + + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("openid") + private String openid; + @SerializedName("type") + private Integer type; + @SerializedName("create_time") + private String createTime; + @SerializedName("path") + private String path; + @SerializedName("status") + private Integer status; + @SerializedName("refund") + private Long refund; + @SerializedName("product_infos") + private List productInfos; + + @Data + public static class ProductInfosBean implements Serializable { + /** + * out_product_id : 234245 + * out_sku_id : 23424 + * product_cnt : 5 + */ + + @SerializedName("out_product_id") + private String outProductId; + @SerializedName("out_sku_id") + private String outSkuId; + @SerializedName("product_cnt") + private Integer productCnt; + } + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopDeliveryGetCompanyListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopDeliveryGetCompanyListResponse.java new file mode 100644 index 000000000..096d92e38 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopDeliveryGetCompanyListResponse.java @@ -0,0 +1,30 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +public class WxMaShopDeliveryGetCompanyListResponse extends WxMaShopBaseResponse implements Serializable { + private static final long serialVersionUID = -1478684494303814483L; + + @SerializedName("company_list") + private List companyList; + + @Data + public static class CompanyListBean implements Serializable { + /** + * delivery_id : SF + * delivery_name : 顺丰速运 + */ + + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("delivery_name") + private String deliveryName; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java index 74f656d25..28a38a1f2 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java @@ -348,6 +348,18 @@ public class WxMaApiUrlConstants { String AUDIT_RESULT = "https://api.weixin.qq.com/shop/audit/result"; String GET_MINIAPP_CERTIFICATE = "https://api.weixin.qq.com/shop/audit/get_miniapp_certificate"; } + + interface Delivery { + String GET_COMPANY_LIST = "https://api.weixin.qq.com/shop/delivery/get_company_list"; + String DELIVERY_SEND = "https://api.weixin.qq.com/shop/delivery/send"; + String DELIVERY_RECEIVE = "https://api.weixin.qq.com/shop/delivery/recieve"; + } + + interface Aftersale { + String AFTERSALE_ADD = "https://api.weixin.qq.com/shop/aftersale/add"; + String AFTERSALE_GET = "https://api.weixin.qq.com/shop/aftersale/get"; + String AFTERSALE_UPDATE = "https://api.weixin.qq.com/shop/aftersale/update"; + } } /** diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImplTest.java new file mode 100644 index 000000000..3d38d82e0 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAfterSaleServiceImplTest.java @@ -0,0 +1,75 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleGetRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author liming1019 + */ +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaShopAfterSaleServiceImplTest { + @Inject + private WxMaService wxService; + + @Test + public void testAdd() throws WxErrorException { + WxMaShopAfterSaleAddRequest.ProductInfosBean productInfosBean = WxMaShopAfterSaleAddRequest.ProductInfosBean.builder() + .outProductId("234245") + .outSkuId("23424") + .productCnt(5) + .build(); + WxMaShopAfterSaleAddRequest request = WxMaShopAfterSaleAddRequest.builder() + .outOrderId("xxxxx") + .outAftersaleId("xxxxxx") + .openid("oTVP50O53a7jgmawAmxKukNlq3XI") + .type(1) + .createTime("2020-12-01 00:00:00") + .status(1) + .finishAllAftersale(0) + .path("/pages/aftersale.html?out_aftersale_id=xxxxx") + .refund(100L) + .productInfos(new ArrayList<>(Arrays.asList(productInfosBean))) + .build(); + WxMaShopBaseResponse response = wxService.getShopAfterSaleService().add(request); + assertThat(response).isNotNull(); + } + + @Test + public void testGet() throws WxErrorException { + WxMaShopAfterSaleGetRequest request = WxMaShopAfterSaleGetRequest.builder() + .openid("oTVP50O53a7jgmawAmxKukNlq3XI") + .orderId(32434234L) + .outOrderId("xxxxx") + .build(); + WxMaShopAfterSaleGetResponse response = wxService.getShopAfterSaleService().get(request); + assertThat(response).isNotNull(); + } + + @Test + public void testUpdate() throws WxErrorException { + WxMaShopAfterSaleUpdateRequest request = WxMaShopAfterSaleUpdateRequest.builder() + .outOrderId("xxxxx") + .openid("oTVP50O53a7jgmawAmxKukNlq3XI") + .outAftersaleId("xxxxxx") + .status(1) + .finishAllAftersale(0) + .build(); + WxMaShopBaseResponse response = wxService.getShopAfterSaleService().update(request); + assertThat(response).isNotNull(); + } +} diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImplTest.java new file mode 100644 index 000000000..e19a9c086 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopDeliveryServiceImplTest.java @@ -0,0 +1,61 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliveryRecieveRequest; +import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopDeliverySendRequest; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopDeliveryGetCompanyListResponse; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.inject.Inject; +import me.chanjar.weixin.common.error.WxErrorException; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Arrays; + +import static org.testng.Assert.assertNotNull; + +/** + * @author liming1019 + */ +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaShopDeliveryServiceImplTest { + @Inject + private WxMaService wxService; + + @Test + public void testGetCompanyList() throws WxErrorException { + WxMaShopDeliveryGetCompanyListResponse response = wxService.getShopDeliveryService().getCompanyList(); + assertNotNull(response); + } + + @Test + public void testSend() throws WxErrorException { + WxMaShopDeliverySendRequest.DeliveryListBean deliveryListBean = WxMaShopDeliverySendRequest.DeliveryListBean.builder() + .deliveryId("SF") + .waybillId("23424324253") + .build(); + WxMaShopDeliverySendRequest request = WxMaShopDeliverySendRequest.builder() + .orderId(123456L) + .outOrderId("xxxxx") + .openid("oTVP50O53a7jgmawAmxKukNlq3XI") + .finishAllDelivery(0) + .deliveryList(new ArrayList<>(Arrays.asList(deliveryListBean))) + .build(); + WxMaShopBaseResponse response = wxService.getShopDeliveryService().send(request); + assertNotNull(response); + } + + @Test + public void testReceive() throws WxErrorException { + WxMaShopDeliveryRecieveRequest request = WxMaShopDeliveryRecieveRequest.builder() + .openid("oTVP50O53a7jgmawAmxKukNlq3XI") + .orderId(123456L) + .outOrderId("xxxxx") + .build(); + WxMaShopBaseResponse response = wxService.getShopDeliveryService().receive(request); + assertNotNull(response); + } +}