You've already forked FrameTour-BE
实现“支付订单金额、预览_支付转化率、扫码_付费用户转化率”和“支付订单数、现场订单数、推送订单数统计”
This commit is contained in:
@ -162,4 +162,13 @@ public class AppMemberServiceImpl implements AppMemberService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Integer> getScenicServiceNoticeStatus(Long scenicId) {
|
||||
Integer scenicServiceNoticeStatus = memberMapper.getScenicServiceNoticeStatus(scenicId, Long.parseLong(BaseContextHandler.getUserId()));
|
||||
if(scenicServiceNoticeStatus==null){
|
||||
scenicServiceNoticeStatus=0;
|
||||
}
|
||||
return ApiResponse.success(scenicServiceNoticeStatus);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,20 @@
|
||||
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.CommonQueryReq;
|
||||
import com.ycwl.basic.service.mobile.AppStatisticsService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/12/12 9:48
|
||||
@ -13,6 +22,10 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class AppStatisticsServiceImpl implements AppStatisticsService {
|
||||
|
||||
@Autowired
|
||||
private StatisticsMapper statisticsMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 支付订单金额、预览_支付转化率、扫码_付费用户转化率
|
||||
* @param query
|
||||
@ -20,6 +33,221 @@ public class AppStatisticsServiceImpl implements AppStatisticsService {
|
||||
*/
|
||||
@Override
|
||||
public ApiResponse<AppSta1VO> oneStatistics(CommonQueryReq query) {
|
||||
return null;
|
||||
AppSta1VO vo = new AppSta1VO();
|
||||
//订单金额格式
|
||||
DecimalFormat orderAmountDf = new DecimalFormat("0.0");
|
||||
//转化率格式
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
if(query.getEndTime()==null && query.getStartTime()==null){
|
||||
// 没有传时间,则代表用户没有自定义查询时间,使用standard来判断查询时间范围
|
||||
Integer standard = query.getStandard();
|
||||
if(standard==null){
|
||||
query.setStandard(0);
|
||||
}
|
||||
//获取当前周期的具体时间范围
|
||||
standardToNewSpecificTime(query);
|
||||
//查询处理数据逻辑
|
||||
oneStatisticsHandler(1,query,vo);
|
||||
//----------------------------------------------------
|
||||
//获取上一个周期的具体时间范围
|
||||
standardToPreviousSpecificTime(query);
|
||||
//查询处理数据逻辑
|
||||
oneStatisticsHandler(2,query,vo);
|
||||
}else{
|
||||
//自定义时间查询,只有当前数据,没有往期对比数据
|
||||
//查询处理数据逻辑
|
||||
oneStatisticsHandler(1,query,vo);
|
||||
}
|
||||
return ApiResponse.success(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<AppSta2VO> twoStatistics(CommonQueryReq query) {
|
||||
AppSta2VO vo = new AppSta2VO();
|
||||
if(query.getEndTime()==null && query.getStartTime()==null){
|
||||
// 没有传时间,则代表用户没有自定义查询时间,使用standard来判断查询时间范围
|
||||
Integer standard = query.getStandard();
|
||||
if(standard==null){
|
||||
query.setStandard(0);
|
||||
}
|
||||
//获取当前周期的具体时间范围
|
||||
standardToNewSpecificTime(query);
|
||||
//查询处理数据逻辑
|
||||
twoStatisticsHandler(1,query,vo);
|
||||
//----------------------------------------------------
|
||||
//获取当前周期的具体时间范围
|
||||
standardToPreviousSpecificTime(query);
|
||||
//查询处理数据逻辑
|
||||
twoStatisticsHandler(2,query,vo);
|
||||
}else{
|
||||
//自定义时间查询,只有当前数据,没有往期对比数据
|
||||
//查询处理数据逻辑
|
||||
twoStatisticsHandler(1,query,vo);
|
||||
}
|
||||
return ApiResponse.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cycle 周期 1当前 2往期
|
||||
* @param query
|
||||
* @param vo
|
||||
*/
|
||||
private void twoStatisticsHandler(Integer cycle,CommonQueryReq query,AppSta2VO vo){
|
||||
//查询现场支付订单数
|
||||
int sceneOrderNum=statisticsMapper.countSceneOrderNum(query);
|
||||
//查询推送支付订单数
|
||||
int pushOrderNum=statisticsMapper.countPushOrderNum(query);
|
||||
// 当前周期的总支付订单数
|
||||
Integer totalOrderNum=sceneOrderNum+pushOrderNum;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cycle 周期 1当前 2往期
|
||||
* @param query
|
||||
* @param vo
|
||||
*/
|
||||
private void oneStatisticsHandler(Integer cycle,CommonQueryReq query,AppSta1VO vo){
|
||||
//订单金额格式
|
||||
DecimalFormat orderAmountDf = new DecimalFormat("0.0");
|
||||
//转化率格式
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
// 计算当前周期的支付订单金额
|
||||
BigDecimal orderAmount=statisticsMapper.countOrderAmount(query).setScale(2, RoundingMode.HALF_UP);
|
||||
//查询预览视频人数
|
||||
int preview=statisticsMapper.countPreviewOfMember(query);
|
||||
//查询扫码人数
|
||||
int scanCode=statisticsMapper.countScanCodeOfMember(query);
|
||||
//查询付费人数
|
||||
int pay=statisticsMapper.countPayOfMember(query);
|
||||
|
||||
if(cycle==1){
|
||||
//当前周期的支付订单金额
|
||||
vo.setNowOrderAmount(orderAmountDf.format(orderAmount));
|
||||
//当前周期预览_支付转化率、扫码_付费用户转化率
|
||||
if(pay==0){
|
||||
vo.setNowPreviewPay("0.00");
|
||||
vo.setNowScanCodePay("0.00");
|
||||
}else {
|
||||
BigDecimal previewPay = new BigDecimal(preview).divide(new BigDecimal(pay), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
||||
vo.setNowPreviewPay(df.format(previewPay));
|
||||
BigDecimal scanCodePay = new BigDecimal(scanCode).divide(new BigDecimal(pay), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
||||
vo.setNowScanCodePay(df.format(scanCodePay));
|
||||
}
|
||||
}else if(cycle==2){
|
||||
//上一个周期的支付订单金额
|
||||
vo.setNowOrderAmount(orderAmountDf.format(orderAmount));
|
||||
// 计算预览_支付转化率
|
||||
if(pay==0){
|
||||
vo.setPreviousPreviewPay("0.00");
|
||||
vo.setPreviousScanCodePay("0.00");
|
||||
}else {
|
||||
BigDecimal previewPay = new BigDecimal(preview).divide(new BigDecimal(pay), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
||||
vo.setNowPreviewPay(df.format(previewPay));
|
||||
BigDecimal scanCodePay = new BigDecimal(scanCode).divide(new BigDecimal(pay), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
||||
vo.setNowScanCodePay(df.format(scanCodePay));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据standard来获取查询时间范围(当前周期)
|
||||
* @param query
|
||||
*/
|
||||
private void standardToNewSpecificTime(CommonQueryReq query) {
|
||||
Integer standard = query.getStandard();
|
||||
Date newDate = new Date();
|
||||
Date startDate = new Date();
|
||||
Date endDate = new Date();
|
||||
switch (standard) {
|
||||
case 4://年
|
||||
startDate = DateUtils.addDateYears(newDate, -1);
|
||||
break;
|
||||
case 3://月
|
||||
startDate = DateUtils.addDateMonths(newDate, -1);
|
||||
break;
|
||||
case 2://周
|
||||
startDate = DateUtils.addDateWeeks(newDate, -1);
|
||||
break;
|
||||
case 1://昨天
|
||||
Date yesterday = DateUtils.addDateDays(newDate, -1);
|
||||
startDate = DateUtils.getStartOfDay(yesterday);
|
||||
endDate = DateUtils.getEndOfDay(yesterday);
|
||||
break;
|
||||
case 0://今天
|
||||
startDate = DateUtils.getStartOfDay(newDate);
|
||||
break;
|
||||
case 9://历史累计
|
||||
startDate = null;
|
||||
endDate = null;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
query.setStartTime(startDate);
|
||||
query.setEndTime(endDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据standard来获取查询时间范围(上一个周期)
|
||||
* @param query
|
||||
*/
|
||||
private void standardToPreviousSpecificTime(CommonQueryReq query) {
|
||||
Integer standard = query.getStandard();
|
||||
Date newDate = new Date();
|
||||
Date startDate = new Date();
|
||||
Date endDate = new Date();
|
||||
switch (standard) {
|
||||
case 4://年,近一年的前一年
|
||||
startDate = DateUtils.addDateYears(newDate, -2);
|
||||
break;
|
||||
case 3://月,近一月的前一个月
|
||||
startDate = DateUtils.addDateMonths(newDate, -2);
|
||||
endDate = DateUtils.addDateMonths(newDate, -1);
|
||||
break;
|
||||
case 2://周,近一周的前一周
|
||||
startDate = DateUtils.addDateWeeks(newDate, -2);
|
||||
endDate = DateUtils.addDateWeeks(newDate, -1);
|
||||
break;
|
||||
case 1://昨天,昨天的前一天
|
||||
Date theDayBeforeYesterday = DateUtils.addDateDays(newDate, -2);
|
||||
startDate = DateUtils.getStartOfDay(theDayBeforeYesterday);
|
||||
endDate = DateUtils.getEndOfDay(theDayBeforeYesterday);
|
||||
break;
|
||||
case 0://今天,今天的前一天
|
||||
Date yesterday = DateUtils.addDateDays(newDate, -1);
|
||||
startDate = DateUtils.getStartOfDay(yesterday);
|
||||
endDate = DateUtils.getEndOfDay(yesterday);
|
||||
break;
|
||||
case 9://历史累计
|
||||
startDate = null;
|
||||
endDate = null;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
query.setStartTime(startDate);
|
||||
query.setEndTime(endDate);
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,6 @@ public interface AppMemberService {
|
||||
|
||||
|
||||
ApiResponse updateScenicServiceNoticeStatus(Long scenicId);
|
||||
|
||||
ApiResponse<Integer> getScenicServiceNoticeStatus(Long scenicId);
|
||||
}
|
||||
|
@ -1,6 +1,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.CommonQueryReq;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
|
||||
@ -11,4 +12,6 @@ import com.ycwl.basic.utils.ApiResponse;
|
||||
|
||||
public interface AppStatisticsService {
|
||||
ApiResponse<AppSta1VO> oneStatistics(CommonQueryReq query);
|
||||
|
||||
ApiResponse<AppSta2VO> twoStatistics(CommonQueryReq query);
|
||||
}
|
||||
|
Reference in New Issue
Block a user