🆕 #2048 【开放平台】实现小商店的部分接口

This commit is contained in:
kelvenlaw
2021-07-03 21:06:02 +08:00
committed by GitHub
parent fb0460e1a1
commit eaa517359a
65 changed files with 3538 additions and 3 deletions

View File

@@ -0,0 +1,40 @@
package me.chanjar.weixin.common.bean.result;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
@Data
public class WxMinishopImageUploadResult implements Serializable {
private static final long serialVersionUID = 330834334738622332L;
private String errcode;
private String errmsg;
private WxMinishopPicFileResult picFile;
public static WxMinishopImageUploadResult fromJson(String json) {
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
WxMinishopImageUploadResult result = new WxMinishopImageUploadResult();
result.setErrcode(jsonObject.get("errcode").getAsNumber().toString());
if (result.getErrcode().equals("0")) {
WxMinishopPicFileResult picFileResult = new WxMinishopPicFileResult();
JsonObject picObject = jsonObject.get("pic_file").getAsJsonObject();
picFileResult.setMediaId(picObject.get("media_id").getAsString());
picFileResult.setPayMediaId(picObject.get("pay_media_id").getAsString());
result.setPicFile(picFileResult);
}
return result;
}
@Override
public String toString() {
return WxGsonBuilder.create().toJson(this);
}
}

View File

@@ -0,0 +1,11 @@
package me.chanjar.weixin.common.bean.result;
import lombok.Data;
import java.io.Serializable;
@Data
public class WxMinishopPicFileResult implements Serializable {
private String mediaId;
private String payMediaId;
}

View File

@@ -0,0 +1,37 @@
package me.chanjar.weixin.common.util.http;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheMinishopMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMinishopMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMinishopMediaUploadRequestExecutor;
import java.io.File;
import java.io.IOException;
public abstract class MinishopUploadRequestExecutor<H, P> implements RequestExecutor<WxMinishopImageUploadResult, File> {
protected RequestHttp<H, P> requestHttp;
public MinishopUploadRequestExecutor(RequestHttp requestHttp) {
this.requestHttp = requestHttp;
}
@Override
public void execute(String uri, File data, ResponseHandler<WxMinishopImageUploadResult> handler, WxType wxType) throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
public static RequestExecutor<WxMinishopImageUploadResult, File> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ApacheMinishopMediaUploadRequestExecutor(requestHttp);
case JODD_HTTP:
return new JoddHttpMinishopMediaUploadRequestExecutor(requestHttp);
case OK_HTTP:
return new OkHttpMinishopMediaUploadRequestExecutor(requestHttp);
default:
return null;
}
}
}

View File

@@ -0,0 +1,59 @@
package me.chanjar.weixin.common.util.http.apache;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
/**
* Created by ecoolper on 2017/5/5.
*/
@Slf4j
public class ApacheMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheMinishopMediaUploadRequestExecutor(RequestHttp requestHttp) {
super(requestHttp);
}
@Override
public WxMinishopImageUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", file)
.setMode(HttpMultipartMode.RFC6532)
.build();
httpPost.setEntity(entity);
}
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: " + responseContent);
return WxMinishopImageUploadResult.fromJson(responseContent);
} finally {
httpPost.releaseConnection();
}
}
}

View File

@@ -0,0 +1,53 @@
package me.chanjar.weixin.common.util.http.jodd;
import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* .
*
* @author ecoolper
* @date 2017/5/5
*/
@Slf4j
public class JoddHttpMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> {
public JoddHttpMinishopMediaUploadRequestExecutor(RequestHttp requestHttp) {
super(requestHttp);
}
@Override
public WxMinishopImageUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
}
request.withConnectionProvider(requestHttp.getRequestHttpClient());
request.form("media", file);
HttpResponse response = request.send();
response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: " + responseContent);
return WxMinishopImageUploadResult.fromJson(responseContent);
}
}

View File

@@ -0,0 +1,51 @@
package me.chanjar.weixin.common.util.http.okhttp;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.MinishopUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import okhttp3.*;
import java.io.File;
import java.io.IOException;
/**
* .
*
* @author ecoolper
* @date 2017/5/5
*/
@Slf4j
public class OkHttpMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
public OkHttpMinishopMediaUploadRequestExecutor(RequestHttp requestHttp) {
super(requestHttp);
}
@Override
public WxMinishopImageUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
RequestBody body = new MultipartBody.Builder()
.setType(MediaType.parse("multipart/form-data"))
.addFormDataPart("media",
file.getName(),
RequestBody.create(MediaType.parse("application/octet-stream"), file))
.build();
Request request = new Request.Builder().url(uri).post(body).build();
Response response = requestHttp.getRequestHttpClient().newCall(request).execute();
String responseContent = response.body().string();
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
log.info("responseContent: " + responseContent);
return WxMinishopImageUploadResult.fromJson(responseContent);
}
}

View File

