微调
This commit is contained in:
parent
8ba93b74ac
commit
c90ffe21e2
|
@ -1,19 +1,19 @@
|
||||||
package com.ruoyi.web.controller.IndexController;
|
package com.ruoyi.web.controller.IndexController;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.utils.CollectionUtils;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.system.domain.EtOperatingArea;
|
import com.ruoyi.system.domain.EtOperatingArea;
|
||||||
import com.ruoyi.system.domain.vo.IndexAdminVo;
|
import com.ruoyi.system.domain.IncomeQuery;
|
||||||
import com.ruoyi.system.domain.vo.IndexVo;
|
import com.ruoyi.system.domain.vo.*;
|
||||||
import com.ruoyi.system.domain.vo.StatisticsResult;
|
|
||||||
import com.ruoyi.system.domain.vo.LeaderboardVo;
|
|
||||||
import com.ruoyi.system.service.IEtOperatingAreaService;
|
import com.ruoyi.system.service.IEtOperatingAreaService;
|
||||||
import com.ruoyi.system.service.IEtOrderService;
|
import com.ruoyi.system.service.IEtOrderService;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -21,7 +21,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,13 +113,33 @@ public class IndexController extends BaseController
|
||||||
if(deptId == null){
|
if(deptId == null){
|
||||||
throw new ServiceException("运营商id不能为空:deptId");
|
throw new ServiceException("运营商id不能为空:deptId");
|
||||||
}
|
}
|
||||||
if(date == null){
|
if(StrUtil.isBlank(date)){
|
||||||
throw new ServiceException("时间参数不能为空:date");
|
throw new ServiceException("时间参数不能为空:date");
|
||||||
}
|
}
|
||||||
List<IndexVo.IncomeVo> incomeList = etOrderService.getIncomeList(deptId, date);
|
LocalDate[] firstAndLastDay =DateUtils.getFirstAndLastDayOfMonth(date);
|
||||||
|
LocalDate startTime = firstAndLastDay[0];
|
||||||
|
LocalDate endTime = firstAndLastDay[1];
|
||||||
|
|
||||||
|
IncomeQuery incomeQuery = new IncomeQuery();
|
||||||
|
incomeQuery.setDeptId(deptId);
|
||||||
|
incomeQuery.setStartTime(startTime);
|
||||||
|
incomeQuery.setEndTime(endTime);
|
||||||
|
List<IncomeVo> incomeList = etOrderService.getIncomeList(incomeQuery);
|
||||||
|
incomeList = CollectionUtils.fillVoids(incomeList, IncomeVo::getDay, (d) -> {
|
||||||
|
IncomeVo vo = new IncomeVo();
|
||||||
|
vo.setDay(d);
|
||||||
|
vo.setIncome(BigDecimal.ZERO);
|
||||||
|
vo.setOrderNum(0);
|
||||||
|
return vo;
|
||||||
|
}, startTime, endTime);
|
||||||
return success(incomeList);
|
return success(incomeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDateStr(Calendar calendar,int day) {
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, day);
|
||||||
|
return new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
private static void assign(IndexVo result, IndexVo areaIndexVo) {
|
private static void assign(IndexVo result, IndexVo areaIndexVo) {
|
||||||
result.setBalance(result.getBalance().add(areaIndexVo.getBalance()));
|
result.setBalance(result.getBalance().add(areaIndexVo.getBalance()));
|
||||||
result.setWithdraw(result.getWithdraw().add(areaIndexVo.getWithdraw()));
|
result.setWithdraw(result.getWithdraw().add(areaIndexVo.getWithdraw()));
|
||||||
|
|
|
@ -830,7 +830,7 @@ public class AppVerifyController extends BaseController
|
||||||
*/
|
*/
|
||||||
@Log(title = "实名认证", businessType = BusinessType.AUTHENTICATION)
|
@Log(title = "实名认证", businessType = BusinessType.AUTHENTICATION)
|
||||||
@GetMapping("/user/authentication")
|
@GetMapping("/user/authentication")
|
||||||
public AjaxResult partnerBillList(AuthenticationVo authenticationVo)
|
public AjaxResult authentication(AuthenticationVo authenticationVo)
|
||||||
{
|
{
|
||||||
logger.info("【实名认证】请求参数:authenticationVo={}", JSON.toJSON(authenticationVo));
|
logger.info("【实名认证】请求参数:authenticationVo={}", JSON.toJSON(authenticationVo));
|
||||||
Object authentication = asUserService.authentication(authenticationVo);
|
Object authentication = asUserService.authentication(authenticationVo);
|
||||||
|
@ -843,13 +843,13 @@ public class AppVerifyController extends BaseController
|
||||||
//保存身份信息
|
//保存身份信息
|
||||||
// 更新用户并更新缓存
|
// 更新用户并更新缓存
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
AsUser asUser = loginUser.getAsUser();
|
AsUser updateUser = new AsUser();
|
||||||
asUser.setUserId(authenticationVo.getUserId());
|
updateUser.setUserId(authenticationVo.getUserId());
|
||||||
asUser.setRealName(authenticationVo.getRealName());
|
updateUser.setRealName(authenticationVo.getRealName());
|
||||||
asUser.setIdCard(authenticationVo.getIdCard());
|
updateUser.setIdCard(authenticationVo.getIdCard());
|
||||||
asUser.setIsAuthentication(ServiceConstants.IS_AUTHENTICATION_YES);
|
updateUser.setIsAuthentication(ServiceConstants.IS_AUTHENTICATION_YES);
|
||||||
int updateUser = asUserService.updateUser(asUser);
|
int updated = asUserService.updateUser(updateUser);
|
||||||
if (updateUser>0)
|
if (updated>0)
|
||||||
{
|
{
|
||||||
logger.info("【实名认证】保存身份信息成功");
|
logger.info("【实名认证】保存身份信息成功");
|
||||||
// 更新缓存用户信息
|
// 更新缓存用户信息
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wjh
|
||||||
|
* 2024/4/29
|
||||||
|
*/
|
||||||
|
public class CollectionUtils extends org.springframework.util.CollectionUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为空,包括空集合、空元素
|
||||||
|
* @param collection
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isEmptyElement(Collection<?> collection) {
|
||||||
|
if (collection == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 过滤空元素
|
||||||
|
List<?> collect = collection.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
return org.springframework.util.CollectionUtils.isEmpty(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNotEmptyElement(Collection<?> collection) {
|
||||||
|
return !isEmptyElement(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO 未经验证
|
||||||
|
/**
|
||||||
|
* 补全列表中的日期数据,对于缺失的日期使用提供的工厂方法生成对象。
|
||||||
|
*
|
||||||
|
* @param dataList 原始数据列表,元素需有getDateMethod返回Date类型属性的方法
|
||||||
|
* @param dateGetter 获取元素日期属性的方法引用
|
||||||
|
* @param customFactory 当日期缺失时,用于生成对应元素的对象工厂方法
|
||||||
|
* @param <T> 数据列表中元素的类型
|
||||||
|
* @return 完整日期序列下的数据列表,缺失的日期已由customFactory填充
|
||||||
|
*/
|
||||||
|
public static <T> List<T> completeMissingDates(List<T> dataList,
|
||||||
|
Function<T, Date> dateGetter,
|
||||||
|
Function<Date, T> customFactory) {
|
||||||
|
if (dataList == null || dataList.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Date> dates = dataList.stream()
|
||||||
|
.map(dateGetter)
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
Date startDate = dates.get(0);
|
||||||
|
Date endDate = dates.get(dates.size() - 1);
|
||||||
|
|
||||||
|
List<Date> fullDates = new ArrayList<>();
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(startDate);
|
||||||
|
|
||||||
|
while (!calendar.getTime().after(endDate)) {
|
||||||
|
fullDates.add(calendar.getTime());
|
||||||
|
calendar.add(Calendar.DATE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Date, T> dateToObjectMap = dataList.stream()
|
||||||
|
.collect(Collectors.toMap(dateGetter, Function.identity()));
|
||||||
|
|
||||||
|
return fullDates.stream()
|
||||||
|
.map(date -> dateToObjectMap.getOrDefault(date, customFactory.apply(date)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNotEmpty(List<?> deviceList) {
|
||||||
|
return !isEmpty(deviceList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 集合映射,去除空值、重复值
|
||||||
|
*/
|
||||||
|
public static <T, R> List<R> map(List<T> list, Function<? super T, ? extends R> keyMapper) {
|
||||||
|
return list.stream().map(keyMapper).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断两个列表及其内容是否一致
|
||||||
|
*/
|
||||||
|
public static boolean equals(List l1, List l2) {
|
||||||
|
if (Objects.equals(l1, l2)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (l1.size() != l2.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for(int i = 0; i < l1.size(); i ++) {
|
||||||
|
Object o1 = l1.get(i);
|
||||||
|
Object o2 = l2.get(i);
|
||||||
|
if (!o1.equals(o2)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充空值
|
||||||
|
* @param list 原始列表
|
||||||
|
* @param getDateFunction 获取日期的方法
|
||||||
|
* @param function 获取填充物的方法
|
||||||
|
* @param start 起始日期
|
||||||
|
* @param end 结束日期
|
||||||
|
* @return 填充后的列表
|
||||||
|
*/
|
||||||
|
public static <T> List<T> fillVoids(List<? extends T> list, Function<? super T, LocalDate> getDateFunction, Function<LocalDate, ? extends T> function, LocalDate start, LocalDate end) {
|
||||||
|
// 输入验证
|
||||||
|
if (start.isAfter(end)) {
|
||||||
|
throw new IllegalArgumentException("起始日期必须早于结束日期");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前日期
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
|
// 使用Map优化查找性能
|
||||||
|
Map<String, T> fillAbleMap = new HashMap<>();
|
||||||
|
for (T item : list) {
|
||||||
|
fillAbleMap.put(DateUtils.getYYYY_MM_DD(getDateFunction.apply(item)), item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建结果列表,并确保线程安全
|
||||||
|
List<T> result = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
LocalDate current = start;
|
||||||
|
while (!current.isAfter(end)) {
|
||||||
|
// 如果当前日期已经超过今天,则不再填充
|
||||||
|
if (current.isAfter(today)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
T currentItem = fillAbleMap.get(DateUtils.getYYYY_MM_DD(current));
|
||||||
|
if (currentItem == null) {
|
||||||
|
try {
|
||||||
|
currentItem = function.apply(current);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 异常处理逻辑,例如记录日志或抛出自定义异常
|
||||||
|
System.err.println("处理日期 " + current + " 时发生异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentItem != null) {
|
||||||
|
result.add(currentItem);
|
||||||
|
}
|
||||||
|
current = current.plusDays(1);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import java.lang.management.ManagementFactory;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.*;
|
import java.time.*;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -116,6 +117,22 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
return DateFormatUtils.format(date, YYYY_MM_DD);
|
return DateFormatUtils.format(date, YYYY_MM_DD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期路径 即年/月/日 如20180808
|
||||||
|
*/
|
||||||
|
public static final String getYYYY_MM_DD(LocalDate date)
|
||||||
|
{
|
||||||
|
return format(date, YYYY_MM_DD);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String format(LocalDate localDate, String format) {
|
||||||
|
if (localDate == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||||
|
return localDate.format(formatter);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期型字符串转化为日期 格式
|
* 日期型字符串转化为日期 格式
|
||||||
*/
|
*/
|
||||||
|
@ -368,4 +385,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
}
|
}
|
||||||
return calendar.getTime(); // 返回新的时间
|
return calendar.getTime(); // 返回新的时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LocalDate[] getFirstAndLastDayOfMonth(String month) {
|
||||||
|
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
LocalDate[] result = new LocalDate[2];
|
||||||
|
|
||||||
|
// 解析传入的月份字符串为 LocalDate
|
||||||
|
LocalDate date = LocalDate.parse(month + "-01", dateFormat);
|
||||||
|
|
||||||
|
// 获取该月的第一天
|
||||||
|
result[0] = date.withDayOfMonth(1);
|
||||||
|
|
||||||
|
// 获取该月的最后一天
|
||||||
|
result[1] = date.withDayOfMonth(date.lengthOfMonth());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IncomeQuery {
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate startTime;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate endTime;
|
||||||
|
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
private List<Long> areaIds;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.ruoyi.system.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收入统计 incomeVo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class IncomeVo {
|
||||||
|
/** 日期 */
|
||||||
|
private LocalDate day;
|
||||||
|
/** 收入 */
|
||||||
|
private BigDecimal income;
|
||||||
|
/** 订单数 */
|
||||||
|
private Integer orderNum;
|
||||||
|
}
|
|
@ -1,9 +1,13 @@
|
||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.system.domain.EtOrder;
|
import com.ruoyi.system.domain.EtOrder;
|
||||||
import com.ruoyi.system.domain.EtOrderQuery;
|
import com.ruoyi.system.domain.EtOrderQuery;
|
||||||
|
import com.ruoyi.system.domain.IncomeQuery;
|
||||||
|
import com.ruoyi.system.domain.vo.IncomeVo;
|
||||||
|
import com.ruoyi.system.domain.vo.IndexVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -360,4 +364,8 @@ public interface EtOrderMapper
|
||||||
*/
|
*/
|
||||||
BigDecimal getDepositDeductionAmount(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr ,@Param("areaId") Long areaId,@Param("channelId") Long channelId);
|
BigDecimal getDepositDeductionAmount(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr ,@Param("areaId") Long areaId,@Param("channelId") Long channelId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日报查询
|
||||||
|
*/
|
||||||
|
List<IncomeVo> selectDailyAmount(@Param("query") IncomeQuery incomeQuery);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,12 @@ package com.ruoyi.system.service;
|
||||||
import com.ruoyi.system.domain.EtOrder;
|
import com.ruoyi.system.domain.EtOrder;
|
||||||
import com.ruoyi.system.domain.EtOrderQuery;
|
import com.ruoyi.system.domain.EtOrderQuery;
|
||||||
import com.ruoyi.system.domain.EtRefund;
|
import com.ruoyi.system.domain.EtRefund;
|
||||||
|
import com.ruoyi.system.domain.IncomeQuery;
|
||||||
import com.ruoyi.system.domain.vo.*;
|
import com.ruoyi.system.domain.vo.*;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -283,5 +285,5 @@ public interface IEtOrderService
|
||||||
/**
|
/**
|
||||||
* 获取营收统计(按月份)
|
* 获取营收统计(按月份)
|
||||||
*/
|
*/
|
||||||
List<IndexVo.IncomeVo> getIncomeList(Long deptId, String date);
|
List<IncomeVo> getIncomeList(IncomeQuery incomeQuery);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -2324,67 +2325,10 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
* 获取营收统计(按月份)
|
* 获取营收统计(按月份)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<IndexVo.IncomeVo> getIncomeList(Long deptId, String date) {
|
public List<IncomeVo> getIncomeList(IncomeQuery incomeQuery) {
|
||||||
// 定义缓存的键
|
incomeQuery.setAreaIds(etOperatingAreaService.selectAreaListByDeptId(incomeQuery.getDeptId()));
|
||||||
String cacheKey = "income:deptId_" + deptId + ":date_" + date;
|
|
||||||
|
|
||||||
// 尝试从缓存中获取数据
|
|
||||||
List<IndexVo.IncomeVo> cachedIncomeVos = redisCache.getCacheObject(cacheKey);
|
|
||||||
if (cachedIncomeVos != null) {
|
|
||||||
log.info("【营收统计】从缓存中获取数据:" + cacheKey);
|
|
||||||
return cachedIncomeVos; // 如果缓存中有数据,直接返回
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<IndexVo.IncomeVo> incomeVos = new ArrayList<>();
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
|
|
||||||
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(DateUtils.getNowDate());
|
|
||||||
List<Long> areaIds = etOperatingAreaService.selectAreaListByDeptId(deptId);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 将传入的 date 字符串解析为日期
|
|
||||||
Date parsedDate = dateFormat.parse(date);
|
|
||||||
calendar.setTime(parsedDate);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
log.error("日期解析失败, 请检查日期格式,错误信息: {}", e.getMessage());
|
|
||||||
return incomeVos;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前月的最后一天
|
// 获取当前月的最后一天
|
||||||
int lastDayOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
return etOrderMapper.selectDailyAmount(incomeQuery);
|
||||||
|
|
||||||
for (int day = 1; day <= lastDayOfMonth; day ++) {
|
|
||||||
// 设置当前日期为每一天
|
|
||||||
calendar.set(Calendar.DAY_OF_MONTH, day);
|
|
||||||
String formattedDate = dayFormat.format(calendar.getTime());
|
|
||||||
|
|
||||||
// 拼接查询的开始和结束时间
|
|
||||||
String startDateStr = formattedDate + " " + Constants.DATE_FORMAT_START_PEREND;
|
|
||||||
String endDateStr = formattedDate + " " + Constants.DATE_FORMAT_END_PEREND;
|
|
||||||
|
|
||||||
// 获取当天的订单统计信息
|
|
||||||
IndexVo.OrderFeeStatisticsVo todayOrderInfo = getOrderFeeStatisticsByDeptId(startDateStr, endDateStr, areaIds);
|
|
||||||
log.info("【获取营收统计】营收统计----------todayOrderInfo: {}" , JSON.toJSON(todayOrderInfo));
|
|
||||||
|
|
||||||
// 如果 orderNum 或 income 为 0,跳过当前循环
|
|
||||||
if (todayOrderInfo.getOrderCount() == 0 && todayOrderInfo.getIncomeFee().compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建收入统计对象
|
|
||||||
IndexVo.IncomeVo incomeVo = new IndexVo.IncomeVo();
|
|
||||||
incomeVo.setDay(formattedDate);
|
|
||||||
incomeVo.setOrderNum(todayOrderInfo.getOrderCount());
|
|
||||||
incomeVo.setIncome(todayOrderInfo.getIncomeFee());
|
|
||||||
|
|
||||||
// 添加到结果列表中
|
|
||||||
incomeVos.add(incomeVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将计算得到的数据存入缓存,缓存有效期为30分钟
|
|
||||||
redisCache.setCacheObject(cacheKey, incomeVos, 30, TimeUnit.MINUTES);
|
|
||||||
return incomeVos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.ruoyi.system.mapper.EtOnlineLogMapper">
|
<mapper namespace="com.ruoyi.system.mapper.EtOnlineLogMapper">
|
||||||
|
|
||||||
<resultMap type="EtOnlineLog" id="EtOnlineLogResult">
|
<resultMap type="EtOnlineLog" id="EtOnlineLogResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="mac" column="mac" />
|
<result property="mac" column="mac" />
|
||||||
|
@ -20,18 +20,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="selectEtOnlineLogList" parameterType="EtOnlineLog" resultMap="EtOnlineLogResult">
|
<select id="selectEtOnlineLogList" parameterType="EtOnlineLog" resultMap="EtOnlineLogResult">
|
||||||
<include refid="selectEtOnlineLogVo"/>
|
<include refid="selectEtOnlineLogVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="mac != null and mac != ''"> and mac like concat('%', #{mac}, '%')</if>
|
<if test="mac != null and mac != ''"> and mac like concat('%', #{mac}, '%')</if>
|
||||||
<if test="sn != null and sn != ''"> and sn like concat('%', #{sn}, '%')</if>
|
<if test="sn != null and sn != ''"> and sn like concat('%', #{sn}, '%')</if>
|
||||||
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
|
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectEtOnlineLogById" parameterType="Long" resultMap="EtOnlineLogResult">
|
<select id="selectEtOnlineLogById" parameterType="Long" resultMap="EtOnlineLogResult">
|
||||||
<include refid="selectEtOnlineLogVo"/>
|
<include refid="selectEtOnlineLogVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertEtOnlineLog" parameterType="EtOnlineLog" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertEtOnlineLog" parameterType="EtOnlineLog" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into et_online_log
|
insert into et_online_log
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
@ -70,9 +71,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteEtOnlineLogByIds" parameterType="String">
|
<delete id="deleteEtOnlineLogByIds" parameterType="String">
|
||||||
delete from et_online_log where id in
|
delete from et_online_log where id in
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -1291,5 +1291,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
) AS combined_amounts
|
) AS combined_amounts
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDailyAmount" resultType="com.ruoyi.system.domain.vo.IncomeVo">
|
||||||
|
select
|
||||||
|
date(o.pay_time) as `day`,
|
||||||
|
COALESCE(sum(o.pay_fee),0) as `income`,
|
||||||
|
count(1) `orderNum`
|
||||||
|
from et_order o
|
||||||
|
where o.status = 4 and o.type = 1 and o.paid = 1
|
||||||
|
<if test="query.areaIds != null and query.areaIds.size() > 0">
|
||||||
|
and area_id IN
|
||||||
|
<foreach item="item" index="index" collection="query.areaIds" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="query.startTime != null ">
|
||||||
|
and DATE(o.pay_time) >= #{query.startTime}
|
||||||
|
</if>
|
||||||
|
<if test="query.endTime != null ">
|
||||||
|
and DATE(o.pay_time) <= #{query.endTime}
|
||||||
|
</if>
|
||||||
|
group by `day`
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user