实现“支付订单金额、预览_支付转化率、扫码_付费用户转化率”和“支付订单数、现场订单数、推送订单数统计”
This commit is contained in:
parent
405b48d9d3
commit
ba4c339660
@ -82,9 +82,16 @@ public class AppMemberController {
|
|||||||
return ApiResponse.success("");
|
return ApiResponse.success("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("新增或修改景区服务通知状态")
|
@ApiOperation("新增或修改景区服务通知状态")
|
||||||
|
@GetMapping("/updateScenicServiceNoticeStatus")
|
||||||
public ApiResponse updateScenicServiceNoticeStatus(Long scenicId) {
|
public ApiResponse updateScenicServiceNoticeStatus(Long scenicId) {
|
||||||
return memberService.updateScenicServiceNoticeStatus(scenicId);
|
return memberService.updateScenicServiceNoticeStatus(scenicId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查看景区服务通知状态 0关闭 1开启")
|
||||||
|
@GetMapping("/getScenicServiceNoticeStatus")
|
||||||
|
public ApiResponse<Integer> getScenicServiceNoticeStatus(Long scenicId) {
|
||||||
|
return memberService.getScenicServiceNoticeStatus(scenicId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ycwl.basic.controller.mobile;
|
package com.ycwl.basic.controller.mobile;
|
||||||
|
|
||||||
import com.ycwl.basic.model.mobile.statistic.AppSta1VO;
|
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.model.mobile.statistic.CommonQueryReq;
|
||||||
import com.ycwl.basic.service.mobile.AppStatisticsService;
|
import com.ycwl.basic.service.mobile.AppStatisticsService;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
@ -29,6 +30,13 @@ public class AppStatisticsController {
|
|||||||
return statisticsService.oneStatistics(query);
|
return statisticsService.oneStatistics(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("支付订单数、现场订单数、推送订单数统计")
|
||||||
|
@PostMapping("/two")
|
||||||
|
public ApiResponse<AppSta2VO> twoStatistics(@RequestBody CommonQueryReq query) {
|
||||||
|
|
||||||
|
return statisticsService.twoStatistics(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
75
src/main/java/com/ycwl/basic/enums/StatisticEnum.java
Normal file
75
src/main/java/com/ycwl/basic/enums/StatisticEnum.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package com.ycwl.basic.enums;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public enum StatisticEnum {
|
||||||
|
SCAN_THE_CODE_TO_ENTER(0,"扫码进入"),
|
||||||
|
UPLOAD_FACE(1,"上传人脸"),
|
||||||
|
PREVIEWING_VIDEO(2,"预览视频"),
|
||||||
|
ON_SITE_PAYMENT(3,"现场支付"),
|
||||||
|
POST_PAYMENT(4,"事后支付"),
|
||||||
|
REFUND(5,"退款"),
|
||||||
|
AGREE_TO_PUSH(6,"同意推送"),
|
||||||
|
REFUSE_PUSH_NOTIFICATIONS(7,"拒绝推送"),
|
||||||
|
DOWNLOAD(8,"下载"),
|
||||||
|
CLICK_ON_PAYMENT(9,"点击支付、购买"),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
public static final Map<Integer, StatisticEnum> cacheMap;
|
||||||
|
|
||||||
|
static {
|
||||||
|
cacheMap = new HashMap<>(StatisticEnum.values().length);
|
||||||
|
for (StatisticEnum value : StatisticEnum.values()) {
|
||||||
|
cacheMap.put(value.code, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static final Map<String, StatisticEnum> valueMap;
|
||||||
|
|
||||||
|
static {
|
||||||
|
valueMap = new HashMap<>(StatisticEnum.values().length);
|
||||||
|
for (StatisticEnum value : StatisticEnum.values()) {
|
||||||
|
valueMap.put(value.value, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public final Integer code;
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
StatisticEnum(Integer code, String value) {
|
||||||
|
this.code = code;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取value值
|
||||||
|
*/
|
||||||
|
public static String getValue(Integer noticeMethod) {
|
||||||
|
if (noticeMethod == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatisticEnum statisticEnum = cacheMap.get(noticeMethod);
|
||||||
|
if (statisticEnum == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return statisticEnum.value;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取code值
|
||||||
|
*/
|
||||||
|
public static Integer getCode(String noticeMethod) {
|
||||||
|
if (noticeMethod == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatisticEnum statisticEnum = valueMap.get(noticeMethod);
|
||||||
|
if (statisticEnum == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return statisticEnum.code;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,52 @@
|
|||||||
package com.ycwl.basic.mapper;
|
package com.ycwl.basic.mapper;
|
||||||
|
|
||||||
|
import com.ycwl.basic.model.mobile.statistic.CommonQueryReq;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:longbinbin
|
* @Author:longbinbin
|
||||||
* @Date:2024/12/12 9:51
|
* @Date:2024/12/12 9:51
|
||||||
*/
|
*/
|
||||||
|
@Mapper
|
||||||
public interface StatisticsMapper {
|
public interface StatisticsMapper {
|
||||||
|
/**
|
||||||
|
* 统计支付订单金额
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
BigDecimal countOrderAmount(CommonQueryReq query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计预览视频人数
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int countPreviewOfMember(CommonQueryReq query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计扫码人数
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int countScanCodeOfMember(CommonQueryReq query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计点击购买人数
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int countClickPayOfMember(CommonQueryReq query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计付费人数
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int countPayOfMember(CommonQueryReq query);
|
||||||
|
|
||||||
|
int countSceneOrderNum(CommonQueryReq query);
|
||||||
|
|
||||||
|
int countPushOrderNum(CommonQueryReq query);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,13 @@ package com.ycwl.basic.model.mobile.statistic;
|
|||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:longbinbin
|
* @Author:longbinbin
|
||||||
* @Date:2024/12/11 18:23
|
* @Date:2024/12/11 18:23
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
@ApiModel("移动端订单金额、预览_支付转化率、扫码_付费用户转化率统计结果类")
|
@ApiModel("移动端订单金额、预览_支付转化率、扫码_付费用户转化率统计结果类")
|
||||||
public class AppSta1VO {
|
public class AppSta1VO {
|
||||||
@ApiModelProperty("现在的数据 支付订单金额")
|
@ApiModelProperty("现在的数据 支付订单金额")
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.ycwl.basic.model.mobile.statistic;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:longbinbin
|
||||||
|
* @Date:2024/12/11 18:23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel("移动端支付订单数、现场订单数、推送订单数统计结果类")
|
||||||
|
public class AppSta2VO {
|
||||||
|
@ApiModelProperty("现在的数据 支付订单数")
|
||||||
|
private Integer nowPayOrderNum;
|
||||||
|
@ApiModelProperty("上一期的数据 支付订单数")
|
||||||
|
private Integer previousPayOrderNum;
|
||||||
|
@ApiModelProperty("现在的数据 现场订单数")
|
||||||
|
private Integer nowSceneOrderNum;
|
||||||
|
@ApiModelProperty("上一期的数据 现场订单数")
|
||||||
|
private Integer previousSceneOrderNum;
|
||||||
|
@ApiModelProperty("现在的数据 推送订单数")
|
||||||
|
private Integer nowPushOrderNum;
|
||||||
|
@ApiModelProperty("上一期的数据 推送订单数")
|
||||||
|
private Integer previousPushOrderNum;
|
||||||
|
}
|
@ -16,6 +16,8 @@ import java.util.Date;
|
|||||||
public class CommonQueryReq {
|
public class CommonQueryReq {
|
||||||
@ApiModelProperty(value = "查询统计纬度 0今天、1昨天、2-近一周(7天)、3-近30天、4-近1年")
|
@ApiModelProperty(value = "查询统计纬度 0今天、1昨天、2-近一周(7天)、3-近30天、4-近1年")
|
||||||
private Integer standard;
|
private Integer standard;
|
||||||
|
@ApiModelProperty(value = "景区id")
|
||||||
|
private Long scenicId;
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
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.AppSta1VO;
|
||||||
|
import com.ycwl.basic.model.mobile.statistic.AppSta2VO;
|
||||||
import com.ycwl.basic.model.mobile.statistic.CommonQueryReq;
|
import com.ycwl.basic.model.mobile.statistic.CommonQueryReq;
|
||||||
import com.ycwl.basic.service.mobile.AppStatisticsService;
|
import com.ycwl.basic.service.mobile.AppStatisticsService;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:longbinbin
|
* @Author:longbinbin
|
||||||
* @Date:2024/12/12 9:48
|
* @Date:2024/12/12 9:48
|
||||||
@ -13,6 +22,10 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class AppStatisticsServiceImpl implements AppStatisticsService {
|
public class AppStatisticsServiceImpl implements AppStatisticsService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StatisticsMapper statisticsMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付订单金额、预览_支付转化率、扫码_付费用户转化率
|
* 支付订单金额、预览_支付转化率、扫码_付费用户转化率
|
||||||
* @param query
|
* @param query
|
||||||
@ -20,6 +33,221 @@ public class AppStatisticsServiceImpl implements AppStatisticsService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ApiResponse<AppSta1VO> oneStatistics(CommonQueryReq query) {
|
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 updateScenicServiceNoticeStatus(Long scenicId);
|
||||||
|
|
||||||
|
ApiResponse<Integer> getScenicServiceNoticeStatus(Long scenicId);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ycwl.basic.service.mobile;
|
package com.ycwl.basic.service.mobile;
|
||||||
|
|
||||||
import com.ycwl.basic.model.mobile.statistic.AppSta1VO;
|
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.model.mobile.statistic.CommonQueryReq;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
|
|
||||||
@ -11,4 +12,6 @@ import com.ycwl.basic.utils.ApiResponse;
|
|||||||
|
|
||||||
public interface AppStatisticsService {
|
public interface AppStatisticsService {
|
||||||
ApiResponse<AppSta1VO> oneStatistics(CommonQueryReq query);
|
ApiResponse<AppSta1VO> oneStatistics(CommonQueryReq query);
|
||||||
|
|
||||||
|
ApiResponse<AppSta2VO> twoStatistics(CommonQueryReq query);
|
||||||
}
|
}
|
||||||
|
@ -27,18 +27,11 @@ public class DateUtils {
|
|||||||
public final static String YYYY_MM = "yyyyMM";
|
public final static String YYYY_MM = "yyyyMM";
|
||||||
public final static String YYYY_MM_DD_HH_MM_SS_SSS = "yyyyMMddHHmmssSSS";
|
public final static String YYYY_MM_DD_HH_MM_SS_SSS = "yyyyMMddHHmmssSSS";
|
||||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||||
/**
|
|
||||||
* 时间格式(yyyy-MM-dd HH:mm:ss)
|
|
||||||
*/
|
|
||||||
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||||
/**
|
|
||||||
* 日期转化为cron表达式
|
|
||||||
*/
|
|
||||||
public final static String CRON_DATE_TIME_PATTERN = "ss mm HH dd MM ? yyyy";
|
public final static String CRON_DATE_TIME_PATTERN = "ss mm HH dd MM ? yyyy";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
* 日期格式化 日期格式为:yyyy-MM-dd
|
||||||
*
|
|
||||||
* @param date 日期
|
* @param date 日期
|
||||||
* @return 返回yyyy-MM-dd格式日期
|
* @return 返回yyyy-MM-dd格式日期
|
||||||
*/
|
*/
|
||||||
@ -47,8 +40,7 @@ public class DateUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
* 日期格式化 自定义格式
|
||||||
*
|
|
||||||
* @param date 日期
|
* @param date 日期
|
||||||
* @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
|
* @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
|
||||||
* @return 返回yyyy-MM-dd格式日期
|
* @return 返回yyyy-MM-dd格式日期
|
||||||
@ -63,21 +55,19 @@ public class DateUtils {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式化 日期格式为:yyyy-MM-dd HH:mm:ss
|
* 日期解析 日期格式为:yyyy-MM-dd HH:mm:ss
|
||||||
*
|
* @param dataStr 日期字符串
|
||||||
* @param dataStr
|
* @return 返回yyyy-MM-dd HH:mm:ss格式日期
|
||||||
* @return 返回yyyy-MM-dd格式日期
|
|
||||||
*/
|
*/
|
||||||
public static Date format(String dataStr) throws ParseException {
|
public static Date parse(String dataStr) throws ParseException {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_PATTERN);
|
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_PATTERN);
|
||||||
return sdf.parse(dataStr);
|
return sdf.parse(dataStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期解析
|
* 日期解析 自定义格式
|
||||||
*
|
* @param date 日期字符串
|
||||||
* @param date 日期
|
|
||||||
* @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
|
* @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
|
||||||
* @return 返回Date
|
* @return 返回Date
|
||||||
*/
|
*/
|
||||||
@ -98,21 +88,27 @@ public class DateUtils {
|
|||||||
*/
|
*/
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static Date startOfDay(Date date) {
|
public static Date startOfDay(Date date) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
Calendar calendar = Calendar.getInstance();
|
||||||
String s = sdf.format(date);
|
calendar.setTime(date);
|
||||||
return sdf.parse(s);
|
// 将时间部分设置为00:00:00.000
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 这个月的第一天
|
* 这个月的第一天
|
||||||
*
|
|
||||||
* @param date 日期
|
* @param date 日期
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Date startOfMonth(Date date) {
|
public static Date startOfMonth(Date date) {
|
||||||
Date date1 = startOfDay(date);
|
Date date1 = startOfDay(date);
|
||||||
date1.setDate(1);
|
Calendar cal = Calendar.getInstance();
|
||||||
return date1;
|
cal.setTime(date1);
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH,1);
|
||||||
|
return cal.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,8 +138,7 @@ public class DateUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得某月最大时间 2019-10-08 23:59:59
|
* 获得某月最大时间
|
||||||
*
|
|
||||||
* @param date
|
* @param date
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -156,6 +151,11 @@ public class DateUtils {
|
|||||||
return getEndOfDay(localDateTimeToDate(endOfDay));
|
return getEndOfDay(localDateTimeToDate(endOfDay));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得某天最大时间
|
||||||
|
* @param date
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static Date getStartMonthOfDay(Date date) {
|
public static Date getStartMonthOfDay(Date date) {
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -243,8 +243,7 @@ public class DateUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得某天最小时间 2019-10-08 00:00:00
|
* 获得某天最小时间
|
||||||
*
|
|
||||||
* @param date
|
* @param date
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -258,8 +257,7 @@ public class DateUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得某天最大时间 2019-10-08 23:59:59
|
* 获得某天最大时间
|
||||||
*
|
|
||||||
* @param date
|
* @param date
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -274,7 +272,6 @@ public class DateUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* localDateTime 转date
|
* localDateTime 转date
|
||||||
*
|
|
||||||
* @param localDateTime
|
* @param localDateTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -284,7 +281,6 @@ public class DateUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 将秒转为时分秒格式【01:01:01】
|
* 将秒转为时分秒格式【01:01:01】
|
||||||
*
|
|
||||||
* @param second 需要转化的秒数
|
* @param second 需要转化的秒数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -308,19 +304,17 @@ public class DateUtils {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param date
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static String getWeekOfDate(Date date) {
|
public static String getWeekOfDate(Date date) {
|
||||||
String[] weekDays = {"1", "2", "3", "4", "5", "6", "7"}; //"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"
|
String[] weekDays = {"7", "1", "2", "3", "4", "5", "6"}; // "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime(date);
|
cal.setTime(date);
|
||||||
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
int w = cal.get(Calendar.DAY_OF_WEEK) - 1; // 将星期日转换为7
|
||||||
if (w < 0)
|
return weekDays[w]; // 直接返回对应的星期数
|
||||||
w = 0;
|
|
||||||
if (Integer.valueOf(weekDays[w]) >= 2) {
|
|
||||||
return String.valueOf(Integer.valueOf(weekDays[w]) - 1);
|
|
||||||
} else {
|
|
||||||
return String.valueOf(7);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -422,6 +416,11 @@ public class DateUtils {
|
|||||||
}
|
}
|
||||||
return timesList;
|
return timesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取24小时制的时间
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static List<String> getAllTimesBetweenDates(){
|
public static List<String> getAllTimesBetweenDates(){
|
||||||
// 创建一个字符串数组,容量为24
|
// 创建一个字符串数组,容量为24
|
||||||
String[] times24 = new String[24];
|
String[] times24 = new String[24];
|
||||||
@ -435,16 +434,65 @@ public class DateUtils {
|
|||||||
return new ArrayList<>(Arrays.asList(times24));
|
return new ArrayList<>(Arrays.asList(times24));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在指定日期上增加i年,负数为减少i年
|
||||||
|
* @param date 指定的日期
|
||||||
|
* @param i 增加/减少的年数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Date addDateYears(Date date, int i) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.add(Calendar.YEAR, i);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在指定日期上增加i月,负数为减少i月
|
||||||
|
* @param date
|
||||||
|
* @param i
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Date addDateMonths(Date date, int i) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.add(Calendar.MONTH, i);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在指定日期上增加i周,负数为减少i周
|
||||||
|
* @param date
|
||||||
|
* @param i
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Date addDateWeeks(Date date, int i) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.add(Calendar.WEEK_OF_YEAR, i);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在指定日期上增加i天,负数为减少i天
|
||||||
|
* @param date
|
||||||
|
* @param i
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Date addDateDays(Date date, int i) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.add(Calendar.DAY_OF_YEAR, i);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// System.out.println(getWeekOfDate(stringToDate("2023-07-31 00:00:00", DATE_TIME_PATTERN)));
|
Date date = new Date();
|
||||||
// String ss = "2,3,4,5,6,7";
|
Date yesterday = DateUtils.addDateDays(date, -1);
|
||||||
// System.out.println(ss.contains(getWeekOfDate(stringToDate("2023-07-31 00:00:00", DATE_TIME_PATTERN))));
|
Date startDate = DateUtils.getStartOfDay(yesterday);
|
||||||
// System.out.println(stringToDate("2020-03-23",DATE_PATTERN));
|
Date endDate = DateUtils.getEndOfDay(yesterday);
|
||||||
// System.out.println("2020-03-23".length());
|
System.out.println(format(startDate, "yyyy-MM-dd HH:mm:ss"));
|
||||||
// Date monthLastDay = endOfNextMonth(new Date());
|
System.out.println(format(endDate, "yyyy-MM-dd HH:mm:ss"));
|
||||||
// System.out.println(format(monthLastDay,DATE_TIME_PATTERN));
|
|
||||||
// String s = secondConvertHourMinSecond(360L);
|
|
||||||
// System.out.println(s);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<result column="cancel_at" property="cancelAt"/>
|
<result column="cancel_at" property="cancelAt"/>
|
||||||
<result column="create_at" property="createAt"/>
|
<result column="create_at" property="createAt"/>
|
||||||
<result column="update_at" property="updateAt"/>
|
<result column="update_at" property="updateAt"/>
|
||||||
<result column="cover_url" property="coverUrl"/>
|
<result column="coverUrl" property="coverUrl"/>
|
||||||
<collection property="orderItemList" select="getOrderItemList" column="id" ofType="com.ycwl.basic.model.pc.order.resp.OrderItemVO">
|
<collection property="orderItemList" select="getOrderItemList" column="id" ofType="com.ycwl.basic.model.pc.order.resp.OrderItemVO">
|
||||||
<result column="oiId" property="id"/>
|
<result column="oiId" property="id"/>
|
||||||
<result column="orderId" property="orderId"/>
|
<result column="orderId" property="orderId"/>
|
||||||
|
@ -1,4 +1,52 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.ycwl.basic.mapper.StatisticsMapper">
|
<mapper namespace="com.ycwl.basic.mapper.StatisticsMapper">
|
||||||
|
<select id="countOrderAmount" resultType="java.math.BigDecimal">
|
||||||
|
select ifnull(sum(pay_price),0) as payPrice
|
||||||
|
from `order`
|
||||||
|
where
|
||||||
|
status = 1 and scenic_id = #{scenicId}
|
||||||
|
<if test="startTime!= null and startTime!= ''">
|
||||||
|
and create_at >= #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime!= null and endTime!= ''">
|
||||||
|
and create_at <= #{endTime}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="countPreviewOfMember" resultType="java.lang.Integer">
|
||||||
|
select ifnull(count(1),0) as count
|
||||||
|
from statistics
|
||||||
|
where type=2 and scenic_id = #{scenicId}
|
||||||
|
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}
|
||||||
|
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}
|
||||||
|
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}
|
||||||
|
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}
|
||||||
|
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}
|
||||||
|
group by morph_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user