Visitar URL original
【视频号】更新视频号小店/微信小店类目、订单、商品、主页管理相关接口,补充starter文档 by lixize · Pull Request #3426 · binarywang/WxJava · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
🎨 【视频号】新增批量修改库存、获取商品获取H5短链/二维码/口令接口,更新添加商品接口
  • Loading branch information
lixize committed Nov 29, 2024
commit 01869d7407cc811c8a6895cbe4b5d1ba47588378
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
package me.chanjar.weixin.channel.api;


import java.util.List;
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
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.SkuStockBatchResponse;
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.SpuInfo;
import me.chanjar.weixin.channel.bean.product.SpuListResponse;
import me.chanjar.weixin.channel.bean.product.SpuUpdateInfo;
import me.chanjar.weixin.channel.bean.product.SpuUpdateResponse;
import me.chanjar.weixin.channel.bean.product.link.ProductH5UrlResponse;
import me.chanjar.weixin.channel.bean.product.link.ProductQrCodeResponse;
import me.chanjar.weixin.channel.bean.product.link.ProductTagLinkResponse;
import me.chanjar.weixin.common.error.WxErrorException;

/**
* 视频号小店 商品服务接口
*
* @author <a href="https://github.com/lixize">Zeyes</a>
* @see <a href="https://developers.weixin.qq.com/doc/store/API/product/product_status.html">商品状态流转图</a>
*/
public interface WxChannelProductService {

Expand All @@ -27,6 +35,28 @@ public interface WxChannelProductService {
*
* @throws WxErrorException 异常
*/
SpuUpdateResponse addProduct(SpuUpdateInfo info) throws WxErrorException;

/**
* 更新商品
*
* @param info 商品信息
* @return 返回商品的状态和id
*
* @throws WxErrorException 异常
*/
SpuUpdateResponse updateProduct(SpuUpdateInfo info) throws WxErrorException;

/**
* 添加商品
*
* @param info 商品信息
* @return 返回商品的状态和id
*
* @throws WxErrorException 异常
* @deprecated 请使用 {@link #addProduct(SpuUpdateInfo)}
*/
@Deprecated
SpuUpdateResponse addProduct(SpuInfo info) throws WxErrorException;

/**
Expand All @@ -36,15 +66,28 @@ public interface WxChannelProductService {
* @return 返回商品的状态和id
*
* @throws WxErrorException 异常
* @deprecated 请使用 {@link #updateProduct(SpuUpdateInfo)}
*/
@Deprecated
SpuUpdateResponse updateProduct(SpuInfo info) throws WxErrorException;

/**
* 免审更新商品
*
* @param info 商品信息
* @return 返回商品的状态和id
*
* @throws WxErrorException 异常
*/
WxChannelBaseResponse updateProductAuditFree(SpuFastInfo info) throws WxErrorException;

/**
* 更新商品库存 (仅对edit_status != 2 的商品适用,其他状态的商品无法通过该接口修改库存)
*
* @param productId 内部商品ID
* @param skuId 内部sku_id
* @param diffType 修改类型 1增加 2减少 3设置
* 建议使用1或2,不建议使用3,因为使用3在高并发场景可能会出现预期外表现
* @param num 增加、减少或者设置的库存值
* @return WxChannelBaseResponse
*
Expand Down Expand Up @@ -127,6 +170,42 @@ WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffTy
*/
SkuStockResponse getSkuStock(String productId, String skuId) throws WxErrorException;

/**
* 批量获取库存信息 (单次请求不能超过50个商品ID)
*
* @param productIds 商品ID列表
* @return 库存信息
* @throws WxErrorException 异常
*/
SkuStockBatchResponse getSkuStockBatch(List<String> productIds) throws WxErrorException;

/**
* 获取商品H5链接
*
* @param productId 商品ID
* @return 商品H5链接
* @throws WxErrorException 异常
*/
ProductH5UrlResponse getProductH5Url(String productId) throws WxErrorException;

/**
* 获取商品二维码
*
* @param productId 商品ID
* @return 商品二维码
* @throws WxErrorException 异常
*/
ProductQrCodeResponse getProductQrCode(String productId) throws WxErrorException;

/**
* 获取商品口令
*
* @param productId 商品ID
* @return 商品口令
* @throws WxErrorException 异常
*/
ProductTagLinkResponse getProductTagLink(String productId) throws WxErrorException;

/**
* 添加限时抢购任务
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,43 @@
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.DELETE_LIMIT_TASK_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;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DELISTING_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DEL_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_BATCH_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_H5URL_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LISTING_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LIST_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_QRCODE_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_TAGLINK_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_STOCK_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.STOP_LIMIT_TASK_URL;

import java.util.List;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.channel.api.WxChannelProductService;
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
import me.chanjar.weixin.channel.bean.limit.LimitTaskAddResponse;
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.SkuStockBatchParam;
import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse;
import me.chanjar.weixin.channel.bean.product.SkuStockParam;
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.SpuInfo;
import me.chanjar.weixin.channel.bean.product.SpuListParam;
import me.chanjar.weixin.channel.bean.product.SpuListResponse;
import me.chanjar.weixin.channel.bean.product.SpuUpdateInfo;
import me.chanjar.weixin.channel.bean.product.SpuUpdateResponse;
import me.chanjar.weixin.channel.bean.product.link.ProductH5UrlResponse;
import me.chanjar.weixin.channel.bean.product.link.ProductQrCodeResponse;
import me.chanjar.weixin.channel.bean.product.link.ProductTagLinkResponse;
import me.chanjar.weixin.channel.util.JsonUtils;
import me.chanjar.weixin.channel.util.ResponseUtils;
import me.chanjar.weixin.common.error.WxErrorException;
Expand All @@ -49,6 +62,20 @@ public WxChannelProductServiceImpl(BaseWxChannelServiceImpl shopService) {
this.shopService = shopService;
}

@Override
public SpuUpdateResponse addProduct(SpuUpdateInfo info) throws WxErrorException {
String reqJson = JsonUtils.encode(info);
String resJson = shopService.post(SPU_ADD_URL, reqJson);
return ResponseUtils.decode(resJson, SpuUpdateResponse.class);
}

@Override
public SpuUpdateResponse updateProduct(SpuUpdateInfo info) throws WxErrorException {
String reqJson = JsonUtils.encode(info);
String resJson = shopService.post(SPU_UPDATE_URL, reqJson);
return ResponseUtils.decode(resJson, SpuUpdateResponse.class);
}

@Override
public SpuUpdateResponse addProduct(SpuInfo info) throws WxErrorException {
String reqJson = JsonUtils.encode(info);
Expand All @@ -63,6 +90,13 @@ public SpuUpdateResponse updateProduct(SpuInfo info) throws WxErrorException {
return ResponseUtils.decode(resJson, SpuUpdateResponse.class);
}

@Override
public WxChannelBaseResponse updateProductAuditFree(SpuFastInfo info) throws WxErrorException {
String reqJson = JsonUtils.encode(info);
String resJson = shopService.post(SPU_AUDIT_FREE_UPDATE_URL, reqJson);
return ResponseUtils.decode(resJson, SpuUpdateResponse.class);
}

@Override
public WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffType, Integer num)
throws WxErrorException {
Expand Down Expand Up @@ -148,6 +182,35 @@ public SkuStockResponse getSkuStock(String productId, String skuId) throws WxErr
return ResponseUtils.decode(resJson, SkuStockResponse.class);
}

@Override
public SkuStockBatchResponse getSkuStockBatch(List<String> productIds) throws WxErrorException {
SkuStockBatchParam param = new SkuStockBatchParam(productIds);
String reqJson = JsonUtils.encode(param);
String resJson = shopService.post(SPU_GET_STOCK_BATCH_URL, reqJson);
return ResponseUtils.decode(resJson, SkuStockBatchResponse.class);
}

@Override
public ProductH5UrlResponse getProductH5Url(String productId) throws WxErrorException {
String reqJson = "{\"product_id\":\"" + productId + "\"}";
String resJson = shopService.post(SPU_H5URL_URL, reqJson);
return ResponseUtils.decode(resJson, ProductH5UrlResponse.class);
}

@Override
public ProductQrCodeResponse getProductQrCode(String productId) throws WxErrorException {
String reqJson = "{\"product_id\":\"" + productId + "\"}";
String resJson = shopService.post(SPU_QRCODE_URL, reqJson);
return ResponseUtils.decode(resJson, ProductQrCodeResponse.class);
}

@Override
public ProductTagLinkResponse getProductTagLink(String productId) throws WxErrorException {
String reqJson = "{\"product_id\":\"" + productId + "\"}";
String resJson = shopService.post(SPU_TAGLINK_URL, reqJson);
return ResponseUtils.decode(resJson, ProductTagLinkResponse.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
Expand Up @@ -20,4 +20,20 @@ public class ExtraServiceInfo implements Serializable {
*/
@JsonProperty("seven_day_return")
private Integer sevenDayReturn;

/** 先用后付,0-不支持先用后付,1-支持先用后付。若店铺已开通先用后付,支持先用后付的类目商品将在上架后自动打开先用后付。 */
@JsonProperty("pay_after_use")
private Integer payAfterUse;

/** 是否支持运费险,0-不支持运费险,1-支持运费险。需要商户开通运费险服务,且当前类目支持运费险才会生效。 */
@JsonProperty("freight_insurance")
private Integer freightInsurance;

/** 是否支持假一赔三,0-不支持假一赔三,1-支持假一赔三。 */
@JsonProperty("fake_one_pay_three")
private Integer fakeOnePayThree;

/** 是否支持坏损包退,0-不支持坏损包退,1-支持坏损包退。 */
@JsonProperty("damage_guarantee")
private Integer damageGuarantee;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package me.chanjar.weixin.channel.bean.product;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 商品资质信息
*
* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProductQuaInfo implements Serializable {

private static final long serialVersionUID = -71766140204505768L;

/** 商品资质id,对应获取类目信息中的字段product_qua_list[].qua_id */
@JsonProperty("qua_id")
private String quaId;

/** 商品资质图片列表 */
@JsonProperty("qua_url")
private List<String> quaUrl;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 <a href="https://github.com/lixize">Zeyes</a>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProductSaleLimitInfo implements Serializable {

/** 是否受到管控,商品存在售卖限制时,固定返回1 */
@JsonProperty("is_limited")
private Integer limited;

/** 售卖限制标题 */
@JsonProperty("title")
private String title;

/** 售卖限制描述 */
@JsonProperty("sub_title")
private String subTitle;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package me.chanjar.weixin.channel.bean.product;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 免审商品更新Sku数据
*
* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Data
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SkuFastInfo implements Serializable {

/** sku_id */
@JsonProperty("sku_id")
private String skuId;

/** 售卖价格,以分为单位,数字类型,最大不超过10000000(1000万元) */
@JsonProperty("sale_price")
private Integer salePrice;

@JsonProperty("stock_info")
private StockInfo stockInfo;

/** sku发货信息 */
@JsonProperty("sku_deliver_info")
private SkuDeliverInfo skuDeliverInfo;

/** 是否要删除当前sku */
@JsonProperty("is_delete")
private Boolean delete;


@Data
@NoArgsConstructor
public static class StockInfo implements Serializable {

/** 修改类型。1: 增加;2:减少;3:设置 */
@JsonProperty("diff_type")
protected Integer diffType;

/** 增加、减少或者设置的库存值 */
@JsonProperty("num")
protected Integer num;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class SkuInfo implements Serializable {

/** skuID */
@JsonProperty("sku_id")
private Long skuId;
private String skuId;

public SkuInfo() {
}
Expand Down
Loading