Skip to content

Commit

Permalink
🆕 #2258 【小程序】增加自定义组件之物流和售后相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
liming1019 authored Aug 13, 2021
1 parent 3f42a16 commit e785b1f
Show file tree
Hide file tree
Showing 16 changed files with 681 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,20 @@ public interface WxMaService extends WxService {
*/
WxImgProcService getImgProcService();

// /**
// * 返回小程序交易组件-售后服务接口
// * @return
// */
// WxMaShopAfterSaleService getShopAfterSaleService();
//
//
// /**
// * 返回小程序交易组件-物流服务接口
// * @return
// */
// WxMaShopDeliveryService getShopDeliveryService();
/**
* 返回小程序交易组件-售后服务接口
*
* @return
*/
WxMaShopAfterSaleService getShopAfterSaleService();


/**
* 返回小程序交易组件-物流服务接口
*
* @return
*/
WxMaShopDeliveryService getShopDeliveryService();


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public abstract class BaseWxMaServiceImpl<H, P> 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<String, WxMaConfig> configMap;
Expand Down Expand Up @@ -546,6 +548,16 @@ public WxMaShopAuditService getShopAuditService() {
return this.shopAuditService;
}

@Override
public WxMaShopAfterSaleService getShopAfterSaleService() {
return this.shopAfterSaleService;
}

@Override
public WxMaShopDeliveryService getShopDeliveryService() {
return this.shopDeliveryService;
}

@Override
public WxMaLinkService getLinkService() {
return this.linkService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,81 @@

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,78 @@

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);
}
}
Original file line number Diff line number Diff line change
@@ -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<ProductInfosBean> 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;
}
}
Loading

0 comments on commit e785b1f

Please sign in to comment.