mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 #2715【企业微信&小程序】微信客服、小程序物流服务和交易组件 等相关接口优化更新
This commit is contained in:
@@ -7,10 +7,14 @@ import cn.binarywang.wx.miniapp.bean.delivery.AddOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.BindAccountResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.GetOrderRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.GetOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.TraceWaybillRequest;
|
||||
@@ -129,4 +133,34 @@ public interface WxMaImmediateDeliveryService {
|
||||
throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 传运单接口 follow_waybill 订阅微信后台会跟踪运单的状态变化
|
||||
* <pre>
|
||||
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/express_open_msg.html
|
||||
* </pre>
|
||||
*
|
||||
* @param request request
|
||||
* @return 响应
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
FollowWaybillResponse followWaybill(FollowWaybillRequest request)
|
||||
throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 查运单接口 query_follow_trace
|
||||
*
|
||||
* <pre>
|
||||
* 商户在调用完trace_waybill接口后,可以使用本接口查询到对应运单的详情信息
|
||||
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/express_open_msg.html
|
||||
* </pre>
|
||||
*
|
||||
* @param request request
|
||||
* @return 响应
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
QueryFollowTraceResponse queryFollowTrace(QueryFollowTraceRequest request)
|
||||
throws WxErrorException ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
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.WxMinishopOrderListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopResult;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSku;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpu;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGet;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGetResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuListResponse;
|
||||
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.util.List;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* 小程序交易组件-商品服务
|
||||
*
|
||||
* @author boris
|
||||
*/
|
||||
public interface WxMaProductService {
|
||||
WxMinishopResult addSpu(WxMinishopSpu spuInfo) throws WxErrorException;
|
||||
|
||||
WxMaShopBaseResponse deleteSpu(Integer productId, String outProductId) throws WxErrorException;
|
||||
|
||||
WxMinishopSpuGetResponse getSpu(Integer productId, String outProductId, Integer needEditSpu)
|
||||
throws WxErrorException;
|
||||
|
||||
WxMinishopSpuListResponse getSpuList(WxMaShopSpuPageRequest request)
|
||||
throws WxErrorException;
|
||||
|
||||
WxMinishopResult<WxMinishopAddGoodsSpuData> updateSpu(WxMinishopSpu spuInfo) throws WxErrorException;
|
||||
|
||||
WxMaShopBaseResponse listingSpu(Integer productId, String outProductId)
|
||||
throws WxErrorException;
|
||||
|
||||
WxMaShopBaseResponse delistingSpu(Integer productId, String outProductId)
|
||||
throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 小商店新增sku信息
|
||||
*
|
||||
* @param sku
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMinishopResult<WxMinishopAddGoodsSkuData> minishiopGoodsAddSku(WxMinishopSku sku) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 小商店批量新增sku信息
|
||||
*
|
||||
* @param skuList
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMinishopResult<List<WxMinishopAddGoodsSkuData>> minishopGoodsBatchAddSku(List<WxMinishopSku> skuList) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 小商店删除sku消息
|
||||
*
|
||||
* @param productId
|
||||
* @param outProductId
|
||||
* @param outSkuId
|
||||
* @param skuId
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopBaseResponse minishopGoodsDelSku(Long productId, Long outProductId, String outSkuId, Long skuId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 小商店更新sku
|
||||
*
|
||||
* @param sku
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSku(WxMinishopSku sku) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 小商店更新sku价格
|
||||
*
|
||||
* @param productId
|
||||
* @param outProductId
|
||||
* @param outSkuId
|
||||
* @param skuId
|
||||
* @param salePrice
|
||||
* @param marketPrice
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSkuPrice(Long productId,
|
||||
Long outProductId, String outSkuId, Long skuId, Long salePrice, Long marketPrice) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 小商店更新sku库存
|
||||
*
|
||||
* @param productId
|
||||
* @param outProductId
|
||||
* @param outSkuId
|
||||
* @param skuId
|
||||
* @param type
|
||||
* @param stockNum
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSkuStock(Long productId,
|
||||
Long 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;
|
||||
}
|
||||
@@ -492,4 +492,15 @@ public interface WxMaService extends WxService {
|
||||
*/
|
||||
WxMaSafetyRiskControlService getSafetyRiskControlService();
|
||||
|
||||
/**
|
||||
* 分享人接口
|
||||
* @return
|
||||
*/
|
||||
WxMaShopSharerService getShopSharerService();
|
||||
|
||||
/**
|
||||
* 标准交易组件接口
|
||||
* @return
|
||||
*/
|
||||
WxMaProductService getProductService();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSearchSharerResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerBindResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerDataSummaryResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveOrderListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveSummaryListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerUnbindResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* 分享员
|
||||
* @author leiin
|
||||
* @date 2022/6/18 2:48 下午
|
||||
*/
|
||||
public interface WxMaShopSharerService {
|
||||
|
||||
/**
|
||||
* 绑定分享员
|
||||
* 用来批量邀请分享员
|
||||
* @param openids
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopSharerBindResponse bindSharer(String[] openids) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取分享员的总带货数据
|
||||
* @param openid
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopSharerDataSummaryResponse getSharerDataSummary(String openid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取已经绑定的分享员列表
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopSharerListResponse getSharerList(Integer page, Integer pageSize) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取分享员的直播间订单汇总
|
||||
* @param openid
|
||||
* @param liveExportId
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopSharerLiveOrderListResponse getSharerLiveOrderList(String openid, String liveExportId,
|
||||
Integer page, Integer pageSize) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取分享员的直播间带货数据汇总
|
||||
* @param openid
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopSharerLiveSummaryListResponse getSharerLiveSummaryList(String openid,
|
||||
Integer page, Integer pageSize) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 查看分享员
|
||||
* @param openid
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopSearchSharerResponse searchSharer(String openid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 解绑分享员
|
||||
* @param openids
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopSharerUnbindResponse unbindSharer(String[] openids) throws WxErrorException;
|
||||
}
|
||||
@@ -79,6 +79,8 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
private final WxMaMarketingService marketingService = new WxMaMarketingServiceImpl(this);
|
||||
private final WxMaImmediateDeliveryService immediateDeliveryService = new WxMaImmediateDeliveryServiceImpl(this);
|
||||
private final WxMaSafetyRiskControlService safetyRiskControlService = new WxMaSafetyRiskControlServiceImpl(this);
|
||||
private final WxMaShopSharerService shopSharerService = new WxMaShopSharerServiceImpl(this);
|
||||
private final WxMaProductService productService = new WxMaProductServiceImpl(this);
|
||||
private Map<String, WxMaConfig> configMap;
|
||||
private int retrySleepMillis = 1000;
|
||||
private int maxRetryTimes = 5;
|
||||
@@ -592,4 +594,10 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
@Override
|
||||
public WxMaSafetyRiskControlService getSafetyRiskControlService(){ return this.safetyRiskControlService; }
|
||||
|
||||
@Override
|
||||
public WxMaShopSharerService getShopSharerService() {return this.shopSharerService; }
|
||||
|
||||
@Override
|
||||
public WxMaProductService getProductService() { return this.productService; }
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,14 @@ import cn.binarywang.wx.miniapp.bean.delivery.AddOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.BindAccountResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.GetOrderRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.GetOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.delivery.TraceWaybillRequest;
|
||||
@@ -186,6 +190,28 @@ public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FollowWaybillResponse followWaybill(
|
||||
FollowWaybillRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(InstantDelivery.FOLLOW_WAYBILL_URL, request);
|
||||
FollowWaybillResponse response = FollowWaybillResponse.fromJson(responseContent);
|
||||
if (response.getErrcode() == -1) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryFollowTraceResponse queryFollowTrace(
|
||||
QueryFollowTraceRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(InstantDelivery.QUERY_FOLLOW_TRACE_URL, request);
|
||||
QueryFollowTraceResponse response = QueryFollowTraceResponse.fromJson(responseContent);
|
||||
if (response.getErrcode() == -1) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析响应.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
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;
|
||||
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_UPDATE_SKU_PRICE_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_UPDATE_SKU_STOCK_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Sku.PRODUCT_UPDATE_SKU_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_ADD_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_DELISTING_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_DEL_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_GET_LIST_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_GET_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_LISTING_URL;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Product.Spu.PRODUCT_SPU_UPDATE_URL;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaProductService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopAddGoodsSkuData;
|
||||
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.WxMinishopSpu;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuGetResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.product.WxMinishopSpuListResponse;
|
||||
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.json.WxMaGsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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 boris
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaProductServiceImpl implements WxMaProductService {
|
||||
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public WxMinishopResult<WxMinishopAddGoodsSpuData> addSpu(WxMinishopSpu spu) throws WxErrorException {
|
||||
|
||||
String response = this.wxMaService.post(PRODUCT_SPU_ADD_URL, spu);
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
|
||||
if (respObj.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(respObj.get("errcode").getAsInt());
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
|
||||
resultData.setProductId(dataObj.get("product_id").getAsLong());
|
||||
resultData.setOutProductId(dataObj.get("out_product_id").getAsString());
|
||||
resultData.setCreateTime(dataObj.get("create_time").getAsString());
|
||||
result.setData(resultData);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse deleteSpu(Integer productId, String outProductId)
|
||||
throws WxErrorException {
|
||||
String responseContent = this.wxMaService
|
||||
.post(PRODUCT_SPU_DEL_URL, GsonHelper.buildJsonObject("product_id", productId,
|
||||
"out_product_id", outProductId));
|
||||
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 WxMinishopSpuGetResponse getSpu(Integer productId, String outProductId, Integer needEditSpu)
|
||||
throws WxErrorException {
|
||||
String response = this.wxMaService
|
||||
.post(PRODUCT_SPU_GET_URL, GsonHelper.buildJsonObject("product_id", productId,
|
||||
"out_product_id", outProductId, "need_edit_spu", needEditSpu));
|
||||
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, WxMinishopSpuGetResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMinishopSpuListResponse getSpuList(WxMaShopSpuPageRequest request)
|
||||
throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(PRODUCT_SPU_GET_LIST_URL, request);
|
||||
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, WxMinishopSpuListResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMinishopResult<WxMinishopAddGoodsSpuData> updateSpu(WxMinishopSpu spu) throws WxErrorException {
|
||||
String response = this.wxMaService.post(PRODUCT_SPU_UPDATE_URL, spu);
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
|
||||
if (respObj.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(respObj.get("errcode").getAsInt());
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
|
||||
resultData.setProductId(dataObj.get("product_id").getAsLong());
|
||||
resultData.setOutProductId(dataObj.get("out_product_id").getAsString());
|
||||
resultData.setUpdateTime(dataObj.get("update_time").getAsString());
|
||||
result.setData(resultData);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse listingSpu(Integer productId, String outProductId)
|
||||
throws WxErrorException {
|
||||
String responseContent = this.wxMaService
|
||||
.post(PRODUCT_SPU_LISTING_URL, GsonHelper.buildJsonObject("product_id", productId,
|
||||
"out_product_id", outProductId));
|
||||
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 delistingSpu(Integer productId, String outProductId)
|
||||
throws WxErrorException {
|
||||
String responseContent = this.wxMaService
|
||||
.post(PRODUCT_SPU_DELISTING_URL, GsonHelper.buildJsonObject("product_id", productId,
|
||||
"out_product_id", outProductId));
|
||||
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 WxMinishopResult<WxMinishopAddGoodsSkuData> minishiopGoodsAddSku(
|
||||
WxMinishopSku sku) throws WxErrorException {
|
||||
String response = this.wxMaService
|
||||
.post(PRODUCT_ADD_SKU_URL, sku);
|
||||
JsonObject jsonObject = GsonParser.parse(response);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsInt());
|
||||
JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
|
||||
WxMinishopAddGoodsSkuData resultData = new WxMinishopAddGoodsSkuData();
|
||||
resultData.setSkuId(dataObj.get("sku_id").getAsLong());
|
||||
resultData.setCreateTime(dataObj.get("create_time").getAsString());
|
||||
result.setData(resultData);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMinishopResult<List<WxMinishopAddGoodsSkuData>> minishopGoodsBatchAddSku(
|
||||
List<WxMinishopSku> skuList) throws WxErrorException {
|
||||
String response = this.wxMaService
|
||||
.post(PRODUCT_BATCH_ADD_SKU_URL, GsonHelper.buildJsonObject("skus", skuList));
|
||||
JsonObject jsonObject = GsonParser.parse(response);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsInt());
|
||||
JsonArray jsonArray = jsonObject.get("data").getAsJsonArray();
|
||||
List<WxMinishopAddGoodsSkuData> skuData = new ArrayList<>();
|
||||
for (JsonElement jsonElement : jsonArray) {
|
||||
JsonObject element = jsonElement.getAsJsonObject();
|
||||
WxMinishopAddGoodsSkuData resultData = new WxMinishopAddGoodsSkuData();
|
||||
resultData.setSkuId(element.get("sku_id").getAsLong());
|
||||
resultData.setOutSkuId(element.get("out_sku_id").getAsString());
|
||||
resultData.setCreateTime(element.get("create_time").getAsString());
|
||||
skuData.add(resultData);
|
||||
}
|
||||
result.setData(skuData);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse minishopGoodsDelSku(Long productId, Long outProductId,
|
||||
String outSkuId, Long skuId) throws WxErrorException {
|
||||
String response = this.wxMaService
|
||||
.post(PRODUCT_DEL_SKU_URL, GsonHelper.buildJsonObject("product_id", productId,
|
||||
"out_product_id", outProductId, "out_sku_id", outSkuId, "sku_id", skuId));
|
||||
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, WxMaShopBaseResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSku(
|
||||
WxMinishopSku sku) throws WxErrorException {
|
||||
String response = this.wxMaService
|
||||
.post(PRODUCT_UPDATE_SKU_URL, sku);
|
||||
JsonObject jsonObject = GsonParser.parse(response);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSkuPrice(
|
||||
Long productId, Long outProductId, String outSkuId, Long skuId, Long salePrice,
|
||||
Long marketPrice) throws WxErrorException {
|
||||
String response = this.wxMaService
|
||||
.post(PRODUCT_UPDATE_SKU_PRICE_URL, GsonHelper.buildJsonObject(
|
||||
"product_id", productId, "out_product_id", outProductId,
|
||||
"sku_id", skuId, "out_sku_id", outSkuId, "sale_price", salePrice, "market_price", marketPrice));
|
||||
JsonObject jsonObject = GsonParser.parse(response);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMinishopResult<WxMinishopUpdateGoodsSkuData> minishopGoodsUpdateSkuStock(
|
||||
Long productId, Long outProductId, String outSkuId, Long skuId, Integer type,
|
||||
Integer stockNum) throws WxErrorException {
|
||||
String response = this.wxMaService
|
||||
.post(PRODUCT_UPDATE_SKU_STOCK_URL, GsonHelper.buildJsonObject(
|
||||
"product_id", productId, "out_product_id", outProductId,
|
||||
"sku_id", skuId, "out_sku_id", outSkuId, "type", type, "stock_num", stockNum));
|
||||
JsonObject jsonObject = GsonParser.parse(response);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(response, WxType.MiniApp));
|
||||
}
|
||||
|
||||
WxMinishopResult result = new WxMinishopResult();
|
||||
result.setErrcode(jsonObject.get("errcode").getAsInt());
|
||||
JsonObject dataObj = jsonObject.get("data").getAsJsonObject();
|
||||
WxMinishopUpdateGoodsSkuData resultData = new WxMinishopUpdateGoodsSkuData();
|
||||
resultData.setUpdateTime(dataObj.get("update_time").getAsString());
|
||||
result.setData(resultData);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Sharer;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShopSharerService;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSearchSharerResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerBindResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerDataSummaryResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveOrderListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveSummaryListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerUnbindResponse;
|
||||
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/6/18 3:38 下午
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaShopSharerServiceImpl implements WxMaShopSharerService {
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public WxMaShopSharerBindResponse bindSharer(String[] openids) throws WxErrorException {
|
||||
JsonObject json = GsonHelper.buildJsonObject("openids", openids);
|
||||
String responseContent = this.wxMaService.post(Sharer.BIND, 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, WxMaShopSharerBindResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopSharerDataSummaryResponse getSharerDataSummary(String openid) throws WxErrorException {
|
||||
JsonObject json = GsonHelper.buildJsonObject("openid", openid);
|
||||
String responseContent = this.wxMaService.post(Sharer.GET_SHARER_DATA_SUMMARY, 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, WxMaShopSharerDataSummaryResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopSharerListResponse getSharerList(Integer page, Integer pageSize) throws WxErrorException {
|
||||
JsonObject json = GsonHelper.buildJsonObject("page", page, "page_size", pageSize);
|
||||
String responseContent = this.wxMaService.post(Sharer.GET_SHARER_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, WxMaShopSharerListResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopSharerLiveOrderListResponse getSharerLiveOrderList(String openid, String liveExportId,
|
||||
Integer page, Integer pageSize) throws WxErrorException {
|
||||
JsonObject json = GsonHelper.buildJsonObject("openid", openid, "live_export_id", liveExportId,
|
||||
"page", page, "page_size", pageSize);
|
||||
String responseContent = this.wxMaService.post(Sharer.GET_SHARER_LIVE_ORDER_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, WxMaShopSharerLiveOrderListResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopSharerLiveSummaryListResponse getSharerLiveSummaryList(String openid,
|
||||
Integer page, Integer pageSize) throws WxErrorException {
|
||||
JsonObject json = GsonHelper.buildJsonObject("openid", openid, "page", page, "page_size", pageSize);
|
||||
String responseContent = this.wxMaService.post(Sharer.GET_SHARER_LIVE_SUMMARY_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, WxMaShopSharerLiveSummaryListResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopSearchSharerResponse searchSharer(String openid) throws WxErrorException {
|
||||
JsonObject json = GsonHelper.buildJsonObject("openid", openid);
|
||||
String responseContent = this.wxMaService.post(Sharer.SEARCH_SHARER, 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, WxMaShopSearchSharerResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopSharerUnbindResponse unbindSharer(String[] openids) throws WxErrorException {
|
||||
JsonObject json = GsonHelper.buildJsonObject("openids", openids);
|
||||
String responseContent = this.wxMaService.post(Sharer.UNBIND, 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, WxMaShopSharerUnbindResponse.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user