Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
视频号分享人接口
Signed-off-by: wanglei <lei.wang@xianbb.cn>
  • Loading branch information
wanglei committed Jun 18, 2022
commit 1249dff0b3081963355a1a24baab01b6a8868580
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package cn.binarywang.wx.miniapp.api;

import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSearchSharerResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerBindResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerDataSummaryResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveOrderListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveSummaryListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerUnbindResponse;
import me.chanjar.weixin.common.error.WxErrorException;

/**
* 分享员
* @author leiin
* @date 2022/6/18 2:48 下午
*/
public interface WxMaShopSharerService {

/**
* 绑定分享员
* 用来批量邀请分享员
* @param openids
* @return
* @throws WxErrorException
*/
WxMaShopSharerBindResponse bindSharer(String[] openids) throws WxErrorException;

/**
* 获取分享员的总带货数据
* @param openid
* @return
* @throws WxErrorException
*/
WxMaShopSharerDataSummaryResponse getSharerDataSummary(String openid) throws WxErrorException;

/**
* 获取已经绑定的分享员列表
* @param page
* @param pageSize
* @return
* @throws WxErrorException
*/
WxMaShopSharerListResponse getSharerList(Integer page, Integer pageSize) throws WxErrorException;

/**
* 获取分享员的直播间订单汇总
* @param openid
* @param liveExportId
* @param page
* @param pageSize
* @return
* @throws WxErrorException
*/
WxMaShopSharerLiveOrderListResponse getSharerLiveOrderList(String openid, String liveExportId,
Integer page, Integer pageSize) throws WxErrorException;

/**
* 获取分享员的直播间带货数据汇总
* @param openid
* @param page
* @param pageSize
* @return
* @throws WxErrorException
*/
WxMaShopSharerLiveSummaryListResponse getSharerLiveSummaryList(String openid,
Integer page, Integer pageSize) throws WxErrorException;

/**
* 查看分享员
* @param openid
* @return
* @throws WxErrorException
*/
WxMaShopSearchSharerResponse searchSharer(String openid) throws WxErrorException;

/**
* 解绑分享员
* @param openids
* @return
* @throws WxErrorException
*/
WxMaShopSharerUnbindResponse unbindSharer(String[] openids) throws WxErrorException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package cn.binarywang.wx.miniapp.api.impl;

import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Sharer;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.WxMaShopSharerService;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSearchSharerResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerBindResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerDataSummaryResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveOrderListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerLiveSummaryListResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopSharerUnbindResponse;
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.GsonHelper;
import me.chanjar.weixin.common.util.json.GsonParser;

/**
* @author leiin
* @date 2022/6/18 3:38 下午
*/
@RequiredArgsConstructor
@Slf4j
public class WxMaShopSharerServiceImpl implements WxMaShopSharerService {
private static final String ERR_CODE = "errcode";
private final WxMaService wxMaService;

@Override
public WxMaShopSharerBindResponse bindSharer(String[] openids) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("openids", openids);
String responseContent = this.wxMaService.post(Sharer.BIND, json);
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, WxMaShopSharerBindResponse.class);
}

@Override
public WxMaShopSharerDataSummaryResponse getSharerDataSummary(String openid) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("openid", openid);
String responseContent = this.wxMaService.post(Sharer.GET_SHARER_DATA_SUMMARY, json);
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, WxMaShopSharerDataSummaryResponse.class);
}

@Override
public WxMaShopSharerListResponse getSharerList(Integer page, Integer pageSize) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("page", page, "page_size", pageSize);
String responseContent = this.wxMaService.post(Sharer.GET_SHARER_LIST, json);
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, WxMaShopSharerListResponse.class);
}

@Override
public WxMaShopSharerLiveOrderListResponse getSharerLiveOrderList(String openid, String liveExportId,
Integer page, Integer pageSize) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("openid", openid, "live_export_id", liveExportId,
"page", page, "page_size", pageSize);
String responseContent = this.wxMaService.post(Sharer.GET_SHARER_LIVE_ORDER_LIST, json);
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, WxMaShopSharerLiveOrderListResponse.class);
}

