Skip to content

Commit

Permalink
🆕 binarywang#3188 【视频号】实现视频号助手相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
imyzt authored and boris.bao committed Mar 23, 2024
1 parent c2cfcdd commit a670e70
Show file tree
Hide file tree
Showing 31 changed files with 1,870 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package me.chanjar.weixin.channel.api;

import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
import me.chanjar.weixin.channel.bean.window.request.AddWindowProductRequest;
import me.chanjar.weixin.channel.bean.window.request.GetWindowProductListRequest;
import me.chanjar.weixin.channel.bean.window.request.WindowProductRequest;
import me.chanjar.weixin.channel.bean.window.response.GetWindowProductListResponse;
import me.chanjar.weixin.channel.bean.window.response.GetWindowProductResponse;
import me.chanjar.weixin.common.error.WxErrorException;

/**
* 视频号助手 橱窗管理服务 <br/>
* 关于橱窗商品ID的说明: <br/>
* 不支持带货中心来源的商品,其余商品的橱窗商品ID与商品来源处的平台内部商品ID相同,对应关系如下 <br/>
* <pre>
* 商品来源 橱窗ID说明
* 视频号小店 视频号小店商品的 product_id 字段
* 交易组件 组件商品的 product_id 字段
* </pre>
*
* @author <a href="https://github.com/imyzt">imyzt</a>
*/
public interface WxAssistantService {

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/windowproduct/add.html">上架商品到橱窗</a>
* @param req 商品信息
* @return 操作结果
*/
WxChannelBaseResponse addWindowProduct(AddWindowProductRequest req) throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/windowproduct/get.html">获取橱窗商品详情</a>
*
* @param req 商品信息
* @return 橱窗商品详情
*/
GetWindowProductResponse getWindowProduct(WindowProductRequest req) throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/windowproduct/list_get.html">获取已添加到橱窗的商品列表</a>
* 接口限制了 page_size × page_index ≤ 10000。命中限制时建议改用传last_buffer顺序翻页的请求方式
* @param req 商品信息
* @return 已添加到橱窗的商品列表
*/
GetWindowProductListResponse getWindowProductList(GetWindowProductListRequest req) throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/windowproduct/off.html">下架橱窗商品</a>
* @param req 商品信息
* @return 操作结果
*/
WxChannelBaseResponse offWindowProduct(WindowProductRequest req) throws WxErrorException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,25 @@ public interface WxChannelService extends BaseWxChannelService {
*/
WxLeagueProductService getLeagueProductService();

/**
* 视频号助手 留资组件管理服务
*
* @return 留资组件管理服务
*/
WxLeadComponentService getLeadComponentService();

/**
* 视频号助手 留资服务的直播数据服务
*
* @return 留资服务的直播数据服务
*/
WxFinderLiveService getFinderLiveService();

/**
* 视频号助手 橱窗管理服务
*
* @return 橱窗管理服务
*/
WxAssistantService getAssistantService();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package me.chanjar.weixin.channel.api;

import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveDataListRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveLeadsDataRequest;
import me.chanjar.weixin.channel.bean.lead.component.response.FinderAttrResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveDataListResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveLeadsDataResponse;
import me.chanjar.weixin.common.error.WxErrorException;

/**
* 视频号助手 留资服务的直播数据服务
*
* @author <a href="https://github.com/imyzt">imyzt</a>
*/
public interface WxFinderLiveService {

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/live/get_finder_attr_by_appid.html">获取视频号账号信息</a>
*
* @return 视频号账号信息
*/
FinderAttrResponse getFinderAttrByAppid() throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/live/get_finder_live_data_list.html">获取留资直播间数据详情</a>
*
* @param req 留资组件信息
* @return 留资信息详情
*/
GetFinderLiveDataListResponse getFinderLiveDataList(GetFinderLiveDataListRequest req) throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/live/get_finder_live_leads_data.html">获取账号收集的留资数量</a>
* 说明:该接口只统计2023.9.13号起的数据,所以start_time应大于等于1694534400
*
* @param req 留资组件信息
* @return 留资信息列表
*/
GetFinderLiveLeadsDataResponse getFinderLiveLeadsData(GetFinderLiveLeadsDataRequest req) throws WxErrorException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package me.chanjar.weixin.channel.api;

import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadInfoByComponentRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsComponentIdRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsComponentPromoteRecordRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsInfoByRequestIdRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsRequestIdRequest;
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsComponentIdResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsComponentPromoteRecordResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsRequestIdResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.LeadInfoResponse;
import me.chanjar.weixin.common.error.WxErrorException;

/**
* 视频号助手 留资组件管理服务
*
* @author <a href="https://github.com/imyzt">imyzt</a>
*/
public interface WxLeadComponentService {

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_info_by_component_id.html">按时间获取留资信息详情</a>
*
* @param req 留资组件信息
* @return 留资信息详情
*/
LeadInfoResponse getLeadsInfoByComponentId(GetLeadInfoByComponentRequest req) throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_info_by_request_id.html">按直播场次获取留资信息详情</a>
*
* @param req 留资组件信息
* @return 留资信息详情
*/
LeadInfoResponse getLeadsInfoByRequestId(GetLeadsInfoByRequestIdRequest req) throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_request_id.html">获取留资request_id列表详情</a>
*
* @param req 留资组件信息
* @return 留资信息列表
*/
GetLeadsRequestIdResponse getLeadsRequestId(GetLeadsRequestIdRequest req) throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_component_promote_record.html">获取留资组件直播推广记录信息详情</a>
*
* @param req 留资组件信息
* @return 留资组件直播推广记录信息详情
*/
GetLeadsComponentPromoteRecordResponse getLeadsComponentPromoteRecord(GetLeadsComponentPromoteRecordRequest req) throws WxErrorException;

/**
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_component_id.html">获取留资组件Id列表详情</a>
*
* @param req 留资组件信息
* @return 留资组件Id列表
*/
GetLeadsComponentIdResponse getLeadsComponentId(GetLeadsComponentIdRequest req) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,26 @@

import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.channel.api.*;
import me.chanjar.weixin.channel.api.WxAssistantService;
import me.chanjar.weixin.channel.api.WxChannelAddressService;
import me.chanjar.weixin.channel.api.WxChannelAfterSaleService;
import me.chanjar.weixin.channel.api.WxChannelBasicService;
import me.chanjar.weixin.channel.api.WxChannelBrandService;
import me.chanjar.weixin.channel.api.WxChannelCategoryService;
import me.chanjar.weixin.channel.api.WxChannelCouponService;
import me.chanjar.weixin.channel.api.WxChannelFreightTemplateService;
import me.chanjar.weixin.channel.api.WxChannelFundService;
import me.chanjar.weixin.channel.api.WxChannelOrderService;
import me.chanjar.weixin.channel.api.WxChannelProductService;
import me.chanjar.weixin.channel.api.WxChannelService;
import me.chanjar.weixin.channel.api.WxChannelSharerService;
import me.chanjar.weixin.channel.api.WxChannelWarehouseService;
import me.chanjar.weixin.channel.api.WxFinderLiveService;
import me.chanjar.weixin.channel.api.WxLeadComponentService;
import me.chanjar.weixin.channel.api.WxLeagueProductService;
import me.chanjar.weixin.channel.api.WxLeaguePromoterService;
import me.chanjar.weixin.channel.api.WxLeagueSupplierService;
import me.chanjar.weixin.channel.api.WxLeagueWindowService;
import me.chanjar.weixin.channel.config.WxChannelConfig;
import me.chanjar.weixin.channel.util.JsonUtils;
import me.chanjar.weixin.common.api.WxConsts;
Expand Down Expand Up @@ -51,6 +70,9 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
private WxLeagueSupplierService leagueSupplierService = null;
private WxLeaguePromoterService leaguePromoterService = null;
private WxLeagueProductService leagueProductService = null;
private WxLeadComponentService leadComponentService = null;
private WxFinderLiveService finderLiveService = null;
private WxAssistantService assistantService = null;

protected WxChannelConfig config;
private int retrySleepMillis = 1000;
Expand Down Expand Up @@ -377,4 +399,30 @@ public synchronized WxLeagueProductService getLeagueProductService() {
}
return leagueProductService;
}

@Override
public WxLeadComponentService getLeadComponentService() {
if (leadComponentService == null) {
leadComponentService = new WxLeadComponentServiceImpl(this);
}
return leadComponentService;
}

@Override
public WxFinderLiveService getFinderLiveService() {
if (finderLiveService == null) {
finderLiveService = new WxFinderLiveServiceImpl(this);
}
return finderLiveService;
}

@Override
public WxAssistantService getAssistantService() {
if (assistantService == null) {
assistantService = new WxAssistantServiceImpl(this) {
};
}
return assistantService;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package me.chanjar.weixin.channel.api.impl;


import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.channel.api.WxAssistantService;
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
import me.chanjar.weixin.channel.bean.window.request.AddWindowProductRequest;
import me.chanjar.weixin.channel.bean.window.request.GetWindowProductListRequest;
import me.chanjar.weixin.channel.bean.window.request.WindowProductRequest;
import me.chanjar.weixin.channel.bean.window.response.GetWindowProductListResponse;
import me.chanjar.weixin.channel.bean.window.response.GetWindowProductResponse;
import me.chanjar.weixin.channel.util.ResponseUtils;
import me.chanjar.weixin.common.error.WxErrorException;

import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assistant.ADD_WINDOW_PRODUCT_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assistant.GET_WINDOW_PRODUCT_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assistant.LIST_WINDOW_PRODUCT_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assistant.OFF_WINDOW_PRODUCT_URL;

/**
* 视频号助手 橱窗管理服务
*
* @author <a href="https://github.com/imyzt">imyzt</a>
*/
@RequiredArgsConstructor
@Slf4j
public class WxAssistantServiceImpl implements WxAssistantService {

/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
@Override
public WxChannelBaseResponse addWindowProduct(AddWindowProductRequest req) throws WxErrorException {
String resJson = shopService.post(ADD_WINDOW_PRODUCT_URL, "{}");
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
}

@Override
public GetWindowProductResponse getWindowProduct(WindowProductRequest req) throws WxErrorException {
String resJson = shopService.post(GET_WINDOW_PRODUCT_URL, "{}");
return ResponseUtils.decode(resJson, GetWindowProductResponse.class);
}

@Override
public GetWindowProductListResponse getWindowProductList(GetWindowProductListRequest req) throws WxErrorException {
String resJson = shopService.post(LIST_WINDOW_PRODUCT_URL, "{}");
return ResponseUtils.decode(resJson, GetWindowProductListResponse.class);
}

@Override
public WxChannelBaseResponse offWindowProduct(WindowProductRequest req) throws WxErrorException {
String resJson = shopService.post(OFF_WINDOW_PRODUCT_URL, "{}");
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package me.chanjar.weixin.channel.api.impl;


import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.channel.api.WxFinderLiveService;
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveDataListRequest;
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveLeadsDataRequest;
import me.chanjar.weixin.channel.bean.lead.component.response.FinderAttrResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveDataListResponse;
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveLeadsDataResponse;
import me.chanjar.weixin.channel.util.ResponseUtils;
import me.chanjar.weixin.common.error.WxErrorException;

import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FinderLive.GET_FINDER_ATTR_BY_APPID;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FinderLive.GET_FINDER_LIVE_DATA_LIST;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FinderLive.GET_FINDER_LIVE_LEADS_DATA;

/**
* 视频号助手 留资服务的直播数据服务
* @author imyzt
* @date 2024/01/27
*/
@RequiredArgsConstructor
@Slf4j
public class WxFinderLiveServiceImpl implements WxFinderLiveService {

/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
@Override
public FinderAttrResponse getFinderAttrByAppid() throws WxErrorException {
String resJson = shopService.post(GET_FINDER_ATTR_BY_APPID, "{}");
return ResponseUtils.decode(resJson, FinderAttrResponse.class);
}

@Override
public GetFinderLiveDataListResponse getFinderLiveDataList(GetFinderLiveDataListRequest req) throws WxErrorException {
String resJson = shopService.post(GET_FINDER_LIVE_DATA_LIST, req);
return ResponseUtils.decode(resJson, GetFinderLiveDataListResponse.class);
}

@Override
public GetFinderLiveLeadsDataResponse getFinderLiveLeadsData(GetFinderLiveLeadsDataRequest req) throws WxErrorException {
String resJson = shopService.post(GET_FINDER_LIVE_LEADS_DATA, req);
return ResponseUtils.decode(resJson, GetFinderLiveLeadsDataResponse.class);
}
}
Loading

0 comments on commit a670e70

Please sign in to comment.