8000 小程序自定义组件之接入商品前必需接口 by liming1019 · Pull Request #2255 · binarywang/WxJava · GitHub
[go: up one dir, main page]

Skip to content

小程序自定义组件之接入商品前必需接口 #2255

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

Merged
merged 8 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
增加小程序自定义组件之商家入驻相关接口
  • Loading branch information
liming committed Aug 9, 2021
commit 0d4fdbc1125242ec6a42ca9dfbb2c92f726b02f1
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ public interface WxMaService extends WxService {
*/
WxMaShopRegisterService getShopRegisterService();

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

/**
* 获取小程序 URL Link服务接口
* @return
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
Expand Up @@ -66,6 +66,7 @@ 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 WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
private Map<String, WxMaConfig> configMap;
Expand Down Expand Up @@ -522,6 +523,11 @@ public WxMaShopRegisterService getShopRegisterService() {
return this.shopRegisterService;
}

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

@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,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;
}

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

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

import java.io.Serializable;

/**
* @author liming1019
* @date 2021/8/9
*/
@Data
public class WxMaShopAccountUpdateInfoRequest implements Serializable {
private static final long serialVersionUID = 5185978220275730559L;
/**
* 小程序path
*/
@SerializedName("service_agent_path")
private String serviceAgentPath;

/**
* 小程序path
*/
@SerializedName("service_agent_phone")
private String serviceAgentPhone;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

import cn.binarywang.wx.miniapp.bean.shop.WxMaShopAccountGetBrandListItem;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.List;

/**
* @author liming1019
* @date 2021/8/9
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxMaShopAccountGetBrandListResponse extends WxMaShopBaseResponse implements Serializable {
private static final long serialVersionUID = -5196210913054514206L;

@SerializedName("data")
private List<WxMaShopAccountGetBrandListItem> items;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

import cn.binarywang.wx.miniapp.bean.shop.WxMaShopAccountGetCategoryListItem;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.List;

/**
* @author liming1019
* @date 2021/8/9
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxMaShopAccountGetCategoryListResponse extends WxMaShopBaseResponse implements Serializable {
private static final long serialVersionUID = -3182300077261435356L;

@SerializedName("data")
private List<WxMaShopAccountGetCategoryListItem> items;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

import cn.binarywang.wx.miniapp.bean.shop.WxMaShopAccountGetInfo;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
* @author liming1019
* @date 2021/8/9
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxMaShopAccountGetInfoResponse extends WxMaShopBaseResponse implements Serializable {
private static final long serialVersionUID = -3954383181691898592L;

@SerializedName("data")
private WxMaShopAccountGetInfo data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ interface Register {
String REGISTER_FINISH_ACCESS_INFO = "https://api.weixin.qq.com/shop/register/finish_access_info";
String REGISTER_APPLY_SCENE = "https://api.weixin.qq.com/shop/register/apply_scene";
}

interface Account {
String GET_CATEGORY_LIST = "https://api.weixin.qq.com/shop/account/get_category_list";
String GET_BRAND_LIST = "https://api.weixin.qq.com/shop/account/get_brand_list";
String UPDATE_INFO = "https://api.weixin.qq.com/shop/account/update_info";
String GET_INFO = "https://api.weixin.qq.com/shop/account/get_info";
}
}

/**
Expand Down
Loading
0