@@ -300,6 +300,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
* @throws WxErrorException 异常
*/
protected String extractAccessToken(String resultContent) throws WxErrorException {
log.info("resultContent: " + resultContent);
WxMaConfig config = this.getWxMaConfig();
WxError error = WxError.fromJson(resultContent, WxType.MiniApp);
if (error.getErrorCode() != 0) {

View File

@@ -1,6 +1,9 @@
package me.chanjar.weixin.open.api;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
@@ -8,8 +11,14 @@ import me.chanjar.weixin.open.bean.WxOpenCreateResult;
import me.chanjar.weixin.open.bean.WxOpenGetResult;
import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate;
import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
import me.chanjar.weixin.open.bean.minishop.*;
import me.chanjar.weixin.open.bean.minishop.coupon.WxMinishopCoupon;
import me.chanjar.weixin.open.bean.minishop.coupon.WxMinishopCouponStock;
import me.chanjar.weixin.open.bean.minishop.goods.*;
import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountGoods;
import me.chanjar.weixin.open.bean.result.*;
import java.io.File;
import java.util.List;
/**
@@ -127,6 +136,38 @@ public interface WxOpenComponentService {
*/
String DELETE_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/deletetemplate";
String REGISTER_SHOP_URL = "https://api.weixin.qq.com/product/register/register_shop";
String CHECK_SHOP_AUDITSTATUS_URL = "https://api.weixin.qq.com/product/register/check_audit_status";
String SUBMIT_MERCHANTINFO_URL = "https://api.weixin.qq.com/product/register/submit_merchantinfo";
String SUBMIT_BASICINFO_URL = "https://api.weixin.qq.com/product/register/submit_basicinfo";
String UPLOAD_IMAGE_URL = "https://api.weixin.qq.com/product/img/upload";
String MINISHOP_CATEGORY_GET_URL = "https://api.weixin.qq.com/product/category/get";
String MINISHOP_BRAND_GET_URL = "https://api.weixin.qq.com/product/brand/get";
String MINISHOP_DELIVERY_TEMPLATE_GET_URL = "https://api.weixin.qq.com/product/delivery/get_freight_template";
String MINISHOP_SHOPCATEGORY_GET_URL = "https://api.weixin.qq.com/product/store/get_shopcat";
String MINISHOP_CREATE_COUPON_URL = "https://api.weixin.qq.com/product/coupon/create";
String MINISHOP_GET_COUPON_LIST = "https://api.weixin.qq.com/product/coupon/get_list";
String MINISHOP_PUSH_COUPON = "https://api.weixin.qq.com/product/coupon/push";
String MINISHOP_UPDATE_COUPON_URL = "https://api.weixin.qq.com/product/coupon/update";
String MINISHOP_UPDATE_COUPON_STATUS_URL = "https://api.weixin.qq.com/product/coupon/update_status";
String MINISHOP_GET_DELIVERY_COMPANY_URL = "https://api.weixin.qq.com/product/delivery/get_company_list";
/**
* Gets wx mp service by appid.
*
@@ -153,6 +194,15 @@ public interface WxOpenComponentService {
@Deprecated
WxOpenFastMaService getWxFastMaServiceByAppid(String appid);
/**
* 获取指定appid的小商店服务
*
* @param appid
* @return
*/
WxOpenMinishopService getWxMinishopServiceByAppid(String appid);
/**
* Gets wx open config storage.
*
@@ -508,4 +558,372 @@ public interface WxOpenComponentService {
* @throws WxErrorException .
*/
WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWechat, String legalPersonaName) throws WxErrorException;
/**
* https://api.weixin.qq.com/product/register/register_shop?component_access_token=xxxxxxxxx
* 注册小商店账号
*
* @param wxName 微信号(必填)
* @param idCardName 身份证姓名(必填)
* @param idCardNumber 身份证号(必填)
* @param channelId 渠道号,服务商后台生成渠道信息。(选填)
* @param apiOpenstoreType 1-整店打包开通小商店2-组件开放(开通小程序,并且已经完整的嵌入电商功能)(必填)
* @param authPageUrl 授权url选填
* @return the wx open result
* @throws WxErrorException
*/
WxOpenResult registerShop(String wxName, String idCardName, String idCardNumber, String channelId, Integer apiOpenstoreType, String authPageUrl) throws WxErrorException;
/**
* https://api.weixin.qq.com/product/register/check_audit_status
* 异步状态查询
* @param wxName 微信号
* @return
*/
String checkAuditStatus(String wxName) throws WxErrorException;
/**
* 已经获取到小商店的appId那么需要通过accesstoken来获取该小商店的状态
* @param appId
* @param wxName
* @return
* @throws WxErrorException
*/
String checkAuditStatus(String appId, String wxName) throws WxErrorException;
/**
*
* @param appId
* @param subjectType
* @param busiLicense
* @param organizationCodeInfo
* @param idcardInfo
* @param superAdministratorInfo
* @param merchantShoprtName
* @return
*/
WxOpenResult submitMerchantInfo(String appId, String subjectType, MinishopBusiLicense busiLicense, MinishopOrganizationCodeInfo organizationCodeInfo, MinishopIdcardInfo idcardInfo, MinishopSuperAdministratorInfo superAdministratorInfo, String merchantShoprtName) throws WxErrorException;
/**
*
* @param appId
* @param nameInfo
* @param returnInfo
* @return
* @throws WxErrorException
*/
WxOpenResult submitBasicInfo(String appId, MinishopNameInfo nameInfo, MinishopReturnInfo returnInfo) throws WxErrorException;
/**
*
* @param height
* @param width
* @param file
* @return
* @throws WxErrorException
*/
WxMinishopImageUploadResult uploadMinishopImagePicFile(String appId, Integer height, Integer width, File file) throws WxErrorException;
/**
* 获取小商店的类目详情
* @param appId小商店APPID
* @param fCatId父类目ID可先填0获取根部类目
* @return 小商店类目信息列表
*/
MinishopCategories getMinishopCategories(String appId, Integer fCatId) throws WxErrorException;
/**
* 获取小商店品牌信息
* @param appId小商店appID
* @return
*/
MinishopBrandList getMinishopBrands(String appId) throws WxErrorException;
/**
* 获取小商店运费模版信息
* @param appId小商店appID
* @return
*/
MinishopDeliveryTemplateResult getMinishopDeliveryTemplate(String appId) throws WxErrorException;
/**
* 获取小商店商品分类信息
* @param appId
* @return
*/
MinishopShopCatList getMinishopCatList(String appId) throws WxErrorException;
/**
* 获取小商店的快递公司列表
* @param appId
* @return
* @throws WxErrorException
*/
WxMinishopAddGoodsSpuResult<List<WxMinishopDeliveryCompany>> getMinishopDeliveryCompany(String appId) throws WxErrorException;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//小商店优惠券接口
/**
* 创建小商店优惠券
* @param appId小商店的appId
* @param couponInfo 优惠券信息
* @return couponId: 优惠券ID
* @throws WxErrorException
*/
Integer minishopCreateCoupon(String appId, WxMinishopCoupon couponInfo) throws WxErrorException;
/**
* 与小商店对接,获取小商店的优惠券信息
* @param appId小商店的appId
* @param startCreateTime优惠券创建时间的搜索开始时间
* @param endCreateTime优惠券创建时间的搜索结束时间
* @param status优惠券状态
* @param page第几页最小填1
* @param pageSize每页数量(不超过10,000)
* @return
* @throws WxErrorException
*/
WxMinishopCouponStock minishopGetCouponList(String appId, String startCreateTime, String endCreateTime, Integer status, Integer page, Integer pageSize) throws WxErrorException;
/**
* 与小商店对接,将优惠券发送给某人
* @param appid小商店appId
* @param openId优惠券接收人的openId
* @param couponId: 优惠券ID
* @return
*/
WxOpenResult minishopPushCouponToUser(String appid, String openId, Integer couponId) throws WxErrorException;
/**
* 与小商店对接,更新商城优惠券
* @param appId
* @param couponInfo
* @return
* @throws WxErrorException
*/
Integer minishopUpdateCoupon(String appId, WxMinishopCoupon couponInfo) throws WxErrorException;
/**
* 从优惠券创建后status=1可流转到2,4,5, COUPON_STATUS_VALID = 2 ;//生效 COUPON_STATUS_INVALID = 4 ;//已作废 COUPON_STATUS_DEL = 5;//删除
* @param appId
* @param couponId
* @param status
* @return
* @throws WxErrorException
*/
WxOpenResult minishopUpdateCouponStatus(String appId, Integer couponId, Integer status) throws WxErrorException;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//小商店spu接口
String MINISHOP_ADD_SPU_URL = "https://api.weixin.qq.com/product/spu/add";
String MINISHOP_DEL_SPU_URL = "https://api.weixin.qq.com/product/spu/del";
String MINISHOP_UPDATE_SPU_URL = "https://api.weixin.qq.com/product/spu/update";
String MINISHOP_LISTING_SPU_URL = "https://api.weixin.qq.com/product/spu/listing";
String MINISHOP_DELISTING_SPU_URL = "https://api.weixin.qq.com/product/spu/delisting";
/**
* 小商店添加商品接口,添加商品后只是添加到草稿箱,需要通过调用上架商品,并通过审核才能在商城中显示。
* @param appId
* @param spu
* @return
* @throws WxErrorException
*/
WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSpuData> minishopGoodsAddSpu(String appId, WxMinishopSpu spu) throws WxErrorException;
/**
* 小商店删除商品接口,直接删除,不会存在小商店回收站里面。
* @param appId
* @param productId
* @param outProductId
* @return
* @throws WxErrorException
*/
WxOpenResult minishopGoodsDelSpu(String appId, Long productId, Long outProductId) throws WxErrorException;
/**
* 小商店更新商品接口,不会直接影响上架商品的信息,而是存在草稿箱,需要调用上架商品接口,并通过审核才能在商城中显示。
* @param appId
* @param spu
* @return
* @throws WxErrorException
*/
WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSpuData> minishopGoodsUpdateSpu(String appId, WxMinishopSpu spu) throws WxErrorException;
/**
* 上架商品。
* @param appId
* @param productId
* @param outProductId
* @return
* @throws WxErrorException
*/
WxOpenResult minishopGoodsListingSpu(String appId, Long productId, Long outProductId) throws WxErrorException;
/**
* 下架商品
* @param appId
* @param productId
* @param outProductId
* @return
* @throws WxErrorException
*/
WxOpenResult minishopGoodsDelistingSpu(String appId, Long productId, Long outProductId) throws WxErrorException;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//小商店sku接口
String MINISHOP_ADD_SKU_URL = "https://api.weixin.qq.com/product/sku/add";
String MINISHOP_BATCH_ADD_SKU_URL = "https://api.weixin.qq.com/product/sku/batch_add";
String MINISHOP_DEL_SKU_URL = "https://api.weixin.qq.com/product/sku/del";
String MINISHOP_UPDATE_SKU_URL = "https://api.weixin.qq.com/product/sku/update";
String MINISHOP_UPDATE_SKU_PRICE_URL = "https://api.weixin.qq.com/product/sku/update_price";
String MINISHOP_UPDATE_SKU_STOCK_URL = "https://api.weixin.qq.com/product/stock/update";
/**
* 小商店新增sku信息
* @param appId
* @param sku
* @return
* @throws WxErrorException
*/
WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSkuData> minishiopGoodsAddSku(String appId, WxMinishopSku sku) throws WxErrorException;
/**
* 小商店批量新增sku信息
* @param appId
* @param skuList
* @return
* @throws WxErrorException
*/
WxOpenResult minishopGoodsBatchAddSku(String appId, List<WxMinishopSku> skuList) throws WxErrorException;
/**
* 小商店删除sku消息
* @param appId
* @param productId
* @param outProductId
* @param outSkuId
* @param skuId
* @return
* @throws WxErrorException
*/
WxOpenResult minishopGoodsDelSku(String appId, Long productId, Long outProductId, String outSkuId, Long skuId) throws WxErrorException;
/**
* 小商店更新sku
* @param appId
* @param sku
* @return
* @throws WxErrorException
*/
WxOpenResult minishopGoodsUpdateSku(String appId, WxMinishopSku sku) throws WxErrorException;
/**
* 小商店更新sku价格
* @param appId
* @param productId
* @param outProductId
* @param outSkuId
* @param skuId
* @param salePrice
* @param marketPrice
* @return
* @throws WxErrorException
*/
WxOpenResult minishopGoodsUpdateSkuPrice(String appId, Long productId, Long outProductId, String outSkuId, Long skuId, Long salePrice, Long marketPrice) throws WxErrorException;
/**
* 小商店更新sku库存
* @param appId
* @param productId
* @param outProductId
* @param outSkuId
* @param skuId
* @param type
* @param stockNum
* @return
* @throws WxErrorException
*/
WxOpenResult minishopGoodsUpdateSkuStock(String appId, Long productId, Long outProductId, String outSkuId, Long skuId, Integer type, Integer stockNum) throws WxErrorException;
/**
* 小商店通用Post接口
* @param appId
* @param url
* @param requestParam
* @return
* @throws WxErrorException
*/
String minishopCommonPost(String appId, String url, String requestParam) throws WxErrorException;
//////////////////////////////////////////////////////////////
//商品抢购任务-秒杀活动
String API_MINISHOP_ADD_LIMIT_DISCOUNT_URL = "https://api.weixin.qq.com/product/limiteddiscount/add/";
String API_MINISHOP_GET_LIMIT_DISCOUNT_URL = "https://api.weixin.qq.com/product/limiteddiscount/get_list/";
String API_MINISHOP_UPDATE_LIMIT_DICOUNT_STATUS_URL = "https://api.weixin.qq.com/product/limiteddiscount/update_status/";
/**
* 添加抢购任务
* 每个商品(SPU)同一时间只能有一个抢购任务。 如果当前有抢购任务没有结束,无论是否开始,都不允许创建第二个抢购任务 可以提前修改抢购任务状态为结束后,再创建新的任务。 每次创建抢购任务时必须填充该SPU下 所有SKU的抢购信息
* @param appId
* @param limitDiscountGoods
* @return
* @throws WxErrorException
*/
Integer addLimitDiscountGoods(String appId, LimitDiscountGoods limitDiscountGoods) throws WxErrorException;
/**
* status为0代表 还未结束的抢购任务,无论是否开始 status为1代表已经结束的 抢购任务 如果不填status则两种都拉取
* @param appId
* @param status
* @return
*/
List<LimitDiscountGoods> getLimitDiscountList(String appId, Integer status) throws WxErrorException;
/**
* 修改抢购任务状态
* 用于提前结束抢购任务,无论抢购任务是否在执行中,都可以关闭。 也可以直接删除抢购任务 注意:结束后不允许再开启,状态不可逆
* @param appId
* @param taskId
* @param status
* @return
*/
WxOpenResult updateLimitDiscountStatus(String appId, Long taskId, Integer status) throws WxErrorException;
}

View File

@@ -3,6 +3,7 @@ package me.chanjar.weixin.open.api;
import cn.binarywang.wx.miniapp.api.WxMaService;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo;
import me.chanjar.weixin.open.bean.ma.WxMaScheme;
import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage;
import me.chanjar.weixin.open.bean.result.*;
@@ -220,6 +221,17 @@ public interface WxOpenMaService extends WxMaService {
*/
String API_SPEED_AUDIT = "https://api.weixin.qq.com/wxa/speedupaudit";
/**
* 获取小程序scheme码
*/
String API_GENERATE_SCHEME = "https://api.weixin.qq.com/wxa/generatescheme";
/**
* 通过此接口开通自定义版交易组件,将同步返回接入结果,不再有异步事件回调。
*/
String API_REGISTER_SHOP_COMPONENT = "https://api.weixin.qq.com/shop/register/apply";
/**
* 获得小程序的域名配置信息
*
@@ -594,6 +606,14 @@ public interface WxOpenMaService extends WxMaService {
*/
WxOpenResult publishQrcodeJump(String prefix) throws WxErrorException;
WxMaScheme generateMaScheme(String jumpWxaPath, String jumpWxaQuery, Boolean isExpire, Long expireTime) throws WxErrorException;
/**
* 为小程序开通小商店组件
* @return
*/
WxOpenResult registerShopComponent() throws WxErrorException;
/**
* 小程序基础信息服务 (小程序名称、头像、描述、类目等信息设置)
*

View File

@@ -0,0 +1,120 @@
package me.chanjar.weixin.open.api;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.bean.minishopGoods.AddMinishopGoodsSPU;
import me.chanjar.weixin.open.bean.minishopGoods.GoodsCatList;
import me.chanjar.weixin.open.bean.minishopGoods.ParentCatId;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
/**
* 微信小商城 商品
* @author xiaojintao
*/
public interface WxOpenMinishopGoodsService {
/**
* 获取类目详情 接入商品前必须接口
*/
String getMinishopGoodsCatUrl = "https://api.weixin.qq.com/product/category/get";
/**
* SPU接口(修改需要重新上架商品) 添加商品 POST
*/
String addMinishopGoodsSPUUrl = "https://api.weixin.qq.com/product/spu/add";
/**
* SPU接口(修改需要重新上架商品) 删除商品 POST
*/
String delMinishopGoodsSPUUrl = "https://api.weixin.qq.com/product/spu/del";
/**
* SPU接口(修改需要重新上架商品) 获取商品 POST
*/
String getMinishopGoodsSPUUrl = "https://api.weixin.qq.com/product/spu/get";
/**
* SPU接口(修改需要重新上架商品) 获取商品列表 POST
*/
String getListMinishopGoodsSPUURL = "https://api.weixin.qq.com/product/spu/get_list";
/**
* SPU接口(修改需要重新上架商品) 搜索商品 POST
*/
String searchMinishopGoodsSPUURL = "https://api.weixin.qq.com/product/spu/search";
/**
* SPU接口(修改需要重新上架商品) 更新商品 POST
*/
String updateMinishopGoodsSPUUrl = "https://api.weixin.qq.com/product/spu/update";
/**
* SPU接口(修改需要重新上架商品) 上架商品 POST
*/
String listingMinishopGoodsSPUUrl = "https://api.weixin.qq.com/product/spu/listing";
/**
* SPU接口(修改需要重新上架商品) 下架商品 POST
*/
String delistingMinishopGoodsSPUUrl = "https://api.weixin.qq.com/product/spu/delisting";
/**
* SKU接口(修改后需重新上架商品) 添加SKU POST
*/
String addMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/sku/add";
/**
* SKU接口(修改后需重新上架商品) 批量添加SKU POST
*/
String batchAddMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/sku/batch_add";
/**
* SKU接口(修改后需重新上架商品) 批量添加SKU POST
*/
String delMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/sku/del";
/**
* SKU接口(修改后需重新上架商品) 获取SKU信息 POST
*/
String getMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/sku/get";
/**
* SKU接口(修改后需重新上架商品) 批量获取SKU信息 POST
*/
String getListMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/sku/get_list";
/**
* SKU接口(修改后需重新上架商品) 批量获取SKU信息 POST
*/
String updateMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/sku/update";
/**
* SKU接口(修改后需重新上架商品) 更新SKU价格 POST
*/
String updatePriceMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/sku/update_price";
/**
* SKU接口(修改后需重新上架商品) 更新库存 POST
*/
String updateStockMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/stock/update";
/**
* SKU接口(修改后需重新上架商品) 获取库存 POST
*/
String getStockMinishopGoodsSKUUrl = "https://api.weixin.qq.com/product/stock/get";
/**
* 获取 商品类目
*/
GoodsCatList getMinishopGoodsCat(ParentCatId fCatId) throws WxErrorException;
/**
* 新增商品SPU
* @param dto
* @return
*/
WxOpenResult addMinishopGoodsSPU(AddMinishopGoodsSPU dto) throws WxErrorException;
}

View File

@@ -0,0 +1,57 @@
package me.chanjar.weixin.open.api;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.bean.minishop.*;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import java.io.File;
/**
* 微信小商店开店接口
* add by kelven 2021-01-29
*/
public interface WxOpenMinishopService {
String submitMerchantInfoUrl = "https://api.weixin.qq.com/product/register/submit_merchantinfo";
String submitBasicInfoUrl = "https://api.weixin.qq.com/product/register/submit_basicinfo";
public final static String UPLOAD_IMG_MINISHOP_FILE_URL = "https://api.weixin.qq.com/product/img/upload";
String getCategoryUrl = "https://api.weixin.qq.com/product/category/get";
String getBrandsUrl = "https://api.weixin.qq.com/product/brand/get";
String getDeliveryUrl = "https://api.weixin.qq.com/product/delivery/get_freight_template";
/**获取店铺的商品分类*/
String getShopCatUrl = "https://api.weixin.qq.com/product/store/get_shopcat";
/**
*
* @param appId
* @param subjectType
* @param busiLicense
* @param organizationCodeInfo
* @param idcardInfo
* @param superAdministratorInfo
* @param merchantShoprtName
* @return
*/
WxOpenResult submitMerchantInfo(String appId, String subjectType, MinishopBusiLicense busiLicense, MinishopOrganizationCodeInfo organizationCodeInfo, MinishopIdcardInfo idcardInfo, MinishopSuperAdministratorInfo superAdministratorInfo, String merchantShoprtName) throws WxErrorException;
WxOpenResult submitBasicInfo(String appId, MinishopNameInfo nameInfo, MinishopReturnInfo returnInfo);
MinishopAuditStatus checkAuditStatus(String wxName) throws WxErrorException;
String uploadImagePicFile(Integer height, Integer width, File file) throws WxErrorException;
MinishopCategories getCategory(Integer fCatId);
MinishopBrandList getBrands();
MinishopShopCatList getShopCat();
}

View File

@@ -1,7 +1,11 @@
package me.chanjar.weixin.open.api;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import java.io.File;
/**
* The interface Wx open service.
*
@@ -49,4 +53,7 @@ public interface WxOpenService {
*/
String post(String url, String postData) throws WxErrorException;
WxMinishopImageUploadResult uploadMinishopMediaFile(String url, File file) throws WxErrorException;
}

