From 6e5800181bfb44d288418d3767cbca2c3b8dca8d Mon Sep 17 00:00:00 2001 From: liming Date: Thu, 25 Aug 2022 22:48:17 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=B0=8F=E7=A8=8B=E5=BA=8F=E3=80=91?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E7=89=88=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E7=BB=84=E4=BB=B6=E8=8E=B7=E5=8F=96=E5=94=AE?= =?UTF-8?q?=E5=90=8E=E5=8D=95=E8=AF=A6=E6=83=85API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../miniapp/api/WxMaShopAfterSaleService.java | 22 +++--- .../impl/WxMaShopAfterSaleServiceImpl.java | 30 +++++--- .../WxMaShopEcAfterSaleGetRequest.java | 27 +++++++ .../WxMaShopEcAfterSaleGetResponse.java | 73 +++++++++++++++++++ .../miniapp/constant/WxMaApiUrlConstants.java | 3 +- .../WxMaShopAfterSaleServiceImplTest.java | 13 ++++ 6 files changed, 145 insertions(+), 23 deletions(-) create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopEcAfterSaleGetResponse.java 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 4f5a3f18d2..76c52e88bc 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,16 +1,7 @@ package cn.binarywang.wx.miniapp.api; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAcceptReturnRequest; -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.WxMaShopAfterSaleListRequest; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUploadReturnInfoRequest; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopUploadCerficatesRequest; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleAddResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleListResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.request.*; +import cn.binarywang.wx.miniapp.bean.shop.response.*; import me.chanjar.weixin.common.error.WxErrorException; /** @@ -38,6 +29,15 @@ public interface WxMaShopAfterSaleService { */ WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) throws WxErrorException; + /** + * 获取售后单详情(EC版) + * + * @param request + * @return WxMaShopEcAfterSaleGetResponse + * @throws WxErrorException + */ + WxMaShopEcAfterSaleGetResponse get(WxMaShopEcAfterSaleGetRequest request) throws WxErrorException; + /** * 更新售后 * 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 5641489b4c..1ec4b0dd3f 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,17 +2,8 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaShopAfterSaleService; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAcceptReturnRequest; -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.WxMaShopAfterSaleListRequest; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUpdateRequest; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleUploadReturnInfoRequest; -import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopUploadCerficatesRequest; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleAddResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleListResponse; -import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.request.*; +import cn.binarywang.wx.miniapp.bean.shop.response.*; import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; @@ -70,6 +61,23 @@ public WxMaShopAfterSaleGetResponse get(WxMaShopAfterSaleGetRequest request) thr return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAfterSaleGetResponse.class); } + /** + * 获取售后单详情(EC版) + * + * @param request + * @return WxMaShopEcAfterSaleGetResponse + * @throws WxErrorException + */ + @Override + public WxMaShopEcAfterSaleGetResponse get(WxMaShopEcAfterSaleGetRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(ECAFTERSALE_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, WxMaShopEcAfterSaleGetResponse.class); + } + /** * 更新售后 * diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java new file mode 100644 index 0000000000..1485d72880 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.bean.shop.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author liming1019 + * created on 2022/8/25 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaShopEcAfterSaleGetRequest implements Serializable { + + private static final long serialVersionUID = -1967384908983649001L; + + @SerializedName("aftersale_id") + private Long aftersaleId; + @SerializedName("out_aftersale_id") + private String outAftersaleId; +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopEcAfterSaleGetResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopEcAfterSaleGetResponse.java new file mode 100644 index 0000000000..fa03fabd0e --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/response/WxMaShopEcAfterSaleGetResponse.java @@ -0,0 +1,73 @@ +package cn.binarywang.wx.miniapp.bean.shop.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author liming1019 + * created on 2022/8/25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxMaShopEcAfterSaleGetResponse extends WxMaShopBaseResponse implements Serializable { + + private static final long serialVersionUID = -338753264205536337L; + + @SerializedName("after_sales_order") + private AfterSalesOrderDTO afterSalesOrder; + + @Data + public static class AfterSalesOrderDTO implements Serializable { + @SerializedName("out_aftersale_id") + private String outAftersaleId; + @SerializedName("aftersale_id") + private Long aftersaleId; + @SerializedName("out_order_id") + private String outOrderId; + @SerializedName("order_id") + private Long orderId; + @SerializedName("product_info") + private ProductInfoDTO productInfo; + @SerializedName("type") + private Integer type; + @SerializedName("return_info") + private ReturnInfoDTO returnInfo; + @SerializedName("orderamt") + private Integer orderamt; + @SerializedName("refund_reason_type") + private Integer refundReasonType; + @SerializedName("refund_reason") + private String refundReason; + @SerializedName("status") + private Integer status; + @SerializedName("create_time") + private String createTime; + @SerializedName("update_time") + private String updateTime; + + @Data + public static class ProductInfoDTO implements Serializable { + @SerializedName("out_product_id") + private String outProductId; + @SerializedName("out_sku_id") + private String outSkuId; + @SerializedName("product_cnt") + private Integer productCnt; + } + + @Data + public static class ReturnInfoDTO implements Serializable { + @SerializedName("order_return_time") + private String orderReturnTime; + @SerializedName("delivery_id") + private String deliveryId; + @SerializedName("waybill_id") + private String waybillId; + @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 f3220514de..d080ef886b 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 @@ -511,7 +511,8 @@ interface Aftersale { String AFTERSALE_UPLOAD_CERTIFICATES = "https://api.weixin.qq.com/shop/ecaftersale/upload_certificates"; String AFTERSALE_UPLOAD_DEADLINE = "https://api.weixin.qq.com/shop/aftersale/update_deadline"; String AFTERSALE_GET_LIST = "https://api.weixin.qq.com/shop/ecaftersale/get_list"; - String AFTERSALE_GET = "https://api.weixin.qq.com/shop/ecaftersale/get"; + String AFTERSALE_GET = "https://api.weixin.qq.com/shop/aftersale/get"; + String ECAFTERSALE_GET = "https://api.weixin.qq.com/shop/ecaftersale/get"; } interface Sharer { 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 index 9839cbf4c1..2446b2e3ef 100644 --- 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 @@ -4,8 +4,10 @@ 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.request.WxMaShopEcAfterSaleGetRequest; import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse; import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse; +import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopEcAfterSaleGetResponse; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; import me.chanjar.weixin.common.error.WxErrorException; @@ -71,4 +73,15 @@ public void testUpdate() throws WxErrorException { WxMaShopBaseResponse response = wxService.getShopAfterSaleService().update(request); assertThat(response).isNotNull(); } + + @Test + public void testEcGet() throws WxErrorException { + WxMaShopEcAfterSaleGetRequest request = WxMaShopEcAfterSaleGetRequest.builder() + .aftersaleId(123L) + .outAftersaleId("aso_123124341") + .build(); + WxMaShopEcAfterSaleGetResponse response = wxService.getShopAfterSaleService().get(request); + assertThat(response).isNotNull(); + } + }