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
wxma shop spu
Signed-off-by: WangLei <904443972@qq.com>
  • Loading branch information
wangleiin committed Mar 23, 2021
commit d7dcad4a45da1d70b6fdd602ef1abcd90a393d9f
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
package cn.binarywang.wx.miniapp.api;

import cn.binarywang.wx.miniapp.bean.shop.WxMaShopSpuInfo;
import cn.binarywang.wx.miniapp.bean.shop.WxMaShopSpuWithoutAuditInfo;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopSpuPageRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAddSpuResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopGetSpuListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopGetSpuResponse;
import me.chanjar.weixin.common.error.WxErrorException;

/**
* 小程序交易组件-商品服务
*
* @author boris
*/
public interface WxMaShopSpuService {
WxMaShopAddSpuResponse addSpu(WxMaShopSpuInfo spuInfo) throws WxErrorException;

WxMaShopBaseResponse deleteSpu(Integer productId, String outProductId) throws WxErrorException;

WxMaShopGetSpuResponse getSpu(Integer productId, String outProductId, Integer needEditSpu)
throws WxErrorException;

WxMaShopGetSpuListResponse getSpuList(WxMaShopSpuPageRequest request)
throws WxErrorException;

WxMaShopAddSpuResponse updateSpu(WxMaShopSpuInfo spuInfo) throws WxErrorException;

WxMaShopAddSpuResponse updateSpuWithoutAudit(WxMaShopSpuWithoutAuditInfo spuInfo)
throws WxErrorException;

WxMaShopBaseResponse listingSpu(Integer productId, String outProductId)
throws WxErrorException;

WxMaShopBaseResponse delistingSpu(Integer productId, String outProductId)
throws WxErrorException;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
package cn.binarywang.wx.miniapp.api.impl;

import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.SPU_ADD_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.SPU_DELISTING_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.SPU_DEL_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.SPU_GET_LIST_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.SPU_GET_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.SPU_LISTING_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.SPU_UPDATE_URL;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Spu.SPU_UPDATE_WITHOUT_URL;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.WxMaShopSpuService;
import cn.binarywang.wx.miniapp.bean.shop.WxMaShopSpuInfo;
import cn.binarywang.wx.miniapp.bean.shop.WxMaShopSpuWithoutAuditInfo;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopSpuPageRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAddSpuResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopGetSpuListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopGetSpuResponse;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.json.GsonHelper;

/**
* @author boris
Expand All @@ -12,6 +31,67 @@
@Slf4j
public class WxMaShopSpuServiceImpl implements WxMaShopSpuService {

private final WxMaService service;
private final WxMaService wxMaService;

@Override
public WxMaShopAddSpuResponse addSpu(WxMaShopSpuInfo spuInfo) throws WxErrorException {
String responseContent = this.wxMaService.post(SPU_ADD_URL, spuInfo);
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAddSpuResponse.class);
}

@Override
public WxMaShopBaseResponse deleteSpu(Integer productId, String outProductId)
throws WxErrorException {
String responseContent = this.wxMaService
.post(SPU_DEL_URL, GsonHelper.buildJsonObject("product_id", productId,
"out_product_id", outProductId));
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}

@Override
public WxMaShopGetSpuResponse getSpu(Integer productId, String outProductId, Integer needEditSpu)
throws WxErrorException {
String responseContent = this.wxMaService
.post(SPU_GET_URL, GsonHelper.buildJsonObject("product_id", productId,
"out_product_id", outProductId, "need_edit_spu", needEditSpu));
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopGetSpuResponse.class);
}

@Override
public WxMaShopGetSpuListResponse getSpuList(WxMaShopSpuPageRequest request)
throws WxErrorException {
String responseContent = this.wxMaService.post(SPU_GET_LIST_URL, request);
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopGetSpuListResponse.class);
}

@Override
public WxMaShopAddSpuResponse updateSpu(WxMaShopSpuInfo spuInfo) throws WxErrorException {
String responseContent = this.wxMaService.post(SPU_UPDATE_URL, spuInfo);
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAddSpuResponse.class);
}

@Override
public WxMaShopAddSpuResponse updateSpuWithoutAudit(WxMaShopSpuWithoutAuditInfo spuInfo)
throws WxErrorException {
String responseContent = this.wxMaService.post(SPU_UPDATE_WITHOUT_URL, spuInfo);
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAddSpuResponse.class);
}

@Override
public WxMaShopBaseResponse listingSpu(Integer productId, String outProductId)
throws WxErrorException {
String responseContent = this.wxMaService
.post(SPU_LISTING_URL, GsonHelper.buildJsonObject("product_id", productId,
"out_product_id", outProductId));
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}

@Override
public WxMaShopBaseResponse delistingSpu(Integer productId, String outProductId)
throws WxErrorException {
String responseContent = this.wxMaService
.post(SPU_DELISTING_URL, GsonHelper.buildJsonObject("product_id", productId,
"out_product_id", outProductId));
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package cn.binarywang.wx.miniapp.bean.shop;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.Data;

/**
* @author leiin
* @date 2021/3/23
* @description: 添加商品参数返回
*/
@Data
public class WxMaShopAddSpuResult implements Serializable {

private static final long serialVersionUID = 2520459849240776617L;
/**
* 交易组件平台内部商品ID
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("product_id")
private String productId;

/**
* 商家自定义商品ID
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("out_product_id")
private String outProductId;

/**
* 创建时间,新建时返回
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("create_time")
private String createTime;

/**
* 更新时间,修改时返回
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("update_time")
private String updateTime;
/**
* sku数组
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("skus")
private List<WxMaShopSkuResult> skus;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package cn.binarywang.wx.miniapp.bean.shop;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;

/**
* @author leiin
* @date 2021/3/23
* @description:
*/
@Data
public class WxMaShopGetSpuResult extends WxMaShopSpuInfo implements Serializable {

private static final long serialVersionUID = -3859372286926181933L;
/**
* 商品审核信息
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("audit_info")
private WxMaShopSpuAudit auditInfo;

/**
* 商品线上状态
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("status")
private Integer status;

/**
* 商品草稿状态
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("edit_status")
private Integer editStatus;
/**
* 创建时间
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("create_time")
private String createTime;

/**
* 更新时间
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("update_time")
private String updateTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class WxMaShopSkuInfo implements Serializable {
* </pre>
*/
@SerializedName("out_product_id")
private String productId;
private String outProductId;

/**
* 商家自定义商品ID
Expand All @@ -41,7 +41,7 @@ public class WxMaShopSkuInfo implements Serializable {
* </pre>
*/
@SerializedName("out_sku_id")
private String skuId;
private String outSkuId;


/**
Expand Down Expand Up @@ -71,6 +71,15 @@ public class WxMaShopSkuInfo implements Serializable {
@SerializedName("market_price")
private Integer market_price;

/**
* 库存
* <pre>
* 是否必填:是
* </pre>
*/
@SerializedName("stock_num")
private Integer stockNum;


/**
* 条形码
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cn.binarywang.wx.miniapp.bean.shop;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;

/**
* @author leiin
* @date 2021/3/23
* @description:
*/
@Data
public class WxMaShopSkuResult implements Serializable {

private static final long serialVersionUID = 7127892618805299305L;
/**
* 交易组件平台自定义skuID
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("sku_id")
private String skuId;

/**
* 商家自定义skuID
* <pre>
* 是否必填:
* </pre>
*/
@SerializedName("out_sku_id")
private String outSkuId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package cn.binarywang.wx.miniapp.bean.shop;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;

/**
* @author leiin
* @date 2021/3/23
* @description:
*/
@Data
public class WxMaShopSkuWithoutAuditInfo implements Serializable {

private static final long serialVersionUID = 3354108922805323888L;

/**
* 商家自定义skuID
* <pre>
* 是否必填: 是
* </pre>
*/
@SerializedName("out_sku_id")
private String outSkuId;

/**
* 售卖价格,以分为单位
* <pre>
* 是否必填: 是
* </pre>
*/
@SerializedName("sale_price")
private Integer salePrice;

/**
* 售卖价格,以分为单位
* <pre>
* 是否必填: 是
* </pre>
*/
@SerializedName("market_price")
private Integer market_price;

/**
* 库存
* <pre>
* 是否必填:是
* </pre>
*/
@SerializedName("stock_num")
private Integer stockNum;


/**
* 条形码
* <pre>
* 是否必填: 否
* </pre>
*/
@SerializedName("barcode")
private String barcode;


/**
* 商品编码
* <pre>
* 是否必填: 否
* </pre>
*/
@SerializedName("sku_code")
private String skuCode;
}
Loading