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

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);
}

View File

@ -0,0 +1,93 @@
package cn.binarywang.wx.miniapp.bean.express.request;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* 创建退货ID
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WxMaExpressDeliveryReturnAddRequest implements Serializable {
private static final long serialVersionUID = -9111430627246688840L;
/**
* 商家内部使用的退货编号
* <pre>
* 是否必填
* 描述
* </pre>
*/
@SerializedName("shop_order_id")
private String shopOrderId;
/**
* 商家退货地址
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("biz_addr")
private WxMaExpressOrderPerson bizAddr;
/**
* 用户购物时的收货地址
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("user_addr")
private WxMaExpressOrderPerson userAddr;
/**
* 退货用户的openid
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("openid")
private String openid;
/**
* 退货订单在小程序中的path
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("order_path")
private String orderPath;
/**
* 退货订单的金额单位
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("goods_list")
private List<WxMaExpressReturnOrder> goodsList;
/**
* 退货订单的金额单位
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("order_price")
private Integer orderPrice;
public String toJson() {
return WxMaGsonBuilder.create().toJson(this);
}
}

View File

@ -0,0 +1,40 @@
package cn.binarywang.wx.miniapp.bean.express.request;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 退货商品对象
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
* @since 2019-11-26
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WxMaExpressReturnOrder implements Serializable {
private static final long serialVersionUID = -7798434835843377474L;
/**
* 商品名称
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("name")
private String name;
/**
* 商品缩略图url
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("url")
private String url;
}

View File

@ -0,0 +1,19 @@
package cn.binarywang.wx.miniapp.bean.express.result;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
public class WxMaExpressInfoResult {
/**
* 错误码
*/
private Integer errcode;
/**
* 错误信息
*/
private String errmsg;
public static WxMaExpressInfoResult fromJson(String json) {
return WxMaGsonBuilder.create().fromJson(json, WxMaExpressInfoResult.class);
}
}

View File

@ -23,19 +23,10 @@ import java.util.Map;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WxMaExpressOrderInfoResult implements Serializable {
public class WxMaExpressOrderInfoResult extends WxMaExpressInfoResult implements Serializable {
private static final long serialVersionUID = -9166603059965942285L;
/**
* 错误码
*/
private Integer errcode;
/**
* 错误信息
*/
private String errmsg;
/**
* 订单ID
*/

View File

@ -0,0 +1,68 @@
package cn.binarywang.wx.miniapp.bean.express.result;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* <pre>
* 运单信息返回结果对象
* </pre>
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
* @since 2019-11-26
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WxMaExpressReturnInfoResult extends WxMaExpressInfoResult implements Serializable {
private static final long serialVersionUID = -9166603059965942285L;
/**
* 退货ID
*/
@SerializedName("return_id")
private String returnId;
/**
* 0 用户未填写退货信息, 1. 在线预约, 2. 自主填写
*/
private String status;
/**
* 运单ID
*/
@SerializedName("waybill_id")
private String waybillId;
/**
* //0 已下单待揽件 1 已揽件 2 运输中 3 派件中 4 已签收 5 异常 6 代签收 7 揽收失败 8 签收失败拒收超区 11 已取消 13 退件中 14 已退件 99 未知
*/
@SerializedName("order_status")
private String orderStatus;
/**
* //运力公司名称
*/
@SerializedName("delivery_name")
private String deliveryName;
/**
* //运力公司名称
*/
@SerializedName("delivery_id")
private String deliveryId;
public static WxMaExpressReturnInfoResult fromJson(String json) {
return WxMaGsonBuilder.create().fromJson(json, WxMaExpressReturnInfoResult.class);
}
}

View File

@ -872,4 +872,18 @@ public class WxMaApiUrlConstants {
String QUERY_PUBLISH_GOODS_URL = "https://api.weixin.qq.com/xpay/query_publish_goods?pay_sig=%s";
}
/**
* 退货组件
* <pre>
* 文档地址https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_sale_return.html
* </pre>
*
*/
public interface ExpressDeliveryReturn{
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";
}
}

View File

@ -35,7 +35,7 @@ public class ApiTestModule implements Module {
binder.bind(WxMaService.class).toInstance(wxService);
binder.bind(WxMaConfig.class).toInstance(config);
WxMaServiceOkHttpImpl wxMaServiceOkHttp = new cn.binarywang.wx.miniapp.api.impl.WxMaServiceOkHttpImpl();
WxMaServiceOkHttpImpl wxMaServiceOkHttp = new WxMaServiceOkHttpImpl();
wxMaServiceOkHttp.setWxMaConfig(config);
binder.bind(WxMaServiceOkHttpImpl.class).toInstance(wxMaServiceOkHttp);

View File

@ -85,9 +85,8 @@ public class Applyment4SubServiceImplTest {
String subMchid = "subMchid";
String applymentId = "applymentId";
applyment4SubService.settlementApplication(subMchid, applymentId);
applyment4SubService.querySettlementModifyStatusByApplicationNo(subMchid, applymentId);
}
}