View File

@@ -1,11 +1,16 @@
package me.chanjar.weixin.open.api.impl;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
@@ -28,6 +33,13 @@ import me.chanjar.weixin.open.bean.WxOpenGetResult;
import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate;
import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
import me.chanjar.weixin.open.bean.minishop.*;
import me.chanjar.weixin.open.bean.minishop.coupon.WxMinishopCoupon;
import me.chanjar.weixin.open.bean.minishop.coupon.WxMinishopCouponStock;
import me.chanjar.weixin.open.bean.minishop.goods.*;
import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountGoods;
import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountSku;
import me.chanjar.weixin.open.bean.result.*;
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerListResult;
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerOptionResult;
@@ -36,6 +48,10 @@ import me.chanjar.weixin.open.bean.result.WxOpenResult;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -53,6 +69,8 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
private static final Map<String, WxOpenMpService> WX_OPEN_MP_SERVICE_MAP = new ConcurrentHashMap<>();
private static final Map<String, WxOpenFastMaService> WX_OPEN_FAST_MA_SERVICE_MAP = new ConcurrentHashMap<>();
private static final Map<String, WxOpenMinishopService> WX_OPEN_MINISHOP_SERVICE_MAP = new ConcurrentHashMap<>();
private final WxOpenService wxOpenService;
@Override
@@ -112,6 +130,22 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
return fastMaService;
}
@Override
public WxOpenMinishopService getWxMinishopServiceByAppid(String appId) {
WxOpenMinishopService minishopService = WX_OPEN_MINISHOP_SERVICE_MAP.get(appId);
if (minishopService == null) {
synchronized (WX_OPEN_MINISHOP_SERVICE_MAP) {
minishopService = WX_OPEN_MINISHOP_SERVICE_MAP.get(appId);
if (minishopService == null) {
minishopService = new WxOpenMinishopServiceImpl(this, appId, getWxOpenConfigStorage().getWxMaConfig(appId));
WX_OPEN_MINISHOP_SERVICE_MAP.put(appId, minishopService);
}
}
}
return minishopService;
}
public WxOpenService getWxOpenService() {
return wxOpenService;
}
@@ -590,4 +624,575 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
String response = post(FAST_REGISTER_WEAPP_SEARCH_URL, jsonObject.toString(), "component_access_token");
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxOpenResult registerShop(String wxName, String idCardName, String idCardNumber, String channelId, Integer apiOpenstoreType, String authPageUrl) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("wx_name", wxName);
jsonObject.addProperty("id_card_name", idCardName);
jsonObject.addProperty("id_card_number", idCardNumber);
if (channelId != null && !channelId.isEmpty()) {
jsonObject.addProperty("channel_id", channelId);
}
jsonObject.addProperty("api_openstore_type", apiOpenstoreType);
if (authPageUrl != null && !authPageUrl.isEmpty()) {
jsonObject.addProperty("auth_page_url", authPageUrl);
}
String response = post(REGISTER_SHOP_URL, jsonObject.toString(), "component_access_token");
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public String checkAuditStatus(String wxName) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("wx_name", wxName);
String url = CHECK_SHOP_AUDITSTATUS_URL + "?access_token=" + getComponentAccessToken(false);
String response = post(url, jsonObject.toString());
log.info("CHECK_SHOP_AUDITSTATUS_URL: " + response);
return response;
}
@Override
public String checkAuditStatus(String appId, String wxName) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("wx_name", wxName);
String url = CHECK_SHOP_AUDITSTATUS_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
String response = post(url, jsonObject.toString());
log.info("CHECK_SHOP_AUDITSTATUS_URL: " + response);
return response;
}
@Override
public WxOpenResult submitMerchantInfo(String appId, String subjectType, MinishopBusiLicense busiLicense, MinishopOrganizationCodeInfo organizationCodeInfo, MinishopIdcardInfo idcardInfo, MinishopSuperAdministratorInfo superAdministratorInfo, String merchantShoprtName) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("app_id", appId);
jsonObject.addProperty("subject_type", subjectType);
jsonObject.add("busi_license", busiLicense.toJsonObject());
if (organizationCodeInfo != null) {
jsonObject.add("organization_code_info", organizationCodeInfo.toJsonObject());
}
if (idcardInfo != null) {
jsonObject.add("id_card_info", idcardInfo.toJsonObject());
}
if (superAdministratorInfo != null) {
jsonObject.add("super_administrator_info", superAdministratorInfo.toJsonObject());
}
if (merchantShoprtName != null) {
jsonObject.addProperty("merchant_shortname", merchantShoprtName);
}
String url = SUBMIT_MERCHANTINFO_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxOpenResult submitBasicInfo(String appId, MinishopNameInfo nameInfo, MinishopReturnInfo returnInfo) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("appid", appId);
jsonObject.add("name_info", nameInfo.toJsonObject());
jsonObject.add("return_info", returnInfo.toJsonObject());
String url = SUBMIT_BASICINFO_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxMinishopImageUploadResult uploadMinishopImagePicFile(String appId, Integer height, Integer width, File file) throws WxErrorException {
String url = WxOpenMinishopService.UPLOAD_IMG_MINISHOP_FILE_URL + "?access_token="+getAuthorizerAccessToken(appId, false)+"&height="+height+"&width="+width;
log.info("upload url: " + url);
// String response = (url, file);
WxMinishopImageUploadResult result = getWxOpenService().uploadMinishopMediaFile(url, file);
return result;
}
@Override
public MinishopCategories getMinishopCategories(String appId, Integer fCatId) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("f_cat_id", fCatId);
String url = MINISHOP_CATEGORY_GET_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
String response = getWxOpenService().post(url, jsonObject.toString());
log.info("response: " + response);
JsonObject respJson = GsonParser.parse(response);
MinishopCategories categories = new MinishopCategories();
categories.setErrcode(respJson.get("errcode").getAsInt());
if (categories.getErrcode() == 0) {
JsonArray catListJson = respJson.getAsJsonArray("cat_list");
if (catListJson != null || catListJson.size() > 0) {
List<MinishopCategory> categoryList = new ArrayList<>();
for (int i = 0; i < catListJson.size(); i++) {
JsonObject catJson = catListJson.get(i).getAsJsonObject();
MinishopCategory cate = new MinishopCategory();
cate.setCatId(catJson.get("cat_id").getAsInt());
cate.setFCatId(catJson.get("f_cat_id").getAsInt());
cate.setName(catJson.get("name").getAsString());
categoryList.add(cate);
}
categories.setCatList(categoryList);
}
} else {
categories.setErrmsg(respJson.get("errmsg").getAsString());
}
return categories;
}
@Override
public MinishopBrandList getMinishopBrands(String appId) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
String url = MINISHOP_BRAND_GET_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respJson = GsonParser.parse(response);
MinishopBrandList brandList = new MinishopBrandList();
brandList.setErrcode(respJson.get("errcode").getAsInt());
if (brandList.getErrcode() == 0) {
JsonArray brandArrayJson = respJson.get("brands").getAsJsonArray();
if (brandArrayJson.size() > 0) {
List<MinishopBrand> brands = new ArrayList<>();
for (int i = 0; i < brandArrayJson.size(); i++) {
JsonObject brandJson = brandArrayJson.get(i).getAsJsonObject();
MinishopBrand brand = new MinishopBrand();
brand.setFirstCatId(brandJson.get("first_cat_id").getAsInt());
brand.setSecondCatId(brandJson.get("second_cat_id").getAsInt());
brand.setThirdCatId(brandJson.get("third_cat_id").getAsInt());
MinishopBrand.MinishopBrandInfo brandInfo = new MinishopBrand.MinishopBrandInfo();
JsonObject brandInfoJson = brandJson.get("brand_info").getAsJsonObject();
brandInfo.setBrandId(brandInfoJson.get("brand_id").getAsInt());
brandInfo.setBrandName(brandInfoJson.get("brand_name").getAsString());
brand.setBrandInfo(brandInfo);
brands.add(brand);
}
brandList.setBrands(brands);
}
} else {
brandList.setErrmsg(respJson.get("errmsg").getAsString());
}
return brandList;
}
@Override
public MinishopDeliveryTemplateResult getMinishopDeliveryTemplate(String appId) throws WxErrorException {
String url = MINISHOP_DELIVERY_TEMPLATE_GET_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
JsonObject jsonObject = new JsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respJson = GsonParser.parse(response);
MinishopDeliveryTemplateResult templateResult = new MinishopDeliveryTemplateResult();
templateResult.setErrCode(respJson.get("errcode").getAsInt());
if (templateResult.getErrCode() == 0) {
JsonArray templateArrayJson = respJson.get("template_list").getAsJsonArray();
if (templateArrayJson.size() > 0) {
List<MinishopDeliveryTemplate> templateList = new ArrayList<>();
for (int i = 0; i < templateArrayJson.size(); i++) {
JsonObject templateJson = templateArrayJson.get(i).getAsJsonObject();
MinishopDeliveryTemplate template = new MinishopDeliveryTemplate();
template.setTemplateId(templateJson.get("template_id").getAsInt());
template.setName(templateJson.get("name").getAsString());
template.setValuationType(templateJson.get("valuation_type").getAsInt() == 1 ? MinishopDeliveryTemplate.ValuationType.WEIGHT : MinishopDeliveryTemplate.ValuationType.PACKAGE);
templateList.add(template);
}
templateResult.setTemplateList(templateList);
}
} else {
templateResult.setErrMsg(respJson.get("errmsg").getAsString());
}
return templateResult;
}
@Override
public MinishopShopCatList getMinishopCatList(String appId) throws WxErrorException {
String url = MINISHOP_SHOPCATEGORY_GET_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
JsonObject jsonObject = new JsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respJson = GsonParser.parse(response);
MinishopShopCatList shopCatList = new MinishopShopCatList();
shopCatList.setErrcode(respJson.get("errcode").getAsInt());
if (shopCatList.getErrcode() == 0) {
JsonArray shopcatArrayJson = respJson.get("shopcat_list").getAsJsonArray();
if (shopcatArrayJson.size() > 0) {
List<MinishopShopCat> shopCats = new ArrayList<>();
for (int i = 0; i < shopcatArrayJson.size(); i++) {
JsonObject shopCatJson = shopcatArrayJson.get(i).getAsJsonObject();
MinishopShopCat shopCat = new MinishopShopCat();
shopCat.setShopCatId(shopCatJson.get("shopcat_id").getAsInt());
shopCat.setShopCatName(shopCatJson.get("shopcat_name").getAsString());
shopCat.setFShopCatId(shopCatJson.get("f_shopcat_id").getAsInt());
shopCat.setCatLevel(shopCatJson.get("cat_level").getAsInt());
shopCats.add(shopCat);
}
shopCatList.setShopCatList(shopCats);
}
} else {
shopCatList.setErrmsg(respJson.get("errmsg").getAsString());
}
return shopCatList;
}
@Override
public WxMinishopAddGoodsSpuResult<List<WxMinishopDeliveryCompany>> getMinishopDeliveryCompany(String appId) throws WxErrorException {
String url = MINISHOP_GET_DELIVERY_COMPANY_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
JsonObject jsonObject = new JsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respObj = GsonParser.parse(response);
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
result.setErrcode(respObj.get("errcode").getAsInt());
if (result.getErrcode() == 0) {
JsonArray companyArray = respObj.get("company_list").getAsJsonArray();
List<WxMinishopDeliveryCompany> companies = new ArrayList<>();
for (int i = 0; i < companyArray.size(); i++) {
JsonObject company = companyArray.get(i).getAsJsonObject();
WxMinishopDeliveryCompany resultData = new WxMinishopDeliveryCompany();
resultData.setDeliveryId(company.get("delivery_id").getAsString());
resultData.setDeliveryName(company.get("delivery_name").getAsString());
companies.add(resultData);
}
result.setData(companies);
} else {
result.setErrmsg(respObj.get("errmsg").getAsString());
}
return result;
}
@Override
public Integer minishopCreateCoupon(String appId, WxMinishopCoupon couponInfo) throws WxErrorException {
String url = MINISHOP_CREATE_COUPON_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = couponInfo.toJsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respJson = GsonParser.parse(response);
Integer couponId = -1;
if (respJson.get("errcode").getAsInt() == 0) {
JsonObject dataJson = respJson.get("data").getAsJsonObject();
couponId = dataJson.get("coupon_id").getAsInt();
}
return couponId;
}
@Override
public WxMinishopCouponStock minishopGetCouponList(String appId, String startCreateTime, String endCreateTime, Integer status, Integer page, Integer pageSize) throws WxErrorException {
String url = MINISHOP_GET_COUPON_LIST + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
return null;
}
@Override
public WxOpenResult minishopPushCouponToUser(String appId, String openId, Integer couponId) throws WxErrorException {
String url = MINISHOP_PUSH_COUPON + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("openid", openId);
jsonObject.addProperty("coupon_id", couponId);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public Integer minishopUpdateCoupon(String appId, WxMinishopCoupon couponInfo) throws WxErrorException {
String url = MINISHOP_UPDATE_COUPON_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = couponInfo.toJsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respJson = GsonParser.parse(response);
Integer couponId = -1;
if (respJson.get("errcode").getAsInt() == 0) {
JsonObject dataJson = respJson.get("data").getAsJsonObject();
couponId = dataJson.get("coupon_id").getAsInt();
}
return couponId;
}
@Override
public WxOpenResult minishopUpdateCouponStatus(String appId, Integer couponId, Integer status) throws WxErrorException {
String url = MINISHOP_UPDATE_COUPON_STATUS_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("coupon_id", couponId);
jsonObject.addProperty("status", status);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSpuData> minishopGoodsAddSpu(String appId, WxMinishopSpu spu) throws WxErrorException {
String url = MINISHOP_ADD_SPU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = spu.toJsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respObj = GsonParser.parse(response);
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
result.setErrcode(respObj.get("errcode").getAsInt());
if (result.getErrcode() == 0) {
JsonObject dataObj = respObj.get("data").getAsJsonObject();
WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
resultData.setProductId(dataObj.get("product_id").getAsLong());
resultData.setOutProductId(dataObj.get("out_product_id").getAsString());
resultData.setCreateTime(dataObj.get("create_time").getAsString());
result.setData(resultData);
} else {
result.setErrmsg(respObj.get("errmsg").getAsString());
}
return result;
}
@Override
public WxOpenResult minishopGoodsDelSpu(String appId, Long productId, Long outProductId) throws WxErrorException {
String url = MINISHOP_DEL_SPU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("product_id", productId);
jsonObject.addProperty("out_product_id", outProductId.toString());
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSpuData> minishopGoodsUpdateSpu(String appId, WxMinishopSpu spu) throws WxErrorException {
String url = MINISHOP_UPDATE_SPU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = spu.toJsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respObj = GsonParser.parse(response);
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
result.setErrcode(respObj.get("errcode").getAsInt());
if (result.getErrcode() == 0) {
JsonObject dataObj = respObj.get("data").getAsJsonObject();
WxMinishopAddGoodsSpuData resultData = new WxMinishopAddGoodsSpuData();
resultData.setProductId(dataObj.get("product_id").getAsLong());
resultData.setOutProductId(dataObj.get("out_product_id").getAsString());
resultData.setCreateTime(dataObj.get("update_time").getAsString());
result.setData(resultData);
} else {
result.setErrmsg(respObj.get("errmsg").getAsString());
}
return result;
}
@Override
public WxOpenResult minishopGoodsListingSpu(String appId, Long productId, Long outProductId) throws WxErrorException {
String url = MINISHOP_LISTING_SPU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("product_id", productId);
jsonObject.addProperty("out_product_id", outProductId.toString());
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxOpenResult minishopGoodsDelistingSpu(String appId, Long productId, Long outProductId) throws WxErrorException {
String url = MINISHOP_DELISTING_SPU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("product_id", productId);
jsonObject.addProperty("out_product_id", outProductId.toString());
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSkuData> minishiopGoodsAddSku(String appId, WxMinishopSku sku) throws WxErrorException {
String url = MINISHOP_ADD_SKU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = sku.toJsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respObj = GsonParser.parse(response);
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
result.setErrcode(respObj.get("errcode").getAsInt());
if (result.getErrcode() == 0) {
JsonObject dataObj = respObj.get("data").getAsJsonObject();
WxMinishopAddGoodsSkuData resultData = new WxMinishopAddGoodsSkuData();
resultData.setSkuId(dataObj.get("sku_id").getAsLong());
resultData.setCreateTime(dataObj.get("create_time").getAsString());
result.setData(resultData);
} else {
result.setErrmsg(respObj.get("errmsg").getAsString());
}
return result;
}
@Override
public WxOpenResult minishopGoodsBatchAddSku(String appId, List<WxMinishopSku> skuList) throws WxErrorException {
String url = MINISHOP_BATCH_ADD_SKU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
JsonArray jsonArray = new JsonArray();
for (WxMinishopSku sku : skuList) {
jsonArray.add(sku.toJsonObject());
}
jsonObject.add("skus", jsonArray);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxOpenResult minishopGoodsDelSku(String appId, Long productId, Long outProductId, String outSkuId, Long skuId) throws WxErrorException {
String url = MINISHOP_DEL_SKU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("product_id", productId);
jsonObject.addProperty("out_product_id", outProductId);
jsonObject.addProperty("sku_id", skuId);
jsonObject.addProperty("out_sku_id", outSkuId);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxOpenResult minishopGoodsUpdateSku(String appId, WxMinishopSku sku) throws WxErrorException {
String url = MINISHOP_UPDATE_SKU_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = sku.toJsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxOpenResult minishopGoodsUpdateSkuPrice(String appId, Long productId, Long outProductId, String outSkuId, Long skuId, Long salePrice, Long marketPrice) throws WxErrorException {
String url = MINISHOP_UPDATE_SKU_PRICE_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("product_id", productId);
jsonObject.addProperty("out_product_id", outProductId);
jsonObject.addProperty("sku_id", skuId);
jsonObject.addProperty("out_sku_id", outSkuId);
jsonObject.addProperty("sale_price", outSkuId);
jsonObject.addProperty("market_price", outSkuId);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxOpenResult minishopGoodsUpdateSkuStock(String appId, Long productId, Long outProductId, String outSkuId, Long skuId, Integer type, Integer stockNum) throws WxErrorException {
String url = MINISHOP_UPDATE_SKU_STOCK_URL + "?access_token=" + getAuthorizerAccessToken(appId, true);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("product_id", productId);
jsonObject.addProperty("out_product_id", outProductId);
jsonObject.addProperty("sku_id", skuId);
jsonObject.addProperty("out_sku_id", outSkuId);
jsonObject.addProperty("type", type);
jsonObject.addProperty("stock_num", stockNum);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public String minishopCommonPost(String appId, String url, String requestParam) throws WxErrorException {
return null;
}
@Override
public Integer addLimitDiscountGoods(String appId, LimitDiscountGoods limitDiscountGoods) throws WxErrorException {
String url = API_MINISHOP_ADD_LIMIT_DISCOUNT_URL + "access_token=" + getAuthorizerAccessToken(appId, false);
JsonObject jsonObject = limitDiscountGoods.toJsonObject();
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respObj = GsonParser.parse(response);
Integer taskId = 0;
if (respObj.get("errcode").getAsInt() == 0) {
taskId = respObj.get("task_id").getAsInt();
}
return taskId;
}
@Override
public List<LimitDiscountGoods> getLimitDiscountList(String appId, Integer status) throws WxErrorException {
String url = API_MINISHOP_GET_LIMIT_DISCOUNT_URL + "access_token=" + getAuthorizerAccessToken(appId, false);
JsonObject jsonObject = new JsonObject();
if (status != null) {
jsonObject.addProperty("status", status);
}
String response = getWxOpenService().post(url, jsonObject.toString());
JsonObject respObj = GsonParser.parse(response);
List<LimitDiscountGoods> limitDiscountGoodsList = new ArrayList<>();
if (respObj.get("errcode").getAsInt() == 0) {
//成功获取到秒杀活动列表
JsonArray jsonArray = respObj.get("limited_discount_list").getAsJsonArray();
if (jsonArray != null && jsonArray.size() > 0) {
for (int i = 0; i < jsonArray.size(); i ++) {
JsonObject goodsObj = jsonArray.get(i).getAsJsonObject();
LimitDiscountGoods discountGoods = new LimitDiscountGoods();
discountGoods.setTaskId(goodsObj.get("task_id").getAsLong());
discountGoods.setStatus(goodsObj.get("status").getAsInt());
discountGoods.setStartTime(new Date(goodsObj.get("start_time").getAsLong()*1000));
discountGoods.setEndTime(new Date(goodsObj.get("end_time").getAsLong()*1000));
List<LimitDiscountSku> skuList = new ArrayList<>();
JsonArray skuArray = goodsObj.get("limited_discount_sku_list").getAsJsonArray();
if (skuArray != null && skuArray.size() > 0) {
for (int j = 0; j < skuArray.size(); j ++) {
JsonObject skuObj = skuArray.get(i).getAsJsonObject();
LimitDiscountSku sku = new LimitDiscountSku();
sku.setSkuId(skuObj.get("sku_id").getAsLong());
sku.setSalePrice(new BigDecimal(skuObj.get("sale_price").getAsDouble() / 100));
sku.setSaleStock(skuObj.get("sale_stock").getAsInt());
skuList.add(sku);
}
discountGoods.setLimitDiscountSkuList(skuList);
}
limitDiscountGoodsList.add(discountGoods);
}
}
}
return limitDiscountGoodsList;
}
@Override
public WxOpenResult updateLimitDiscountStatus(String appId, Long taskId, Integer status) throws WxErrorException {
String url = API_MINISHOP_UPDATE_LIMIT_DICOUNT_STATUS_URL + "access_token=" + getAuthorizerAccessToken(appId, false);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("task_id", taskId);
jsonObject.addProperty("status", status);
String response = getWxOpenService().post(url, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
}

View File

@@ -5,6 +5,8 @@ import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import lombok.Getter;
@@ -14,6 +16,7 @@ import me.chanjar.weixin.open.api.WxOpenMaBasicService;
import me.chanjar.weixin.open.api.WxOpenMaService;
import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo;
import me.chanjar.weixin.open.bean.ma.WxMaQrcodeParam;
import me.chanjar.weixin.open.bean.ma.WxMaScheme;
import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage;
import me.chanjar.weixin.open.bean.result.*;
import me.chanjar.weixin.open.executor.MaQrCodeRequestExecutor;
@@ -359,6 +362,40 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public WxMaScheme generateMaScheme(String jumpWxaPath, String jumpWxaQuery, Boolean isExpire, Long expireTime) throws WxErrorException {
JsonObject jumpWxa = null;
if (jumpWxaPath != null && jumpWxaQuery != null) {
jumpWxa = new JsonObject();
jumpWxa.addProperty("path", jumpWxaPath);
jumpWxa.addProperty("query", jumpWxaQuery);
}
JsonObject params = new JsonObject();
if (jumpWxa != null) {
params.add("jump_wxa", jumpWxa);
}
if (isExpire != null) {
params.addProperty("is_expire", isExpire);
}
if (expireTime != null) {
params.addProperty("expire_time", expireTime);
}
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
String response = post(API_GENERATE_SCHEME, gson.toJson(params));
return WxMaGsonBuilder.create().fromJson(response, WxMaScheme.class);
}
@Override
public WxOpenResult registerShopComponent() throws WxErrorException {
JsonObject params = new JsonObject();
String response = post(API_REGISTER_SHOP_COMPONENT, GSON.toJson(params));
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
private JsonArray toJsonArray(List<String> strList) {
JsonArray jsonArray = new JsonArray();
if (strList != null && !strList.isEmpty()) {

View File

@@ -0,0 +1,37 @@
package me.chanjar.weixin.open.api.impl;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.api.WxOpenMinishopGoodsService;
import me.chanjar.weixin.open.bean.minishopGoods.AddMinishopGoodsSPU;
import me.chanjar.weixin.open.bean.minishopGoods.GoodsCatList;
import me.chanjar.weixin.open.bean.minishopGoods.ParentCatId;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
@Slf4j
public class WxOpenMinishopGoodsServiceImpl extends WxMaServiceImpl implements WxOpenMinishopGoodsService {
@Override
public GoodsCatList getMinishopGoodsCat(ParentCatId dto) throws WxErrorException {
String response = post(getMinishopGoodsCatUrl, dto.toJsonObject().toString());
log.info(response);
return null;
}
@Override
public WxOpenResult addMinishopGoodsSPU(AddMinishopGoodsSPU dto) throws WxErrorException {
String response = post(addMinishopGoodsSPUUrl, dto.toJsonObject().toString());
return null;
}
}

View File

@@ -0,0 +1,80 @@
package me.chanjar.weixin.open.api.impl;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.api.WxOpenComponentService;
import me.chanjar.weixin.open.api.WxOpenMinishopService;
import me.chanjar.weixin.open.api.WxOpenService;
import me.chanjar.weixin.open.bean.minishop.*;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import java.io.File;
@Slf4j
public class WxOpenMinishopServiceImpl extends WxMaServiceImpl implements WxOpenMinishopService {
private final WxOpenComponentService wxOpenComponentService;
private final WxMaConfig wxMaConfig;
private final String appId;
public WxOpenMinishopServiceImpl(WxOpenComponentService wxOpenComponentService, String appId, WxMaConfig wxMaConfig) {
this.wxOpenComponentService = wxOpenComponentService;
this.appId = appId;
this.wxMaConfig = wxMaConfig;
log.info("appId: " + appId);
if (wxMaConfig == null) {
log.error("WxMaConfig is null");
}
this.addConfig(appId, wxMaConfig);
initHttp();
}
@Override
public WxOpenResult submitMerchantInfo(String appId, String subjectType, MinishopBusiLicense busiLicense, MinishopOrganizationCodeInfo organizationCodeInfo, MinishopIdcardInfo idcardInfo, MinishopSuperAdministratorInfo superAdministratorInfo, String merchantShoprtName) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("app_id", appId);
jsonObject.addProperty("subject_type", subjectType);
jsonObject.add("busi_license", busiLicense.toJsonObject());
jsonObject.add("organization_code_info", organizationCodeInfo.toJsonObject());
jsonObject.add("id_card_info", idcardInfo.toJsonObject());
jsonObject.add("super_administrator_info", superAdministratorInfo.toJsonObject());
String response = post(submitMerchantInfoUrl, jsonObject.toString());
return null;
}
@Override
public WxOpenResult submitBasicInfo(String appId, MinishopNameInfo nameInfo, MinishopReturnInfo returnInfo) {
return null;
}
@Override
public MinishopAuditStatus checkAuditStatus(String wxName) throws WxErrorException {
return null;
}
@Override
public String uploadImagePicFile(Integer height, Integer width, File file) throws WxErrorException {
String url = UPLOAD_IMG_MINISHOP_FILE_URL + "?access_token="+getAccessToken(true)+"&height="+height+"&width="+width;
log.info("upload url: " + url);
String response = post(url, file);
return response;
}
@Override
public MinishopCategories getCategory(Integer fCatId) {
return null;
}
@Override
public MinishopBrandList getBrands() {
return null;
}
@Override
public MinishopShopCatList getShopCat() {
return null;
}
}

View File

@@ -1,15 +1,17 @@
package me.chanjar.weixin.open.api.impl;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
import me.chanjar.weixin.common.util.http.*;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
/**
* apache-http方式实现
*
@@ -64,4 +66,9 @@ public class WxOpenServiceApacheHttpClientImpl extends WxOpenServiceAbstractImpl
public String post(String url, String postData) throws WxErrorException {
return execute(SimplePostRequestExecutor.create(this), url, postData);
}
@Override
public WxMinishopImageUploadResult uploadMinishopMediaFile(String url, File file) throws WxErrorException {
return execute(MinishopUploadRequestExecutor.create(this), url, file);
}
}

View File

@@ -0,0 +1,9 @@
package me.chanjar.weixin.open.bean.ma;
import lombok.Data;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
@Data
public class WxMaScheme extends WxOpenResult {
private String openlink;
}

View File

@@ -0,0 +1,75 @@
package me.chanjar.weixin.open.bean.minishop;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("小商店地址信息")
public class MinishopAddressInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 收货人姓名
*/
@ApiModelProperty("收货人姓名 必填")
private String userName;
/**
* 邮政编码
*/
@ApiModelProperty("邮政编码 必填")
private String postalCode;
/**
* 省份,格式:广东省 北京市
*/
@ApiModelProperty("省份,格式:广东省 北京市 必填")
private String province;
/**
* 城市,格式:广州市
*/
@ApiModelProperty("城市,格式:广州市 必填")
private String cityName;
/**
* 区,格式:海珠区
*/
@ApiModelProperty("区,格式:海珠区 必填")
private String countyName;
/**
* 详细地址
*/
@ApiModelProperty("详细地址,必填")
private String detailInfo;
/**
* 国家码
*/
@ApiModelProperty("国家码,选填")
private String nationalCode;
/**
* 电话号码
*/
@ApiModelProperty("电话号码")
private String telNumber;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("user_name", userName);
jsonObject.addProperty("postal_code", postalCode);
jsonObject.addProperty("province_name", province);
jsonObject.addProperty("city_name", cityName);
jsonObject.addProperty("county_name", countyName);
jsonObject.addProperty("detail_info", detailInfo);
jsonObject.addProperty("national_code", nationalCode);
jsonObject.addProperty("tel_number", telNumber);
return jsonObject;
}
}

View File

@@ -0,0 +1,63 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import me.chanjar.weixin.common.error.WxError;
import java.io.Serializable;
@Data
public class MinishopAuditStatus implements Serializable {
private WxError wxError;
/**
* 注册状态 0:成功 1:已发送协议还未签约 2: 未发送协议或协议已过期需发送协议当register_status为0时以下字段有意义
*/
private Integer registerStatus;
/**
* 商家信息状态, 具体含义查看状态枚举值
*/
private Integer merchantInfoStatus;
/**
* 账户验证状态, 具体含义查看状态枚举值
*/
private Integer acctVerifyStatus;
/**
* 基础信息状态, 具体含义查看状态枚举值
*/
private Integer basicInfoStatus;
/**
* 支付签约状态, 具体含义查看状态枚举值
*/
private Integer paySignStatus;
/**
* 基础信息驳回原因
*/
private String auditRejectReason;
/**
* 法人验证链接
*/
private String legalValidationUrl;
/**
* 参数名
*/
private String payAuditDetailParamName;
/**
* 支付资质驳回原因
*/
private String payAuditDetailRejectReason;
/**
* 注册的appid
*/
private String registeredAppId;
}

View File

@@ -0,0 +1,71 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author luowentao
* @since 2021-01-27
*/
@Data
public class MinishopBaseInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 微信小商店ID自定
*/
private Long miniShopId;
/**
* 小程序ID
*/
private String appId;
/**
* 1小程序名称可以由中文、数字、英文、空格及部分特殊符号(“空格”、“-”、“+”、“&”、“.”)组成。长度在4-30个字符之间一个中文字等于2个字符。
2公众号、小程序在微信公众平台上的名称是唯一的且属于同一主体下可以重名。
3不得与不同主体的公众号名称重名。
*/
private String nickName;
/**
* 1小程序简称可以从小程序名称中按顺序截取字符创建。长度在4-10个字符之间一个中文字等于2个字符。
2小程序简称在微信公众平台是不唯一的可以重名。但对于仿冒、侵权等恶意情况平台仍会做出相关处罚。开发者也可通过侵权投诉维护自己的正当权益。
3小程序简称设置后将在客户端任务栏向用户展示。开发者可以凭借此功能更好地实现产品品牌价值和展示。目前暂不支持名称的其他功能。
*/
private String abbr;
/**
* 介绍。请确认介绍内容不含国家相关法律法规禁止内容,介绍字数为4-120个字符一个中文占2个字符。一个月内可申请5次修改。请提供可支持命名的材料
*/
private String introduction;
/**
* 补充材料传media id数组当返回210047时必填
*/
private String namingOtherStuff;
/**
* 邮箱
*/
private String mail;
/**
* 退货地址
*/
private Integer returnAddressId;
/**
* 公司地址
*/
private Integer companyAddressId;
}

View File

@@ -0,0 +1,26 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Data
public class MinishopBrand implements Serializable {
private Integer firstCatId;
private Integer secondCatId;
private Integer thirdCatId;
@Data
@Getter
@Setter
public static class MinishopBrandInfo implements Serializable {
private Integer brandId;
private String brandName;
}
private MinishopBrandInfo brandInfo;
}

View File

@@ -0,0 +1,15 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class MinishopBrandList implements Serializable {
private Integer errcode;
private String errmsg;
private List<MinishopBrand> brands;
}

View File

@@ -0,0 +1,98 @@
package me.chanjar.weixin.open.bean.minishop;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
* 企业上传的营业执照信息
* </p>
*
* @author luowentao
* @since 2021-01-27
*/
@Data
@Accessors(chain = true)
public class MinishopBusiLicense implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 营业执照相关信息
*/
private Integer busiLicenseId;
/**
* 营业执照类型 1:三证合一 2: 普通营业执照
*/
private Integer licenseType;
/**
* 营业执照图片
*/
private MinishopPicFile picFile;
/**
* 营业执照图片url
*/
private String picFileUrl;
/**
* 请填写营业执照上的注册号/统一社会信用代码,
须为15位数字或18位数字大写字母。
示例值123456789012345678 特殊规则长度最小15个字节
*/
private String registrationNum;
/**
* 1、请填写营业执照/登记证书的商家名称2~110个字符支持括号
2、个体工商户/党政、机关及事业单位,不能以“公司”结尾。
3、个体工商户若营业执照上商户名称为空或为“无”请填写"个体户+经营者姓名"
如“个体户张三” 。示例值:腾讯科技有限公司
*/
private String merchantName;
/**
* 请填写证件的经营者/法定代表人姓名。示例值:张三
*/
private String legalRepresentative;
/**
* 注册地址
*/
private String registeredAddrs;
/**
* 注册日期格式2014-01-01
*/
private String startDate;
/**
* 结束有效期格式2014-01-01
1、若证件有效期为长期请填写长期。
2、结束时间需大于开始时间。
3、有效期必须大于60天即结束时间距当前时间需超过60天。
*/
private String endDate;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("license_type", this.licenseType);
jsonObject.add("pic_file", picFile.toJsonObject());
jsonObject.addProperty("registration_num", registrationNum);
jsonObject.addProperty("merchant_name", merchantName);
jsonObject.addProperty("legal_representative", legalRepresentative);
if (registeredAddrs != null) {
jsonObject.addProperty("registered_addrs", registeredAddrs);
}
jsonObject.addProperty("start_date", startDate);
jsonObject.addProperty("end_date", endDate);
return jsonObject;
}
}

View File

@@ -0,0 +1,15 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class MinishopCategories implements Serializable {
private Integer errcode;
private String errmsg;
private List<MinishopCategory> catList;
}

View File

@@ -0,0 +1,14 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import java.io.Serializable;
@Data
public class MinishopCategory implements Serializable {
private Integer catId;
private Integer fCatId;
private String name;
}

View File

@@ -0,0 +1,20 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import java.io.Serializable;
@Data
public class MinishopDeliveryTemplate implements Serializable {
public enum ValuationType {
PACKAGE,
WEIGHT
}
private Integer templateId;
private String name;
private ValuationType valuationType;
}

View File

@@ -0,0 +1,21 @@
package me.chanjar.weixin.open.bean.minishop;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel("小商店运费模版信息")
public class MinishopDeliveryTemplateResult implements Serializable {
@ApiModelProperty(value = "错误码")
private Integer errCode;
@ApiModelProperty(value = "错误信息")
private String errMsg;
@ApiModelProperty(value = "运费模版列表")
private List<MinishopDeliveryTemplate> templateList;
}

View File

@@ -0,0 +1,88 @@
package me.chanjar.weixin.open.bean.minishop;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author luowentao
* @since 2021-01-27
*/
@Data
@Accessors(chain = true)
public class MinishopIdcardInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 身份证信息Id
*/
private Integer idCardInfoId;
/**
* 小程序ID
*/
private String appId;
/**
* 人像面照片media_id
*/
private MinishopPicFile portraitPicFile;
/**
* 人像面照片url
*/
private String protraitPicFileUrl;
/**
* 国徽面照片
*/
private MinishopPicFile nationPicFile;
/**
* 国徽面照片url
*/
private String nationPicFileUrl;
/**
* 请填写经营者/法定代表人对应身份证的姓名2~30个中文字符、英文字符、符号。
*/
private String idCardName;
/**
* 请填写经营者/法定代表人对应身份证的号码
*/
private String idCardNumber;
/**
* 注册日期格式2014-01-01
*/
private String startDate;
/**
* 结束有效期格式2014-01-01
1、若证件有效期为长期请填写长期。
2、结束时间需大于开始时间。
3、有效期必须大于60天即结束时间距当前时间需超过60天。
*/
private String endDate;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.add("portrait_pic_file", portraitPicFile.toJsonObject());
jsonObject.add("nation_pic_file", nationPicFile.toJsonObject());
jsonObject.addProperty("id_card_name", idCardName);
jsonObject.addProperty("id_card_number", idCardNumber);
jsonObject.addProperty("start_date", startDate);
jsonObject.addProperty("end_date", endDate);
return jsonObject;
}
}

View File

@@ -0,0 +1,96 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author luowentao
* @since 2021-01-27
*/
@Data
@Accessors(chain = true)
public class MinishopMerchantinfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 小商店认证ID
*/
private Long merchantId;
/**
* 小商店APPID
*/
private String appId;
/**
* 主体类型
"4":个体工商户,营业执照上的主体类型一般为个体户、个体工商户、个体经营。
"2":企业,营业执照上的主体类型一般为有限公司、有限责任公司。
*/
private String subjectType;
/**
* 商户简称 UTF-8格式中文占3个字节即最多16个汉字长度。
将在支付完成页向买家展示,需与商家的实际售卖商品相符 。示例值:腾讯
*/
private String merchantShortname;
/**
* 补充描述
*/
private String supplementaryDesc;
/**
* 营业执照/登记证书信息
*/
private Integer busiLicenseId;
/**
* 组织机构代码证信息(非必填)
*/
private Integer organizationCodeInfo;
/**
* 身份证信息
*/
private Integer idCardInfo;
/**
* 超级管理员信息 请填写店铺的超级管理员信息。超级管理员需在开户后进行签约,
并可接收日常重要管理信息和进行资金操作,请确定其为商户法定代表人或负责人。
*/
private Integer superAdministratorInfoId;
/**
* 特殊资质 1、根据商户经营业务要求提供相关资质详情查看《行业对应特殊资质》。
2、请提供为“申请商家主体”所属的特殊资质可授权使用总公司/分公司的特殊资 质;
3、最多可上传5张照片请填写通过图片上传接口预先上传图片生成好的MediaID 。
*/
private Integer specialQualificationId;
/**
* 补充材料
*/
private Integer supplementaryMaterialId;
/**
* 状态0为审核中1为已通过-1为审批驳回
*/
private Integer status;
/**
* 提交时间
*/
private Date submitTime;
}

View File

@@ -0,0 +1,59 @@
package me.chanjar.weixin.open.bean.minishop;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel("小商店名称信息")
public class MinishopNameInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 1小程序名称可以由中文、数字、英文、空格及部分特殊符号(“空格”、“-”、“+”、“&”、“.”)组成。长度在4-30个字符之间一个中文字等于2个字符。
* 2公众号、小程序在微信公众平台上的名称是唯一的且属于同一主体下可以重名。
* 3不得与不同主体的公众号名称重名。
*/
@ApiModelProperty(value = "1小程序名称可以由中文、数字、英文、空格及部分特殊符号(“空格”、“-”、“+”、“&”、“.”)组成。长度在4-30个字符之间一个中文字等于2个字符。\n" +
" * 2公众号、小程序在微信公众平台上的名称是唯一的且属于同一主体下可以重名。\n" +
" * 3不得与不同主体的公众号名称重名。", required = true)
private String nickName;
/**
* 1小程序简称可以从小程序名称中按顺序截取字符创建。长度在4-10个字符之间一个中文字等于2个字符。
* 2小程序简称在微信公众平台是不唯一的可以重名。但对于仿冒、侵权等恶意情况平台仍会做出相关处罚。开发者也可通过侵权投诉维护自己的正当权益。
* 3小程序简称设置后将在客户端任务栏向用户展示。开发者可以凭借此功能更好地实现产品品牌价值和展示。目前暂不支持名称的其他功能。
*/
@ApiModelProperty(value = " * 1小程序简称可以从小程序名称中按顺序截取字符创建。长度在4-10个字符之间一个中文字等于2个字符。\n" +
" * 2小程序简称在微信公众平台是不唯一的可以重名。但对于仿冒、侵权等恶意情况平台仍会做出相关处罚。开发者也可通过侵权投诉维护自己的正当权益。\n" +
" * 3小程序简称设置后将在客户端任务栏向用户展示。开发者可以凭借此功能更好地实现产品品牌价值和展示。目前暂不支持名称的其他功能。", required = true)
private String abbr;
/**
* 请确认介绍内容不含国家相关法律法规禁止内容,介绍字数为4-120个字符一个中文占2个字符。一个月内可申请5次修改。请提供可支持命名的材料
*/
@ApiModelProperty(value = "请确认介绍内容不含国家相关法律法规禁止内容,介绍字数为4-120个字符一个中文占2个字符。一个月内可申请5次修改。请提供可支持命名的材料", required = true)
private String introduction;
/**
* 补充材料传media id数组当返回210047时必填
*/
@ApiModelProperty(value = "补充材料传media id数组当返回210047时必填", required = false)
private List<String> namingOtherStuff;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("nickname", nickName);
jsonObject.addProperty("abbr", abbr);
jsonObject.addProperty("introduction", introduction);
return jsonObject;
}
}

View File

@@ -0,0 +1,62 @@
package me.chanjar.weixin.open.bean.minishop;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author luowentao
* @since 2021-01-27
*/
@Data
public class MinishopOrganizationCodeInfo implements Serializable {
private static final long serialVersionUID = 1L;
private Integer organizationCodeInfoId;
/**
* 小程序ID
*/
private String appId;
/**
* 组织机构代码证图片
*/
private MinishopPicFile picFile;
/**
* 1、请填写组织机构代码证上的组织机构代码。
2、可填写9或10位 数字\字母\连字符。示例值12345679-A
*/
private String organizationCode;
/**
* 注册日期格式2014-01-01
*/
private String startDate;
/**
* 结束有效期格式2014-01-01
1、若证件有效期为长期请填写长期。
2、结束时间需大于开始时间。
3、有效期必须大于60天即结束时间距当前时间需超过60天。
*/
private String endDate;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.add("pic_file", picFile.toJsonObject());
jsonObject.addProperty("organization_code", organizationCode);
jsonObject.addProperty("start_date", startDate);
jsonObject.addProperty("end_date", endDate);
return jsonObject;
}
}

View File

@@ -0,0 +1,22 @@
package me.chanjar.weixin.open.bean.minishop;
import com.google.gson.JsonObject;
import lombok.Data;
import java.io.Serializable;
@Data
public class MinishopPicFile implements Serializable {
private String mediaId;
private String payMediaId;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("media_id", mediaId);
jsonObject.addProperty("pay_media_id", payMediaId);
return jsonObject;
}
}

View File

@@ -0,0 +1,39 @@
package me.chanjar.weixin.open.bean.minishop;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("小商店退货信息")
public class MinishopReturnInfo implements Serializable {
/**
* 退货地址
*/
@ApiModelProperty(value = "退货地址 必填", required = true)
private MinishopAddressInfo addressInfo;
/**
* 邮箱
*/
@ApiModelProperty(value = "邮箱 必填", required = true)
private String email;
/**
* 公司地址
*/
@ApiModelProperty(value = "公司地址信息 必填", required = true)
private MinishopAddressInfo companyAddress;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.add("address_info", addressInfo.toJsonObject());
jsonObject.addProperty("mail", email);
jsonObject.add("company_address", companyAddress.toJsonObject());
return jsonObject;
}
}

