Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加小程序自定义组件之商家入驻相关接口 #2249

Merged
merged 4 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -393,30 +393,49 @@ public interface WxMaService extends WxService {

/**
* 返回小程序交易组件-订单服务接口
*
* @return
*/
WxMaShopOrderService getShopOrderService();

/**
* 返回小程序交易组件-spu商品服务接口
*
* @return
*/
WxMaShopSpuService getShopSpuService();

/**
* 返回小程序交易组件-接入申请接口
*
* @return
*/
WxMaShopRegisterService getShopRegisterService();

/**
* 返回小程序交易组件-商户入驻接口
*
* @return
*/
WxMaShopAccountService getShopAccountService();

/**
* 小程序交易组件-接入商品前必需接口-类目相关
*
* @return
*/
WxMaShopCatService getShopCatService();

/**
* 获取小程序 URL Link服务接口
*
* @return
*/
WxMaLinkService getLinkService();

/**
* 获取电子发票报销方服务接口
*
* @return
*/
WxMaReimburseInvoiceService getReimburseInvoiceService();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package cn.binarywang.wx.miniapp.api;

import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAccountUpdateInfoRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetBrandListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetCategoryListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetInfoResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import me.chanjar.weixin.common.error.WxErrorException;

/**
* 小程序交易组件-商家入驻接口
*
* @author liming1019
*/
public interface WxMaShopAccountService {
/**
* 获取商家类目列表
*
* @return WxMaShopAccountGetCategoryListResponse
* @throws WxErrorException
*/
WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorException;

/**
* 获取商家品牌列表
*
* @return WxMaShopAccountGetBrandListResponse
* @throws WxErrorException
*/
WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorException;

/**
* 更新商家信息
*
* @param request
* @return WxMaShopBaseResponse
* @throws WxErrorException
*/
WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request) throws WxErrorException;

/**
* 获取商家信息
*
* @return WxMaShopAccountGetInfoResponse
* @throws WxErrorException
*/
WxMaShopAccountGetInfoResponse getInfo() throws WxErrorException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cn.binarywang.wx.miniapp.api;

import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCatGetResponse;
import me.chanjar.weixin.common.error.WxErrorException;

/**
* 小程序交易组件-接入商品前必需接口
*
* @author liming1019
*/
public interface WxMaShopCatService {
/**
* 获取商品类目
*
* @return WxMaShopCatGetResponse
* @throws WxErrorException
*/
WxMaShopCatGetResponse getCat() throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
private final WxMaShopSpuService shopSpuService = new WxMaShopSpuServiceImpl(this);
private final WxMaShopOrderService shopOrderService = new WxMaShopOrderServiceImpl(this);
private final WxMaShopRegisterService shopRegisterService = new WxMaShopRegisterServiceImpl(this);
private final WxMaShopAccountService shopAccountService = new WxMaShopAccountServiceImpl(this);
private final WxMaShopCatService shopCatService = new WxMaShopCatServiceImpl(this);
private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
private Map<String, WxMaConfig> configMap;
Expand Down Expand Up @@ -522,6 +524,16 @@ public WxMaShopRegisterService getShopRegisterService() {
return this.shopRegisterService;
}

@Override
public WxMaShopAccountService getShopAccountService() {
return this.shopAccountService;
}

@Override
public WxMaShopCatService getShopCatService() {
return this.shopCatService;
}

@Override
public WxMaLinkService getLinkService() {
return this.linkService;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package cn.binarywang.wx.miniapp.api.impl;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.WxMaShopAccountService;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAccountUpdateInfoRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetBrandListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetCategoryListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetInfoResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import com.google.gson.JsonObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.json.GsonParser;

import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Account.*;

/**
* @author liming1019
*/
@RequiredArgsConstructor
@Slf4j
public class WxMaShopAccountServiceImpl implements WxMaShopAccountService {
private static final String ERR_CODE = "errcode";
private final WxMaService wxMaService;

@Override
public WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorException {
String responseContent = this.wxMaService.post(GET_CATEGORY_LIST, new JsonObject());
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetCategoryListResponse.class);
}

@Override
public WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorException {
String responseContent = this.wxMaService.post(GET_BRAND_LIST, new JsonObject());
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetBrandListResponse.class);
}

@Override
public WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request) throws WxErrorException {
String responseContent = this.wxMaService.post(UPDATE_INFO, request);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
}

@Override
public WxMaShopAccountGetInfoResponse getInfo() throws WxErrorException {
String responseContent = this.wxMaService.post(GET_INFO, new JsonObject());
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetInfoResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package cn.binarywang.wx.miniapp.api.impl;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.WxMaShopCatService;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCatGetResponse;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import com.google.gson.JsonObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.json.GsonParser;

import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Cat.GET_CAT;
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;

/**
* @author liming1019
*/
@RequiredArgsConstructor
@Slf4j
public class WxMaShopCatServiceImpl implements WxMaShopCatService {
private final WxMaService wxMaService;

@Override
public WxMaShopCatGetResponse getCat() throws WxErrorException {
String responseContent = this.wxMaService.post(GET_CAT, new JsonObject());
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCatGetResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cn.binarywang.wx.miniapp.bean.shop;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.io.Serializable;

/**
* @author liming1019
* @date 2021/8/9
*/
@Data
public class WxMaShopAccountGetBrandListItem implements Serializable {
private static final long serialVersionUID = -8889271375365538573L;

/**
* 品牌ID
*/
@SerializedName("brand_id")
private Long brandId;

/**
* 品牌名称
*/
@SerializedName("brand_wording")
private String brandWording;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package cn.binarywang.wx.miniapp.bean.shop;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.io.Serializable;

/**
* @author liming1019
* @date 2021/8/9
*/
@Data
public class WxMaShopAccountGetCategoryListItem implements Serializable {
private static final long serialVersionUID = -6574489801942310752L;

/**
* 一级类目ID
*/
@SerializedName("first_cat_id")
private Long firstCatId;
/**
* 二级类目ID
*/
@SerializedName("second_cat_id")
private Long secondCatId;
/**
* 类目ID
*/
@SerializedName("third_cat_id")
private Long thirdCatId;
/**
* 一级类目名称
*/
@SerializedName("first_cat_name")
private String firstCatName;
/**
* 二级类目名称
*/
@SerializedName("second_cat_name")
private String secondCatName;

/**
* 类目名称
*/
@SerializedName("third_cat_name")
private String thirdCatName;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cn.binarywang.wx.miniapp.bean.shop;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.io.Serializable;

/**
* @author liming1019
* @date 2021/8/9
*/
@Data
public class WxMaShopAccountGetInfo implements Serializable {
/**
* 品牌ID
*/
@SerializedName("brand_id")
private Long brandId;

/**
* 品牌名称
*/
@SerializedName("brand_wording")
private String brandWording;
}

Loading