🎨 【小程序】增加退货组件相关接口,同时绑定/解绑物流账号接口增加缺失返回值

This commit is contained in:
hellocder
2023-09-29 08:43:21 +00:00
committed by Binary Wang
parent f53eed6779
commit d4bc91a102
17 changed files with 334 additions and 43 deletions

View File

@@ -0,0 +1,22 @@
package cn.binarywang.wx.miniapp.api;
import cn.binarywang.wx.miniapp.bean.express.request.WxMaExpressDeliveryReturnAddRequest;
import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressReturnInfoResult;
import me.chanjar.weixin.common.error.WxErrorException;
/**
* 退货组件
*/
public interface WxMaExpressDeliveryReturnService {
/**
* 获取支持的快递公司列表
*/
String ADD_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/add";
String GET_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/get";
String UNBIND_DELIVERY_RETURN_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/return/unbind";
WxMaExpressReturnInfoResult addDeliveryReturn(WxMaExpressDeliveryReturnAddRequest wxMaExpressDeliveryReturnAddRequest) throws WxErrorException;
WxMaExpressReturnInfoResult getDeliveryReturn(String returnId) throws WxErrorException;
WxMaExpressReturnInfoResult unbindDeliveryReturn(String returnId) throws WxErrorException;
}

View File

@@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.bean.express.WxMaExpressDelivery;
import cn.binarywang.wx.miniapp.bean.express.WxMaExpressPath;
import cn.binarywang.wx.miniapp.bean.express.WxMaExpressPrinter;
import cn.binarywang.wx.miniapp.bean.express.request.*;
import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressInfoResult;
import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressOrderInfoResult;
import me.chanjar.weixin.common.error.WxErrorException;
@@ -44,7 +45,7 @@ public interface WxMaExpressService {
* @param wxMaExpressBindAccountRequest 物流账号对象
* @throws WxErrorException 请求失败时返回
*/
void bindAccount(WxMaExpressBindAccountRequest wxMaExpressBindAccountRequest) throws WxErrorException;
WxMaExpressInfoResult bindAccount(WxMaExpressBindAccountRequest wxMaExpressBindAccountRequest) throws WxErrorException;
/**
* 获取电子面单余额。仅在使用加盟类快递公司时,才可以调用。

View File

@@ -46,7 +46,7 @@ public interface WxMaMediaService {
* @param inputStream 输入流
* @return the wx media upload result
* @throws WxErrorException the wx error exception
* @see #uploadMedia(java.lang.String, java.io.File) #uploadMedia(java.lang.String, java.io.File)
* @see #uploadMedia(String, File) #uploadMedia(java.lang.String, java.io.File)
*/
WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputStream inputStream) throws WxErrorException;

View File