View File

@@ -0,0 +1,19 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import java.io.Serializable;
/**
* 店铺的商品分类
*/
@Data
public class MinishopShopCat implements Serializable {
private Integer shopCatId;
private String shopCatName;
private Integer fShopCatId;
private Integer catLevel;
}

View File

@@ -0,0 +1,15 @@
package me.chanjar.weixin.open.bean.minishop;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class MinishopShopCatList implements Serializable {
private Integer errcode;
private String errmsg;
private List<MinishopShopCat> shopCatList;
}

View File

@@ -0,0 +1,71 @@
package me.chanjar.weixin.open.bean.minishop;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author luowentao
* @since 2021-01-27
*/
@Data
@Accessors(chain = true)
public class MinishopSuperAdministratorInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 店铺管理员ID
*/
private Integer superAdminInfoId;
/**
* 个体工商户/企业/党政、机关及事业单位/其他组织可选择65-法人/经营者、66- 负责人。
(负责人:经商户授权办理微信支付业务的人员,授权范围包括但不限于签约,入驻过程需完成账户验证)。
示例值65
*/
private String type;
/**
* 1、若管理员类型为“法人”则该姓名需与法人身份证姓名一致。
2、若管理员类型为“经办人”则可填写实际经办人的姓名。
*/
private String name;
/**
* 1、若管理员类型为法人则该身份证号码需与法人身份证号码一致。若管理员类型为经办人
则可填写实际经办人的身份证号码。
2、可传身份证、来往内地通行证、来往大陆通行证、护照等证件号码。
3、超级管理员签约时校验微信号绑定的银行卡实名信息是否与该证件号码一致。
*/
private String idCardNumber;
/**
* 请填写管理员的手机号11位数字 用于接收微信支付的重要管理信息及日常操作验证码 。
*/
private String phone;
/**
* 1、用于接收微信支付的开户邮件及日常业务通知。
2、需要带@,遵循邮箱格式校验 。
*/
private String mail;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("type", type);
jsonObject.addProperty("name", name);
jsonObject.addProperty("id_card_number", idCardNumber);
jsonObject.addProperty("phone", phone);
jsonObject.addProperty("mail", mail);
return jsonObject;
}
}

