Skip to content

feat(channel): 实现视频号小店缺失的商品相关API(Issue #4002)#4033

Open
Copilot wants to merge 3 commits into
developfrom
copilot/weixin-java-channel-add-missing-endpoints
Open

feat(channel): 实现视频号小店缺失的商品相关API(Issue #4002)#4033
Copilot wants to merge 3 commits into
developfrom
copilot/weixin-java-channel-add-missing-endpoints

Conversation

Copilot AI commented May 31, 2026

Copy link
Copy Markdown
Contributor

Issue #4002 列出了 weixin-java-channel 模块中缺失的28个视频号小店接口。本次实现其中有官方文档可查的14个接口,跳过文档404的6个接口(礼品活动、审核策略、审核配额)。

新增 WxChannelGiftService(赠品管理)

6个接口:addGiftProduct / updateGiftProduct / setProductAsGift / getGiftProduct / listGiftProduct / updateGiftStock

WxChannelGiftService giftService = wxChannelService.getGiftService();

// 添加非卖赠品
GiftProductInfo info = new GiftProductInfo();
info.setTitle("赠品名称");
// ...
GiftProductResponse resp = giftService.addGiftProduct(info);

// 获取赠品详情
GiftGetResponse detail = giftService.getGiftProduct(productId, 3);

扩展 WxChannelProductService(新增8个接口)

方法 对应微信API
updateLimitTask 更新限时抢购任务
getStockFlow 获取库存流水
categoryPreCheck 发品前类目资质校验
getProductBrandRecommend 商品品牌推荐
externalProductMapping 站内外商品属性映射
externalProductMappingNew 站内外商品属性映射(新版)
beginTimingSale 商品立即开售
cancelTimingSale 取消商品开售

新增 Bean 类

  • bean/gift/:13个类,涵盖赠品增删改查及库存变更所需的请求/响应模型
  • bean/limit/LimitSkuUpdateLimitTaskUpdateParamLimitTaskUpdateResponse
  • bean/product/StockFlow*(4个)、CategoryPreCheckResponseProductBrandRecommend*(2个)、ExternalProductMapping*(4个)、ExternalAttribute

注意事项

GiftProductUpdateInfo 未继承 GiftProductInfo,避免 Jackson 对同名 @JsonProperty("skus") 字段产生重复序列化。

Copilot AI changed the title [WIP] Add missing gift management endpoints to WxChannelProductService feat(channel): 实现视频号小店缺失的商品相关API(Issue #4002) Jun 1, 2026
@binarywang binarywang added this to the 4.8.5 milestone Jun 1, 2026
@binarywang binarywang marked this pull request as ready for review July 1, 2026 01:56
Copilot AI review requested due to automatic review settings July 1, 2026 01:56
@augmentcode

augmentcode Bot commented Jul 1, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR implements a set of previously-missing 视频号小店商品相关 API wrappers in weixin-java-channel (per Issue #4002).

Changes:

  • Introduces WxChannelGiftService + WxChannelGiftServiceImpl to support gift product management (add/update/set/get/list/stock update).
  • Extends WxChannelService / BaseWxChannelServiceImpl to expose and lazily initialize the new gift service.
  • Adds 8 new methods to WxChannelProductService / WxChannelProductServiceImpl (limited-discount task update, stock flow query, category pre-check, brand recommend, external mapping v1/v2, begin/cancel timing sale).
  • Adds multiple new request/response beans under bean/gift, bean/limit, and bean/product to model the new endpoints.
  • Updates WxChannelApiUrlConstants with new endpoint URLs, including a new Gift URL group.

Technical Notes: Most new endpoints post JSON bodies via JsonUtils.encode and decode via ResponseUtils.decode, aligning with existing channel service patterns.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.


@Override
public GiftGetResponse getGiftProduct(String productId, Integer dataType) throws WxErrorException {
String reqJson = "{\"product_id\":\"" + productId + "\",\"data_type\":" + dataType + "}";

@augmentcode augmentcode Bot Jul 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

getGiftProduct is building the request body via raw string concatenation; if productId contains characters needing JSON escaping (or if dataType is null), this can generate invalid JSON or send unintended values to the API. Consider using a structured JSON builder/JsonUtils.encode(...) approach so fields are properly escaped and optional fields can be omitted when unset.

Other locations where this applies: weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelGiftServiceImpl.java:79, weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java:279, weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java:310, weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java:317

Severity: medium

Other Locations
  • weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelGiftServiceImpl.java:79
  • weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java:279
  • weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java:310
  • weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java:317

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22a6f33fbe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +24 to +25
@JsonProperty("product_id")
private Long productId;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep stock-flow product IDs as strings

All existing channel product/stock APIs expose product_id and sku_id as String identifiers, so this new request bean forces callers to parse IDs returned by the SDK before they can call getStockFlow. In cases where WeChat returns a non-numeric or out-of-range identifier, the API becomes unusable and Jackson also emits a JSON number instead of the string form used by the rest of the product APIs; please model these IDs as String here as well.

Useful? React with 👍 / 👎.

Comment on lines +35 to +36
@JsonProperty("order_id")
private Long orderId;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Decode stock-flow order IDs as strings

For stock-flow rows created by order operations, this field is the same order_id that the rest of the channel module consistently models as a String. Mapping it to Long makes a successful response with a quoted, non-numeric, or larger-than-64-bit order ID fail deserialization in JsonUtils.decode, causing ResponseUtils to return an internal-error response instead of the stock-flow data.

Useful? React with 👍 / 👎.


@Override
public GiftGetResponse getGiftProduct(String productId, Integer dataType) throws WxErrorException {
String reqJson = "{\"product_id\":\"" + productId + "\",\"data_type\":" + dataType + "}";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the default gift data type

The new API documents dataType as defaulting to 3, but when callers pass null to use that default this manually constructed body sends an explicit "data_type":null instead of omitting the optional field like the other request beans do. For stores relying on the documented default, WeChat can reject the request rather than returning both online and draft data; use a NON_NULL request bean or default the value before serializing.

Useful? React with 👍 / 👎.

Comment on lines +81 to +83
/** 在售赠品的来源商品id */
@JsonProperty("src_product_id")
private Long srcProductId;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve source product IDs as strings

For gifts converted from an on-sale product, src_product_id is the source product identifier; the existing product model already maps the same JSON field as String. Mapping it to Long here means a successful getGiftProduct response with a quoted, non-numeric, or out-of-range source product ID cannot be decoded correctly, so callers lose the origin product linkage for converted gifts.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

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 模块补齐视频号小店商品相关缺失接口(对应 Issue #4002 的一部分),新增赠品管理子服务,并扩展商品服务以覆盖限时抢购更新、库存流水、类目资质校验、品牌推荐、站内外属性映射、立即开售/取消开售等能力。

Changes:

  • WxChannelProductService / WxChannelProductServiceImpl 中新增 8 个商品相关接口,并补充对应请求/响应 Bean。
  • 新增 WxChannelGiftService / WxChannelGiftServiceImpl(赠品管理 6 个接口)及对应 bean/gift/* 模型。
  • WxChannelApiUrlConstants 中补齐新增端点 URL 常量,并在 WxChannelService 暴露 getGiftService()

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java 新增商品扩展端点与赠品端点 URL 常量
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/StockFlowResponse.java 新增“库存流水”响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/StockFlowParam.java 新增“库存流水”请求参数模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/StockFlowInfo.java 新增库存流水明细模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/StockFlowExtInfo.java 新增库存流水扩展信息模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductBrandRecommendResponse.java 新增品牌推荐响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductBrandRecommendParam.java 新增品牌推荐请求参数模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingResponse.java 新增站内外属性映射响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingParam.java 新增站内外属性映射请求参数模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingNewResponse.java 新增站内外属性映射(新版)响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingNewParam.java 新增站内外属性映射(新版)请求参数模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalAttribute.java 新增外部属性键值对模型(用于映射新版)
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/CategoryPreCheckResponse.java 新增类目资质预校验响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskUpdateResponse.java 新增更新限时抢购任务响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitTaskUpdateParam.java 新增更新限时抢购任务请求参数模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/limit/LimitSkuUpdate.java 新增限时抢购 SKU 更新模型(补充 product_id)
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftSkuStockDiff.java 新增赠品库存差量模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftSetSkuParam.java 新增在售商品转赠品 SKU 划拨参数模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftSetParam.java 新增在售商品转赠品请求模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftProductUpdateSkuInfo.java 新增赠品 SKU 更新模型(含 sku_id/stock_diff)
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftProductUpdateInfo.java 新增更新非卖赠品请求模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftProductSkuInfo.java 新增添加非卖赠品 SKU 信息模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftProductSku.java 新增赠品 SKU 详情模型(查询返回)
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftProductResponse.java 新增添加/更新赠品响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftProductListResponse.java 新增赠品列表/转赠品响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftProductInfo.java 新增添加非卖赠品请求模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftProduct.java 新增赠品详情数据模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftListParam.java 新增赠品列表分页请求模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/gift/GiftGetResponse.java 新增赠品详情获取响应模型(线上/草稿)
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java 对外暴露赠品服务入口 getGiftService()
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java 扩展商品服务接口(新增 8 个方法签名)
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelGiftService.java 新增赠品管理服务接口定义
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java 实现新增商品相关接口调用
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelGiftServiceImpl.java 新增赠品管理服务实现
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java 在基础服务实现中懒加载 GiftService 并实现接口方法

Comment on lines +61 to +63
public GiftGetResponse getGiftProduct(String productId, Integer dataType) throws WxErrorException {
String reqJson = "{\"product_id\":\"" + productId + "\",\"data_type\":" + dataType + "}";
String resJson = shopService.post(GET_GIFT_PRODUCT_URL, reqJson);
Comment on lines +323 to +327
* @param taskId 预售任务ID
* @return WxChannelBaseResponse
* @throws WxErrorException 异常
*/
WxChannelBaseResponse beginTimingSale(String productId, String taskId) throws WxErrorException;
Comment on lines +309 to +312
public WxChannelBaseResponse beginTimingSale(String productId, String taskId) throws WxErrorException {
String reqJson = "{\"product_id\":\"" + productId + "\",\"task_id\":\"" + taskId + "\"}";
String resJson = shopService.post(BEGIN_TIMING_SALE_URL, reqJson);
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
Comment on lines +27 to +30
/**
* 操作来源(仅对 op_type=1/2/3 生效)。
* 2: API(开发者调用);3: API(服务商代调用);5: 手机端;6: web端
*/
Comment on lines +263 to +267
@Override
public LimitTaskUpdateResponse updateLimitTask(LimitTaskUpdateParam param) throws WxErrorException {
String reqJson = JsonUtils.encode(param);
String resJson = shopService.post(UPDATE_LIMIT_TASK_URL, reqJson);
return ResponseUtils.decode(resJson, LimitTaskUpdateResponse.class);
Comment on lines +39 to +43
@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);
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.

[weixin-java-channel] WxChannelProductService 缺失赠品/买赠活动/限时抢购/库存等完整子API(共28个端点)

3 participants