🆕 #2758 【小程序】增加微信小商店标准版相关接口

This commit is contained in:
Boris 2022-07-26 21:45:32 +08:00 committed by GitHub
parent b550806956
commit 1747190674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 1965 additions and 60 deletions

View File

@ -1,5 +1,6 @@
package me.chanjar.weixin.common.bean.result;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.Data;
@ -25,8 +26,12 @@ public class WxMinishopImageUploadResult implements Serializable {
if (result.getErrcode().equals("0")) {
WxMinishopPicFileResult picFileResult = new WxMinishopPicFileResult();
JsonObject picObject = jsonObject.get("pic_file").getAsJsonObject();
picFileResult.setMediaId(picObject.get("media_id").getAsString());
picFileResult.setPayMediaId(picObject.get("pay_media_id").getAsString());
JsonElement mediaId = picObject.get("media_id");
picFileResult.setMediaId(mediaId==null ? "" : mediaId.getAsString());
JsonElement payMediaId = picObject.get("pay_media_id");
picFileResult.setPayMediaId(payMediaId==null ? "" : payMediaId.getAsString());
JsonElement tempImgUrl = picObject.get("temp_img_url");
picFileResult.setTempImgUrl(tempImgUrl==null ? "" : tempImgUrl.getAsString());
result.setPicFile(picFileResult);
}

View File

@ -8,4 +8,5 @@ import java.io.Serializable;
public class WxMinishopPicFileResult implements Serializable {
private String mediaId;
private String payMediaId;
private String tempImgUrl;
}

View File

@ -0,0 +1,76 @@
package cn.binarywang.wx.miniapp.api;
import cn.binarywang.wx.miniapp.bean.product.WxMiniBatchGetAfterSaleOrderResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMiniGetAfterSaleOrderResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMiniOrderDeliveryRequest;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderDetailResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import java.util.List;
import me.chanjar.weixin.common.error.WxErrorException;
/**
* 小程序交易组件-标准版-商品服务
*
* @author boris
*/
public interface WxMaProductOrderService {
/**
* 获取订单列表
*
* @param startCreateTime (未填更新时间范围时必填)
* @param endCreateTime (未填更新时间范围时必填)
* @param startUpdateTime (未填创建时间范围时必填)
* @param endUpdateTime (未填创建时间范围时必填)
* @param status 订单状态枚举值见RequestOrderStatus
* @param page 第几页最小填1
* @param pageSize 每页数量(不超过10,000)
* @param source 1:小商店,2:CPS带货
* @return
* @throws WxErrorException
*/
WxMinishopOrderListResponse getOrderList(
String startCreateTime,
String endCreateTime,
String startUpdateTime,
String endUpdateTime,
Integer status,
Integer page,
Integer pageSize,
Integer source
) throws WxErrorException;
/**
* 获取订单详情
*
* @param orderId 订单ID可从获取订单列表中获得
* @return
*/
WxMinishopOrderDetailResponse getOrderDetail(Long orderId) throws WxErrorException;
/**
* 修改订单备注
* @param orderId 订单id
* @param merchantNotes 备注内容
*/
void changeMerchantNotes(Long orderId,String merchantNotes) throws WxErrorException;
WxMaShopBaseResponse deliverySend(WxMiniOrderDeliveryRequest request)
throws WxErrorException;
WxMiniGetAfterSaleOrderResponse getAfterSaleOrder(Long afterSaleOrderId)
throws WxErrorException;
WxMiniBatchGetAfterSaleOrderResponse batchGetAfterSaleOrder(List<Long> afterSaleOrderIdList)
throws WxErrorException;
WxMaShopBaseResponse afterSaleAccept(Long orderId, Long addressId)
throws WxErrorException;
WxMaShopBaseResponse afterSaleReject(Long afterSaleOrderId, String rejectReason)
throws WxErrorException;
}

View File

@ -2,9 +2,13 @@ package cn.binarywang.wx.miniapp.api;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopAddGoodsSkuData;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopAddGoodsSpuData;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetBrandResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetCategoryResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetFrightTemplateResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderListResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopResult;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSku;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSkuListResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpu;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGet;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGetResponse;
@ -13,7 +17,9 @@ import cn.binarywang.wx.miniapp.bean.product.WxMinishopUpdateGoodsSkuData;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopSpuPageRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopGetSpuListResponse;
import java.io.File;
import java.util.List;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
/**
@ -22,7 +28,18 @@ import me.chanjar.weixin.common.error.WxErrorException;
* @author boris
*/
public interface WxMaProductService {
WxMinishopResult addSpu(WxMinishopSpu spuInfo) throws WxErrorException;
WxMinishopImageUploadResult uploadImg(File file, Integer respType, Integer width, Integer height) throws WxErrorException;
WxMinishopImageUploadResult uploadImg(String imgUrl, Integer respType) throws WxErrorException;
WxMinishopGetCategoryResponse getCategory(Integer fCatId) throws WxErrorException;
WxMinishopGetBrandResponse getBrand() throws WxErrorException;
WxMinishopGetFrightTemplateResponse getFreightTemplate() throws WxErrorException;
WxMinishopResult<WxMinishopAddGoodsSpuData> addSpu(WxMinishopSpu spuInfo) throws WxErrorException;
WxMaShopBaseResponse deleteSpu(Integer productId, String outProductId) throws WxErrorException;
@ -40,6 +57,9 @@ public interface WxMaProductService {
WxMaShopBaseResponse delistingSpu(Integer productId, String outProductId)
throws WxErrorException;
WxMinishopSkuListResponse getSkuList(Long productId, Integer needRealStock, Integer needEditSku)
throws WxErrorException;
/**
* 小商店新增sku信息
*
@ -96,7 +116,7 @@ public interface WxMaProductService {
* @throws WxErrorException
*/
WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSkuPrice(Long productId,
Long outProductId, String outSkuId, Long skuId, Long salePrice, Long marketPrice) throws WxErrorException;
String outProductId, String outSkuId, Long skuId, Long salePrice, Long marketPrice) throws WxErrorException;
/**
@ -112,8 +132,6 @@ public interface WxMaProductService {
* @throws WxErrorException
*/
WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSkuStock(Long productId,
Long outProductId, String outSkuId, Long skuId, Integer type, Integer stockNum) throws WxErrorException;
String outProductId, String outSkuId, Long skuId, Integer type, Integer stockNum) throws WxErrorException;
WxMinishopOrderListResponse minishopOrderGetList(String startCreateTime, String endCreateTime,
Integer status, Integer page, Integer pageSize, Integer source) throws WxErrorException;
}

View File

@ -494,13 +494,25 @@ public interface WxMaService extends WxService {
/**
* 分享人接口
* @return
* @return WxMaShopSharerService
*/
WxMaShopSharerService getShopSharerService();
/**
* 标准交易组件接口
* @return
* @return WxMaProductService
*/
WxMaProductService getProductService();
/**
* 小商店-标准交易组件-订单服务
* @return getProductOrderService
*/
WxMaProductOrderService getProductOrderService();
/**
* 小商店-标准交易组件-优惠券
* @return getWxMaShopCouponService
*/
WxMaShopCouponService getWxMaShopCouponService();
}

View File

