Skip to content

Commit 0104af1

Browse files
authored
🆕 #3188 【视频号】实现视频号助手相关接口
1 parent 44ec8b2 commit 0104af1

31 files changed

+1870
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
4+
import me.chanjar.weixin.channel.bean.window.request.AddWindowProductRequest;
5+
import me.chanjar.weixin.channel.bean.window.request.GetWindowProductListRequest;
6+
import me.chanjar.weixin.channel.bean.window.request.WindowProductRequest;
7+
import me.chanjar.weixin.channel.bean.window.response.GetWindowProductListResponse;
8+
import me.chanjar.weixin.channel.bean.window.response.GetWindowProductResponse;
9+
import me.chanjar.weixin.common.error.WxErrorException;
10+
11+
/**
12+
* 视频号助手 橱窗管理服务 <br/>
13+
* 关于橱窗商品ID的说明: <br/>
14+
* 不支持带货中心来源的商品,其余商品的橱窗商品ID与商品来源处的平台内部商品ID相同,对应关系如下 <br/>
15+
* <pre>
16+
* 商品来源 橱窗ID说明
17+
* 视频号小店 视频号小店商品的 product_id 字段
18+
* 交易组件 组件商品的 product_id 字段
19+
* </pre>
20+
*
21+
* @author <a href="https://github.com/imyzt">imyzt</a>
22+
*/
23+
public interface WxAssistantService {
24+
25+
/**
26+
* <a href="https://developers.weixin.qq.com/doc/channels/API/windowproduct/add.html">上架商品到橱窗</a>
27+
* @param req 商品信息
28+
* @return 操作结果
29+
*/
30+
WxChannelBaseResponse addWindowProduct(AddWindowProductRequest req) throws WxErrorException;
31+
32+
/**
33+
* <a href="https://developers.weixin.qq.com/doc/channels/API/windowproduct/get.html">获取橱窗商品详情</a>
34+
*
35+
* @param req 商品信息
36+
* @return 橱窗商品详情
37+
*/
38+
GetWindowProductResponse getWindowProduct(WindowProductRequest req) throws WxErrorException;
39+
40+
/**
41+
* <a href="https://developers.weixin.qq.com/doc/channels/API/windowproduct/list_get.html">获取已添加到橱窗的商品列表</a>
42+
* 接口限制了 page_size × page_index ≤ 10000。命中限制时建议改用传last_buffer顺序翻页的请求方式
43+
* @param req 商品信息
44+
* @return 已添加到橱窗的商品列表
45+
*/
46+
GetWindowProductListResponse getWindowProductList(GetWindowProductListRequest req) throws WxErrorException;
47+
48+
/**
49+
* <a href="https://developers.weixin.qq.com/doc/channels/API/windowproduct/off.html">下架橱窗商品</a>
50+
* @param req 商品信息
51+
* @return 操作结果
52+
*/
53+
WxChannelBaseResponse offWindowProduct(WindowProductRequest req) throws WxErrorException;
54+
55+
}

Diff for: weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java

