-
-
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.
🆕 #3368 【视频号】新增视频号助手-直播大屏数据、罗盘达人版API相关接口
- Loading branch information
1 parent
0b9444d
commit 31d2f72
Showing
64 changed files
with
3,475 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...va-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelCompassFinderService.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,58 @@ | ||
package me.chanjar.weixin.channel.api; | ||
|
||
import me.chanjar.weixin.channel.bean.compass.finder.OverallResponse; | ||
import me.chanjar.weixin.channel.bean.compass.finder.ProductDataResponse; | ||
import me.chanjar.weixin.channel.bean.compass.finder.ProductListResponse; | ||
import me.chanjar.weixin.channel.bean.compass.finder.SaleProfileDataResponse; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
|
||
/** | ||
* 视频号助手 罗盘达人版服务 | ||
* | ||
* @author <a href="https://github.com/Winnie-by996">Winnie</a> | ||
*/ | ||
public interface WxChannelCompassFinderService { | ||
|
||
/** | ||
* 获取电商概览数据 | ||
* | ||
* @param ds 日期,格式 yyyyMMdd | ||
* @return 电商概览数据 | ||
* | ||
* @throws WxErrorException 异常 | ||
*/ | ||
OverallResponse getOverall(String ds) throws WxErrorException; | ||
|
||
/** | ||
* 获取带货商品数据 | ||
* | ||
* @param ds 日期,格式 yyyyMMdd | ||
* @param productId 商品id | ||
* @return 带货商品数据 | ||
* | ||
* @throws WxErrorException 异常 | ||
*/ | ||
ProductDataResponse getProductData(String ds, String productId) throws WxErrorException; | ||
|
||
/** | ||
* 获取带货商品列表 | ||
* | ||
* @param ds 日期,格式 yyyyMMdd | ||
* @return 带货商品列表 | ||
* | ||
* @throws WxErrorException 异常 | ||
*/ | ||
ProductListResponse getProductList(String ds) throws WxErrorException; | ||
|
||
/** | ||
* 获取带货人群数据 | ||
* | ||
* @param ds 日期,格式 yyyyMMdd | ||
* @param type 用户类型,1=商品曝光用户, 2=商品点击用户, 3=购买用户, 4=首购用户, 5=复购用户, 6=直播观看用户 | ||
* @return 带货人群数据 | ||
* | ||
* @throws WxErrorException 异常 | ||
*/ | ||
SaleProfileDataResponse getSaleProfileData(String ds, Integer type) throws WxErrorException; | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...va-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelLiveDashboardService.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,34 @@ | ||
package me.chanjar.weixin.channel.api; | ||
|
||
import me.chanjar.weixin.channel.bean.live.dashboard.LiveDataResponse; | ||
import me.chanjar.weixin.channel.bean.live.dashboard.LiveListResponse; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
|
||
/** | ||
* 视频号助手 直播大屏数据服务 | ||
* | ||
* @author <a href="https://github.com/Winnie-by996">Winnie</a> | ||
*/ | ||
public interface WxChannelLiveDashboardService { | ||
|
||
/** | ||
* 获取直播大屏直播列表 | ||
* | ||
* @param ds 日期,格式 yyyyMMdd | ||
* @return 播大屏直播列表 | ||
* | ||
* @throws WxErrorException 异常 | ||
*/ | ||
LiveListResponse getLiveList(Long ds) throws WxErrorException; | ||
|
||
/** | ||
* 获取直播大屏数据 | ||
* | ||
* @param exportId 直播唯一ID | ||
* @return 播大屏数据 | ||
* | ||
* @throws WxErrorException 异常 | ||
*/ | ||
LiveDataResponse getLiveData(String exportId) 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
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
54 changes: 54 additions & 0 deletions
54
...l/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelCompassFinderServiceImpl.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,54 @@ | ||
package me.chanjar.weixin.channel.api.impl; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import me.chanjar.weixin.channel.api.WxChannelCompassFinderService; | ||
import me.chanjar.weixin.channel.bean.compass.finder.*; | ||
import me.chanjar.weixin.channel.util.ResponseUtils; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
|
||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.CompassFinder.*; | ||
|
||
/** | ||
* 视频号助手 罗盘达人版服务实现 | ||
* | ||
* @author <a href="https://github.com/Winnie-by996">Winnie</a> | ||
*/ | ||
@Slf4j | ||
public class WxChannelCompassFinderServiceImpl implements WxChannelCompassFinderService { | ||
|
||
/** | ||
* 微信商店服务 | ||
*/ | ||
private final BaseWxChannelServiceImpl shopService; | ||
|
||
public WxChannelCompassFinderServiceImpl(BaseWxChannelServiceImpl shopService) {this.shopService = shopService;} | ||
|
||
@Override | ||
public OverallResponse getOverall(String ds) throws WxErrorException { | ||
CompassFinderBaseParam param = new CompassFinderBaseParam(ds); | ||
String resJson = shopService.post(GET_OVERALL_URL, param); | ||
return ResponseUtils.decode(resJson, OverallResponse.class); | ||
} | ||
|
||
@Override | ||
public ProductDataResponse getProductData(String ds, String productId) throws WxErrorException { | ||
ProductDataParam param = new ProductDataParam(ds, productId); | ||
String resJson = shopService.post(GET_PRODUCT_DATA_URL, param); | ||
return ResponseUtils.decode(resJson, ProductDataResponse.class); | ||
} | ||
|
||
@Override | ||
public ProductListResponse getProductList(String ds) throws WxErrorException { | ||
CompassFinderBaseParam param = new CompassFinderBaseParam(ds); | ||
String resJson = shopService.post(GET_PRODUCT_LIST_URL, param); | ||
return ResponseUtils.decode(resJson, ProductListResponse.class); | ||
} | ||
|
||
@Override | ||
public SaleProfileDataResponse getSaleProfileData(String ds, Integer type) throws WxErrorException { | ||
SaleProfileDataParam param = new SaleProfileDataParam(ds, type); | ||
String resJson = shopService.post(GET_SALE_PROFILE_DATA_URL, param); | ||
return ResponseUtils.decode(resJson, SaleProfileDataResponse.class); | ||
} | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
...l/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelLiveDashboardServiceImpl.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,81 @@ | ||
package me.chanjar.weixin.channel.api.impl; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.extern.slf4j.Slf4j; | ||
import me.chanjar.weixin.channel.api.WxChannelLiveDashboardService; | ||
import me.chanjar.weixin.channel.bean.live.dashboard.LiveDataParam; | ||
import me.chanjar.weixin.channel.bean.live.dashboard.LiveDataResponse; | ||
import me.chanjar.weixin.channel.bean.live.dashboard.LiveListParam; | ||
import me.chanjar.weixin.channel.bean.live.dashboard.LiveListResponse; | ||
import me.chanjar.weixin.channel.util.ResponseUtils; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
import org.apache.commons.lang3.ObjectUtils; | ||
|
||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.LiveDashboard.*; | ||
|
||
/** | ||
* 视频号助手 直播大屏数据服务实现 | ||
* | ||
* @author <a href="https://github.com/Winnie-by996">Winnie</a> | ||
*/ | ||
@Slf4j | ||
public class WxChannelLiveDashboardServiceImpl implements WxChannelLiveDashboardService { | ||
|
||
/** | ||
* 微信商店服务 | ||
*/ | ||
private final BaseWxChannelServiceImpl shopService; | ||
private final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
public WxChannelLiveDashboardServiceImpl(BaseWxChannelServiceImpl shopService) {this.shopService = shopService;} | ||
|
||
@Override | ||
public LiveListResponse getLiveList(Long ds) throws WxErrorException { | ||
LiveListParam param = new LiveListParam(ds); | ||
String resJson = shopService.post(GET_LIVE_LIST_URL, param); | ||
return ResponseUtils.decode(resJson, LiveListResponse.class); | ||
} | ||
|
||
@Override | ||
public LiveDataResponse getLiveData(String exportId) throws WxErrorException { | ||
LiveDataParam param = new LiveDataParam(exportId); | ||
String resJson = shopService.post(GET_LIVE_DATA_URL, param); | ||
return this.convertLiveDataResponse(resJson); | ||
} | ||
|
||
/** | ||
* 微信接口获取直播数据中存在非标准JSON,方便业务处理返回前做好解析 | ||
* 处理参数: | ||
* live_dashboard_data,live_comparison_index,live_ec_data_summary,live_ec_conversion_metric, | ||
* live_ec_profile,live_distribution_channel,single_live_ec_spu_data_page_v2 | ||
* | ||
* @param resJson 直播数据返回JSON | ||
* @return LiveDataResponse | ||
* | ||
* @throws WxErrorException 异常 | ||
*/ | ||
private LiveDataResponse convertLiveDataResponse(String resJson) throws WxErrorException { | ||
try { | ||
ObjectNode rootNode = (ObjectNode) objectMapper.readTree(resJson); | ||
String[] dataKeyArray = new String[] { | ||
"live_dashboard_data", "live_comparison_index", "live_ec_data_summary", "live_ec_conversion_metric", | ||
"live_ec_profile", "live_distribution_channel", "single_live_ec_spu_data_page_v2" | ||
}; | ||
for(String dataKey : dataKeyArray) { | ||
JsonNode jsonNode = rootNode.get(dataKey); | ||
if (ObjectUtils.isNotEmpty(jsonNode)) { | ||
JsonNode dataJsonNode = objectMapper.readTree(jsonNode.asText()); | ||
rootNode.set(dataKey, dataJsonNode); | ||
} | ||
} | ||
String json = objectMapper.writeValueAsString(rootNode); | ||
return ResponseUtils.decode(json, LiveDataResponse.class); | ||
} catch (JsonProcessingException e) { | ||
throw new WxErrorException(e); | ||
} | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...l/src/main/java/me/chanjar/weixin/channel/bean/compass/finder/CompassFinderBaseParam.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,30 @@ | ||
package me.chanjar.weixin.channel.bean.compass.finder; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* 获取达人罗盘数据通用请求参数 | ||
* | ||
* @author <a href="https://github.com/Winnie-by996">Winnie</a> | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class CompassFinderBaseParam implements Serializable { | ||
|
||
private static final long serialVersionUID = - 4900361041041434435L; | ||
|
||
/** | ||
* 日期,格式 yyyyMMdd | ||
*/ | ||
@JsonProperty("ds") | ||
private String ds; | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/compass/finder/Field.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,33 @@ | ||
package me.chanjar.weixin.channel.bean.compass.finder; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
/** | ||
* 维度数据 | ||
* | ||
* @author <a href="https://github.com/Winnie-by996">Winnie</a> | ||
*/ | ||
@Data | ||
@NoArgsConstructor | ||
public class Field implements Serializable { | ||
|
||
private static final long serialVersionUID = - 4243469984232948689L; | ||
|
||
/** | ||
* 维度类别名 | ||
*/ | ||
@JsonProperty("field_name") | ||
private String fieldName; | ||
|
||
/** | ||
* 维度指标数据列表 | ||
*/ | ||
@JsonProperty("data_list") | ||
private List<FieldData> dataList; | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...n-java-channel/src/main/java/me/chanjar/weixin/channel/bean/compass/finder/FieldData.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,32 @@ | ||
package me.chanjar.weixin.channel.bean.compass.finder; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* 维度指标数据 | ||
* | ||
* @author <a href="https://github.com/Winnie-by996">Winnie</a> | ||
*/ | ||
@Data | ||
@NoArgsConstructor | ||
public class FieldData implements Serializable { | ||
|
||
private static final long serialVersionUID = - 4022953139259283599L; | ||
|
||
/** | ||
* 维度指标名 | ||
*/ | ||
@JsonProperty("dim_key") | ||
private String dimKey; | ||
|
||
/** | ||
* 维度指标值 | ||
*/ | ||
@JsonProperty("dim_value") | ||
private String dimValue; | ||
|
||
} |
Oops, something went wrong.