@Override
public WxMaShopSharerLiveSummaryListResponse getSharerLiveSummaryList(String openid,
Integer page, Integer pageSize) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("openid", openid, "page", page, "page_size", pageSize);
String responseContent = this.wxMaService.post(Sharer.GET_SHARER_LIVE_SUMMARY_LIST, json);
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, WxMaShopSharerLiveSummaryListResponse.class);
}

@Override
public WxMaShopSearchSharerResponse searchSharer(String openid) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("openid", openid);
String responseContent = this.wxMaService.post(Sharer.SEARCH_SHARER, json);
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, WxMaShopSearchSharerResponse.class);
}

@Override
public WxMaShopSharerUnbindResponse unbindSharer(String[] openids) throws WxErrorException {
JsonObject json = GsonHelper.buildJsonObject("openids", openids);
String responseContent = this.wxMaService.post(Sharer.UNBIND, json);
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, WxMaShopSharerUnbindResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cn.binarywang.wx.miniapp.bean.shop;

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

/**
* @author leiin
* @date 2022/6/18 3:14 下午
*/
@Data
public class WxMaPromotionInfo implements Serializable {

private static final long serialVersionUID = 2090629980847386450L;

@SerializedName("finder_username")
private String finderUsername;
@SerializedName("finder_nickname")
private String finderNickname;
@SerializedName("sharer_openid")
private String sharerOpenid;
@SerializedName("live_start_time")
private String liveStartTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
public class WxMaShopOrderDetail implements Serializable {
private static final long serialVersionUID = 3325843289672341160L;

@SerializedName("promotion_info")
private WxMaPromotionInfo promotionInfo;

/**
* 下单商品信息
* <pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class WxMaShopPayInfo implements Serializable {
@SerializedName("pay_method_type")
private Integer payMethodType;

@SerializedName("pay_method")
private String payMethod;

/**
* 预支付ID
* <pre>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

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

/**
* @author leiin
* @date 2022/6/18 2:58 下午
*/
@Data
public class WxMaShopSearchSharerResponse extends WxMaShopBaseResponse implements Serializable {

private static final long serialVersionUID = 2049214239752832818L;

@SerializedName("invited_time")
private Long invitedTime;
@SerializedName("bind_time")
private Long bindTime;
@SerializedName("nickname")
private String nickname;
@SerializedName("bind_status")
private Integer bindStatus;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

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

/**
* @author leiin
* @date 2022/6/18 2:51 下午
*/
@Data
public class WxMaShopSharerBindResponse extends WxMaShopBaseResponse implements Serializable {

private static final long serialVersionUID = 5648529892711033276L;

@SerializedName("success_list")
private List<String> successList;

@SerializedName("fail_list")
private List<String> failList;

@SerializedName("refuse_list")
private List<String> refuseList;

@SerializedName("result_list")
private List<ResultListItem> resultList;

@Getter
@Setter
public static class ResultListItem {
private String openid;
@SerializedName("result_code")
private Integer resultCode;
@SerializedName("reason_code")
private Integer reasonCode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

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

/**
* @author leiin
* @date 2022/6/18 2:53 下午
*/
@Data
public class WxMaShopSharerDataSummaryResponse extends WxMaShopBaseResponse implements Serializable {

private static final long serialVersionUID = 3985829585979186778L;

private Long gmv;
@SerializedName("order_cnt")
private Long orderCnt;
@SerializedName("user_cnt")
private Long userCnt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

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

/**
* @author leiin
* @date 2022/6/18 2:55 下午
*/
@Data
public class WxMaShopSharerListResponse extends WxMaShopBaseResponse implements Serializable {

private static final long serialVersionUID = -8533731677643022825L;

private List<SharerInfo> sharers;
@SerializedName("total_num")
private Integer totalNum;

@Data
public static class SharerInfo {
private String openid;
@SerializedName("invited_time")
private Long invitedTime;
@SerializedName("bind_time")
private Long bindTime;
private String nickname;
}
}
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.WxMaShopOrderDetail;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.Data;

/**
* @author leiin
* @date 2022/6/18 2:56 下午
*/
@Data
public class WxMaShopSharerLiveOrderListResponse extends WxMaShopBaseResponse implements Serializable {

private static final long serialVersionUID = -4190199778148290127L;

private List<WxMaShopOrderDetail> orders;

@SerializedName("total_num")
private Integer totalNum;
}
Loading