View File

@@ -0,0 +1,81 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("小商店优惠券信息")
public class WxMinishopCoupon implements Serializable {
//新增完成之后可以看到这个couponId
private Integer couponId;
//优惠券状态
private Integer status;
@ApiModelProperty(value = "优惠券类型: 1 商品条件折券, discount_condition.product_ids, discount_condition.product_cnt, discount_info.discount_num 必填" +
"2 商品满减券, discount_condition.product_ids, discount_condition.product_price, discount_info.discount_fee 必填" +
"3 商品统一折扣券, discount_condition.product_ids, discount_info.discount_num必填" +
"4 商品直减券, 如果小于可用的商品中的最小价格会提醒(没有商品时超过50w提醒, discount_condition.product_ids, discount_fee 必填" +
"101 店铺条件折扣券, discount_condition.product_cnt, discount_info.discount_num必填" +
"102 店铺满减券, discount_condition.product_price, discount_info.discount_fee 必填" +
"103 店铺统一折扣券, discount_info.discount_num 必填" +
"104 店铺直减券, 如果小于可用的商品中的最小价格会提醒(没有商品时超过50w提醒, discount_fee 必填", required = true)
private Integer type;
@ApiModelProperty(value = "优惠券名称", required = true)
private String name;
@ApiModelProperty(value = "商品折扣券信息")
private WxMinishopCouponDiscountInfo discountInfo;
@ApiModelProperty(value = "优惠券额外信息")
private WxMinishopCouponExtInfo extInfo;
@ApiModelProperty(value = "推广渠道信息",required = true)
private WxMinishopCouponPromoteInfo promoteInfo;
@ApiModelProperty(value = "优惠券领取信息", required = true)
private WxMinishopCouponReceiveInfo receiveInfo;
@ApiModelProperty(value = "优惠券有效期信息", required = true)
private WxMinishopCouponValidInfo validInfo;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
if (couponId != null) {
jsonObject.addProperty("coupon_id", couponId);
}
if (status != null) {
jsonObject.addProperty("status", status);
}
jsonObject.addProperty("type", type);
jsonObject.addProperty("name", name);
if (discountInfo != null) {
jsonObject.add("discount_info", discountInfo.toJsonObject());
}
if (extInfo != null) {
jsonObject.add("ext_info", extInfo.toJsonObject());
}
if(promoteInfo != null) {
jsonObject.add("promote_info", promoteInfo.toJsonObject());
}
if (receiveInfo != null) {
jsonObject.add("receive_info", receiveInfo.toJsonObject());
}
if (validInfo != null) {
jsonObject.add("valid_info", validInfo.toJsonObject());
}
return jsonObject;
}
}

