-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c71b2a
commit 16d98a6
Showing
18 changed files
with
582 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopAccountService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
19 changes: 19 additions & 0 deletions
19
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaShopCatService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...a-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAccountServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopCatServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...app/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetBrandListItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
48 changes: 48 additions & 0 deletions
48
.../src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetCategoryListItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
26 changes: 26 additions & 0 deletions
26
...java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/WxMaShopAccountGetInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
Oops, something went wrong.