实现“扫码访问人数、推送订阅人数、预览视频人数统计”

This commit is contained in:
longbinbin 2024-12-12 16:21:52 +08:00
parent ba4c339660
commit ebd01b4247
6 changed files with 164 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package com.ycwl.basic.controller.mobile;
import com.ycwl.basic.model.mobile.statistic.AppSta1VO;
import com.ycwl.basic.model.mobile.statistic.AppSta2VO;
import com.ycwl.basic.model.mobile.statistic.AppSta3VO;
import com.ycwl.basic.model.mobile.statistic.CommonQueryReq;
import com.ycwl.basic.service.mobile.AppStatisticsService;
import com.ycwl.basic.utils.ApiResponse;
@ -37,6 +38,11 @@ public class AppStatisticsController {
return statisticsService.twoStatistics(query);
}
@ApiOperation("扫码访问人数、推送订阅人数、预览视频人数统计")
@PostMapping("/free")
public ApiResponse<AppSta3VO> freeStatistics(@RequestBody CommonQueryReq query) {
return statisticsService.freeStatistics(query);
}
}

View File

@ -26,7 +26,7 @@ public interface StatisticsMapper {
int countPreviewOfMember(CommonQueryReq query);
/**
* 统计扫码人数
* 统计扫码访问人数
* @param query
* @return
*/
@ -46,7 +46,24 @@ public interface StatisticsMapper {
*/
int countPayOfMember(CommonQueryReq query);
/**
* 统计现场支付订单数
* @param query
* @return
*/
int countSceneOrderNum(CommonQueryReq query);
/**
* 统计推送支付订单数
* @param query
* @return
*/
int countPushOrderNum(CommonQueryReq query);
/**
* 统计推送订阅人数
* @param query
* @return
*/
int countPushOfMember(CommonQueryReq query);
}

View File

@ -0,0 +1,26 @@
package com.ycwl.basic.model.mobile.statistic;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Authorlongbinbin
* @Date2024/12/11 18:23
*/
@Data
@ApiModel("移动端扫码访问人数、推送订阅人数、预览视频人数统计结果类")
public class AppSta3VO {
@ApiModelProperty("现在的数据 扫码访问人数")
private Integer nowScanCodeOfPeopleNum;
@ApiModelProperty("上一期的数据 扫码访问人数")
private Integer previousScanCodeOfPeopleNum;
@ApiModelProperty("现在的数据 推送订阅人数")
private Integer nowPushOfPeopleNum;
@ApiModelProperty("上一期的数据 推送订阅人数")
private Integer previousPushOfPeopleNum;
@ApiModelProperty("现在的数据 预览视频人数")
private Integer nowPreviewVideoOfPeopleNum;
@ApiModelProperty("上一期的数据 预览视频人数")
private Integer previousPreviewVideoOfPeopleNum;
}

View File

@ -3,6 +3,7 @@ package com.ycwl.basic.service.impl.mobile;
import com.ycwl.basic.mapper.StatisticsMapper;
import com.ycwl.basic.model.mobile.statistic.AppSta1VO;
import com.ycwl.basic.model.mobile.statistic.AppSta2VO;
import com.ycwl.basic.model.mobile.statistic.AppSta3VO;
import com.ycwl.basic.model.mobile.statistic.CommonQueryReq;
import com.ycwl.basic.service.mobile.AppStatisticsService;
import com.ycwl.basic.utils.ApiResponse;
@ -87,6 +88,63 @@ public class AppStatisticsServiceImpl implements AppStatisticsService {
return ApiResponse.success(vo);
}
@Override
public ApiResponse<AppSta3VO> freeStatistics(CommonQueryReq query) {
AppSta3VO vo = new AppSta3VO();
if(query.getEndTime()==null && query.getStartTime()==null){
// 没有传时间则代表用户没有自定义查询时间使用standard来判断查询时间范围
Integer standard = query.getStandard();
if(standard==null){
query.setStandard(0);
}
//获取当前周期的具体时间范围
standardToNewSpecificTime(query);
//查询处理数据逻辑
freeStatisticsHandler(1,query,vo);
//----------------------------------------------------
//获取当前周期的具体时间范围
standardToPreviousSpecificTime(query);
//查询处理数据逻辑
freeStatisticsHandler(2,query,vo);
}else{
//自定义时间查询只有当前数据没有往期对比数据
//查询处理数据逻辑
freeStatisticsHandler(1,query,vo);
}
return ApiResponse.success(vo);
}
/**
*
* @param cycle 周期 1当前 2往期
* @param query
* @param vo
*/
private void freeStatisticsHandler(Integer cycle,CommonQueryReq query,AppSta3VO vo){
//查询扫码访问人数
int sceneNum=statisticsMapper.countScanCodeOfMember(query);
//查询推送订阅人数
int pushNum=statisticsMapper.countPushOfMember(query);
// 查询预览视频人数
Integer previewNum=statisticsMapper.countPreviewOfMember(query);
if(cycle==1){
//当前周期的扫码访问人数
vo.setNowScanCodeOfPeopleNum(sceneNum);
//当前周期的推送订阅人数
vo.setNowPushOfPeopleNum(pushNum);
//当前周期的预览视频人数
vo.setNowPreviewVideoOfPeopleNum(previewNum);
}else if(cycle==2){
//上一个周期的扫码访问人数
vo.setPreviousScanCodeOfPeopleNum(sceneNum);
//上一个周期的推送订阅人数
vo.setPreviousPushOfPeopleNum(pushNum);
//上一个周期的预览视频人数
vo.setPreviousPreviewVideoOfPeopleNum(previewNum);
}
}
/**
*
* @param cycle 周期 1当前 2往期
@ -104,16 +162,16 @@ public class AppStatisticsServiceImpl implements AppStatisticsService {
if(cycle==1){
//当前周期的总支付订单数
vo.setNowPayOrderNum(totalOrderNum);
//查询现场支付订单数
//当前周期的现场支付订单数
vo.setNowSceneOrderNum(sceneOrderNum);
//查询推送支付订单数
//当前周期的推送支付订单数
vo.setNowPushOrderNum(pushOrderNum);
}else if(cycle==2){
//当前周期的总支付订单数
//上一个周期的总支付订单数
vo.setPreviousPayOrderNum(totalOrderNum);
//查询现场支付订单数
//上一个周期的现场支付订单数
vo.setPreviousSceneOrderNum(sceneOrderNum);
//查询推送支付订单数
//上一个周期的推送支付订单数
vo.setPreviousPushOrderNum(pushOrderNum);
}
}

View File

@ -2,6 +2,7 @@ package com.ycwl.basic.service.mobile;
import com.ycwl.basic.model.mobile.statistic.AppSta1VO;
import com.ycwl.basic.model.mobile.statistic.AppSta2VO;
import com.ycwl.basic.model.mobile.statistic.AppSta3VO;
import com.ycwl.basic.model.mobile.statistic.CommonQueryReq;
import com.ycwl.basic.utils.ApiResponse;
@ -14,4 +15,6 @@ public interface AppStatisticsService {
ApiResponse<AppSta1VO> oneStatistics(CommonQueryReq query);
ApiResponse<AppSta2VO> twoStatistics(CommonQueryReq query);
ApiResponse<AppSta3VO> freeStatistics(CommonQueryReq query);
}

View File

@ -17,36 +17,84 @@
select ifnull(count(1),0) as count
from statistics
where type=2 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
</select>
<select id="countScanCodeOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=0 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
</select>
<select id="countClickPayOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=9 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
</select>
<select id="countPayOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type in(3,4) and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
</select>
<select id="countSceneOrderNum" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=3 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by morph_id
</select>
<select id="countPushOrderNum" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=4 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by morph_id
</select>
<select id="countPushOfMember" resultType="java.lang.Integer">
select ifnull(count(1),0) as count
from statistics
where type=6 and scenic_id = #{scenicId}
<if test="startTime!= null and startTime!= ''">
and create_time >= #{startTime}
</if>
<if test="endTime!= null and endTime!= ''">
and create_time &lt;= #{endTime}
</if>
group by member_id
</select>
</mapper>