| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package me.chanjar.weixin.channel.api; | ||
|
|
||
| import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftGetResponse; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftProductInfo; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftProductListResponse; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftProductResponse; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftProductUpdateInfo; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftSetParam; | ||
| import me.chanjar.weixin.common.error.WxErrorException; | ||
|
|
||
| /** | ||
| * 视频号小店 赠品管理服务接口 | ||
| * | ||
| * @author <a href="https://github.com/features/copilot">GitHub Copilot</a> | ||
| * @see <a href="https://developers.weixin.qq.com/doc/store/shop/API/channels-shop-product/gift/api_addgiftproduct.html">赠品管理接口文档</a> | ||
| */ | ||
| public interface WxChannelGiftService { | ||
|
|
||
| /** | ||
| * 添加非卖商品(赠品) | ||
| * | ||
| * @param info 赠品信息 | ||
| * @return GiftProductResponse | ||
| * @throws WxErrorException 异常 | ||
| */ | ||
| GiftProductResponse addGiftProduct(GiftProductInfo info) throws WxErrorException; | ||
|
|
||
| /** | ||
| * 更新非卖商品(赠品) | ||
| * | ||
| * @param info 赠品更新信息 | ||
| * @return GiftProductResponse | ||
| * @throws WxErrorException 异常 | ||
| */ | ||
| GiftProductResponse updateGiftProduct(GiftProductUpdateInfo info) throws WxErrorException; | ||
|
|
||
| /** | ||
| * 在售商品转赠品(设置在售商品为赠品) | ||
| * | ||
| * @param param 请求参数(product_id + skus 列表) | ||
| * @return GiftProductListResponse | ||
| * @throws WxErrorException 异常 | ||
| */ | ||
| GiftProductListResponse setProductAsGift(GiftSetParam param) throws WxErrorException; | ||
|
|
||
| /** | ||
| * 获取赠品详情 | ||
| * | ||
| * @param productId 赠品商品ID | ||
| * @param dataType 数据类型。1: 仅获取线上数据;2: 仅获取草稿数据;3: 同时获取(默认) | ||
| * @return GiftGetResponse | ||
| * @throws WxErrorException 异常 | ||
| */ | ||
| GiftGetResponse getGiftProduct(String productId, Integer dataType) throws WxErrorException; | ||
|
|
||
| /** | ||
| * 获取赠品列表 | ||
| * | ||
| * @param pageSize 每页数量 | ||
| * @param nextKey 翻页上下文,不传默认获取第一页 | ||
| * @param status 赠品状态过滤 | ||
| * @return GiftProductListResponse | ||
| * @throws WxErrorException 异常 | ||
| */ | ||
| GiftProductListResponse listGiftProduct(Integer pageSize, String nextKey, Integer status) | ||
| throws WxErrorException; | ||
|
|
||
| /** | ||
| * 更新赠品库存 | ||
| * | ||
| * @param productId 赠品商品ID | ||
| * @param skuId SKU ID | ||
| * @param diffType 差量类型。1: 增加;2: 减少 | ||
| * @param num 变更数量 | ||
| * @return WxChannelBaseResponse | ||
| * @throws WxErrorException 异常 | ||
| */ | ||
| WxChannelBaseResponse updateGiftStock(String productId, String skuId, Integer diffType, Integer num) | ||
| throws WxErrorException; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package me.chanjar.weixin.channel.api.impl; | ||
|
|
||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Gift.ADD_GIFT_PRODUCT_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Gift.GET_GIFT_PRODUCT_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Gift.LIST_GIFT_PRODUCT_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Gift.SET_PRODUCT_AS_GIFT_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Gift.UPDATE_GIFT_PRODUCT_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Gift.UPDATE_GIFT_STOCK_URL; | ||
|
|
||
| import lombok.extern.slf4j.Slf4j; | ||
| import me.chanjar.weixin.channel.api.WxChannelGiftService; | ||
| import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftGetResponse; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftListParam; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftProductInfo; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftProductListResponse; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftProductResponse; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftProductUpdateInfo; | ||
| import me.chanjar.weixin.channel.bean.gift.GiftSetParam; | ||
| import me.chanjar.weixin.channel.util.JsonUtils; | ||
| import me.chanjar.weixin.channel.util.ResponseUtils; | ||
| import me.chanjar.weixin.common.error.WxErrorException; | ||
|
|
||
| /** | ||
| * 视频号小店 赠品管理服务实现 | ||
| * | ||
| * @author <a href="https://github.com/features/copilot">GitHub Copilot</a> | ||
| */ | ||
| @Slf4j | ||
| public class WxChannelGiftServiceImpl implements WxChannelGiftService { | ||
|
|
||
| /** 微信商店服务 */ | ||
| private final BaseWxChannelServiceImpl<?, ?> shopService; | ||
|
|
||
| public WxChannelGiftServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) { | ||
| this.shopService = shopService; | ||
| } | ||
|
|
||
| @Override | ||
| public GiftProductResponse addGiftProduct(GiftProductInfo info) throws WxErrorException { | ||
| String reqJson = JsonUtils.encode(info); | ||
| String resJson = shopService.post(ADD_GIFT_PRODUCT_URL, reqJson); | ||
| return ResponseUtils.decode(resJson, GiftProductResponse.class); | ||
|
Comment thread
binarywang marked this conversation as resolved.
|
||
| } | ||
|
|
||
| @Override | ||
| public GiftProductResponse updateGiftProduct(GiftProductUpdateInfo info) throws WxErrorException { | ||
| String reqJson = JsonUtils.encode(info); | ||
| String resJson = shopService.post(UPDATE_GIFT_PRODUCT_URL, reqJson); | ||
| return ResponseUtils.decode(resJson, GiftProductResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public GiftProductListResponse setProductAsGift(GiftSetParam param) throws WxErrorException { | ||
| String reqJson = JsonUtils.encode(param); | ||
| String resJson = shopService.post(SET_PRODUCT_AS_GIFT_URL, reqJson); | ||
| return ResponseUtils.decode(resJson, GiftProductListResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public GiftGetResponse getGiftProduct(String productId, Integer dataType) throws WxErrorException { | ||
| String reqJson = "{\"product_id\":\"" + productId + "\",\"data_type\":" + dataType + "}"; | ||
|
Comment thread
binarywang marked this conversation as resolved.
Comment thread
binarywang marked this conversation as resolved.
|
||
| String resJson = shopService.post(GET_GIFT_PRODUCT_URL, reqJson); | ||
|
Comment thread
binarywang marked this conversation as resolved.
|
||
| return ResponseUtils.decode(resJson, GiftGetResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public GiftProductListResponse listGiftProduct(Integer pageSize, String nextKey, Integer status) | ||
| throws WxErrorException { | ||
| GiftListParam param = new GiftListParam(pageSize, nextKey, status); | ||
| String reqJson = JsonUtils.encode(param); | ||
| String resJson = shopService.post(LIST_GIFT_PRODUCT_URL, reqJson); | ||
| return ResponseUtils.decode(resJson, GiftProductListResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public WxChannelBaseResponse updateGiftStock(String productId, String skuId, Integer diffType, Integer num) | ||
| throws WxErrorException { | ||
| String reqJson = "{\"product_id\":\"" + productId + "\",\"sku_id\":\"" + skuId | ||
| + "\",\"diff_type\":" + diffType + ",\"num\":" + num + "}"; | ||
| String resJson = shopService.post(UPDATE_GIFT_STOCK_URL, reqJson); | ||
| return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); | ||
| } | ||
| } | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.