@ -1,9 +1,15 @@
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 me.chanjar.weixin.common.error.WxErrorException;
@ -21,7 +27,7 @@ public interface WxMaShopAfterSaleService {
* @return WxMaShopBaseResponse
* @throws WxErrorException
*/
WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException;
WxMaShopAfterSaleAddResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException;
/**
* 获取订单下售后单
@ -41,4 +47,81 @@ public interface WxMaShopAfterSaleService {
*/
WxMaShopBaseResponse update(WxMaShopAfterSaleUpdateRequest request) throws WxErrorException;
/**
* 用户取消售后申请
* @param outAfterSaleId 商家自定义订单ID
* @param afterSaleId 与out_aftersale_id二选一
* @param openId 用户openid
* @return
* @throws WxErrorException
*/
WxMaShopBaseResponse cancel(String outAfterSaleId, Long afterSaleId, String openId)
throws WxErrorException;
/**
* 用户上传退货物流
* @param request
* @return
* @throws WxErrorException
*/
WxMaShopBaseResponse uploadReturnInfo(WxMaShopAfterSaleUploadReturnInfoRequest request)
throws WxErrorException;
/**
* 商家同意退款
* @param outAfterSaleId
* @param afterSaleId
* @return
* @throws WxErrorException
*/
WxMaShopBaseResponse acceptRefund(String outAfterSaleId, Long afterSaleId)
throws WxErrorException;
/**
* 商家同意退货
* @param request
* @return
* @throws WxErrorException
*/
WxMaShopBaseResponse acceptReturn(WxMaShopAcceptReturnRequest request)
throws WxErrorException;
/**
* 商家拒绝售后
* @param outAfterSaleId
* @param afterSaleId
* @return
* @throws WxErrorException
*/
WxMaShopBaseResponse reject(String outAfterSaleId, Long afterSaleId)
throws WxErrorException;
/**
* 商家上传退款凭证
* @param request
* @return
* @throws WxErrorException
*/
WxMaShopBaseResponse uploadCertificates(WxMaShopUploadCerficatesRequest request)
throws WxErrorException;
/**
* 商家更新订单售后期
* @param outOrderId
* @param orderId
* @param openid
* @param afterSaleDeadline
* @return
* @throws WxErrorException
*/
WxMaShopBaseResponse updateDeadline(String outOrderId, Long orderId, String openid,
Long afterSaleDeadline) throws WxErrorException;
/**
* 获取售后单详情
* @param request
* @return
* @throws WxErrorException
*/
WxMaShopAfterSaleListResponse list(WxMaShopAfterSaleListRequest request) throws WxErrorException;
}

View File

@ -0,0 +1,40 @@
package cn.binarywang.wx.miniapp.api;
import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCouponListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCouponResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopUserCouponListResponse;
import me.chanjar.weixin.common.error.WxErrorException;
/**
* @author leiin
* @date 2022/7/1 2:49 下午
*/
public interface WxMaShopCouponService {
WxMaShopBaseResponse addCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException;
WxMaShopCouponResponse getCoupon(String outCouponId) throws WxErrorException;
WxMaShopCouponListResponse getCouponList(Integer pageSize,
Integer offset) throws WxErrorException;
WxMaShopBaseResponse updateCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException;
WxMaShopBaseResponse updateCouponStatus(String outCouponId,
Integer status) throws WxErrorException;
WxMaShopBaseResponse updateCouponStock(String outCouponId, Integer isUsedNum, Integer receiveNum) throws WxErrorException;
WxMaShopBaseResponse addUserCoupon(String openid, String outUserCouponId,
String outCouponId, Integer status, Long recvTime) throws WxErrorException;
WxMaShopUserCouponListResponse getUserCouponList(Integer pageSize, Integer offset, String openid) throws WxErrorException;
WxMaShopBaseResponse updateUserCoupon(String openid, String outUserCouponId,
String outCouponId, Long useTime, Long recvTime) throws WxErrorException;
WxMaShopBaseResponse updateUserCouponStatus(String openid, String outUserCouponId,
String outCouponId, Integer status) throws WxErrorException;
}

View File

@ -81,6 +81,8 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
private final WxMaSafetyRiskControlService safetyRiskControlService = new WxMaSafetyRiskControlServiceImpl(this);
private final WxMaShopSharerService shopSharerService = new WxMaShopSharerServiceImpl(this);
private final WxMaProductService productService = new WxMaProductServiceImpl(this);
private final WxMaProductOrderService productOrderService = new WxMaProductOrderServiceImpl(this);
private final WxMaShopCouponService wxMaShopCouponService = new WxMaShopCouponServiceImpl(this);
private Map<String, WxMaConfig> configMap;
private int retrySleepMillis = 1000;
private int maxRetryTimes = 5;
@ -600,4 +602,14 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
@Override
public WxMaProductService getProductService() { return this.productService; }
@Override
public WxMaProductOrderService getProductOrderService() {
return this.productOrderService;
}
@Override
public WxMaShopCouponService getWxMaShopCouponService() {
return this.wxMaShopCouponService;
}
}

View File

@ -0,0 +1,167 @@
package cn.binarywang.wx.miniapp.api.impl;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.AFTER_SALE_ACCEPT_APPLY;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.AFTER_SALE_REJECT_APPLY;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.BATCH_GET_AFTER_SALE_ORDER;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.GET_AFTER_SALE_ORDER;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_DELIVERY_SEND;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_ORDER_CHANGE_MERCHANT_NOTES_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_ORDER_DETAIL_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_ORDER_GET_LIST;
import cn.binarywang.wx.miniapp.api.WxMaProductOrderService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.product.WxMiniBatchGetAfterSaleOrderResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMiniGetAfterSaleOrderResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMiniOrderDeliveryRequest;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderDetailResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.json.GsonHelper;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
/**
* 小程序交易组件-标准版-订单服务
*
* @author boris 详情请见 : https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent/API/order/get_order_list.html
*/
@RequiredArgsConstructor
@Slf4j
public class WxMaProductOrderServiceImpl implements WxMaProductOrderService {
private final WxMaService wxMaService;
@Override
public WxMinishopOrderListResponse getOrderList(
String startCreateTime, String endCreateTime, String startUpdateTime,
String endUpdateTime, Integer status, Integer page, Integer pageSize, Integer source)
throws WxErrorException {
String responseContent = this.wxMaService
.post(PRODUCT_ORDER_GET_LIST, GsonHelper.buildJsonObject(
"start_create_time", startCreateTime, "end_create_time", endCreateTime,
"start_update_time", startUpdateTime, "end_update_time", endUpdateTime,
"status", status, "page", page, "page_size", pageSize, "source", source));
WxMinishopOrderListResponse response = WxMaGsonBuilder.create()
.fromJson(responseContent, WxMinishopOrderListResponse.class);
if (response.getErrCode() != 0) {
throw new WxErrorException(new WxError(response.getErrCode(), response.getErrMsg()));
}
return response;
}
@Override
public WxMinishopOrderDetailResponse getOrderDetail(
Long orderId) throws WxErrorException {
String responseContent = this.wxMaService
.post(PRODUCT_ORDER_DETAIL_URL, GsonHelper.buildJsonObject(
"order_id", orderId));
WxMinishopOrderDetailResponse getDetailResponse = WxMaGsonBuilder.create()
.fromJson(responseContent, WxMinishopOrderDetailResponse.class);
if (getDetailResponse.getErrCode() != 0) {
throw new WxErrorException(
new WxError(getDetailResponse.getErrCode(), getDetailResponse.getErrMsg()));
}
return getDetailResponse;
}
@Override
public void changeMerchantNotes(Long orderId, String merchantNotes) throws WxErrorException {
String responseContent = this.wxMaService
.post(PRODUCT_ORDER_CHANGE_MERCHANT_NOTES_URL, GsonHelper.buildJsonObject(
"order_id", orderId,"merchant_notes",merchantNotes));
WxMaShopBaseResponse changeResult = WxMaGsonBuilder.create()
.fromJson(responseContent, WxMaShopBaseResponse.class);
if (changeResult.getErrCode() != 0) {
throw new WxErrorException(
new WxError(changeResult.getErrCode(), changeResult.getErrMsg()));
}
}
@Override
public WxMaShopBaseResponse deliverySend(WxMiniOrderDeliveryRequest request)
throws WxErrorException {
String response = this.wxMaService.post(PRODUCT_DELIVERY_SEND, request);
WxMaShopBaseResponse baseResponse = WxMaGsonBuilder.create()
.fromJson(response, WxMaShopBaseResponse.class);
if (baseResponse.getErrCode() != 0) {
throw new WxErrorException(
new WxError(baseResponse.getErrCode(), baseResponse.getErrMsg()));
}
return baseResponse;
}
@Override
public WxMiniGetAfterSaleOrderResponse getAfterSaleOrder(Long afterSaleOrderId)
throws WxErrorException {
String response = this.wxMaService.post(GET_AFTER_SALE_ORDER,
GsonHelper.buildJsonObject("after_sale_order_id", afterSaleOrderId));
WxMiniGetAfterSaleOrderResponse orderResponse = WxMaGsonBuilder.create()
.fromJson(response, WxMiniGetAfterSaleOrderResponse.class);
if (orderResponse.getErrCode() != 0) {
throw new WxErrorException(
new WxError(orderResponse.getErrCode(), orderResponse.getErrMsg()));
}
return orderResponse;
}
@Override
public WxMiniBatchGetAfterSaleOrderResponse batchGetAfterSaleOrder(
List<Long> afterSaleOrderIdList)
throws WxErrorException {
String response = this.wxMaService.post(BATCH_GET_AFTER_SALE_ORDER,
GsonHelper.buildJsonObject("after_sale_order_id_list", afterSaleOrderIdList));
WxMiniBatchGetAfterSaleOrderResponse orderResponse = WxMaGsonBuilder.create()
.fromJson(response, WxMiniBatchGetAfterSaleOrderResponse.class);
if (orderResponse.getAfterSaleOrderList() == null) {
throw new WxErrorException(
new WxError(orderResponse.getErrCode(), "售后查询不存在"));
}
return orderResponse;
}
@Override
public WxMaShopBaseResponse afterSaleAccept(Long orderId, Long addressId)
throws WxErrorException {
String response = this.wxMaService.post(AFTER_SALE_ACCEPT_APPLY,
GsonHelper.buildJsonObject("order_id", orderId, "address_id", addressId));
WxMaShopBaseResponse baseResponse = WxGsonBuilder.create()
.fromJson(response, WxMaShopBaseResponse.class);
if (baseResponse.getErrCode() != 0) {
throw new WxErrorException(
new WxError(baseResponse.getErrCode(), baseResponse.getErrMsg()));
}
return baseResponse;
}
@Override
public WxMaShopBaseResponse afterSaleReject(Long afterSaleOrderId, String rejectReason)
throws WxErrorException {
String response = this.wxMaService.post(AFTER_SALE_REJECT_APPLY,
GsonHelper.buildJsonObject("order_id", afterSaleOrderId, "reject_reason", rejectReason));
WxMaShopBaseResponse baseResponse = WxGsonBuilder.create()
.fromJson(response, WxMaShopBaseResponse.class);
if (baseResponse.getErrCode() != 0) {
throw new WxErrorException(
new WxError(baseResponse.getErrCode(), baseResponse.getErrMsg()));
}
return baseResponse;
}
}

