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

This commit is contained in:
Boris
2022-07-26 21:45:32 +08:00
committed by GitHub
parent b550806956
commit 1747190674
44 changed files with 1965 additions and 60 deletions

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