View File

@@ -0,0 +1,35 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("小商店商品折扣券详细信息")
public class WxMinishopCouponDiscountCondition {
@ApiModelProperty(value = "商品折扣券打折金额", required = false)
private Integer productCnt;
@ApiModelProperty(value = "商品id商品折扣券需填写", required = false)
private List<Integer> productIds;
@ApiModelProperty(value = "商品价格,满减券需填写", required = false)
private Integer productPrice;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
jsonObject.addProperty("product_cnt", productCnt);
jsonObject.add("product_ids", gson.toJsonTree(productIds));
jsonObject.addProperty("product_price", productPrice);
return jsonObject;
}
}

View File

@@ -0,0 +1,28 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("小商店商品折扣券信息")
public class WxMinishopCouponDiscountInfo {
@ApiModelProperty(value = "小商店商品折扣详情")
private WxMinishopCouponDiscountCondition discountCondition;
@ApiModelProperty(value = "满减金额", required = true)
private Integer discountFee;
@ApiModelProperty(value = "打折商品数量,满减券需填写")
private Integer discountNum;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.add("discount_condition", discountCondition.toJsonObject());
jsonObject.addProperty("discount_fee", discountFee);
jsonObject.addProperty("discount_num", discountNum);
return jsonObject;
}
}

View File