View File

@ -1,5 +1,13 @@
package cn.binarywang.wx.miniapp.api.impl;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.GET_BRAND;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.GET_CATEGORY;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.GET_FREIGHT_TEMPLATE;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.OTHER.IMG_UPLOAD;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_ADD_SKU_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_BATCH_ADD_SKU_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_DEL_SKU_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_SKU_LIST;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Order.PRODUCT_ORDER_GET_LIST;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_ADD_SKU_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_BATCH_ADD_SKU_URL;
@ -22,6 +30,12 @@ import cn.binarywang.wx.miniapp.bean.product.WxMinishopAddGoodsSpuData;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopOrderListResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopResult;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSku;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetBrandResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetCategoryResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopGetFrightTemplateResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopResult;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSku;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSkuListResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpu;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGetResponse;
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuListResponse;
@ -32,10 +46,16 @@ import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
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.http.MinishopUploadRequestExecutor;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
@ -52,6 +72,66 @@ public class WxMaProductServiceImpl implements WxMaProductService {
private static final String ERR_CODE = "errcode";
private final WxMaService wxMaService;
@Override
public WxMinishopImageUploadResult uploadImg(File file, Integer respType, Integer width,
Integer height) throws WxErrorException {
String url = IMG_UPLOAD + "?upload_type=0" + "&height=" + height + "&width=" + width + "&resp_type=" + respType;
WxMinishopImageUploadResult result = this.wxMaService.execute(
MinishopUploadRequestExecutor.create(this.wxMaService.getRequestHttp()), url, file);
return result;
}
@Override
public WxMinishopImageUploadResult uploadImg(String imgUrl, Integer respType) throws WxErrorException {
JsonObject jsonObject = GsonHelper.buildJsonObject("img_url", imgUrl);
String url = IMG_UPLOAD + "?upload_type=1" + "&resp_type=" + respType;
String response = this.wxMaService.post(url, jsonObject);
JsonObject respObj = GsonParser.parse(response);
if (respObj.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
}
return WxMinishopImageUploadResult.fromJson(response);
}
@Override
public WxMinishopGetCategoryResponse getCategory(Integer fCatId) throws WxErrorException {
JsonObject jsonObject = GsonHelper.buildJsonObject("f_cat_id", fCatId);
String response = this.wxMaService.post(GET_CATEGORY, jsonObject);
JsonObject respObj = GsonParser.parse(response);
if (respObj.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(response, WxMinishopGetCategoryResponse.class);
}
@Override
public WxMinishopGetBrandResponse getBrand() throws WxErrorException {
String response = this.wxMaService.post(GET_BRAND, new Object());
JsonObject respObj = GsonParser.parse(response);
if (respObj.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(response, WxMinishopGetBrandResponse.class);
}
@Override
public WxMinishopGetFrightTemplateResponse getFreightTemplate() throws WxErrorException {
String response = this.wxMaService.post(GET_FREIGHT_TEMPLATE, new Object());
JsonObject respObj = GsonParser.parse(response);
if (respObj.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(response, WxMinishopGetFrightTemplateResponse.class);
}
@Override
public WxMinishopResult<WxMinishopAddGoodsSpuData> addSpu(WxMinishopSpu spu) throws WxErrorException {
@ -157,6 +237,19 @@ public class WxMaProductServiceImpl implements WxMaProductService {
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
@Override
public WxMinishopSkuListResponse getSkuList(Long productId, Integer needRealStock, Integer needEditSku)
throws WxErrorException {
String responseContent = this.wxMaService
.post(PRODUCT_SKU_LIST, GsonHelper.buildJsonObject("product_id", productId,
"need_edit_sku", needEditSku, "need_real_stock", needRealStock));
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMinishopSkuListResponse.class);
}
@Override
public WxMinishopResult<WxMinishopAddGoodsSkuData> minishiopGoodsAddSku(
WxMinishopSku sku) throws WxErrorException {
@ -228,7 +321,6 @@ public class WxMaProductServiceImpl implements WxMaProductService {
result.setErrcode(jsonObject.get("errcode").getAsInt());
JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
resultData.setSkuId(dataObj.get("sku_id").getAsLong());
resultData.setUpdateTime(dataObj.get("update_time").getAsString());
result.setData(resultData);
return result;
@ -236,7 +328,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
@Override
public WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSkuPrice(
Long productId, Long outProductId, String outSkuId, Long skuId, Long salePrice,
Long productId, String outProductId, String outSkuId, Long skuId, Long salePrice,
Long marketPrice) throws WxErrorException {
String response = this.wxMaService
.post(PRODUCT_UPDATE_SKU_PRICE_URL, GsonHelper.buildJsonObject(
@ -251,7 +343,6 @@ public class WxMaProductServiceImpl implements WxMaProductService {
result.setErrcode(jsonObject.get("errcode").getAsInt());
JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
resultData.setSkuId(dataObj.get("sku_id").getAsLong());
resultData.setUpdateTime(dataObj.get("update_time").getAsString());
result.setData(resultData);
return result;
@ -259,7 +350,7 @@ public class WxMaProductServiceImpl implements WxMaProductService {
@Override
public WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSkuStock(
Long productId, Long outProductId, String outSkuId, Long skuId, Integer type,
Long productId, String outProductId, String outSkuId, Long skuId, Integer type,
Integer stockNum) throws WxErrorException {
String response = this.wxMaService
.post(PRODUCT_UPDATE_SKU_STOCK_URL, GsonHelper.buildJsonObject(
@ -279,20 +370,6 @@ public class WxMaProductServiceImpl implements WxMaProductService {
return result;
}
@Override
public WxMinishopOrderListResponse minishopOrderGetList(String startCreateTime, String endCreateTime,
Integer status, Integer page, Integer pageSize, Integer source) throws WxErrorException {
String response = this.wxMaService
.post(PRODUCT_ORDER_GET_LIST, GsonHelper.buildJsonObject(
"start_create_time", startCreateTime, "end_create_time", endCreateTime,
"status", status, "page", page, "page_size", pageSize, "source", source));
JsonObject jsonObject = GsonParser.parse(response);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(response, WxMinishopOrderListResponse.class);
}
}

View File

@ -2,10 +2,16 @@ 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.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.json.WxMaGsonBuilder;
import com.google.gson.JsonObject;
@ -14,6 +20,7 @@ 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.GsonHelper;
import me.chanjar.weixin.common.util.json.GsonParser;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Aftersale.*;
@ -37,13 +44,13 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
* @throws WxErrorException
*/
@Override
public WxMaShopBaseResponse add(WxMaShopAfterSaleAddRequest request) throws WxErrorException {
public WxMaShopAfterSaleAddResponse 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);
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAfterSaleAddResponse.class);
}
/**
@ -79,4 +86,154 @@ public class WxMaShopAfterSaleServiceImpl implements WxMaShopAfterSaleService {
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
/**
* 用户取消售后申请
* @param outAfterSaleId 商家自定义订单ID
* @param afterSaleId 与out_aftersale_id二选一
* @param openId 用户openid
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopBaseResponse cancel(String outAfterSaleId, Long afterSaleId, String openId)
throws WxErrorException {
JsonObject request = GsonHelper.buildJsonObject("out_aftersale_id", outAfterSaleId,
"aftersale_id", afterSaleId, "openid", openId);
String resp = this.wxMaService.post(AFTERSALE_CANCEL, request);
JsonObject jsonObject = GsonParser.parse(resp);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
}
/**
* 用户上传退货物流
* @param request
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopBaseResponse uploadReturnInfo(WxMaShopAfterSaleUploadReturnInfoRequest request)
throws WxErrorException {
String resp = this.wxMaService.post(AFTERSALE_UPLOAD_RETURN_INFO, request);
JsonObject jsonObject = GsonParser.parse(resp);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
}
/**
* 商家同意退款
* @param outAfterSaleId
* @param afterSaleId
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopBaseResponse acceptRefund(String outAfterSaleId, Long afterSaleId)
throws WxErrorException {
JsonObject request = GsonHelper.buildJsonObject("out_aftersale_id", outAfterSaleId,
"aftersale_id", afterSaleId);
String resp = this.wxMaService.post(AFTERSALE_ACCEPT_REFUND, request);
JsonObject jsonObject = GsonParser.parse(resp);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
}
/**
* 商家同意退货
* @param request
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopBaseResponse acceptReturn(WxMaShopAcceptReturnRequest request)
throws WxErrorException {
String resp = this.wxMaService.post(AFTERSALE_ACCEPT_RETURN, request);
JsonObject jsonObject = GsonParser.parse(resp);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
}
/**
* 商家拒绝售后
* @param outAfterSaleId
* @param afterSaleId
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopBaseResponse reject(String outAfterSaleId, Long afterSaleId)
throws WxErrorException {
JsonObject request = GsonHelper.buildJsonObject("out_aftersale_id", outAfterSaleId,
"aftersale_id", afterSaleId);
String resp = this.wxMaService.post(AFTERSALE_REJECT, request);
JsonObject jsonObject = GsonParser.parse(resp);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
}
/**
* 商家上传退款凭证
* @param request
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopBaseResponse uploadCertificates(WxMaShopUploadCerficatesRequest request)
throws WxErrorException {
String resp = this.wxMaService.post(AFTERSALE_UPLOAD_CERTIFICATES, request);
JsonObject jsonObject = GsonParser.parse(resp);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
}
/**
* 商家更新订单售后期
* @param outOrderId
* @param orderId
* @param openid
* @param afterSaleDeadline
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopBaseResponse updateDeadline(String outOrderId, Long orderId, String openid,
Long afterSaleDeadline) throws WxErrorException {
JsonObject request = GsonHelper.buildJsonObject("out_order_id", outOrderId,
"order_id", orderId, "openid", openid, "after_sale_deadline", afterSaleDeadline);
String resp = this.wxMaService.post(AFTERSALE_UPLOAD_DEADLINE, request);
JsonObject jsonObject = GsonParser.parse(resp);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopBaseResponse.class);
}
/**
* 获取售后单详情
* @param request
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopAfterSaleListResponse list(WxMaShopAfterSaleListRequest request) throws WxErrorException {
String resp = this.wxMaService.post(AFTERSALE_GET_LIST, request);
JsonObject jsonObject = GsonParser.parse(resp);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(resp, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(resp, WxMaShopAfterSaleListResponse.class);
}
}

View File

@ -0,0 +1,165 @@
package cn.binarywang.wx.miniapp.api.impl;
import static cn.binarywang.wx.miniapp.api.impl.WxMaImmediateDeliveryServiceImpl.ERR_CODE;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.WxMaShopCouponService;
import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCouponListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCouponResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopUserCouponListResponse;
import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Coupon;
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.GsonHelper;
import me.chanjar.weixin.common.util.json.GsonParser;
/**
* @author leiin
* @date 2022/7/1 2:49 下午
*/
@RequiredArgsConstructor
@Slf4j
public class WxMaShopCouponServiceImpl implements WxMaShopCouponService {
private final WxMaService wxMaService;
@Override
public WxMaShopBaseResponse addCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("coupon", couponInfo);
String responseContent = this.wxMaService.post(Coupon.ADD_COUPON, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
@Override
public WxMaShopCouponResponse getCoupon(String outCouponId) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("out_coupon_id", outCouponId);
String responseContent = this.wxMaService.post(Coupon.GET_COUPON, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCouponResponse.class);
}
@Override
public WxMaShopCouponListResponse getCouponList(Integer pageSize, Integer offset) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("page_size", pageSize, "offset", offset);
String responseContent = this.wxMaService.post(Coupon.GET_COUPON_LIST, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCouponListResponse.class);
}
@Override
public WxMaShopBaseResponse updateCoupon(WxMaShopCouponInfo couponInfo) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("coupon", couponInfo);
String responseContent = this.wxMaService.post(Coupon.UPDATE_COUPON, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
@Override
public WxMaShopBaseResponse updateCouponStatus(String outCouponId, Integer status) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("out_coupon_id", outCouponId, "status", status);
String responseContent = this.wxMaService.post(Coupon.UPDATE_COUPON_STATUS, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
@Override
public WxMaShopBaseResponse updateCouponStock(String outCouponId, Integer isUsedNum, Integer receiveNum) throws WxErrorException {
JsonObject stockInfo = GsonHelper.buildJsonObject("issued_num", isUsedNum, "receive_num", receiveNum);
JsonObject stock = GsonHelper.buildJsonObject("out_coupon_id", outCouponId, "stock_info", stockInfo);
JsonObject json = GsonHelper.buildJsonObject("coupon_stock", stock);
String responseContent = this.wxMaService.post(Coupon.UPDATE_COUPON_STOCK, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
@Override
public WxMaShopBaseResponse addUserCoupon(String openid, String outUserCouponId,
String outCouponId, Integer status, Long recvTime) throws WxErrorException {
JsonObject userCoupon = GsonHelper.buildJsonObject("out_user_coupon_id", outUserCouponId,
"out_coupon_id", outCouponId,
"status", status);
JsonObject json = GsonHelper.buildJsonObject("openid", openid, "user_coupon", userCoupon,
"recv_time", recvTime);
String responseContent = this.wxMaService.post(Coupon.ADD_USER_COUPON, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
@Override
public WxMaShopUserCouponListResponse getUserCouponList(Integer pageSize, Integer offset, String openid) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("page_size", pageSize, "offset", offset,
"openid", openid);
String responseContent = this.wxMaService.post(Coupon.GET_USER_COUPON_LIST, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopUserCouponListResponse.class);
}
@Override
public WxMaShopBaseResponse updateUserCoupon(String openid, String outUserCouponId,
String outCouponId, Long useTime, Long recvTime) throws WxErrorException {
JsonObject extInfo = GsonHelper.buildJsonObject("use_time", useTime);
JsonObject userCoupon = GsonHelper.buildJsonObject("out_user_coupon_id", outUserCouponId,
"out_coupon_id", outCouponId, "ext_info", extInfo);
JsonObject json = GsonHelper.buildJsonObject("openid", openid, "user_coupon", userCoupon,
"recv_time", recvTime);
String responseContent = this.wxMaService.post(Coupon.UPDATE_USER_COUPON, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
@Override
public WxMaShopBaseResponse updateUserCouponStatus(String openid, String outUserCouponId,
String outCouponId, Integer status) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("openid", openid,
"out_user_coupon_id", outUserCouponId,
"out_coupon_id", outCouponId,
"status", status);
String responseContent = this.wxMaService.post(Coupon.UPDATE_USER_COUPON_STATUS, json);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
}

View File

@ -0,0 +1,95 @@
package cn.binarywang.wx.miniapp.bean.product;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/11 20:33
*/
@Data
public class WxMiniAfterSaleOrder {
@SerializedName("order_id")
private Long orderId;
@SerializedName("status")
private String status;
@SerializedName("openid")
private String openid;
@SerializedName("original_order_id")
private Long originalOrderId;
@SerializedName("product_info")
private AfterSaleProductInfo productInfo;
private AfterSaleDetails details;
@SerializedName("refund_info")
private RefundInfo refundInfo;
@SerializedName("return_info")
private ReturnInfo returnInfo;
@SerializedName("merchant_upload_info")
private MerchantUploadInfo merchantUploadInfo;
@SerializedName("create_time")
private Long createTime;
@SerializedName("update_time")
private Long updateTime;
@SerializedName("reason")
private String reason;
@SerializedName("refund_resp")
private RefundResp refundResp;
private String type;
@Data
public static class AfterSaleProductInfo {
@SerializedName("product_id")
private Long productId;
@SerializedName("sku_id")
private Long skuId;
@SerializedName("count")
private Integer count;
}
@Data
public static class AfterSaleDetails {
@SerializedName("num")
private Integer num;
@SerializedName("desc")
private String desc;
@SerializedName("cancel_time")
private Long cancelTime;
@SerializedName("prove_imgs")
private List<String> proveImgs;
@SerializedName("tel_number")
private String telNumber;
}
@Data
public static class RefundInfo {
private Long amount;
}
@Data
public static class ReturnInfo {
@SerializedName("delivery_id")
private String deliveryId;
@SerializedName("waybill_id")
private String waybillId;
@SerializedName("delivery_name")
private String deliveryName;
}
@Data
public static class MerchantUploadInfo {
@SerializedName("reject_reason")
private String rejectReason;
@SerializedName("refund_certificates")
private List<String> refundCertificates;
}
@Data
public static class RefundResp {
private String code;
private Integer ret;
private String message;
}
}

View File

@ -0,0 +1,16 @@
package cn.binarywang.wx.miniapp.bean.product;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/11 20:59
*/
@Data
public class WxMiniBatchGetAfterSaleOrderResponse extends WxMaShopBaseResponse {
@SerializedName("after_sale_order_list")
private List<WxMiniAfterSaleOrder> afterSaleOrderList;
}

View File

@ -0,0 +1,15 @@
package cn.binarywang.wx.miniapp.bean.product;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/11 20:58
*/
@Data
public class WxMiniGetAfterSaleOrderResponse extends WxMaShopBaseResponse {
@SerializedName("after_sale_order")
private WxMiniAfterSaleOrder afterSaleOrder;
}

View File

@ -0,0 +1,24 @@
package cn.binarywang.wx.miniapp.bean.product;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/6/20 7:16 下午
*/
@Data
public class WxMiniOrderAfterSaleDetail {
@SerializedName("aftersale_order_list")
private List<AfterSaleOrder> aftersaleOrderList;
@SerializedName("on_aftersale_order_cnt")
private Integer onAftersaleOrderCnt;
@Data
public static class AfterSaleOrder {
@SerializedName("aftersale_order_id")
private Long aftersaleOrderId;
private Integer status;
}
}

View File

@ -0,0 +1,41 @@
package cn.binarywang.wx.miniapp.bean.product;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/14 19:05
*/
@Data
public class WxMiniOrderDeliveryRequest {
@SerializedName("order_id")
private Long orderId;
@SerializedName("delivery_list")
private List<DeliveryListBean> deliveryList;
@Data
public static class DeliveryListBean implements Serializable {
@SerializedName("delivery_id")
private String deliveryId;
@SerializedName("is_all_product")
private Boolean isAllProduct;
@SerializedName("waybill_id")
private String waybillId;
@SerializedName("product_infos")
private List<ProductInfosBean> productInfoList;
}
@Data
public static class ProductInfosBean implements Serializable {
@SerializedName("product_id")
private String productId;
@SerializedName("sku_id")
private String skuId;
@SerializedName("product_cnt")
private Integer productCnt;
}
}

View File

@ -16,7 +16,7 @@ public class WxMinishopAddressInfo {
@SerializedName("province_name")
private String provinceName;
@SerializedName("city_name")
private String cityame;
private String cityName;
@SerializedName("county_name")
private String countyName;
@SerializedName("detail_info")

View File

@ -17,7 +17,7 @@ public class WxMinishopDeliveryInfo {
@SerializedName("delivery_product_info")
private List<DeliveryProductInfo> deliveryProductInfo;
@SerializedName("ship_done_time")
private Long ship_done_time;
private Long shipDoneTime;
@SerializedName("insurance_info")
private InsuranceInfo insuranceInfo;
@SerializedName("deliver_type")
@ -53,10 +53,10 @@ public class WxMinishopDeliveryInfo {
@Data
public static class ProductInfo {
@SerializedName("product_id")
private Long product_id;
private Long productId;
@SerializedName("sku_id")
private Long sku_id;
private Long skuId;
@SerializedName("product_cnt")
private Long product_cnt;
private Long productCnt;
}
}

View File

@ -0,0 +1,35 @@
package cn.binarywang.wx.miniapp.bean.product;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/8 3:46 下午
*/
@Data
public class WxMinishopGetBrandResponse extends WxMaShopBaseResponse {
private List<MinishopBrandItem> brands;
@Data
public static class MinishopBrandItem {
@SerializedName("first_cat_id")
private Integer firstCatId;
@SerializedName("second_cat_id")
private Integer secondCatId;
@SerializedName("third_cat_id")
private Integer thirdCatId;
@SerializedName("brand_info")
private MinishopBrandInfo brandInfo;
}
@Data
public static class MinishopBrandInfo {
@SerializedName("brand_id")
private Long brandId;
@SerializedName("brand_name")
private String brandName;
}
}

View File

@ -0,0 +1,30 @@
package cn.binarywang.wx.miniapp.bean.product;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author leiin
* @date 2022/7/8 3:39 下午
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxMinishopGetCategoryResponse extends WxMaShopBaseResponse {
@SerializedName("cat_list")
private List<MinishopCatItem> catList;
@Data
public static class MinishopCatItem {
@SerializedName("cat_id")
private Integer catId;
@SerializedName("f_cat_id")
private Integer fCatId;
private String name;
}
}

View File

@ -0,0 +1,26 @@
package cn.binarywang.wx.miniapp.bean.product;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/8 3:46 下午
*/
@Data
public class WxMinishopGetFrightTemplateResponse extends WxMaShopBaseResponse {
@SerializedName("template_list")
private List<MinishopFeightTemplateItem> templateList;
@Data
public static class MinishopFeightTemplateItem {
@SerializedName("template_id")
private Long templateId;
private String name;
@SerializedName("valuation_type")
private Integer valuationType;
}
}

View File

@ -0,0 +1,19 @@
package cn.binarywang.wx.miniapp.bean.product;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import lombok.Data;
/**
* 获取订单详情 回包结构
*
* @author leiin
* @date 2022/6/20 7:09 下午
*/
@Data
public class WxMinishopOrderDetailResponse extends WxMaShopBaseResponse {
/**
* 订单结构
*/
private WxMinishopOrderResult order;
}

View File

@ -1,6 +1,5 @@
package cn.binarywang.wx.miniapp.bean.product;
import cn.binarywang.wx.miniapp.bean.shop.WxMaShopOrderDetail;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;
@ -37,7 +36,7 @@ public class WxMinishopOrderResult implements Serializable {
private WxMinishopOrderDetail orderDetail;
@SerializedName("aftersale_detail")
private WxMiniAfterSaleDetail afterSaleDetail;
private WxMiniOrderAfterSaleDetail afterSaleDetail;
/**
* 商家小程序该订单的用户id

View File

@ -18,11 +18,17 @@ public class WxMinishopProductInfo implements Serializable {
@SerializedName("product_id")
private Integer productId;
@SerializedName("out_product_id")
private String outProductId;
/**
* 交易组件平台内部skuID可填0如果这个product_id下没有sku
*/
@SerializedName("sku_id")
private Integer skuId;
@SerializedName("out_sku_id")
private String outSkuId;
/**
* 购买的数量
* <pre>

View File

@ -18,6 +18,9 @@ public class WxMinishopSku implements Serializable {
@SerializedName("out_sku_id")
private String outSkuId;
@SerializedName("sku_id")
private Long skuId;
@SerializedName("thumb_img")
private String thumbImg;

View File

@ -0,0 +1,14 @@
package cn.binarywang.wx.miniapp.bean.product;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/13 20:00
*/
@Data
public class WxMinishopSkuListResponse extends WxMaShopBaseResponse {
private List<WxMinishopSku> skus;
}

View File

@ -0,0 +1,319 @@
package cn.binarywang.wx.miniapp.bean.shop;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author leiin
* @date 2022/7/1 2:57 下午
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxMaShopCouponInfo implements Serializable {
private static final long serialVersionUID = 5807154725645642700L;
/**
* 是否必填
* 说明商家侧优惠券ID
*/
@SerializedName("out_coupon_id")
private String outCouponId;
/**
* 是否必填
* 说明优惠券类型
*/
@SerializedName("type")
private Integer type;
/**
* 是否必填
* 说明优惠券推广类型
*/
@SerializedName("promote_type")
private Integer promoteType;
@SerializedName("coupon_info")
private CouponInfo couponInfo;
// 返回参数
/**
* 优惠券状态
*/
@SerializedName("status")
private Integer status;
/**
* 创建时间
*/
@SerializedName("create_time")
private Long createTime;
/**
* 更新时间
*/
@SerializedName("update_time")
private Long updateTime;
@SerializedName("coupon_stock")
private CouponStock couponStock;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class CouponInfo implements Serializable {
private static final long serialVersionUID = -7913225774910831745L;
/**
* 是否必填
* 说明优惠券名
*/
private String name;
@SerializedName("promote_info")
private PromoteInfo promoteInfo;
@SerializedName("discount_info")
private DiscountInfo discountInfo;
@SerializedName("receive_info")
private ReceiveInfo receiveInfo;
@SerializedName("valid_info")
private ValidInfo validInfo;
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class PromoteInfo {
@SerializedName("promote_type")
private Integer promoteType;
private PromoteFinder finder;
@Data
public static class PromoteFinder {
private String nickname;
}
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class DiscountInfo {
/**
* 是否必填
* 说明折扣数,比如5.1折,则填5100,折扣券必需
*/
@SerializedName("discount_num")
private Integer discountNum;
/**
* 是否必填
* 说明减金额,单位为分直减券满减券必需
*/
@SerializedName("discount_fee")
private Long discountFee;
@SerializedName("discount_condition")
private DiscountCondition discountCondition;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class DiscountCondition {
/**
* 是否必填
* 说明优惠条件所需的商品数
*/
@SerializedName("product_cnt")
private Integer productCnt;
/**
* 是否必填
* 说明优惠条件所需满足的金额
*/
@SerializedName("product_price")
private Long productPrice;
/**
* 是否必填
* 说明指定商品商家侧ID商品券必需最多128个
*/
@SerializedName("out_product_ids")
private List<String> outProductIds;
@SerializedName("tradein_info")
private TradeinInfo tradeinInfo;
@SerializedName("buyget_info")
private BuygetInfo buyget_info;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class TradeinInfo {
/**
* 是否必填
* 说明换购商品商家侧ID换购券必需
*/
@SerializedName("out_product_id")
private String outProductId;
/**
* 是否必填
* 说明需要支付的金额单位分换购券必需
*/
@SerializedName("price")
private Long price;
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class BuygetInfo {
/**
* 是否必填
* 说明购买商品商家侧ID买赠券必需
*/
@SerializedName("buy_out_product_id")
private String buyOutProductId;
/**
* 是否必填
* 说明购买商品数买赠券必需
*/
@SerializedName("buy_product_cnt")
private Integer buyProductCnt;
/**
* 是否必填
* 说明赠送商品商家侧ID买赠券必需
*/
@SerializedName("get_out_product_id")
private String getOutProductId;
/**
* 是否必填
* 说明赠送商品数买赠券必需
*/
@SerializedName("get_product_cnt")
private Integer getProductCnt;
}
}
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ReceiveInfo {
/**
* 是否必填
* 说明领取开始时间 秒级时间戳
*/
@SerializedName("start_time")
private Long startTime;
/**
* 是否必填
* 说明领取结束时间 秒级时间戳
*/
@SerializedName("end_time")
private Long endTime;
/**
* 是否必填
* 说明个人限领张数只做展示领券回调时接入方判断有无超领
*/
@SerializedName("limit_num_one_person")
private Integer limitNumOnePerson;
/**
* 是否必填
* 说明总发放量即初始库存数只做展示领券回调时接入方判断有无超领
*/
@SerializedName("total_num")
private Integer totalNum;
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ValidInfo {
/**
* 是否必填
* 说明有效期类型,1:商品指定时间区间,2:生效天数,3:生效秒数
*/
@SerializedName("valid_type")
private Integer validType;
/**
* 是否必填
* 说明生效天数有效期类型为2时必需
*/
@SerializedName("valid_day_num")
private Integer validDayNum;
/**
* 是否必填
* 说明生效秒数有效期类型为3时必需
*/
@SerializedName("valid_second")
private Long validSecond;
/**
* 是否必填
* 说明生效开始时间有效期类型为1时必需
*/
@SerializedName("start_time")
private Long startTime;
/**
* 是否必填
* 说明生效结束时间有效期类型为1时必需
*/
@SerializedName("end_time")
private Long endTime;
}
@Data
public static class CouponStock {
/**
* 商家侧优惠券ID
*/
@SerializedName("out_coupon_id")
private String outCouponId;
/**
* 创建时间
*/
@SerializedName("create_time")
private Long createTime;
/**
* 更新时间
*/
@SerializedName("update_time")
private Long updateTime;
@SerializedName("stock_info")
private StockInfo stockInfo;
@Data
public static class StockInfo {
/**
* 优惠券库存剩余量
*/
@SerializedName("issued_num")
private Integer issuedNum;
/**
* 优惠卷发放量
*/
@SerializedName("receive_num")
private Integer receiveNum;
}
}
}

View File

@ -84,4 +84,53 @@ public class WxMaShopOrderInfo implements Serializable {
@SerializedName("address_info")
private WxMaShopAddressInfo addressInfo;
/**
* 订单类型0普通单1二级商户单
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("fund_type")
private Integer fundType; // 订单类型0普通单1二级商户单
/**
* unix秒级时间戳订单超时时间取值[15min, 1d]
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("expire_time")
private Long expireTime; // unix秒级时间戳订单超时时间取值[15min, 1d]
/**
* 取值范围[73 * 365]单位
* <pre>
* 是否必填选填
* </pre>
*/
@SerializedName("aftersale_duration")
private Integer aftersaleDuration; // 取值范围[73 * 365]单位
/**
* 会影响主播归因分享员归因等从下单前置检查获取
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("trace_id")
private String traceId; // 会影响主播归因分享员归因等从下单前置检查获取
/**
* 默认退货地址退货售后超时时会让用户将货物寄往此地址
* <pre>
* 是否必填选填
* </pre>œ
*/
@SerializedName("default_receiving_address")
private WxMaShopAddressInfo defaultReceivingAddress; // 默认退货地址退货售后超时时会让用户将货物寄往此地址
/**
* 生成的order_id以字符串形式返回
* <pre>
* 是否必填选填
* </pre>
*/
@SerializedName("stringify_64bits_number")
private Boolean stringify64bitsNumber; // 生成的order_id以字符串形式返回
}

View File

@ -0,0 +1,43 @@
package cn.binarywang.wx.miniapp.bean.shop.request;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author leiin
* @date 2022/6/28 11:39 上午
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxMaShopAcceptReturnRequest implements Serializable {
@SerializedName("out_aftersale_id")
private String outAftersaleId;
@SerializedName("aftersale_id")
private Long aftersaleId;
@SerializedName("address_info")
private RefundAddressInfo addressInfo;
@Data
public static class RefundAddressInfo {
@SerializedName("receiver_name")
private String receiverName;
@SerializedName("detailed_address")
private String detailedAddress;
@SerializedName("tel_number")
private String telNumber;
@SerializedName("country")
private String country;
@SerializedName("province")
private String province;
@SerializedName("city")
private String city;
@SerializedName("town")
private String town;
}
}

View File

@ -33,6 +33,8 @@ public class WxMaShopAfterSaleAddRequest implements Serializable {
* product_infos : [{"out_product_id":"234245","out_sku_id":"23424","product_cnt":5}]
*/
@SerializedName("order_id")
private Long orderId;
@SerializedName("out_order_id")
private String outOrderId;
@SerializedName("out_aftersale_id")
@ -41,8 +43,14 @@ public class WxMaShopAfterSaleAddRequest implements Serializable {
private String openid;
@SerializedName("type")
private Integer type;
@SerializedName("create_time")
private String createTime;
@SerializedName("product_info")
private ProductInfosBean productInfo;
@SerializedName("orderamt")
private Long orderamt;
@SerializedName("refund_reason")
private String refundReason;
@SerializedName("refund_reason_type")
private Integer refundReasonType;
@SerializedName("status")
private Integer status;
@SerializedName("finish_all_aftersale")
@ -51,8 +59,8 @@ public class WxMaShopAfterSaleAddRequest implements Serializable {
private String path;
@SerializedName("refund")
private Long refund;
@SerializedName("product_infos")
private List<ProductInfosBean> productInfos;
@SerializedName("media_list")
private UploadMediaList mediaList;
@Data
@Builder
@ -72,4 +80,12 @@ public class WxMaShopAfterSaleAddRequest implements Serializable {
@SerializedName("product_cnt")
private Integer productCnt;
}
@Data
public static class UploadMediaList {
private Integer type;
private String url;
@SerializedName("thumb_url")
private String thumbUrl;
}
}

View File

@ -0,0 +1,36 @@
package cn.binarywang.wx.miniapp.bean.shop.request;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author leiin
* @date 2022/6/28 11:39 上午
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxMaShopAfterSaleListRequest implements Serializable {
@SerializedName("status")
private Integer status; //售后单状态 AfterSalesState
@SerializedName("out_order_id")
private String outOrderId; //售后单关联的外部订单号
@SerializedName("order_id")
private Long orderId; //售后单关联的微信侧订单号
@SerializedName("openid")
private String openid; //买家openid
@SerializedName("begin_create_time")
private Long beginCreateTime; //申请时间单位毫秒起始
@SerializedName("end_create_time")
private Long endCreateTime; //申请时间单位毫秒结束
@SerializedName("offset")
private Long offset; //本次拉取的起始位置从0开始
@SerializedName("limit")
private Integer limit; //本次拉取的大小最大50
}

View File

@ -1,5 +1,6 @@
package cn.binarywang.wx.miniapp.bean.shop.request;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest.UploadMediaList;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -33,6 +34,16 @@ public class WxMaShopAfterSaleUpdateRequest implements Serializable {
private String openid;
@SerializedName("out_aftersale_id")
private String outAftersaleId;
@SerializedName("type")
private Integer type;
@SerializedName("orderamt")
private Long orderamt;
@SerializedName("refund_reason")
private String refundReason;
@SerializedName("refund_reason_type")
private Integer refundReasonType;
@SerializedName("media_list")
private UploadMediaList mediaList;
@SerializedName("status")
private Integer status;
@SerializedName("finish_all_aftersale")

View File

@ -0,0 +1,31 @@
package cn.binarywang.wx.miniapp.bean.shop.request;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author leiin
* @date 2022/6/28 11:39 上午
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxMaShopAfterSaleUploadReturnInfoRequest implements Serializable {
@SerializedName("out_aftersale_id")
private String outAftersaleId;
@SerializedName("aftersale_id")
private Long aftersaleId;
@SerializedName("openid")
private String openid;
@SerializedName("delivery_id")
private String deliveryId;
@SerializedName("waybill_id")
private String waybillId;
@SerializedName("delivery_name")
private String deliveryName;
}

View File

@ -0,0 +1,28 @@
package cn.binarywang.wx.miniapp.bean.shop.request;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author leiin
* @date 2022/6/28 11:39 上午
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxMaShopUploadCerficatesRequest implements Serializable {
@SerializedName("out_aftersale_id")
private String outAftersaleId;
@SerializedName("aftersale_id")
private Long aftersaleId;
@SerializedName("refund_desc")
private String refundDesc;
@SerializedName("certificates")
private List<String> certificates;
}

View File

@ -0,0 +1,15 @@
package cn.binarywang.wx.miniapp.bean.shop.response;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;
/**
* @author leiin
* @date 2022/6/28 11:29 上午
*/
@Data
public class WxMaShopAfterSaleAddResponse extends WxMaShopBaseResponse implements Serializable {
@SerializedName("aftersale_id")
private String aftersaleId;
}

View File

@ -1,5 +1,6 @@
package cn.binarywang.wx.miniapp.bean.shop.response;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest.UploadMediaList;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -29,24 +30,43 @@ public class WxMaShopAfterSaleGetResponse extends WxMaShopBaseResponse implement
* product_infos : [{"out_product_id":"234245","out_sku_id":"23424","product_cnt":5}]
*/
@SerializedName("out_order_id")
private String outOrderId;
@SerializedName("aftersale_id")
private Long aftersaleId;
@SerializedName("out_aftersale_id")
private String outAftersaleId;
@SerializedName("openid")
private String openid;
@SerializedName("out_order_id")
private String outOrderId;
@SerializedName("order_id")
private Long orderId;
@SerializedName("product_info")
private List<ProductInfosBean> productInfo;
@SerializedName("type")
private Integer type;
@SerializedName("create_time")
private String createTime;
@SerializedName("path")
private String path;
@SerializedName("return_info")
private ReturnInfo returnInfo;
@SerializedName("orderamt")
private Long orderamt;
@SerializedName("refund_reason")
private String refundReason;
@SerializedName("refund_reason_type")
private Integer refundReasonType;
@SerializedName("media_list")
private UploadMediaList mediaList;
@SerializedName("status")
private Integer status;
@SerializedName("refund")
private Long refund;
@SerializedName("product_infos")
private List<ProductInfosBean> productInfos;
@SerializedName("create_time")
private String createTime;
@SerializedName("update_time")
private String updateTime;
@SerializedName("openid")
private String openid;
@SerializedName("refund_pay_detail")
private RefundPayDetail refund_pay_detail;
@SerializedName("return_id")
private String returnId;
@SerializedName("complaint_order_id_list")
private List<Long> complaintOrderIdList;
@Data
public static class ProductInfosBean implements Serializable {
@ -58,10 +78,32 @@ public class WxMaShopAfterSaleGetResponse extends WxMaShopBaseResponse implement
@SerializedName("out_product_id")
private String outProductId;
@SerializedName("product_id")
private Long productId;
@SerializedName("out_sku_id")
private String outSkuId;
@SerializedName("sku_id")
private Long skuId;
@SerializedName("product_cnt")
private Integer productCnt;
}
@Data
public static class ReturnInfo {
@SerializedName("order_return_time")
private Long orderReturnTime;
@SerializedName("delivery_id")
private String deliveryId;
@SerializedName("waybill_id")
private String waybillId;
@SerializedName("delivery_name")
private String deliveryName;
}
@Data
public static class RefundPayDetail {
@SerializedName("refund_id")
private String refundId;
}
}
}

View File

@ -0,0 +1,25 @@
package cn.binarywang.wx.miniapp.bean.shop.response;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAfterSaleGetResponse.AftersaleInfosBean;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author leiin
* @date 2022/6/28 11:39 上午
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxMaShopAfterSaleListResponse extends WxMaShopBaseResponse implements Serializable {
@SerializedName("has_more")
private Boolean hasMore;
@SerializedName("after_sales_orders")
private List<AftersaleInfosBean> afterSalesOrders;
}

View File

@ -21,7 +21,7 @@ public class WxMaShopBaseResponse implements Serializable {
* </pre>
*/
@SerializedName("errcode")
private Integer errcode;
private Integer errCode;
/**
* 错误信息
@ -30,5 +30,5 @@ public class WxMaShopBaseResponse implements Serializable {
* </pre>
*/
@SerializedName("errmsg")
private String errmsg;
private String errMsg;
}

View File

@ -0,0 +1,23 @@
package cn.binarywang.wx.miniapp.bean.shop.response;
import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/1 3:34 下午
*/
@Data
public class WxMaShopCouponListResponse extends WxMaShopBaseResponse {
@SerializedName("total_num")
private Long totalNum;
@SerializedName("result_list")
private List<ResponseCouponResult> resultList;
@Data
public static class ResponseCouponResult {
private WxMaShopCouponInfo coupon;
}
}

View File

@ -0,0 +1,18 @@
package cn.binarywang.wx.miniapp.bean.shop.response;
import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/1 3:34 下午
*/
@Data
public class WxMaShopCouponResponse extends WxMaShopBaseResponse {
private ResponseCouponResult result;
@Data
public static class ResponseCouponResult {
private WxMaShopCouponInfo coupon;
}
}

View File

@ -0,0 +1,76 @@
package cn.binarywang.wx.miniapp.bean.shop.response;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
/**
* @author leiin
* @date 2022/7/1 3:59 下午
*/
@Data
public class WxMaShopUserCouponListResponse extends WxMaShopBaseResponse implements Serializable {
private static final long serialVersionUID = 3264119403757388410L;
@SerializedName("total_num")
private Long totalNum;
@SerializedName("result_list")
private List<UserCouponResultItem> resultList;
@Data
public static class UserCouponResultItem {
/**
* 商家侧用户优惠券ID
*/
@SerializedName("out_user_coupon_id")
private String outUserCouponId;
/**
* openid
*/
@SerializedName("openid")
private String openid;
/**
* 商家侧优惠券ID
*/
@SerializedName("out_coupon_id")
private String outCouponId;
/**
* 用户优惠券状态
*/
@SerializedName("status")
private Integer status;
/**
* 用户优惠券创建时间
*/
@SerializedName("create_time")
private Long createTime;
/**
* 用户优惠券更新时间
*/
@SerializedName("update_time")
private Long updateTime;
/**
* 用户优惠券有效开始时间
*/
@SerializedName("start_time")
private Long startTime;
/**
* 用户优惠券有效结束时间
*/
@SerializedName("end_time")
private Long endTime;
@SerializedName("ext_info")
private UserCouponExtInfo extInfo;
@Data
public static class UserCouponExtInfo {
@SerializedName("use_time")
private Long useTime;
}
}
}

View File

@ -419,10 +419,27 @@ public class WxMaApiUrlConstants {
String PRODUCT_UPDATE_SKU_URL = "https://api.weixin.qq.com/product/sku/update";
String PRODUCT_UPDATE_SKU_PRICE_URL = "https://api.weixin.qq.com/product/sku/update_price";
String PRODUCT_UPDATE_SKU_STOCK_URL = "https://api.weixin.qq.com/product/stock/update";
String PRODUCT_SKU_LIST = "https://api.weixin.qq.com/product/sku/get_list";
}
interface Order {
String PRODUCT_ORDER_GET_LIST = "https://api.weixin.qq.com/product/order/get_list";
String PRODUCT_ORDER_DETAIL_URL = "https://api.weixin.qq.com/product/order/get";
String PRODUCT_ORDER_CHANGE_MERCHANT_NOTES_URL = "https://api.weixin.qq.com/product/order/change_merchant_notes";
String PRODUCT_DELIVERY_SEND = "https://api.weixin.qq.com/product/delivery/send";
String GET_AFTER_SALE_ORDER = "https://api.weixin.qq.com/product/order/getaftersaleorder";
String BATCH_GET_AFTER_SALE_ORDER = "https://api.weixin.qq.com/product/order/batchgetaftersaleorder";
String AFTER_SALE_ACCEPT_APPLY = "https://api.weixin.qq.com/product/order/acceptapply";
String AFTER_SALE_REJECT_APPLY = "https://api.weixin.qq.com/product/order/rejectrefund";
}
interface OTHER {
String GET_CATEGORY = "https://api.weixin.qq.com/product/category/get";
String GET_BRAND = "https://api.weixin.qq.com/product/brand/get";
String GET_FREIGHT_TEMPLATE = "https://api.weixin.qq.com/product/delivery/get_freight_template";
String IMG_UPLOAD = "https://api.weixin.qq.com/product/img/upload";
}
}
@ -484,9 +501,17 @@ public class WxMaApiUrlConstants {
}
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";
String AFTERSALE_ADD = "https://api.weixin.qq.com/shop/ecaftersale/add";
String AFTERSALE_CANCEL = "https://api.weixin.qq.com/shop/ecaftersale/cancel";
String AFTERSALE_UPDATE = "https://api.weixin.qq.com/shop/ecaftersale/update";
String AFTERSALE_UPLOAD_RETURN_INFO = "https://api.weixin.qq.com/shop/ecaftersale/uploadreturninfo";
String AFTERSALE_ACCEPT_REFUND = "https://api.weixin.qq.com/shop/ecaftersale/acceptrefund";
String AFTERSALE_ACCEPT_RETURN = "https://api.weixin.qq.com/shop/ecaftersale/acceptreturn";
String AFTERSALE_REJECT = "https://api.weixin.qq.com/shop/ecaftersale/reject";
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";
}
interface Sharer {
@ -498,6 +523,19 @@ public class WxMaApiUrlConstants {
String SEARCH_SHARER = "https://api.weixin.qq.com/shop/sharer/search_sharer";
String UNBIND = "https://api.weixin.qq.com/shop/sharer/unbind";
}
interface Coupon {
String ADD_COUPON = "https://api.weixin.qq.com/shop/coupon/add";
String GET_COUPON = "https://api.weixin.qq.com/shop/coupon/get";
String GET_COUPON_LIST = "https://api.weixin.qq.com/shop/coupon/get_list";
String UPDATE_COUPON = "https://api.weixin.qq.com/shop/coupon/update";
String UPDATE_COUPON_STATUS = "https://api.weixin.qq.com/shop/coupon/update_status";
String UPDATE_COUPON_STOCK = "https://api.weixin.qq.com/shop/coupon/update_coupon_stock";
String ADD_USER_COUPON = "https://api.weixin.qq.com/shop/coupon/add_user_coupon";
String GET_USER_COUPON_LIST = "https://api.weixin.qq.com/shop/coupon/get_usercoupon_list";
String UPDATE_USER_COUPON = "https://api.weixin.qq.com/shop/coupon/update_user_coupon";
String UPDATE_USER_COUPON_STATUS = "https://api.weixin.qq.com/shop/coupon/update_usercoupon_status";
}
}
/**

View File

@ -38,12 +38,11 @@ public class WxMaShopAfterSaleServiceImplTest {
.outAftersaleId("318092069606883328X")
.openid("odIi15CuQ0IQviqsnUMy6CKNetrMX")
.type(1)
.createTime("2021-08-20 00:00:00")
.status(1)
.finishAllAftersale(0)
.path("/pages/aftersale.html?out_aftersale_id=318092069606883328X")
.refund(100L)
.productInfos(new ArrayList<>(Arrays.asList(productInfosBean)))
.productInfo(productInfosBean)
.build();
WxMaShopBaseResponse response = wxService.getShopAfterSaleService().add(request);
assertThat(response).isNotNull();