Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +13 to +16
import me.chanjar.weixin.channel.bean.product.SpuInfo;
import me.chanjar.weixin.channel.bean.product.SpuListResponse;
import me.chanjar.weixin.channel.bean.product.SpuUpdateInfo;
Expand Down Expand Up @@ -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;

/**
* 添加限时抢购任务
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Comment on lines +235 to +236
}

@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();
Comment on lines +257 to +258
}

@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();
Comment on lines +281 to +282
}

@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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<MainProduct> 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<GiftItem> 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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
Loading