@@ -19,7 +19,7 @@ public interface WxMaOpenApiService {
*
* @return 是否成功
* @throws WxErrorException the wx error exception
* @apiNote !!! 单小程序直接调用该方法 , 如多个appid调用此方法前请调用 {@link cn.binarywang.wx.miniapp.api.WxMaService#switchoverTo} 切换appid !!!
* @apiNote !!! 单小程序直接调用该方法 , 如多个appid调用此方法前请调用 {@link WxMaService#switchoverTo} 切换appid !!!
* @code wxMaService.getWxMaOpenApiService().clearQuota() //单个
* @code wxMaService.switchoverTo(" appid ").getWxMaOpenApiService().clearQuota() //多个
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/clearQuota.html">注意事项参考微信文档</a>
@@ -55,7 +55,7 @@ public interface WxMaOpenApiService {
*
* @return 是否成功
* @throws WxErrorException 微信异常
* @apiNote !!! 单小程序直接调用该方法 , 如多个appid调用此方法前请调用 {@link cn.binarywang.wx.miniapp.api.WxMaService#switchoverTo} 切换appid!!!
* @apiNote !!! 单小程序直接调用该方法 , 如多个appid调用此方法前请调用 {@link WxMaService#switchoverTo} 切换appid!!!
* 参考示例
* @code wxMaService.getWxMaOpenApiService().clearQuotaByAppSecret() //单个
* @code wxMaService.switchoverTo(" appid ").getWxMaOpenApiService().clearQuotaByAppSecret() //多个

View File

@@ -554,4 +554,5 @@ public interface WxMaService extends WxService {
* @return getWxMaXPayService
*/
WxMaXPayService getWxMaXPayService();
WxMaExpressDeliveryReturnService getWxMaExpressDeliveryReturnService();
}

View File

@@ -91,6 +91,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
private final WxMaOpenApiService wxMaOpenApiService = new WxMaOpenApiServiceImpl(this);
private final WxMaVodService wxMaVodService = new WxMaVodServiceImpl(this);
private final WxMaXPayService wxMaXPayService = new WxMaXPayServiceImpl(this);
private final WxMaExpressDeliveryReturnService wxMaExpressDeliveryReturnService = new WxMaExpressDeliveryReturnServiceImpl(this);
private Map<String, WxMaConfig> configMap = new HashMap<>();
private int retrySleepMillis = 1000;
@@ -677,4 +678,9 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
public WxMaXPayService getWxMaXPayService() {
return this.wxMaXPayService;
}
@Override
public WxMaExpressDeliveryReturnService getWxMaExpressDeliveryReturnService(){
return this.wxMaExpressDeliveryReturnService;
}
}

View File

@@ -0,0 +1,36 @@
package cn.binarywang.wx.miniapp.api.impl;
import cn.binarywang.wx.miniapp.api.WxMaExpressDeliveryReturnService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.express.request.WxMaExpressDeliveryReturnAddRequest;
import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressReturnInfoResult;
import com.google.gson.JsonObject;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
@RequiredArgsConstructor
public class WxMaExpressDeliveryReturnServiceImpl implements WxMaExpressDeliveryReturnService {
private final WxMaService service;
@Override
public WxMaExpressReturnInfoResult addDeliveryReturn(WxMaExpressDeliveryReturnAddRequest wxMaExpressDeliveryReturnAddRequest) throws WxErrorException {
String result= this.service.get(ADD_DELIVERY_RETURN_URL,wxMaExpressDeliveryReturnAddRequest.toJson());
return WxMaExpressReturnInfoResult.fromJson(result);
}
@Override
public WxMaExpressReturnInfoResult getDeliveryReturn(String returnId) throws WxErrorException {
JsonObject param = new JsonObject();
param.addProperty("return_id",returnId);
String result= this.service.get(GET_DELIVERY_RETURN_URL,param.toString());
return WxMaExpressReturnInfoResult.fromJson(result);
}
@Override
public WxMaExpressReturnInfoResult unbindDeliveryReturn(String returnId) throws WxErrorException {
JsonObject param = new JsonObject();
param.addProperty("return_id",returnId);
String result= this.service.get(UNBIND_DELIVERY_RETURN_URL,param.toString());
return WxMaExpressReturnInfoResult.fromJson(result);
}
}

View File

@@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.bean.express.WxMaExpressDelivery;
import cn.binarywang.wx.miniapp.bean.express.WxMaExpressPath;
import cn.binarywang.wx.miniapp.bean.express.WxMaExpressPrinter;
import cn.binarywang.wx.miniapp.bean.express.request.*;
import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressInfoResult;
import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressOrderInfoResult;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import lombok.RequiredArgsConstructor;
@@ -39,8 +40,8 @@ public class WxMaExpressServiceImpl implements WxMaExpressService {
}
@Override
public void bindAccount(WxMaExpressBindAccountRequest wxMaExpressBindAccountRequest) throws WxErrorException {
this.service.post(BIND_ACCOUNT_URL, wxMaExpressBindAccountRequest.toJson());
public WxMaExpressInfoResult bindAccount(WxMaExpressBindAccountRequest wxMaExpressBindAccountRequest) throws WxErrorException {
return WxMaExpressInfoResult.fromJson(this.service.post(BIND_ACCOUNT_URL, wxMaExpressBindAccountRequest.toJson()));
}
@Override

View File

@@ -59,7 +59,7 @@ public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
*/
@Override
public BindAccountResponse getBindAccount() throws WxErrorException {
return this.parse(this.wxMaService.post(WxMaApiUrlConstants.InstantDelivery.GET_BIND_ACCOUNT, "{}"),
return this.parse(this.wxMaService.post(InstantDelivery.GET_BIND_ACCOUNT, "{}"),
BindAccountResponse.class);
}
@@ -76,7 +76,7 @@ public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
@Override
public AddOrderResponse addOrder(final AddOrderRequest request) throws WxErrorException {
request.getDeliverySign();
return this.parse(this.wxMaService.post(WxMaApiUrlConstants.InstantDelivery.PlaceAnOrder.ADD_ORDER, request),
return this.parse(this.wxMaService.post(InstantDelivery.PlaceAnOrder.ADD_ORDER, request),
AddOrderResponse.class);
}
@@ -94,7 +94,7 @@ public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
@Override
public GetOrderResponse getOrder(final GetOrderRequest request) throws WxErrorException {
request.getDeliverySign();
return this.parse(this.wxMaService.post(WxMaApiUrlConstants.InstantDelivery.GET_ORDER, request),
return this.parse(this.wxMaService.post(InstantDelivery.GET_ORDER, request),
GetOrderResponse.class);
}
@@ -111,7 +111,7 @@ public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
@Override
public CancelOrderResponse cancelOrder(final CancelOrderRequest request) throws WxErrorException {
request.getDeliverySign();
return this.parse(this.wxMaService.post(WxMaApiUrlConstants.InstantDelivery.Cancel.CANCEL_ORDER, request),
return this.parse(this.wxMaService.post(InstantDelivery.Cancel.CANCEL_ORDER, request),
CancelOrderResponse.class);
}
@@ -128,7 +128,7 @@ public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
@Override
public AbnormalConfirmResponse abnormalConfirm(final AbnormalConfirmRequest request) throws WxErrorException {
request.getDeliverySign();
return this.parse(this.wxMaService.post(WxMaApiUrlConstants.InstantDelivery.Cancel.ABNORMAL_CONFIRM, request),
return this.parse(this.wxMaService.post(InstantDelivery.Cancel.ABNORMAL_CONFIRM, request),
AbnormalConfirmResponse.class);
}
@@ -144,7 +144,7 @@ public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
*/
@Override
public MockUpdateOrderResponse mockUpdateOrder(final MockUpdateOrderRequest request) throws WxErrorException {
return this.parse(this.wxMaService.post(WxMaApiUrlConstants.InstantDelivery.MOCK_UPDATE_ORDER, request),
return this.parse(this.wxMaService.post(InstantDelivery.MOCK_UPDATE_ORDER, request),
MockUpdateOrderResponse.class);
}