feat(channel): 新增微信小店赠品与买赠活动模块接口支持#4030
Open
Copilot wants to merge 2 commits into
Open
Conversation
Copilot
AI
changed the title
[WIP] Add support for gift and buy-gift promotion modules
feat(channel): 新增微信小店赠品与买赠活动模块接口支持
May 31, 2026
There was a problem hiding this comment.
Pull request overview
该 PR 为 weixin-java-channel 商品服务新增微信小店赠品与买赠活动相关接口能力,补充 URL 常量、请求/响应模型、服务实现与测试入口。
Changes:
- 新增赠品商品与买赠活动的 9 个服务方法及实现。
- 新增赠品/活动相关请求响应模型。
- 在商品服务测试中补充新增接口调用用例。
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
WxChannelProductService.java |
新增赠品与买赠活动服务接口定义 |
WxChannelProductServiceImpl.java |
实现新增接口的 HTTP 调用与响应解析 |
WxChannelApiUrlConstants.java |
新增 9 个微信小店赠品/活动 API URL 常量 |
GiftProductInfo.java |
新增赠品商品信息模型 |
GiftProductAddResponse.java |
新增赠品创建响应模型 |
GiftProductGetResponse.java |
新增赠品详情响应模型 |
GiftProductListParam.java |
新增赠品列表查询参数 |
GiftProductListResponse.java |
新增赠品列表响应模型 |
GiftActivityInfo.java |
新增买赠活动信息模型 |
GiftActivityAddParam.java |
新增买赠活动创建参数包装模型 |
GiftActivityAddResponse.java |
新增买赠活动创建响应模型 |
WxChannelProductServiceImplTest.java |
新增赠品与买赠活动接口测试入口 |
Comment on lines
+235
to
+236
| GiftProductAddResponse response = ResponseUtils.decode(resJson, GiftProductAddResponse.class); | ||
| return response.getProductId(); |
| public void updateGiftProduct(GiftProductInfo info) throws WxErrorException { | ||
| String reqJson = JsonUtils.encode(info); | ||
| String resJson = shopService.post(GIFT_PRODUCT_UPDATE_URL, reqJson); | ||
| ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
| public void setProductAsGift(String productId) throws WxErrorException { | ||
| String reqJson = "{\"product_id\":\"" + productId + "\"}"; | ||
| String resJson = shopService.post(GIFT_PRODUCT_ON_SALE_SET_URL, reqJson); | ||
| ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
Comment on lines
+257
to
+258
| GiftProductGetResponse response = ResponseUtils.decode(resJson, GiftProductGetResponse.class); | ||
| return response.getProduct() != null ? response.getProduct() : response.getEditProduct(); |
|
|
||
| @Override | ||
| public void updateGiftStock(String productId, String skuId, Integer stock) throws WxErrorException { | ||
| SkuStockParam param = new SkuStockParam(productId, skuId, 3, stock); |
Comment on lines
+281
to
+282
| GiftActivityAddResponse response = ResponseUtils.decode(resJson, GiftActivityAddResponse.class); | ||
| return response.getActivityId(); |
| public void deleteGiftActivity(String activityId) throws WxErrorException { | ||
| String reqJson = "{\"activity_id\":\"" + activityId + "\"}"; | ||
| String resJson = shopService.post(GIFT_ACTIVITY_DELETE_URL, reqJson); | ||
| ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
| public void stopGiftActivity(String activityId) throws WxErrorException { | ||
| String reqJson = "{\"activity_id\":\"" + activityId + "\"}"; | ||
| String resJson = shopService.post(GIFT_ACTIVITY_STOP_URL, reqJson); | ||
| ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
Comment on lines
+13
to
+16
| import me.chanjar.weixin.channel.bean.product.GiftActivityInfo; | ||
| import me.chanjar.weixin.channel.bean.product.GiftProductInfo; | ||
| import me.chanjar.weixin.channel.bean.product.GiftProductListParam; | ||
| import me.chanjar.weixin.channel.bean.product.GiftProductListResponse; |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
当前
weixin-java-channel的商品服务未覆盖微信小店「赠品」与「买赠活动」能力,导致相关营销链路在 SDK 中不可用。该变更在WxChannelProductService补齐官方文档列出的 9 个接口,并提供对应请求/响应模型与实现。接口能力补齐(商品服务)
WxChannelProductService新增 9 个方法:addGiftProduct、updateGiftProduct、setProductAsGift、getGiftProduct、listGiftProduct、updateGiftStockaddGiftActivity、deleteGiftActivity、stopGiftActivityWxChannelProductServiceImpl完成对应调用与返回值映射(创建类接口返回 ID,更新/删除/停止类接口按空返回设计处理)。API 路径常量新增
WxChannelApiUrlConstants.Spu增加:/channels/ec/product/gift/add/channels/ec/product/gift/update/channels/ec/product/gift/onsale/set/channels/ec/product/gift/get/channels/ec/product/gift/list/get/channels/ec/product/gift/stock/update/channels/ec/product/activity/add/channels/ec/product/activity/del/channels/ec/product/activity/stop数据模型新增(按接口语义拆分)
GiftProductInfo、GiftProductAddResponse、GiftProductGetResponse、GiftProductListParam、GiftProductListResponseGiftActivityInfo、GiftActivityAddParam、GiftActivityAddResponse单元测试补充
WxChannelProductServiceImplTest增加 9 个对应测试方法,覆盖新增服务入口的调用与基本返回契约。示例(新增服务调用):