-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
feat(channel): 实现视频号小店缺失的商品相关API(Issue #4002) #4033
New issue
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
Open
Copilot
wants to merge
3
commits into
develop
Choose a base branch
from
copilot/weixin-java-channel-add-missing-endpoints
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelGiftService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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="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/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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...va-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelGiftServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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="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/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); | ||
|
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 + "}"; | ||
|
binarywang marked this conversation as resolved.
binarywang marked this conversation as resolved.
|
||
| String resJson = shopService.post(GET_GIFT_PRODUCT_URL, reqJson); | ||
|
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); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.