From 2978a7ae93da2c5e11acef6482d41dccdd4280e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 14:19:13 +0000 Subject: [PATCH 1/2] Initial plan From 5fabd7cb6cbf074033f11c83796509956129c2b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 14:27:26 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=B0=8F=E5=BA=97=E8=B5=A0=E5=93=81=E4=B8=8E=E4=B9=B0=E8=B5=A0?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=8E=A5=E5=8F=A3=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../channel/api/WxChannelProductService.java | 82 +++++++++++++++++ .../api/impl/WxChannelProductServiceImpl.java | 85 +++++++++++++++++ .../bean/product/GiftActivityAddParam.java | 23 +++++ .../bean/product/GiftActivityAddResponse.java | 23 +++++ .../bean/product/GiftActivityInfo.java | 92 +++++++++++++++++++ .../bean/product/GiftProductAddResponse.java | 24 +++++ .../bean/product/GiftProductGetResponse.java | 28 ++++++ .../channel/bean/product/GiftProductInfo.java | 11 +++ .../bean/product/GiftProductListParam.java | 31 +++++++ .../bean/product/GiftProductListResponse.java | 33 +++++++ .../constant/WxChannelApiUrlConstants.java | 18 ++++ .../impl/WxChannelProductServiceImplTest.java | 67 ++++++++++++++ 12 files changed, 517 insertions(+) create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityAddParam.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityAddResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityInfo.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductAddResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductGetResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductInfo.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductListParam.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductListResponse.java diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java index 7064adf70f..5853776fc5 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java @@ -10,6 +10,10 @@ import me.chanjar.weixin.channel.bean.product.SkuStockResponse; import me.chanjar.weixin.channel.bean.product.SpuFastInfo; import me.chanjar.weixin.channel.bean.product.SpuGetResponse; +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; import me.chanjar.weixin.channel.bean.product.SpuInfo; import me.chanjar.weixin.channel.bean.product.SpuListResponse; import me.chanjar.weixin.channel.bean.product.SpuUpdateInfo; @@ -206,6 +210,84 @@ WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffTy */ ProductTagLinkResponse getProductTagLink(String productId) throws WxErrorException; + /** + * 添加非卖商品 + * + * @param info 赠品信息 + * @return 赠品商品ID + * @throws WxErrorException 异常 + */ + String addGiftProduct(GiftProductInfo info) throws WxErrorException; + + /** + * 更新非卖商品 + * + * @param info 赠品信息 + * @throws WxErrorException 异常 + */ + void updateGiftProduct(GiftProductInfo info) throws WxErrorException; + + /** + * 在售商品转赠品 + * + * @param productId 商品ID + * @throws WxErrorException 异常 + */ + void setProductAsGift(String productId) throws WxErrorException; + + /** + * 获取赠品 + * + * @param productId 赠品商品ID + * @return 赠品信息 + * @throws WxErrorException 异常 + */ + GiftProductInfo getGiftProduct(String productId) throws WxErrorException; + + /** + * 获取赠品列表 + * + * @param param 查询参数 + * @return 赠品列表 + * @throws WxErrorException 异常 + */ + GiftProductListResponse listGiftProduct(GiftProductListParam param) throws WxErrorException; + + /** + * 更新赠品库存 + * + * @param productId 赠品商品ID + * @param skuId 赠品sku_id + * @param stock 库存值 + * @throws WxErrorException 异常 + */ + void updateGiftStock(String productId, String skuId, Integer stock) throws WxErrorException; + + /** + * 创建赠品活动 + * + * @param info 活动信息 + * @return 活动ID + * @throws WxErrorException 异常 + */ + String addGiftActivity(GiftActivityInfo info) throws WxErrorException; + + /** + * 删除赠品活动 + * + * @param activityId 活动ID + * @throws WxErrorException 异常 + */ + void deleteGiftActivity(String activityId) throws WxErrorException; + + /** + * 停止赠品活动 + * + * @param activityId 活动ID + * @throws WxErrorException 异常 + */ + void stopGiftActivity(String activityId) throws WxErrorException; + /** * 添加限时抢购任务 * diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java index 08c9638f0c..d301ee20d1 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java @@ -4,6 +4,15 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.ADD_LIMIT_TASK_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.CANCEL_AUDIT_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.DELETE_LIMIT_TASK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_ACTIVITY_ADD_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_ACTIVITY_DELETE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_ACTIVITY_STOP_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_ADD_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_GET_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_ON_SALE_SET_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_STOCK_UPDATE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_UPDATE_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.LIST_LIMIT_TASK_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_ADD_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_FREE_UPDATE_URL; @@ -29,6 +38,14 @@ import me.chanjar.weixin.channel.bean.limit.LimitTaskListParam; import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse; import me.chanjar.weixin.channel.bean.limit.LimitTaskParam; +import me.chanjar.weixin.channel.bean.product.GiftActivityAddParam; +import me.chanjar.weixin.channel.bean.product.GiftActivityAddResponse; +import me.chanjar.weixin.channel.bean.product.GiftActivityInfo; +import me.chanjar.weixin.channel.bean.product.GiftProductAddResponse; +import me.chanjar.weixin.channel.bean.product.GiftProductGetResponse; +import me.chanjar.weixin.channel.bean.product.GiftProductInfo; +import me.chanjar.weixin.channel.bean.product.GiftProductListParam; +import me.chanjar.weixin.channel.bean.product.GiftProductListResponse; import me.chanjar.weixin.channel.bean.product.SkuStockBatchParam; import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse; import me.chanjar.weixin.channel.bean.product.SkuStockParam; @@ -211,6 +228,74 @@ public ProductTagLinkResponse getProductTagLink(String productId) throws WxError return ResponseUtils.decode(resJson, ProductTagLinkResponse.class); } + @Override + public String addGiftProduct(GiftProductInfo info) throws WxErrorException { + String reqJson = JsonUtils.encode(info); + String resJson = shopService.post(GIFT_PRODUCT_ADD_URL, reqJson); + GiftProductAddResponse response = ResponseUtils.decode(resJson, GiftProductAddResponse.class); + return response.getProductId(); + } + + @Override + 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); + } + + @Override + 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); + } + + @Override + public GiftProductInfo getGiftProduct(String productId) throws WxErrorException { + String reqJson = "{\"product_id\":\"" + productId + "\"}"; + String resJson = shopService.post(GIFT_PRODUCT_GET_URL, reqJson); + GiftProductGetResponse response = ResponseUtils.decode(resJson, GiftProductGetResponse.class); + return response.getProduct() != null ? response.getProduct() : response.getEditProduct(); + } + + @Override + public GiftProductListResponse listGiftProduct(GiftProductListParam param) throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(GIFT_PRODUCT_LIST_URL, reqJson); + return ResponseUtils.decode(resJson, GiftProductListResponse.class); + } + + @Override + public void updateGiftStock(String productId, String skuId, Integer stock) throws WxErrorException { + SkuStockParam param = new SkuStockParam(productId, skuId, 3, stock); + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(GIFT_PRODUCT_STOCK_UPDATE_URL, reqJson); + ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public String addGiftActivity(GiftActivityInfo info) throws WxErrorException { + GiftActivityAddParam param = new GiftActivityAddParam(info); + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(GIFT_ACTIVITY_ADD_URL, reqJson); + GiftActivityAddResponse response = ResponseUtils.decode(resJson, GiftActivityAddResponse.class); + return response.getActivityId(); + } + + @Override + 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); + } + + @Override + 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); + } + @Override public LimitTaskAddResponse addLimitTask(LimitTaskParam param) throws WxErrorException { String reqJson = JsonUtils.encode(param); diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityAddParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityAddParam.java new file mode 100644 index 0000000000..89a226efc2 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityAddParam.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 创建买赠活动参数 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GiftActivityAddParam implements Serializable { + + private static final long serialVersionUID = -3332952823917162308L; + + @JsonProperty("gift_activity") + private GiftActivityInfo giftActivity; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityAddResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityAddResponse.java new file mode 100644 index 0000000000..e8648246b5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityAddResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 创建买赠活动响应 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class GiftActivityAddResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -4527079816331082871L; + + @JsonProperty("activity_id") + private String activityId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityInfo.java new file mode 100644 index 0000000000..f185fe02bc --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftActivityInfo.java @@ -0,0 +1,92 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; + +/** + * 买赠活动信息 + * + * @author GitHub Copilot + */ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GiftActivityInfo implements Serializable { + + private static final long serialVersionUID = 3970308144375119175L; + + @JsonProperty("activity_id") + private String activityId; + + @JsonProperty("title") + private String title; + + @JsonProperty("start_time") + private Long startTime; + + @JsonProperty("end_time") + private Long endTime; + + @JsonProperty("detail") + private Detail detail; + + @Data + public static class Detail implements Serializable { + private static final long serialVersionUID = 1019081831733485084L; + + @JsonProperty("show_scene") + private Integer showScene; + + @JsonProperty("receive_limit") + private ReceiveLimit receiveLimit; + + @JsonProperty("main_products") + private List mainProducts; + + @JsonProperty("gift_set") + private GiftSet giftSet; + } + + @Data + public static class ReceiveLimit implements Serializable { + private static final long serialVersionUID = 3332293571373311829L; + + @JsonProperty("is_limited") + private Boolean limited; + + @JsonProperty("limit_num") + private Integer limitNum; + } + + @Data + public static class MainProduct implements Serializable { + private static final long serialVersionUID = 6368866030784193437L; + + @JsonProperty("product_id") + private String productId; + } + + @Data + public static class GiftSet implements Serializable { + private static final long serialVersionUID = 8473755235926932739L; + + @JsonProperty("gift_items") + private List giftItems; + + @JsonProperty("gift_set_num") + private Integer giftSetNum; + } + + @Data + public static class GiftItem implements Serializable { + private static final long serialVersionUID = -4130391476834450014L; + + @JsonProperty("gift_id") + private String giftId; + + @JsonProperty("give_num") + private Integer giveNum; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductAddResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductAddResponse.java new file mode 100644 index 0000000000..1548f2293f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductAddResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 添加赠品响应 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class GiftProductAddResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -5971026809157610975L; + + /** 赠品商品ID */ + @JsonProperty("product_id") + private String productId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductGetResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductGetResponse.java new file mode 100644 index 0000000000..07bb99004c --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductGetResponse.java @@ -0,0 +1,28 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 赠品详情响应 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class GiftProductGetResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 5331169221157446692L; + + /** 赠品线上数据 */ + @JsonProperty("product") + private GiftProductInfo product; + + /** 赠品草稿数据 */ + @JsonProperty("edit_product") + private GiftProductInfo editProduct; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductInfo.java new file mode 100644 index 0000000000..732d0b2c2d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductInfo.java @@ -0,0 +1,11 @@ +package me.chanjar.weixin.channel.bean.product; + +/** + * 赠品商品信息 + * + * @author GitHub Copilot + */ +public class GiftProductInfo extends SpuUpdateInfo { + + private static final long serialVersionUID = -4366133550331058445L; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductListParam.java new file mode 100644 index 0000000000..696e6fcc20 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductListParam.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import me.chanjar.weixin.channel.bean.base.StreamPageParam; + +/** + * 赠品列表查询参数 + * + * @author GitHub Copilot + */ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GiftProductListParam extends StreamPageParam { + + private static final long serialVersionUID = 7583500622060651067L; + + /** 赠品状态 */ + @JsonProperty("status") + private Integer status; + + public GiftProductListParam() { + } + + public GiftProductListParam(Integer pageSize, String nextKey, Integer status) { + this.pageSize = pageSize; + this.nextKey = nextKey; + this.status = status; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductListResponse.java new file mode 100644 index 0000000000..21923b9fd3 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/GiftProductListResponse.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 赠品列表响应 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class GiftProductListResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -2734111694780970778L; + + /** 总数 */ + @JsonProperty("total_num") + private Integer totalNum; + + /** 本次翻页的上下文,用于请求下一页 */ + @JsonProperty("next_key") + private String nextKey; + + /** 赠品商品 id 列表 */ + @JsonProperty("product_ids") + private List ids; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java index 6c2076d85b..5f7858c459 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java @@ -153,6 +153,24 @@ public interface Spu { String SPU_GET_STOCK_BATCH_URL = "https://api.weixin.qq.com/channels/ec/product/stock/batchget"; /** 更新商品库存 */ String SPU_UPDATE_STOCK_URL = "https://api.weixin.qq.com/channels/ec/product/stock/update"; + /** 添加非卖商品 */ + String GIFT_PRODUCT_ADD_URL = "https://api.weixin.qq.com/channels/ec/product/gift/add"; + /** 更新非卖商品 */ + String GIFT_PRODUCT_UPDATE_URL = "https://api.weixin.qq.com/channels/ec/product/gift/update"; + /** 在售商品转赠品 */ + String GIFT_PRODUCT_ON_SALE_SET_URL = "https://api.weixin.qq.com/channels/ec/product/gift/onsale/set"; + /** 获取赠品 */ + String GIFT_PRODUCT_GET_URL = "https://api.weixin.qq.com/channels/ec/product/gift/get"; + /** 获取赠品列表 */ + String GIFT_PRODUCT_LIST_URL = "https://api.weixin.qq.com/channels/ec/product/gift/list/get"; + /** 更新赠品库存 */ + String GIFT_PRODUCT_STOCK_UPDATE_URL = "https://api.weixin.qq.com/channels/ec/product/gift/stock/update"; + /** 创建赠品活动 */ + String GIFT_ACTIVITY_ADD_URL = "https://api.weixin.qq.com/channels/ec/product/activity/add"; + /** 删除赠品活动 */ + String GIFT_ACTIVITY_DELETE_URL = "https://api.weixin.qq.com/channels/ec/product/activity/del"; + /** 停止赠品活动 */ + String GIFT_ACTIVITY_STOP_URL = "https://api.weixin.qq.com/channels/ec/product/activity/stop"; /** 添加限时抢购任务 */ String ADD_LIMIT_TASK_URL = "https://api.weixin.qq.com/channels/ec/product/limiteddiscounttask/add"; /** 拉取限时抢购任务列表 */ diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImplTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImplTest.java index ed83434ee0..5e9b93c2d1 100644 --- a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImplTest.java +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImplTest.java @@ -12,6 +12,10 @@ import me.chanjar.weixin.channel.bean.limit.LimitTaskAddResponse; import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse; import me.chanjar.weixin.channel.bean.limit.LimitTaskParam; +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; import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse; import me.chanjar.weixin.channel.bean.product.SkuStockResponse; import me.chanjar.weixin.channel.bean.product.SpuGetResponse; @@ -212,4 +216,67 @@ public void testDeleteLimitTask() throws WxErrorException { assertNotNull(response); assertTrue(response.isSuccess()); } + + @Test + public void testAddGiftProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + GiftProductInfo info = new GiftProductInfo(); + String response = productService.addGiftProduct(info); + assertNotNull(response); + } + + @Test + public void testUpdateGiftProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + GiftProductInfo info = new GiftProductInfo(); + productService.updateGiftProduct(info); + } + + @Test + public void testSetProductAsGift() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + productService.setProductAsGift(""); + } + + @Test + public void testGetGiftProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + GiftProductInfo response = productService.getGiftProduct(""); + assertNotNull(response); + } + + @Test + public void testListGiftProduct() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + GiftProductListParam param = new GiftProductListParam(10, null, null); + GiftProductListResponse response = productService.listGiftProduct(param); + assertNotNull(response); + assertTrue(response.isSuccess()); + } + + @Test + public void testUpdateGiftStock() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + productService.updateGiftStock("", "", 10); + } + + @Test + public void testAddGiftActivity() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + GiftActivityInfo info = new GiftActivityInfo(); + String response = productService.addGiftActivity(info); + assertNotNull(response); + } + + @Test + public void testDeleteGiftActivity() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + productService.deleteGiftActivity(""); + } + + @Test + public void testStopGiftActivity() throws WxErrorException { + WxChannelProductService productService = channelService.getProductService(); + productService.stopGiftActivity(""); + } }