@@ -0,0 +1,33 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("小商店优惠券的扩展信息")
public class WxMinishopCouponExtInfo implements Serializable {
@ApiModelProperty("备注信息")
private String notes;
@ApiModelProperty(value = "优惠券有效时间, valid_type=0时与valid_info.start_time一致, valid_type=1时商家自己填一个绝对开始时间", required = true)
private Long validTime;
@ApiModelProperty(value = "优惠券失效时间, valid_type=0时与valid_info.end_time一致, valid_type=1时商家自己填一个绝对结束时间", required = true)
private Long invalidTime;
@ApiModelProperty(value = "商品券可以填,领取后跳转")
private Long jumpProductId;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("jump_product_id", jumpProductId);
jsonObject.addProperty("notes", notes);
jsonObject.addProperty("valid_time", validTime);
jsonObject.addProperty("invalid_time", invalidTime);
return jsonObject;
}
}

View File

@@ -0,0 +1,25 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("小商店优惠券推广渠道")
public class WxMinishopCouponPromoteInfo implements Serializable {
@ApiModelProperty(value = "用户自定义推广渠道", required = true)
private String customizeChannel;
@ApiModelProperty(value = "推广类型, 1:店铺内推广,2:自定义推广渠道", required = true)
private Integer promotionType;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("customize_channel", customizeChannel);
jsonObject.addProperty("promote_type", promotionType);
return jsonObject;
}
}

View File

@@ -0,0 +1,34 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("小商店优惠券领取信息")
public class WxMinishopCouponReceiveInfo implements Serializable {
@ApiModelProperty(value = "优惠券领用结束时间", required = true)
private Long endTime;
@ApiModelProperty(value = "是否限制一人使用", required = true)
private Integer limitNumOnePerson;
@ApiModelProperty(value = "优惠券领用开始时间",required = true)
private Long startTime;
@ApiModelProperty(value = "优惠券领用总数", required = true)
private Integer totalNum;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("start_time", startTime);
jsonObject.addProperty("end_time", endTime);
jsonObject.addProperty("limit_num_one_person", limitNumOnePerson);
jsonObject.addProperty("total_num", totalNum);
return jsonObject;
}
}

View File

@@ -0,0 +1,23 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel("小商店优惠券请求回复数据信息")
public class WxMinishopCouponResponse implements Serializable {
@ApiModelProperty("错误码")
private Integer errcode;
@ApiModelProperty("错误信息")
private String errmsg;
@ApiModelProperty("优惠券信息")
private List<WxMinishopCouponStock> coupons;
}

View File

@@ -0,0 +1,32 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ApiModel("小商店优惠券返回信息")
@Data
public class WxMinishopCouponStock implements Serializable {
@ApiModelProperty("优惠券ID")
private Integer couponId;
@ApiModelProperty("优惠券类型")
private Integer type;
@ApiModelProperty("优惠券状态")
private Integer status;
@ApiModelProperty("优惠券创建时间")
private String createTime;
@ApiModelProperty("优惠券更新时间")
private String updateTime;
@ApiModelProperty("优惠券详情信息")
private WxMinishopCoupon couponInfo;
@ApiModelProperty("优惠券使用信息")
private WxMinishopCouponStockInfo stockInfo;
}

View File

@@ -0,0 +1,20 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("小商店优惠券消耗信息")
public class WxMinishopCouponStockInfo implements Serializable {
@ApiModelProperty(value = "优惠券发放量")
private Integer issuedNum;
@ApiModelProperty(value = "优惠券领用量")
private Integer receiveNum;
@ApiModelProperty(value = "优惠券已用量")
private Integer usedNum;
}

View File

@@ -0,0 +1,35 @@
package me.chanjar.weixin.open.bean.minishop.coupon;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("小商店优惠券有效信息设置")
public class WxMinishopCouponValidInfo implements Serializable {
@ApiModelProperty(value = "优惠券有效期结束时间若填了start必填")
private Long endTime;
@ApiModelProperty(value = "优惠券有效期开始时间和valid_day_num二选一")
private Long startTime;
@ApiModelProperty(value = "优惠券有效期天数和start_time二选一", required = true)
private Integer validDayNum;
@ApiModelProperty(value = "优惠券有效期类型, 0: 指定时间范围生效; 1: 生效天数", required = true)
private Integer validType;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("start_time", startTime);
jsonObject.addProperty("end_time", endTime);
jsonObject.addProperty("valid_day_num", validDayNum);
jsonObject.addProperty("valid_type", validType);
return jsonObject;
}
}

View File

@@ -0,0 +1,12 @@
package me.chanjar.weixin.open.bean.minishop.goods;
import lombok.Data;
import java.io.Serializable;
@Data
public class WxMinishopAddGoodsSkuData implements Serializable {
private Long skuId;
private String createTime;
}

View File

@@ -0,0 +1,14 @@
package me.chanjar.weixin.open.bean.minishop.goods;
import lombok.Data;
import java.io.Serializable;
@Data
public class WxMinishopAddGoodsSpuData implements Serializable {
private Long productId;
private String outProductId;
private String createTime;
}

View File

@@ -0,0 +1,14 @@
package me.chanjar.weixin.open.bean.minishop.goods;
import lombok.Data;
import java.io.Serializable;
@Data
public class WxMinishopAddGoodsSpuResult<T> implements Serializable {
private Integer errcode;
private String errmsg;
private T data;
}

View File

@@ -0,0 +1,12 @@
package me.chanjar.weixin.open.bean.minishop.goods;
import lombok.Data;
import java.io.Serializable;
@Data
public class WxMinishopDeliveryCompany implements Serializable {
private String deliveryId;
private String deliveryName;
}

