Skip to content

feat(channel): 新增微信小店赠品与买赠活动模块接口支持#4030

Open
Copilot wants to merge 2 commits into
developfrom
copilot/fix-1343140-49122742-f5592df9-6312-4996-9035-a3f2c97651a8
Open

feat(channel): 新增微信小店赠品与买赠活动模块接口支持#4030
Copilot wants to merge 2 commits into
developfrom
copilot/fix-1343140-49122742-f5592df9-6312-4996-9035-a3f2c97651a8

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2026

当前 weixin-java-channel 的商品服务未覆盖微信小店「赠品」与「买赠活动」能力,导致相关营销链路在 SDK 中不可用。该变更在 WxChannelProductService 补齐官方文档列出的 9 个接口,并提供对应请求/响应模型与实现。

  • 接口能力补齐(商品服务)

    • WxChannelProductService 新增 9 个方法:
      • 赠品:addGiftProductupdateGiftProductsetProductAsGiftgetGiftProductlistGiftProductupdateGiftStock
      • 买赠活动:addGiftActivitydeleteGiftActivitystopGiftActivity
    • WxChannelProductServiceImpl 完成对应调用与返回值映射(创建类接口返回 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
  • 数据模型新增(按接口语义拆分)

    • 赠品:GiftProductInfoGiftProductAddResponseGiftProductGetResponseGiftProductListParamGiftProductListResponse
    • 买赠活动:GiftActivityInfoGiftActivityAddParamGiftActivityAddResponse
  • 单元测试补充

    • WxChannelProductServiceImplTest 增加 9 个对应测试方法,覆盖新增服务入口的调用与基本返回契约。

示例(新增服务调用):

WxChannelProductService productService = channelService.getProductService();

// 创建赠品活动
GiftActivityInfo info = new GiftActivityInfo();
String activityId = productService.addGiftActivity(info);

// 停止活动
productService.stopGiftActivity(activityId);

Copilot AI changed the title [WIP] Add support for gift and buy-gift promotion modules feat(channel): 新增微信小店赠品与买赠活动模块接口支持 May 31, 2026
Copilot AI requested a review from binarywang May 31, 2026 14:28
@binarywang binarywang marked this pull request as ready for review May 31, 2026 14:32
Copilot AI review requested due to automatic review settings May 31, 2026 14:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 新增赠品和买赠活动模块支持

3 participants