Skip to content

Commit d9caa8a

Browse files
authored
🆕 #4109 【视频号】微信小店新增商品赠品、限时抢购、库存及商品辅助服务等支持
1 parent 1246de1 commit d9caa8a

36 files changed

Lines changed: 1797 additions & 74 deletions

weixin-java-channel/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
<groupId>org.apache.maven.plugins</groupId>
134134
<artifactId>maven-surefire-plugin</artifactId>
135135
<configuration>
136+
<skip>false</skip>
136137
<suiteXmlFiles>
137138
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
138139
</suiteXmlFiles>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
4+
import me.chanjar.weixin.channel.bean.product.GiftActivityAddResponse;
5+
import me.chanjar.weixin.channel.bean.product.GiftActivityInfo;
6+
import me.chanjar.weixin.channel.bean.product.GiftProductAddResponse;
7+
import me.chanjar.weixin.channel.bean.product.GiftProductGetResponse;
8+
import me.chanjar.weixin.channel.bean.product.GiftProductInfo;
9+
import me.chanjar.weixin.channel.bean.product.GiftProductListParam;
10+
import me.chanjar.weixin.channel.bean.product.GiftProductListResponse;
11+
import me.chanjar.weixin.common.error.WxErrorException;
12+
13+
/**
14+
* 微信小店赠品与买赠活动服务。
15+
*/
16+
public interface WxChannelGiftService {
17+
18+
/**
19+
* 添加非卖商品。
20+
*
21+
* @param info 赠品信息
22+
* @return 添加赠品响应
23+
* @throws WxErrorException 异常
24+
*/
25+
GiftProductAddResponse addGiftProduct(GiftProductInfo info) throws WxErrorException;
26+
27+
/**
28+
* 更新非卖商品。
29+
*
30+
* @param info 赠品信息
31+
* @return 操作响应
32+
* @throws WxErrorException 异常
33+
*/
34+
WxChannelBaseResponse updateGiftProduct(GiftProductInfo info) throws WxErrorException;
35+
36+
/**
37+
* 在售商品转赠品。
38+
*
39+
* @param productId 商品ID
40+
* @return 操作响应
41+
* @throws WxErrorException 异常
42+
*/
43+
WxChannelBaseResponse setProductAsGift(String productId) throws WxErrorException;
44+
45+
/**
46+
* 获取赠品。
47+
*
48+
* @param productId 赠品商品ID
49+
* @return 赠品详情响应
50+
* @throws WxErrorException 异常
51+
*/
52+
GiftProductGetResponse getGiftProduct(String productId) throws WxErrorException;
53+
54+
/**
55+
* 获取赠品列表。
56+
*
57+
* @param param 查询参数
58+
* @return 赠品列表
59+
* @throws WxErrorException 异常
60+
*/
61+
GiftProductListResponse listGiftProduct(GiftProductListParam param) throws WxErrorException;
62+
63+
/**
64+
* 更新赠品库存。
65+
*
66+
* @param productId 赠品商品ID
67+
* @param skuId 赠品sku_id
68+
* @param diffType 修改类型 1增加 2减少 3设置
69+
* @param num 增加、减少或者设置的库存值
70+
* @return 操作响应
71+
* @throws WxErrorException 异常
72+
*/
73+
WxChannelBaseResponse updateGiftStock(String productId, String skuId, Integer diffType, Integer num)
74+
throws WxErrorException;
75+
76+
/**
77+
* 创建赠品活动。
78+
*
79+
* @param info 活动信息
80+
* @return 创建赠品活动响应
81+
* @throws WxErrorException 异常
82+
*/
83+
GiftActivityAddResponse addGiftActivity(GiftActivityInfo info) throws WxErrorException;
84+
85+
/**
86+
* 删除赠品活动。
87+
*
88+
* @param activityId 活动ID
89+
* @return 操作响应
90+
* @throws WxErrorException 异常
91+
*/
92+
WxChannelBaseResponse deleteGiftActivity(String activityId) throws WxErrorException;
93+
94+
/**
95+
* 停止赠品活动。
96+
*
97+
* @param activityId 活动ID
98+
* @return 操作响应
99+
* @throws WxErrorException 异常
100+
*/
101+
WxChannelBaseResponse stopGiftActivity(String activityId) throws WxErrorException;
102+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
4+
import me.chanjar.weixin.channel.bean.limit.LimitTaskAddResponse;
5+
import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse;
6+
import me.chanjar.weixin.channel.bean.limit.LimitTaskParam;
7+
import me.chanjar.weixin.channel.bean.limit.LimitTaskUpdateParam;
8+
import me.chanjar.weixin.channel.bean.limit.LimitTaskUpdateResponse;
9+
import me.chanjar.weixin.common.error.WxErrorException;
10+
11+
/**
12+
* 微信小店限时抢购服务。
13+
*/
14+
public interface WxChannelLimitedDiscountService {
15+
16+
/**
17+
* 添加限时抢购任务。
18+
*
19+
* @param param 限时抢购任务
20+
* @return 添加任务响应
21+
* @throws WxErrorException 异常
22+
*/
23+
LimitTaskAddResponse addLimitTask(LimitTaskParam param) throws WxErrorException;
24+
25+
/**
26+
* 拉取限时抢购任务列表。
27+
*
28+
* @param pageSize 每页数量
29+
* @param nextKey 翻页上下文
30+
* @param status 抢购活动状态
31+
* @return 任务列表响应
32+
* @throws WxErrorException 异常
33+
*/
34+
LimitTaskListResponse listLimitTask(Integer pageSize, String nextKey, Integer status) throws WxErrorException;
35+
36+
/**
37+
* 停止限时抢购任务。
38+
*
39+
* @param taskId 限时抢购任务ID
40+
* @return 操作响应
41+
* @throws WxErrorException 异常
42+
*/
43+
WxChannelBaseResponse stopLimitTask(String taskId) throws WxErrorException;
44+
45+
/**
46+
* 删除限时抢购任务。
47+
*
48+
* @param taskId 限时抢购任务ID
49+
* @return 操作响应
50+
* @throws WxErrorException 异常
51+
*/
52+
WxChannelBaseResponse deleteLimitTask(String taskId) throws WxErrorException;
53+
54+
/**
55+
* 更新限时抢购任务。
56+
*
57+
* @param param 更新任务参数
58+
* @return 更新任务响应
59+
* @throws WxErrorException 异常
60+
*/
61+
LimitTaskUpdateResponse updateLimitTask(LimitTaskUpdateParam param) throws WxErrorException;
62+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
4+
import me.chanjar.weixin.channel.bean.product.assistant.BeginTimingSaleParam;
5+
import me.chanjar.weixin.channel.bean.product.assistant.CancelTimingSaleParam;
6+
import me.chanjar.weixin.channel.bean.product.assistant.CategoryPreCheckParam;
7+
import me.chanjar.weixin.channel.bean.product.assistant.CategoryPreCheckResponse;
8+
import me.chanjar.weixin.channel.bean.product.assistant.ExternalProductMappingNewParam;
9+
import me.chanjar.weixin.channel.bean.product.assistant.ExternalProductMappingNewResponse;
10+
import me.chanjar.weixin.channel.bean.product.assistant.ExternalProductMappingParam;
11+
import me.chanjar.weixin.channel.bean.product.assistant.ExternalProductMappingResponse;
12+
import me.chanjar.weixin.channel.bean.product.assistant.ProductBrandRecommendParam;
13+
import me.chanjar.weixin.channel.bean.product.assistant.ProductBrandRecommendResponse;
14+
import me.chanjar.weixin.common.error.WxErrorException;
15+
16+
/**
17+
* 微信小店商品辅助功能服务。
18+
*/
19+
public interface WxChannelProductAssistantService {
20+
21+
/**
22+
* 发品前校验。
23+
*
24+
* @param param 校验参数
25+
* @return 校验结果
26+
* @throws WxErrorException 异常
27+
*/
28+
CategoryPreCheckResponse categoryPreCheck(CategoryPreCheckParam param) throws WxErrorException;
29+
30+
/**
31+
* 获取商品品牌推荐。
32+
*
33+
* @param param 推荐参数
34+
* @return 推荐结果
35+
* @throws WxErrorException 异常
36+
*/
37+
ProductBrandRecommendResponse getProductBrandRecommend(ProductBrandRecommendParam param)
38+
throws WxErrorException;
39+
40+
/**
41+
* 获取站内外商品属性映射。
42+
*
43+
* @param param 映射参数
44+
* @return 映射结果
45+
* @throws WxErrorException 异常
46+
*/
47+
ExternalProductMappingResponse externalProductMapping(ExternalProductMappingParam param)
48+
throws WxErrorException;
49+
50+
/**
51+
* 获取商品属性映射及推荐。
52+
*
53+
* @param param 映射参数
54+
* @return 映射结果
55+
* @throws WxErrorException 异常
56+
*/
57+
ExternalProductMappingNewResponse externalProductMappingNew(ExternalProductMappingNewParam param)
58+
throws WxErrorException;
59+
60+
/**
61+
* 将定时开售商品改为立即开售。
62+
*
63+
* @param param 开售参数
64+
* @return 操作结果
65+
* @throws WxErrorException 异常
66+
*/
67+
WxChannelBaseResponse beginTimingSale(BeginTimingSaleParam param) throws WxErrorException;
68+
69+
/**
70+
* 取消商品定时开售。
71+
*
72+
* @param param 取消参数
73+
* @return 操作结果
74+
* @throws WxErrorException 异常
75+
*/
76+
WxChannelBaseResponse cancelTimingSale(CancelTimingSaleParam param) throws WxErrorException;
77+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import java.util.List;
4+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
5+
import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse;
6+
import me.chanjar.weixin.channel.bean.product.SkuStockResponse;
7+
import me.chanjar.weixin.channel.bean.product.stock.StockFlowParam;
8+
import me.chanjar.weixin.channel.bean.product.stock.StockFlowResponse;
9+
import me.chanjar.weixin.common.error.WxErrorException;
10+
11+
/**
12+
* 微信小店商品库存服务。
13+
*/
14+
public interface WxChannelProductStockService {
15+
16+
/**
17+
* 更新商品库存。
18+
*
19+
* @param productId 商品ID
20+
* @param skuId 商品sku_id
21+
* @param diffType 修改类型 1增加 2减少 3设置
22+
* @param num 增加、减少或者设置的库存值
23+
* @return 操作响应
24+
* @throws WxErrorException 异常
25+
*/
26+
WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffType, Integer num)
27+
throws WxErrorException;
28+
29+
/**
30+
* 获取商品实时库存。
31+
*
32+
* @param productId 商品ID
33+
* @param skuId 商品sku_id
34+
* @return 库存响应
35+
* @throws WxErrorException 异常
36+
*/
37+
SkuStockResponse getSkuStock(String productId, String skuId) throws WxErrorException;
38+
39+
/**
40+
* 批量获取库存信息。
41+
*
42+
* @param productIds 商品ID列表,单次请求不超过50个
43+
* @return 库存信息
44+
* @throws WxErrorException 异常
45+
*/
46+
SkuStockBatchResponse getSkuStockBatch(List<String> productIds) throws WxErrorException;
47+
48+
/**
49+
* 获取商品库存流水。
50+
*
51+
* @param param 库存流水查询参数
52+
* @return 库存流水响应
53+
* @throws WxErrorException 异常
54+
*/
55+
StockFlowResponse getStockFlow(StockFlowParam param) throws WxErrorException;
56+
}

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,42 @@ public interface WxChannelService extends BaseWxChannelService {
3535
*/
3636
WxChannelProductService getProductService();
3737

38+
/**
39+
* 赠品与买赠活动服务
40+
*
41+
* @return 赠品与买赠活动服务
42+
*/
43+
default WxChannelGiftService getGiftService() {
44+
throw new UnsupportedOperationException("Gift service is not supported by this implementation");
45+
}
46+
47+
/**
48+
* 限时抢购服务
49+
*
50+
* @return 限时抢购服务
51+
*/
52+
default WxChannelLimitedDiscountService getLimitedDiscountService() {
53+
throw new UnsupportedOperationException("Limited discount service is not supported by this implementation");
54+
}
55+
56+
/**
57+
* 商品库存服务
58+
*
59+
* @return 商品库存服务
60+
*/
61+
default WxChannelProductStockService getProductStockService() {
62+
throw new UnsupportedOperationException("Product stock service is not supported by this implementation");
63+
}
64+
65+
/**
66+
* 商品辅助功能服务
67+
*
68+
* @return 商品辅助功能服务
69+
*/
70+
default WxChannelProductAssistantService getProductAssistantService() {
71+
throw new UnsupportedOperationException("Product assistant service is not supported by this implementation");
72+
}
73+
3874
/**
3975
* 仓库服务
4076
*

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
3737
private final WxChannelBasicService basicService = new WxChannelBasicServiceImpl(this);
3838
private final WxChannelCategoryService categoryService = new WxChannelCategoryServiceImpl(this);
3939
private final WxChannelBrandService brandService = new WxChannelBrandServiceImpl(this);
40-
private final WxChannelProductService productService = new WxChannelProductServiceImpl(this);
40+
private final WxChannelGiftService giftService = new WxChannelGiftServiceImpl(this);
41+
private final WxChannelLimitedDiscountService limitedDiscountService =
42+
new WxChannelLimitedDiscountServiceImpl(this);
43+
private final WxChannelProductStockService productStockService = new WxChannelProductStockServiceImpl(this);
44+
private final WxChannelProductAssistantService productAssistantService =
45+
new WxChannelProductAssistantServiceImpl(this);
46+
private final WxChannelProductService productService = new WxChannelProductServiceImpl(
47+
this, giftService, limitedDiscountService, productStockService);
4148
private final WxChannelWarehouseService warehouseService = new WxChannelWarehouseServiceImpl(this);
4249
private final WxChannelOrderService orderService = new WxChannelOrderServiceImpl(this);
4350
private final WxChannelAfterSaleService afterSaleService = new WxChannelAfterSaleServiceImpl(this);
@@ -336,6 +343,26 @@ public WxChannelProductService getProductService() {
336343
return productService;
337344
}
338345

346+
@Override
347+
public WxChannelGiftService getGiftService() {
348+
return giftService;
349+
}
350+
351+
@Override
352+
public WxChannelLimitedDiscountService getLimitedDiscountService() {
353+
return limitedDiscountService;
354+
}
355+
356+
@Override
357+
public WxChannelProductStockService getProductStockService() {
358+
return productStockService;
359+
}
360+
361+
@Override
362+
public WxChannelProductAssistantService getProductAssistantService() {
363+
return productAssistantService;
364+
}
365+
339366
@Override
340367
public WxChannelWarehouseService getWarehouseService() {
341368
return warehouseService;

0 commit comments

Comments
 (0)