+21
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,25 @@ public interface WxChannelService extends BaseWxChannelService {
119119
*/
120120
WxLeagueProductService getLeagueProductService();
121121

122+
/**
123+
* 视频号助手 留资组件管理服务
124+
*
125+
* @return 留资组件管理服务
126+
*/
127+
WxLeadComponentService getLeadComponentService();
128+
129+
/**
130+
* 视频号助手 留资服务的直播数据服务
131+
*
132+
* @return 留资服务的直播数据服务
133+
*/
134+
WxFinderLiveService getFinderLiveService();
135+
136+
/**
137+
* 视频号助手 橱窗管理服务
138+
*
139+
* @return 橱窗管理服务
140+
*/
141+
WxAssistantService getAssistantService();
142+
122143
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveDataListRequest;
4+
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveLeadsDataRequest;
5+
import me.chanjar.weixin.channel.bean.lead.component.response.FinderAttrResponse;
6+
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveDataListResponse;
7+
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveLeadsDataResponse;
8+
import me.chanjar.weixin.common.error.WxErrorException;
9+
10+
/**
11+
* 视频号助手 留资服务的直播数据服务
12+
*
13+
* @author <a href="https://github.com/imyzt">imyzt</a>
14+
*/
15+
public interface WxFinderLiveService {
16+
17+
/**
18+
* <a href="https://developers.weixin.qq.com/doc/channels/API/live/get_finder_attr_by_appid.html">获取视频号账号信息</a>
19+
*
20+
* @return 视频号账号信息
21+
*/
22+
FinderAttrResponse getFinderAttrByAppid() throws WxErrorException;
23+
24+
/**
25+
* <a href="https://developers.weixin.qq.com/doc/channels/API/live/get_finder_live_data_list.html">获取留资直播间数据详情</a>
26+
*
27+
* @param req 留资组件信息
28+
* @return 留资信息详情
29+
*/
30+
GetFinderLiveDataListResponse getFinderLiveDataList(GetFinderLiveDataListRequest req) throws WxErrorException;
31+
32+
/**
33+
* <a href="https://developers.weixin.qq.com/doc/channels/API/live/get_finder_live_leads_data.html">获取账号收集的留资数量</a>
34+
* 说明:该接口只统计2023.9.13号起的数据,所以start_time应大于等于1694534400
35+
*
36+
* @param req 留资组件信息
37+
* @return 留资信息列表
38+
*/
39+
GetFinderLiveLeadsDataResponse getFinderLiveLeadsData(GetFinderLiveLeadsDataRequest req) throws WxErrorException;
40+
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadInfoByComponentRequest;
4+
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsComponentIdRequest;
5+
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsComponentPromoteRecordRequest;
6+
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsInfoByRequestIdRequest;
7+
import me.chanjar.weixin.channel.bean.lead.component.request.GetLeadsRequestIdRequest;
8+
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsComponentIdResponse;
9+
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsComponentPromoteRecordResponse;
10+
import me.chanjar.weixin.channel.bean.lead.component.response.GetLeadsRequestIdResponse;
11+
import me.chanjar.weixin.channel.bean.lead.component.response.LeadInfoResponse;
12+
import me.chanjar.weixin.common.error.WxErrorException;
13+
14+
/**
15+
* 视频号助手 留资组件管理服务
16+
*
17+
* @author <a href="https://github.com/imyzt">imyzt</a>
18+
*/
19+
public interface WxLeadComponentService {
20+
21+
/**
22+
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_info_by_component_id.html">按时间获取留资信息详情</a>
23+
*
24+
* @param req 留资组件信息
25+
* @return 留资信息详情
26+
*/
27+
LeadInfoResponse getLeadsInfoByComponentId(GetLeadInfoByComponentRequest req) throws WxErrorException;
28+
29+
/**
30+
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_info_by_request_id.html">按直播场次获取留资信息详情</a>
31+
*
32+
* @param req 留资组件信息
33+
* @return 留资信息详情
34+
*/
35+
LeadInfoResponse getLeadsInfoByRequestId(GetLeadsInfoByRequestIdRequest req) throws WxErrorException;
36+
37+
/**
38+
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_request_id.html">获取留资request_id列表详情</a>
39+
*
40+
* @param req 留资组件信息
41+
* @return 留资信息列表
42+
*/
43+
GetLeadsRequestIdResponse getLeadsRequestId(GetLeadsRequestIdRequest req) throws WxErrorException;
44+
45+
/**
46+
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_component_promote_record.html">获取留资组件直播推广记录信息详情</a>
47+
*
48+
* @param req 留资组件信息
49+
* @return 留资组件直播推广记录信息详情
50+
*/
51+
GetLeadsComponentPromoteRecordResponse getLeadsComponentPromoteRecord(GetLeadsComponentPromoteRecordRequest req) throws WxErrorException;
52+
53+
/**
54+
* <a href="https://developers.weixin.qq.com/doc/channels/API/leads/get_leads_component_id.html">获取留资组件Id列表详情</a>
55+
*
56+
* @param req 留资组件信息
57+
* @return 留资组件Id列表
58+
*/
59+
GetLeadsComponentIdResponse getLeadsComponentId(GetLeadsComponentIdRequest req) throws WxErrorException;
60+
}

Diff for: weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java

+49-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@
33

44
import com.google.gson.JsonObject;
55
import lombok.extern.slf4j.Slf4j;
6-
import me.chanjar.weixin.channel.api.*;
6+
import me.chanjar.weixin.channel.api.WxAssistantService;
7+
import me.chanjar.weixin.channel.api.WxChannelAddressService;
8+
import me.chanjar.weixin.channel.api.WxChannelAfterSaleService;
9+
import me.chanjar.weixin.channel.api.WxChannelBasicService;
10+
import me.chanjar.weixin.channel.api.WxChannelBrandService;
11+
import me.chanjar.weixin.channel.api.WxChannelCategoryService;
12+
import me.chanjar.weixin.channel.api.WxChannelCouponService;
13+
import me.chanjar.weixin.channel.api.WxChannelFreightTemplateService;
14+
import me.chanjar.weixin.channel.api.WxChannelFundService;
15+
import me.chanjar.weixin.channel.api.WxChannelOrderService;
16+
import me.chanjar.weixin.channel.api.WxChannelProductService;
17+
import me.chanjar.weixin.channel.api.WxChannelService;
18+
import me.chanjar.weixin.channel.api.WxChannelSharerService;
19+
import me.chanjar.weixin.channel.api.WxChannelWarehouseService;
20+
import me.chanjar.weixin.channel.api.WxFinderLiveService;
21+
import me.chanjar.weixin.channel.api.WxLeadComponentService;
22+
import me.chanjar.weixin.channel.api.WxLeagueProductService;
23+
import me.chanjar.weixin.channel.api.WxLeaguePromoterService;
24+
import me.chanjar.weixin.channel.api.WxLeagueSupplierService;
25+
import me.chanjar.weixin.channel.api.WxLeagueWindowService;
726
import me.chanjar.weixin.channel.config.WxChannelConfig;
827
import me.chanjar.weixin.channel.util.JsonUtils;
928
import me.chanjar.weixin.common.api.WxConsts;
@@ -51,6 +70,9 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
5170
private WxLeagueSupplierService leagueSupplierService = null;
5271
private WxLeaguePromoterService leaguePromoterService = null;
5372
private WxLeagueProductService leagueProductService = null;
73+
private WxLeadComponentService leadComponentService = null;
74+
private WxFinderLiveService finderLiveService = null;
75+
private WxAssistantService assistantService = null;
5476

5577
protected WxChannelConfig config;
5678
private int retrySleepMillis = 1000;
@@ -377,4 +399,30 @@ public synchronized WxLeagueProductService getLeagueProductService() {
377399
}
378400
return leagueProductService;
379401
}
402+
403+
@Override
404+
public WxLeadComponentService getLeadComponentService() {
405+
if (leadComponentService == null) {
406+
leadComponentService = new WxLeadComponentServiceImpl(this);
407+
}
408+
return leadComponentService;
409+
}
410+
411+
@Override
412+
public WxFinderLiveService getFinderLiveService() {
413+
if (finderLiveService == null) {
414+
finderLiveService = new WxFinderLiveServiceImpl(this);
415+
}
416+
return finderLiveService;
417+
}
418+
419+
@Override
420+
public WxAssistantService getAssistantService() {
421+
if (assistantService == null) {
422+
assistantService = new WxAssistantServiceImpl(this) {
423+
};
424+
}
425+
return assistantService;
426+
}
427+
380428
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package me.chanjar.weixin.channel.api.impl;
2+
3+
4+
import lombok.RequiredArgsConstructor;
5+
import lombok.extern.slf4j.Slf4j;
6+
import me.chanjar.weixin.channel.api.WxAssistantService;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
import me.chanjar.weixin.channel.bean.window.request.AddWindowProductRequest;
9+
import me.chanjar.weixin.channel.bean.window.request.GetWindowProductListRequest;
10+
import me.chanjar.weixin.channel.bean.window.request.WindowProductRequest;
11+
import me.chanjar.weixin.channel.bean.window.response.GetWindowProductListResponse;
12+
import me.chanjar.weixin.channel.bean.window.response.GetWindowProductResponse;
13+
import me.chanjar.weixin.channel.util.ResponseUtils;
14+
import me.chanjar.weixin.common.error.WxErrorException;
15+
16+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assistant.ADD_WINDOW_PRODUCT_URL;
17+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assistant.GET_WINDOW_PRODUCT_URL;
18+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assistant.LIST_WINDOW_PRODUCT_URL;
19+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assistant.OFF_WINDOW_PRODUCT_URL;
20+
21+
/**
22+
* 视频号助手 橱窗管理服务
23+
*
24+
* @author <a href="https://github.com/imyzt">imyzt</a>
25+
*/
26+
@RequiredArgsConstructor
27+
@Slf4j
28+
public class WxAssistantServiceImpl implements WxAssistantService {
29+
30+
/** 微信商店服务 */
31+
private final BaseWxChannelServiceImpl shopService;
32+
@Override
33+
public WxChannelBaseResponse addWindowProduct(AddWindowProductRequest req) throws WxErrorException {
34+
String resJson = shopService.post(ADD_WINDOW_PRODUCT_URL, "{}");
35+
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
36+
}
37+
38+
@Override
39+
public GetWindowProductResponse getWindowProduct(WindowProductRequest req) throws WxErrorException {
40+
String resJson = shopService.post(GET_WINDOW_PRODUCT_URL, "{}");
41+
return ResponseUtils.decode(resJson, GetWindowProductResponse.class);
42+
}
43+
44+
@Override
45+
public GetWindowProductListResponse getWindowProductList(GetWindowProductListRequest req) throws WxErrorException {
46+
String resJson = shopService.post(LIST_WINDOW_PRODUCT_URL, "{}");
47+
return ResponseUtils.decode(resJson, GetWindowProductListResponse.class);
48+
}
49+
50+
@Override
51+
public WxChannelBaseResponse offWindowProduct(WindowProductRequest req) throws WxErrorException {
52+
String resJson = shopService.post(OFF_WINDOW_PRODUCT_URL, "{}");
53+
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package me.chanjar.weixin.channel.api.impl;
2+
3+
4+
import lombok.RequiredArgsConstructor;
5+
import lombok.extern.slf4j.Slf4j;
6+
import me.chanjar.weixin.channel.api.WxFinderLiveService;
7+
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveDataListRequest;
8+
import me.chanjar.weixin.channel.bean.lead.component.request.GetFinderLiveLeadsDataRequest;
9+
import me.chanjar.weixin.channel.bean.lead.component.response.FinderAttrResponse;
10+
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveDataListResponse;
11+
import me.chanjar.weixin.channel.bean.lead.component.response.GetFinderLiveLeadsDataResponse;
12+
import me.chanjar.weixin.channel.util.ResponseUtils;
13+
import me.chanjar.weixin.common.error.WxErrorException;
14+
15+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FinderLive.GET_FINDER_ATTR_BY_APPID;
16+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FinderLive.GET_FINDER_LIVE_DATA_LIST;
17+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.FinderLive.GET_FINDER_LIVE_LEADS_DATA;
18+
19+
/**
20+
* 视频号助手 留资服务的直播数据服务
21+
* @author imyzt
22+
* @date 2024/01/27
23+
*/
24+
@RequiredArgsConstructor
25+
@Slf4j
26+
public class WxFinderLiveServiceImpl implements WxFinderLiveService {
27+
28+
/** 微信商店服务 */
29+
private final BaseWxChannelServiceImpl shopService;
30+
@Override
31+
public FinderAttrResponse getFinderAttrByAppid() throws WxErrorException {
32+
String resJson = shopService.post(GET_FINDER_ATTR_BY_APPID, "{}");
33+
return ResponseUtils.decode(resJson, FinderAttrResponse.class);
34+
}
35+
36+
@Override
37+
public GetFinderLiveDataListResponse getFinderLiveDataList(GetFinderLiveDataListRequest req) throws WxErrorException {
38+
String resJson = shopService.post(GET_FINDER_LIVE_DATA_LIST, req);
39+
return ResponseUtils.decode(resJson, GetFinderLiveDataListResponse.class);
40+
}
41+
42+
@Override
43+
public GetFinderLiveLeadsDataResponse getFinderLiveLeadsData(GetFinderLiveLeadsDataRequest req) throws WxErrorException {
44+
String resJson = shopService.post(GET_FINDER_LIVE_LEADS_DATA, req);
45+
return ResponseUtils.decode(resJson, GetFinderLiveLeadsDataResponse.class);
46+
}
47+
}

0 commit comments

Comments
 (0)