登录时增加shopName,logo;增加支付笔数;支付笔数饼图只判断完成的订单,

This commit is contained in:
liuyingfang
2024-03-14 09:44:22 +08:00
parent 8d9ba78594
commit f8f3212bdb
11 changed files with 110 additions and 9 deletions

View File

@@ -10,11 +10,9 @@ import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
import cn.ysk.cashier.service.SummaryService;
import cn.ysk.cashier.utils.DateUtil;
import cn.ysk.cashier.vo.CountPayTypeVO;
import cn.ysk.cashier.vo.SumDateVO;
import cn.ysk.cashier.vo.SummaryVO;
import cn.ysk.cashier.vo.ProductVO;
import cn.ysk.cashier.vo.*;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -53,9 +51,49 @@ public class SummaryServiceImpl implements SummaryService {
//用户数
Tuple count = tbShopUserRepository.searchByCount(shopId.toString());
summaryVO.setTotalUser(count.get(0, Long.class));
//支付笔数柱形图
List<Object[]> objects = shopUserDutyRepository.sumByDateOrderNum(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
List<CountDateVO> countDateList = new ArrayList<>();
for (Object[] o :objects) {
CountDateVO countDateVO = new CountDateVO();
countDateVO.setCount((BigDecimal) o[0]);
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);
}
summaryVO.setCountDateList(countDateLists);
//用户数折线图
return summaryVO;
}
@Override
public Map<String,Object> selectSummaryDate(Integer shopId, Integer day) {
Date startTime = new Date();

View File

@@ -243,9 +243,17 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new);
ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId());
tbShopInfo.copy(resources);
tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli());
tbShopInfoRepository.save(tbShopInfo);
}
@Override
public void updateShopId(TbShopInfo resources) {
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new);
ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId());
tbShopInfo.copy(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(String account) {

View File

@@ -70,6 +70,9 @@ public interface TbShopInfoService {
*/
void update(TbShopInfo resources);
void updateShopId(TbShopInfo resources);
void update(String account);
/**