mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
⬆️ Upgrading dependencies. spring boot 2.1.4
✨ 添加新特性。 公众号数据统计功能
This commit is contained in:
1 parent
4219161d47
commit
4e64acf8a2
5 files changed
+92
-5
No files matched your search
@@ -18,7 +18,7 @@
|
||||
<properties>
|
||||
<pigx.version>2.8.0</pigx.version>
|
||||
<mybatis-plus.version>3.1.0</mybatis-plus.version>
|
||||
<mysql.connector.version>8.0.13</mysql.connector.version>
|
||||
<mysql.connector.version>8.0.15</mysql.connector.version>
|
||||
<swagger.core.version>1.5.22</swagger.core.version>
|
||||
<mp.weixin.version>3.3.0</mp.weixin.version>
|
||||
</properties>
|
||||
|
||||
+11
@@ -133,4 +133,15 @@ public class WxAccountController {
|
||||
return new R<>(wxAccountService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公众号接口数据
|
||||
*
|
||||
* @param appId 公众号
|
||||
* @param interval 时间间隔
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
public R statistics(String appId, String interval) {
|
||||
return wxAccountService.statistics(appId, interval);
|
||||
}
|
||||
}
|
||||
+9
@@ -35,4 +35,13 @@ public interface WxAccountService extends IService<WxAccount> {
|
||||
* @return
|
||||
*/
|
||||
R generateQr(String appId);
|
||||
|
||||
/**
|
||||
* 获取公众号统计数据
|
||||
*
|
||||
* @param appId
|
||||
* @param interval
|
||||
* @return
|
||||
*/
|
||||
R statistics(String appId, String interval);
|
||||
}
|
||||
+67
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.mp.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
@@ -26,10 +27,20 @@ import com.pig4cloud.pigx.mp.mapper.WxAccountMapper;
|
||||
import com.pig4cloud.pigx.mp.service.WxAccountService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpDataCubeService;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult;
|
||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult;
|
||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult;
|
||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 公众号账户
|
||||
*
|
||||
@@ -66,4 +77,60 @@ public class WxAccountServiceImpl extends ServiceImpl<WxAccountMapper, WxAccount
|
||||
|
||||
return R.builder().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公众号统计数据
|
||||
*
|
||||
* @param appId 公众号信息
|
||||
* @param interval 时间间隔
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R statistics(String appId, String interval) {
|
||||
String[] split = interval.split(StrUtil.DASHED);
|
||||
Date start = new Date(Long.parseLong(split[0]));
|
||||
Date end = new Date(Long.parseLong(split[1]));
|
||||
|
||||
WxMpService wxMpService = WxMpConfiguration.getMpServices().get(appId);
|
||||
WxMpDataCubeService cubeService = wxMpService.getDataCubeService();
|
||||
|
||||
List<List<Object>> result = new ArrayList<>();
|
||||
try {
|
||||
// 获取累计用户数据
|
||||
List<Object> cumulateList = cubeService.getUserCumulate(start, end).stream()
|
||||
.map(WxDataCubeUserCumulate::getCumulateUser)
|
||||
.collect(Collectors.toList());
|
||||
result.add(cumulateList);
|
||||
|
||||
// 获取用户分享数据
|
||||
List<Object> shareList = cubeService.getUserShare(start, end).stream()
|
||||
.map(WxDataCubeArticleResult::getShareCount)
|
||||
.collect(Collectors.toList());
|
||||
result.add(shareList);
|
||||
|
||||
// 获取消息发送概况数据
|
||||
List<Object> upstreamList = cubeService.getUpstreamMsg(start, end).stream()
|
||||
.map(WxDataCubeMsgResult::getMsgCount)
|
||||
.collect(Collectors.toList());
|
||||
result.add(upstreamList);
|
||||
|
||||
// 获取接口调用概况数据
|
||||
List<WxDataCubeInterfaceResult> interfaceSummaryList = cubeService.getInterfaceSummary(start, end);
|
||||
List<Object> interfaceList = interfaceSummaryList.stream()
|
||||
.map(WxDataCubeInterfaceResult::getCallbackCount)
|
||||
.collect(Collectors.toList());
|
||||
result.add(interfaceList);
|
||||
|
||||
// 接口日期保存
|
||||
List<Object> dateList = interfaceSummaryList.stream()
|
||||
.map(WxDataCubeInterfaceResult::getRefDate)
|
||||
.collect(Collectors.toList());
|
||||
result.add(dateList);
|
||||
} catch (WxErrorException e) {
|
||||
log.error(" 获取公众号统计数据报错", e);
|
||||
return R.builder().code(CommonConstants.FAIL).msg("获取公众号数据失败:" + e.getError().getErrorMsg()).build();
|
||||
}
|
||||
|
||||
return R.builder().data(result).build();
|
||||
}
|
||||
}
|
||||
@@ -42,14 +42,14 @@
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<spring-boot.version>2.1.3.RELEASE</spring-boot.version>
|
||||
<spring-boot.version>2.1.4.RELEASE</spring-boot.version>
|
||||
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
|
||||
<spring-platform.version>Cairo-SR7</spring-platform.version>
|
||||
<spring-platform.version>Cairo-SR8</spring-platform.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<spring-boot-admin.version>2.1.3</spring-boot-admin.version>
|
||||
<hutool.version>4.4.5</hutool.version>
|
||||
<hutool.version>4.5.3</hutool.version>
|
||||
<kaptcha.version>0.0.9</kaptcha.version>
|
||||
<swagger.fox.version>2.9.2</swagger.fox.version>
|
||||
<curator.version>2.10.0</curator.version>
|
||||
@@ -57,7 +57,7 @@
|
||||
<lcn.version>4.1.0</lcn.version>
|
||||
<jasypt.version>2.1.1</jasypt.version>
|
||||
<ttl.version>2.10.2</ttl.version>
|
||||
<minio.version>6.0.2</minio.version>
|
||||
<minio.version>6.0.4</minio.version>
|
||||
<elastic-job-lite.version>2.1.5</elastic-job-lite.version>
|
||||
<security.oauth.version>2.3.5.RELEASE</security.oauth.version>
|
||||
<security.oauth.auto.version>2.1.2.RELEASE</security.oauth.auto.version>
|
||||
|
||||
Reference in new issue
Block a user