View File

@@ -0,0 +1,23 @@
package me.chanjar.weixin.open.bean.minishop.goods;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
@Data
public class WxMinishopGoodsSkuAttr implements Serializable {
private String attrKey;
private String attrValue;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("attr_key", attrKey);
jsonObject.addProperty("attr_value", attrValue);
return jsonObject;
}
}

View File

@@ -0,0 +1,51 @@
package me.chanjar.weixin.open.bean.minishop.goods;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
public class WxMinishopSku implements Serializable {
private Long productId;
private String outProductId;
private String outSkuId;
private String thumbImg;
private Integer salePrice;
private Integer marketPrice;
private Integer stockNum;
private String skuCode;
private String barCode;
private List<WxMinishopGoodsSkuAttr> skuAttrs;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("product_id", productId);
jsonObject.addProperty("out_product_id", outProductId);
jsonObject.addProperty("out_sku_id", outSkuId);
jsonObject.addProperty("thumb_img", thumbImg);
jsonObject.addProperty("sale_price", salePrice);
jsonObject.addProperty("market_price", marketPrice);
jsonObject.addProperty("stock_num", stockNum);
jsonObject.addProperty("sku_code", skuCode);
jsonObject.addProperty("barcode", barCode);
JsonArray jsonArray = new JsonArray();
for (WxMinishopGoodsSkuAttr attr : skuAttrs) {
jsonArray.add(attr.toJsonObject());
}
jsonObject.add("sku_attrs", jsonArray);
return jsonObject;
}
}

View File

@@ -0,0 +1,86 @@
package me.chanjar.weixin.open.bean.minishop.goods;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import lombok.Data;
import me.chanjar.weixin.open.bean.minishop.MinishopShopCat;
import java.io.Serializable;
import java.util.List;
@Data
public class WxMinishopSpu implements Serializable {
private String outProductId;
private String title;
private String subTitle;
private List<String> headImgs;
private List<String> descInfoImgs;
private Long brandId;
private List<MinishopShopCat> shopCats;
private List<WxMinishopGoodsSkuAttr> attrs;
private String model;
private Long expressTemplateId;
private List<WxMinishopSku> skus;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("out_product_id", outProductId);
jsonObject.addProperty("title", title);
jsonObject.addProperty("sub_title", subTitle);
JsonArray imgArray = new JsonArray();
for (String img : headImgs) {
imgArray.add(img);
}
jsonObject.add("head_img", imgArray);
JsonArray descImgArray = new JsonArray();
for (String img : descInfoImgs) {
descImgArray.add(img);
}
JsonObject descInfo = new JsonObject();
descInfo.add("imgs", descImgArray);
jsonObject.add("desc_info", descInfo);
jsonObject.addProperty("brand_id", brandId);
JsonArray catArray = new JsonArray();
for (MinishopShopCat cat : shopCats) {
JsonObject catObj = new JsonObject();
catObj.addProperty("cat_id", cat.getShopCatId());
catObj.addProperty("level", cat.getCatLevel());
catArray.add(catObj);
}
jsonObject.add("cats", catArray);
JsonArray attrArray = new JsonArray();
for (WxMinishopGoodsSkuAttr attr : attrs) {
attrArray.add(attr.toJsonObject());
}
jsonObject.add("attrs", attrArray);
jsonObject.addProperty("model", model);
JsonObject expressObj = new JsonObject();
expressObj.addProperty("template_id", expressTemplateId);
jsonObject.add("express_info", expressObj);
JsonArray skuArray = new JsonArray();
for (WxMinishopSku sku : skus) {
skuArray.add(sku.toJsonObject());
}
jsonObject.add("skus", skuArray);
return jsonObject;
}
}

View File

@@ -0,0 +1,60 @@
package me.chanjar.weixin.open.bean.minishop.limitdiscount;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 小商店商品秒杀活动
*/
@Data
@ApiModel("小商店商品秒杀")
public class LimitDiscountGoods implements Serializable {
@ApiModelProperty("小商店秒杀任务ID")
private Long taskId;
@ApiModelProperty("秒杀任务状态")
private Integer status;
@ApiModelProperty("小商店商品ID需要检查该商品在小商店的状态如果不是上线状态可以提示客户需要先上架到小商店再进行处理")
private Long productId;
@ApiModelProperty("开始时间,发给小商店的时候需要转换为getTime")
private Date startTime;
@ApiModelProperty("结束时间发给小商店的时候需要转换为getTime")
private Date endTime;
@ApiModelProperty("商品sku列表")
private List<LimitDiscountSku> limitDiscountSkuList;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
if (taskId != null) {
jsonObject.addProperty("task_id", taskId);
}
if (status != null) {
jsonObject.addProperty("status", status);
}
jsonObject.addProperty("product_id", productId);
jsonObject.addProperty("start_time", startTime.getTime());
jsonObject.addProperty("end_time", endTime.getTime());
JsonArray jsonArray = new JsonArray();
for (LimitDiscountSku sku : limitDiscountSkuList) {
jsonArray.add(sku.toJsonObject());
}
jsonObject.add("limited_discount_sku_list", jsonArray);
return jsonObject;
}
}

View File

@@ -0,0 +1,36 @@
package me.chanjar.weixin.open.bean.minishop.limitdiscount;
import com.google.gson.JsonObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 商品抢购活动sku信息
*/
@Data
@ApiModel("商品抢购活动sku")
public class LimitDiscountSku implements Serializable {
@ApiModelProperty("商品skuID")
private Long skuId;
@ApiModelProperty("秒杀价格")
private BigDecimal salePrice;
@ApiModelProperty("商品秒杀库存")
private Integer saleStock;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("sku_id", skuId);
//需要将saleprice转换为以分为单位
jsonObject.addProperty("sale_price", salePrice.multiply(new BigDecimal(100)).longValue());
jsonObject.addProperty("sale_stock", saleStock);
return jsonObject;
}
}

View File

@@ -0,0 +1,89 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Arrays;
import java.util.List;
/**
* 属性后面的 true 代表必传 false 代表非必传
*/
@Data
@Accessors(chain = true)
public class AddMinishopGoodsSPU {
/**
* 商家自定义商品ID与product_id二选一 true
*/
private String outProductId;
/**
* 标题 true
*/
private String title;
/**
* 副标题 false
*/
private String subTitle;
/**
* 主图,多张,列表 true
*/
private List<String> headImg;
/**
* 商品详情,图文(目前只支持图片) true
*/
private DescInfo descInfo;
/**
* 品牌ID商家需要申请品牌并通过获取品牌接口brand/get获取如果是无品牌请填2100000000 true
*/
private Integer brandId = 2100000000;
/**
* 类目 true
*/
private List<Cat> cats;
/**
* 属性 true
*/
private List<Attr> attrs;
/**
* 商品型号 false
*/
private String model;
/**
* 运费模板 true
*/
private ExpressInfo expressInfo;
/**
* SKU false
*/
private List<Sku> skus;
public JsonObject toJsonObject() {
Gson gson = new Gson();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("out_product_id", outProductId);
jsonObject.addProperty("title",title);
jsonObject.addProperty("sub_title",subTitle);
jsonObject.addProperty("head_img",gson.toJson(headImg));
jsonObject.addProperty("desc_info",gson.toJson(descInfo));
jsonObject.addProperty("brand_id",brandId.toString());
jsonObject.addProperty("cats",gson.toJson(cats));
jsonObject.addProperty("attrs",gson.toJson(attrs));
jsonObject.addProperty("model",model);
jsonObject.addProperty("expressInfo",gson.toJson(expressInfo));
jsonObject.addProperty("skus",gson.toJson(skus));
return jsonObject;
}
public static void main(String[] args) {
GoodsCatList goodsCatList = new GoodsCatList();
goodsCatList.setErrcode(1).setErrmsg("正常").setCatList(Arrays.asList(new GoodsCat().setCatId(1).setFCatId(0).setName("服饰"),
new GoodsCat().setCatId(2).setFCatId(0).setName("鞋包") ));
System.out.println(goodsCatList.toString());
System.out.println(goodsCatList.toJsonObject());
}
}

View File

@@ -0,0 +1,28 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class Attr {
/**
* 属性键key属性自定义用
*/
private String attrKey;
/**
* 属性值(属性自定义用)
*/
private String attrValue;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("attr_key", attrKey);
jsonObject.addProperty("attr_value", attrValue);
return jsonObject;
}
}

View File

@@ -0,0 +1,28 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class Cat {
/**
* 类目ID如果brand_id=2100000000需要先通过获取类目接口category/get拿到可用的cat_id
* 如果brand_id!=2100000000则这里的cat_id需要与获取品牌接口brand/get中的1,2,3级类目一一对应
*/
private Integer catId;
/**
* 类目层级
*/
private Integer level;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("cat_id", catId);
jsonObject.addProperty("level", level);
return jsonObject;
}
}

View File

@@ -0,0 +1,25 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class DescInfo {
/**
* 商品详情,图文(目前只支持图片) true
*/
private List<String> imgs;
public JsonObject toJsonObject() {
Gson gson = new Gson();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("imgs", gson.toJson(imgs));
return jsonObject;
}
}

View File

@@ -0,0 +1,23 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class ExpressInfo {
/**
* 运费模板ID先通过获取运费模板接口delivery/get_freight_template拿到
*/
private Integer templateId;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("template_id", templateId);
return jsonObject;
}
}

View File

@@ -0,0 +1,31 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class GoodsCat {
/**
* 类目id
*/
private Integer catId;
/**
* 类目父id
*/
private Integer fCatId;
/**
* 类目名称
*/
private String name;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("cat_id", catId);
jsonObject.addProperty("f_cat_id", fCatId);
jsonObject.addProperty("name", name);
return jsonObject;
}
}

View File

@@ -0,0 +1,36 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class GoodsCatList {
/**
* 错误码信息
*/
private Integer errcode;
/**
* 错误信息
*/
private String errmsg;
/**
* 类目数组
*/
private List<GoodsCat> catList;
public JsonObject toJsonObject() {
Gson gson = new Gson();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("errcode", errcode);
jsonObject.addProperty("errmsg", errmsg);
jsonObject.addProperty("cat_list", gson.toJson(catList));
return jsonObject;
}
}

View File

@@ -0,0 +1,15 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.JsonObject;
import lombok.Data;
@Data
public class ParentCatId {
private Integer fCatId;
public JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("f_cat_id", fCatId);
return jsonObject;
}
}

View File

@@ -0,0 +1,68 @@
package me.chanjar.weixin.open.bean.minishopGoods;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Arrays;
import java.util.List;
@Data
@Accessors(chain = true)
public class Sku {
/**
* 商家自定义商品ID skus非空时必填
*/
private String outProductId;
/**
* 商家自定义skuID skus非空时必填
*/
private String outSkuId;
/**
* sku小图 skus非空时必填
*/
private String thumbImg;
/**
* 售卖价格,以分为单位 skus非空时必填
*/
private Integer salePrice;
/**
* 市场价格,以分为单位 skus非空时必填
*/
private Integer marketPrice;
/**
* 库存 skus非空时必填
*/
private Integer stockNum;
/**
* 条形码 false
*/
private String barcode;
/**
*商品编码 false
*/
private String skuCode;
/**
* sku属性
*/
private List<Attr> skuAttr;
public JsonObject toJsonObject() {
Gson gson = new Gson();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("out_product_id", outProductId);
jsonObject.addProperty("out_sku_id", outSkuId);
jsonObject.addProperty("thumb_img", thumbImg);
jsonObject.addProperty("sale_price", salePrice);
jsonObject.addProperty("market_price", marketPrice);
jsonObject.addProperty("stock_num", stockNum);
jsonObject.addProperty("barcode", barcode);
jsonObject.addProperty("sku_code", skuCode);
jsonObject.addProperty("sku_attr",gson.toJson(skuAttr));
return jsonObject;
}
}