Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
SongZhang 2024-09-11 11:18:45 +08:00
commit 373fb2bdf0
13 changed files with 306 additions and 100 deletions

View File

@ -24,6 +24,11 @@
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>com.github.gavlyukovskiy</groupId>
<artifactId>p6spy-spring-boot-starter</artifactId>
<version>1.7.0</version>
</dependency>
<!-- 代码生成模块 -->
<dependency>
<groupId>cn.ysk.cashier</groupId>

View File

@ -2,6 +2,7 @@ package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.BaseQueryDto;
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
import cn.ysk.cashier.service.SummaryService;
import lombok.RequiredArgsConstructor;
@ -23,11 +24,20 @@ public class SummaryController {
@Resource
private SummaryService summaryService;
@GetMapping
private Object shopSummary(@RequestParam Integer shopId) {
return summaryService.selectSummary(shopId);
@PostMapping("/trade")
@AnonymousPostMapping
private Object shopSummaryDate(@RequestBody BaseQueryDto param) {
return summaryService.trade(param);
}
// @GetMapping
// private Object shopSummary(@RequestParam Integer shopId) {
// return summaryService.selectSummary(shopId);
// }
@GetMapping("/date")
private Object shopSummaryDate(@RequestParam Integer shopId, @RequestParam Integer day) {
return summaryService.selectSummaryDate(shopId, day);

View File

@ -50,8 +50,8 @@ public class TbDeviceStockController {
throw new RuntimeException("请先添加台桌");
}
if (downloadDto.getCount() > (shopTables.size() * 2)) {
throw new RuntimeException("最多可获取台桌数量的2倍");
if (downloadDto.getCount() > 500) {
throw new RuntimeException("最多可获取500个");
}
TbDeviceStock lastRecord = tbDeviceStockService.findLastRecord();

View File

@ -0,0 +1,36 @@
package cn.ysk.cashier.dto;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
public class BaseQueryDto {
private Integer shopId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}

View File

@ -23,6 +23,7 @@ import javax.persistence.Column;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.List;
/**
* @website https://eladmin.vip
@ -192,4 +193,10 @@ public class TbShopInfoDto implements Serializable {
private String isReturn;
private String isMemberIn;
private String isMemberReturn;
private Integer isTableFee;
private BigDecimal tableFee;
private List<String> eatModel;
//程序码(零点八零首页)
private String smallQrcode;
private String paymentQrcode;
}

View File

@ -18,8 +18,13 @@ package cn.ysk.cashier.mapper.shop;
import cn.ysk.cashier.base.BaseMapper;
import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.dto.shop.TbShopInfoDto;
import cn.ysk.cashier.utils.ListUtil;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;
/**
* @website https://eladmin.vip
@ -29,4 +34,19 @@ import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TbShopInfoMapper extends BaseMapper<TbShopInfoDto, TbShopInfo> {
// 自定义的字符串到整数列表的转换方法
default List<String> map(String value) {
return ListUtil.stringChangeStringList(value);
}
// 如果需要从DTO转回实体也可能需要实现反向的映射方法
default String map(List<String> values) {
if (!CollectionUtils.isEmpty(values)) {
return "";
}
// 将整数列表转换为由逗号分隔的字符串
return values.stream()
.map(String::valueOf)
.collect(Collectors.joining(","));
}
}

View File

@ -5,9 +5,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @author GYJ
@ -41,6 +41,33 @@ public interface TbShopUserFlowMapper extends BaseMapper<TbShopUserFlow> {
@Param("startTime") String startTime,
@Param("endTime") String endTime);
@Select("<script>" +
"SELECT" +
" COALESCE(SUM(CASE WHEN flow.biz_code IN ('cashMemberIn', 'inMoneyIn', 'scanMemberIn') THEN flow.amount ELSE 0 END),0) AS 'inAmount'," +
" COALESCE(SUM(CASE WHEN flow.biz_code = 'inMoneyOut' THEN flow.amount ELSE 0 END),0) AS 'outAmount'," +
" COALESCE(SUM(CASE WHEN flow.biz_code IN ('accountGroupPay', 'accountPay', 'consumeOut', 'vipCardCash') THEN flow.amount ELSE 0 END),0) AS 'useAmount'," +
" COALESCE(COUNT(CASE WHEN flow.biz_code IN ('accountGroupPay', 'accountPay', 'consumeOut', 'vipCardCash') THEN 1 ELSE NULL END),0) AS 'useNum'" +
"FROM" +
" tb_shop_user_flow flow" +
" INNER JOIN tb_shop_user vip ON flow.shop_user_id = vip.id and vip.shop_id= #{shopId} " +
"WHERE" +
" flow.create_time BETWEEN #{startTime} AND #{endTime} " +
"</script>")
Map<String, Object> tradeIndexFlow(@Param("shopId") Integer shopId,
@Param("startTime") String startTime,
@Param("endTime") String endTime);
@Select("<script>" +
"SELECT COALESCE(count(1),0) from( " +
" SELECT flow.create_time " +
" FROM tb_shop_user_flow flow " +
" INNER JOIN tb_shop_user vip ON flow.shop_user_id = vip.id AND vip.shop_id = #{shopId} " +
"WHERE biz_code IN ('cashMemberIn', 'inMoneyIn', 'scanMemberIn') " +
"GROUP BY " +
" shop_user_id) as flows where flows.create_time BETWEEN #{startTime} AND #{endTime}" +
"</script>")
Integer tradeIndexNewFlow(@Param("shopId") Integer shopId, @Param("startTime") String startTime, @Param("endTime") String endTime);
@Select(value = "select * from tb_shop_user_flow where shop_user_id=#{userId} order by id desc limit #{page},#{size}")
List<TbShopUserFlow> selectByUserId(@Param("userId") Integer userId,@Param("page") Integer page,@Param("size") Integer size);

View File

@ -258,13 +258,28 @@ public class TbShopInfo implements Serializable {
@ApiModelProperty(value = "是否允许用户自定义金额")
private String isMemberIn;
@Column(name = "is_member_return")
@ApiModelProperty(value = "是否允许用户自定义金额")
private String isMemberReturn;
@Column(name = "is_table_fee")
@ApiModelProperty(value = "是否免除桌位费 0否1是")
private Integer isTableFee;
@Column(name = "tableFee")
@ApiModelProperty(value = "桌位费")
private BigDecimal tableFee;
@Column(name = "eat_model")
@ApiModelProperty(value = "就餐模式 堂食 dine-in 外带 take-out")
private String eatModel;
@Column(name = "small_qrcode")
@ApiModelProperty(value = "程序码(零点八零首页)")
private String smallQrcode;
@Column(name = "payment_qrcode")
@ApiModelProperty(value = "店铺收款码")
private String paymentQrcode;
public void copy(TbShopInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));

View File

@ -31,6 +31,7 @@ import javax.persistence.Tuple;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @website https://eladmin.vip
@ -54,6 +55,22 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
"AND info.createdAt>:start AND info.createdAt<:end")
TbOrderPayCountVo queryTbOrderRefund(@Param("shopId")String shopId, @Param("tableName") String tableName ,@Param("start") Long start, @Param("end") Long end);
@Query(value = "SELECT " +
"COALESCE(SUM( info.order_amount ),0) AS 'saleAmount'," +
"COALESCE(count( 1 ),0) AS 'saleNum'," +
"COALESCE(sum( discount_amount ),0) AS 'saveAmount'," +
"COALESCE(COUNT( CASE WHEN discount_amount IS NOT NULL AND discount_amount > 0.00 THEN 1 ELSE NULL END ),0) AS 'saveNum' " +
"FROM tb_order_info info " +
"WHERE info.shop_id = :shopId " +
"AND info.created_at > :startTime AND info.created_at < :endTime " +
"AND ((info.STATUS = 'closed' ) OR ( info.STATUS = 'refund' AND info.order_type != 'return' ))", nativeQuery = true)
Map<String,Object> tradeIndex(@Param("shopId") Integer shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
@Query(value = "SELECT COALESCE(SUM(info.order_amount),0) FROM tb_order_info info " +
"WHERE info.shop_id = :shopId AND info.order_type = 'return' " +
"AND info.created_at > :startTime AND info.created_at < :endTime", nativeQuery = true)
BigDecimal tradeIndexRefund(@Param("shopId") Integer shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
@Query(value = "SELECT COUNT(1) ,pay_type AS payType FROM tb_order_info Where shop_id = :shopId AND " +
" created_at BETWEEN :startTime AND :endTime AND status='closed'AND order_type <>'return' GROUP BY pay_type", nativeQuery = true)
List<Object[]> countByShopId(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.service;
import cn.ysk.cashier.dto.BaseQueryDto;
import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
import cn.ysk.cashier.vo.ShopTableSaleInfoVo;
@ -17,8 +18,9 @@ import java.util.Map;
* @author lyf
*/
public interface SummaryService {
SummaryVO selectSummary(Integer shop);
Map<String,Object> trade(BaseQueryDto param);
// SummaryVO selectSummary(Integer shop);
Map<String,Object> selectSummaryDate(Integer shopId, Integer day);
Map<String,Object> selectSummaryToday(Integer shopId);

View File

@ -1,15 +1,19 @@
package cn.ysk.cashier.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.dto.BaseQueryDto;
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
import cn.ysk.cashier.enums.PayTypeEnum;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper;
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
import cn.ysk.cashier.repository.ShopUserDutyDetailRepository;
import cn.ysk.cashier.repository.ShopUserDutyRepository;
import cn.ysk.cashier.repository.TbTokenRepository;
import cn.ysk.cashier.repository.order.TbOrderDetailRepository;
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
import cn.ysk.cashier.repository.shop.TbShopTableRepository;
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
import cn.ysk.cashier.service.SummaryService;
import cn.ysk.cashier.utils.DateUtil;
@ -56,106 +60,160 @@ public class SummaryServiceImpl implements SummaryService {
@Resource
private TbTokenRepository tbTokenRepository;
@Autowired
private TbShopUserFlowMapper tbShopUserFlowMapper;
@Resource
private TbShopUserFlowService tbShopUserFlowService;
@Autowired
private TbOrderDetailRepository tbOrderDetailRepository;
private final TbShopTableRepository tbShopTableRepository;
@Override
public SummaryVO selectSummary(Integer shopId) {
SummaryVO summaryVO = new SummaryVO();
//支付笔数,
Tuple result = tbOrderInfoRepository.countByShopId(shopId.toString());
summaryVO.setPaymentsNumber(result.get(0, Long.class) == null ? 0L : result.get(0, Long.class));
summaryVO.setTotalSales(result.get(1, BigDecimal.class) == null ? new BigDecimal("0") : result.get(1, BigDecimal.class));
if (summaryVO.getPaymentsNumber() == 0) {
summaryVO.setAverageSales(new BigDecimal("0"));
} else {
summaryVO.setAverageSales(summaryVO.getTotalSales().divide(new BigDecimal(summaryVO.getPaymentsNumber()), 2, RoundingMode.DOWN));
public Map<String, Object> trade(BaseQueryDto param) {
if (ObjectUtil.isNull(param.getShopId())) {
throw new BadRequestException("参数不合法");
}
//用户数
Tuple count = tbShopUserRepository.searchByCount(shopId.toString());
summaryVO.setTotalUser(count == null ? 0L : count.get(0, Long.class));
//支付笔数柱形图
List<Object[]> objects = tbOrderInfoRepository.sumByDateOrderNum(shopId.toString(), DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
List<CountDateVO> countDateList = new ArrayList<>();
for (Object[] o : objects) {
CountDateVO countDateVO = new CountDateVO();
BigInteger integers = (BigInteger) o[0];
countDateVO.setCount(new BigDecimal(integers.toString()));
countDateVO.setTradeDay((String) o[1]);
countDateList.add(countDateVO);
Map<String, Object> result = new HashMap<>();
Map<String, Object> sale = new HashMap<>();
Map<String, Object> vip = new HashMap<>();
Map<String, Object> count = new HashMap<>();
//订单 销售金额 saleAmount /订单数 saleNum /优惠金额 saveAmount /优惠笔数 saveNum
Map<String, Object> orderMap = tbOrderInfoRepository.tradeIndex(param.getShopId(), param.getStartTime().getTime(), param.getEndTime().getTime());
//退款金额
BigDecimal refundAmount = tbOrderInfoRepository.tradeIndexRefund(param.getShopId(), param.getStartTime().getTime(), param.getEndTime().getTime());
//会员 充值金额 inAmount /退款金额 outAmount /会员消费金额 useAmount /会员消费笔数 useNum
Map<String, Object> flowMap = tbShopUserFlowMapper.tradeIndexFlow(param.getShopId(), DateUtil.getStrTime(param.getStartTime()), DateUtil.getStrTime(param.getEndTime()));
// 新增会员数
Integer newFlow = tbShopUserFlowMapper.tradeIndexNewFlow(param.getShopId(), DateUtil.getStrTime(param.getStartTime()), DateUtil.getStrTime(param.getEndTime()));
//台桌数
int tables = tbShopTableRepository.countAllByShopId(param.getShopId());
sale.put("totalSaleAmount", new BigDecimal(orderMap.get("saleAmount").toString()).add(refundAmount));//总金额
sale.put("incomeAmount", new BigDecimal(orderMap.get("saleAmount").toString()).add(new BigDecimal(flowMap.get("inAmount").toString())));//实收
sale.put("refundAmount", refundAmount);//销售退款金额
sale.put("inAmount", flowMap.get("inAmount"));//会员充值金额
sale.put("outAmount", flowMap.get("outAmount"));//会员退款金额
result.put("sale",sale);
vip.put("useAmount", flowMap.get("useAmount"));//会员消费金额
vip.put("newFlow",newFlow);//新增会员数
vip.put("useNum",flowMap.get("useNum"));//会员消费笔数
result.put("vip",vip);
BigDecimal saleAmount = new BigDecimal(orderMap.get("saleAmount").toString()).add(refundAmount);
//客单价
if(saleAmount.compareTo(BigDecimal.ZERO) == 0){
count.put("unitPrice",BigDecimal.ZERO);
}else {
count.put("unitPrice",saleAmount.divide(new BigDecimal(orderMap.get("saleNum").toString()),2,RoundingMode.DOWN));
}
//填充日期
Map<String, CountDateVO> dataMap = new HashMap<>();
for (CountDateVO entry : countDateList) {
String tradeDay = entry.getTradeDay();
BigDecimal countOrder = entry.getCount();
dataMap.put(tradeDay, new CountDateVO(tradeDay, countOrder));
BigDecimal saleNum = new BigDecimal(orderMap.get("saleNum").toString());
if(saleNum.compareTo(BigDecimal.ZERO) == 0){
count.put("turnoverRate",BigDecimal.ZERO+"%");//翻台率
}else {
count.put("turnoverRate",saleNum.divide(new BigDecimal(tables),2,RoundingMode.DOWN).subtract(BigDecimal.ONE).multiply(new BigDecimal("100"))+"%");//翻台率
}
// 获取今天的日期
LocalDate today = LocalDate.now();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 转换为字符串
List<CountDateVO> countDateLists = new ArrayList<>();
for (int i = 0; i < 30; i++) {
LocalDate tradeDayLocalDate = today.minusDays(i);
String tradeDayString = tradeDayLocalDate.format(formatter);
CountDateVO countDateVO;
// 检查数据Map中是否存在该日期的数据
if (dataMap.containsKey(tradeDayString)) {
countDateVO = dataMap.get(tradeDayString);
} else {
// 如果不存在则创建新的SumDateVO对象amount设为0
countDateVO = new CountDateVO(tradeDayString, BigDecimal.ZERO);
}
// 将SumDateVO对象添加到列表中
countDateLists.add(countDateVO);
}
countDateLists.sort((a, b) -> a.getTradeDay().compareTo(b.getTradeDay()));
summaryVO.setCountDateList(countDateLists);
//访问量
Tuple tuple = tbTokenRepository.countByAccountId(shopId);
summaryVO.setTotalVisits(tuple == null ? 0L : tuple.get(0, Long.class));
//访问量柱状图
List<Object[]> objectsVisits = tbTokenRepository.countByMonth(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
List<CountVisitsVO> visitsList = new ArrayList<>();
for (Object[] o : objectsVisits) {
CountVisitsVO countDateVO = new CountVisitsVO();
countDateVO.setCount((BigInteger) o[0]);
countDateVO.setTradeDay((String) o[1]);
visitsList.add(countDateVO);
}
//填充日期
Map<String, CountVisitsVO> dataVisitsMap = new HashMap<>();
for (CountVisitsVO entry : visitsList) {
String tradeDay = entry.getTradeDay();
BigInteger countOrder = entry.getCount();
dataVisitsMap.put(tradeDay, new CountVisitsVO(tradeDay, countOrder));
}
// 转换为字符串
List<CountVisitsVO> countVisitsLists = new ArrayList<>();
for (int i = 0; i < 30; i++) {
LocalDate tradeDayLocalDate = today.minusDays(i);
String tradeDayString = tradeDayLocalDate.format(formatter);
CountVisitsVO countDateVO;
// 检查数据Map中是否存在该日期的数据
if (dataVisitsMap.containsKey(tradeDayString)) {
countDateVO = dataVisitsMap.get(tradeDayString);
} else {
// 如果不存在则创建新的SumDateVO对象amount设为0
countDateVO = new CountVisitsVO(tradeDayString, BigInteger.ZERO);
}
// 将SumDateVO对象添加到列表中
countVisitsLists.add(countDateVO);
}
countVisitsLists.sort((a, b) -> a.getTradeDay().compareTo(b.getTradeDay()));
summaryVO.setVisitsCountList(countVisitsLists);
return summaryVO;
count.put("saveAmount",orderMap.get("saveAmount"));//优惠金额
count.put("saveNum",orderMap.get("saveNum"));//优惠单数
result.put("count",count);
return result;
}
// @Override
// public SummaryVO selectSummary(Integer shopId) {
// SummaryVO summaryVO = new SummaryVO();
// //支付笔数,
// Tuple result = tbOrderInfoRepository.countByShopId(shopId.toString());
// summaryVO.setPaymentsNumber(result.get(0, Long.class) == null ? 0L : result.get(0, Long.class));
// summaryVO.setTotalSales(result.get(1, BigDecimal.class) == null ? new BigDecimal("0") : result.get(1, BigDecimal.class));
// if (summaryVO.getPaymentsNumber() == 0) {
// summaryVO.setAverageSales(new BigDecimal("0"));
// } else {
// summaryVO.setAverageSales(summaryVO.getTotalSales().divide(new BigDecimal(summaryVO.getPaymentsNumber()), 2, RoundingMode.DOWN));
// }
// //用户数
// Tuple count = tbShopUserRepository.searchByCount(shopId.toString());
// summaryVO.setTotalUser(count == null ? 0L : count.get(0, Long.class));
// //支付笔数柱形图
// List<Object[]> objects = tbOrderInfoRepository.sumByDateOrderNum(shopId.toString(), DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
// List<CountDateVO> countDateList = new ArrayList<>();
// for (Object[] o : objects) {
// CountDateVO countDateVO = new CountDateVO();
// BigInteger integers = (BigInteger) o[0];
// countDateVO.setCount(new BigDecimal(integers.toString()));
// countDateVO.setTradeDay((String) o[1]);
// countDateList.add(countDateVO);
// }
// //填充日期
// Map<String, CountDateVO> dataMap = new HashMap<>();
// for (CountDateVO entry : countDateList) {
// String tradeDay = entry.getTradeDay();
// BigDecimal countOrder = entry.getCount();
// dataMap.put(tradeDay, new CountDateVO(tradeDay, countOrder));
// }
// // 获取今天的日期
// LocalDate today = LocalDate.now();
// // 定义日期格式
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// // 转换为字符串
// List<CountDateVO> countDateLists = new ArrayList<>();
// for (int i = 0; i < 30; i++) {
// LocalDate tradeDayLocalDate = today.minusDays(i);
// String tradeDayString = tradeDayLocalDate.format(formatter);
// CountDateVO countDateVO;
// // 检查数据Map中是否存在该日期的数据
// if (dataMap.containsKey(tradeDayString)) {
// countDateVO = dataMap.get(tradeDayString);
// } else {
// // 如果不存在则创建新的SumDateVO对象amount设为0
// countDateVO = new CountDateVO(tradeDayString, BigDecimal.ZERO);
// }
// // 将SumDateVO对象添加到列表中
// countDateLists.add(countDateVO);
// }
// countDateLists.sort((a, b) -> a.getTradeDay().compareTo(b.getTradeDay()));
// summaryVO.setCountDateList(countDateLists);
// //访问量
// Tuple tuple = tbTokenRepository.countByAccountId(shopId);
// summaryVO.setTotalVisits(tuple == null ? 0L : tuple.get(0, Long.class));
// //访问量柱状图
// List<Object[]> objectsVisits = tbTokenRepository.countByMonth(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
// List<CountVisitsVO> visitsList = new ArrayList<>();
// for (Object[] o : objectsVisits) {
// CountVisitsVO countDateVO = new CountVisitsVO();
// countDateVO.setCount((BigInteger) o[0]);
// countDateVO.setTradeDay((String) o[1]);
// visitsList.add(countDateVO);
// }
// //填充日期
// Map<String, CountVisitsVO> dataVisitsMap = new HashMap<>();
// for (CountVisitsVO entry : visitsList) {
// String tradeDay = entry.getTradeDay();
// BigInteger countOrder = entry.getCount();
// dataVisitsMap.put(tradeDay, new CountVisitsVO(tradeDay, countOrder));
// }
// // 转换为字符串
// List<CountVisitsVO> countVisitsLists = new ArrayList<>();
// for (int i = 0; i < 30; i++) {
// LocalDate tradeDayLocalDate = today.minusDays(i);
// String tradeDayString = tradeDayLocalDate.format(formatter);
// CountVisitsVO countDateVO;
// // 检查数据Map中是否存在该日期的数据
// if (dataVisitsMap.containsKey(tradeDayString)) {
// countDateVO = dataVisitsMap.get(tradeDayString);
// } else {
// // 如果不存在则创建新的SumDateVO对象amount设为0
// countDateVO = new CountVisitsVO(tradeDayString, BigInteger.ZERO);
// }
// // 将SumDateVO对象添加到列表中
// countVisitsLists.add(countDateVO);
// }
// countVisitsLists.sort((a, b) -> a.getTradeDay().compareTo(b.getTradeDay()));
// summaryVO.setVisitsCountList(countVisitsLists);
// return summaryVO;
// }
@Override
public Map<String, Object> selectSummaryDate(Integer shopId, Integer day) {
Date startTime = new Date();

View File

@ -4,11 +4,12 @@ spring:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
# driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
# url: jdbc:mysql://127.0.0.1:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
username: cashier
password: Cashier@1@
driver-class-name: com.mysql.cj.jdbc.Driver
# driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# 初始连接数
initial-size: 5
# 最小连接数
@ -135,3 +136,11 @@ file:
# 文件大小 /M
maxSize: 100
avatarMaxSize: 5
decorator:
datasource:
p6spy:
# logging: slf4j
logging: file
log-file: spy.log
log-format: executeTime:%(executionTime) ms | sql:%(sqlSingleLine)
multiline: false

View File

@ -38,9 +38,9 @@
<logger name="jdbc.sqlonly" level="ERROR" additivity="false">
<appender-ref ref="console" />
</logger>
<logger name="org.hibernate.SQL" level="debug">
<!-- <logger name="org.hibernate.SQL" level="debug">-->
</logger>
<!-- </logger>-->
<logger name="jdbc.resultset" level="ERROR" additivity="false">
<appender-ref ref="console" />