首页数据改正
This commit is contained in:
@@ -14,6 +14,7 @@ import cn.ysk.cashier.utils.DateUtil;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.vo.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -34,6 +35,7 @@ import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class SummaryServiceImpl implements SummaryService {
|
||||
@Resource
|
||||
private ShopUserDutyRepository shopUserDutyRepository;
|
||||
@@ -52,8 +54,8 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
@Override
|
||||
public SummaryVO selectSummary(Integer shopId) {
|
||||
SummaryVO summaryVO = new SummaryVO();
|
||||
//支付笔数
|
||||
Tuple result = shopUserDutyRepository.sumByShopId(shopId);
|
||||
//支付笔数,
|
||||
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) {
|
||||
@@ -65,11 +67,12 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
Tuple count = tbShopUserRepository.searchByCount(shopId.toString());
|
||||
summaryVO.setTotalUser(count == null ? 0L : count.get(0, Long.class));
|
||||
//支付笔数柱形图
|
||||
List<Object[]> objects = shopUserDutyRepository.sumByDateOrderNum(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
List<Object[]> objects = tbOrderInfoRepository.sumByDateOrderNum(shopId.toString(), DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
List<CountDateVO> countDateList = new ArrayList<>();
|
||||
for (Object[] o : objects) {
|
||||
CountDateVO countDateVO = new CountDateVO();
|
||||
countDateVO.setCount((BigDecimal) o[0]);
|
||||
BigInteger integers = (BigInteger) o[0];
|
||||
countDateVO.setCount(new BigDecimal(integers.toString()));
|
||||
countDateVO.setTradeDay((String) o[1]);
|
||||
countDateList.add(countDateVO);
|
||||
}
|
||||
@@ -160,25 +163,28 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
endTime = DateUtil.getDayEnd();
|
||||
}
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
Tuple tuple = shopUserDutyDetailRepository.searchByDutyIdSum(shopId, startTime, endTime);
|
||||
List<Object[]> objects = shopUserDutyDetailRepository.searchByDutyGroup(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
Tuple tuple = detailRepository.sumByShopId(shopId, startTime, endTime);
|
||||
List<Object[]> objects = detailRepository.sumByShopIdGroup(shopId, startTime, endTime);
|
||||
//List<Object[]> objects = shopUserDutyDetailRepository.searchByDutyGroup(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
List<CountDateVO> numList = new ArrayList<>();
|
||||
for (Object[] o : objects) {
|
||||
CountDateVO countDateVO = new CountDateVO();
|
||||
countDateVO.setCount((BigDecimal) o[0]);
|
||||
countDateVO.setTradeDay((String) o[1]);
|
||||
BigInteger integers = (BigInteger)o[1];
|
||||
countDateVO.setCount(new BigDecimal(integers.toString()));
|
||||
Date date =(Date)o[2];
|
||||
countDateVO.setTradeDay(date.toString());
|
||||
numList.add(countDateVO);
|
||||
}
|
||||
List<Object[]> objects1 = shopUserDutyDetailRepository.searchByGroup(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
List<Object[]> objects2 = tbOrderInfoRepository.queryTbOrderPaySumByDay(shopId.toString(), startTime, endTime);
|
||||
List<CountDateVO> amountList = new ArrayList<>();
|
||||
for (Object[] o : objects1) {
|
||||
for (Object[] o : objects2) {
|
||||
CountDateVO countDateVO = new CountDateVO();
|
||||
countDateVO.setCount((BigDecimal) o[0]);
|
||||
countDateVO.setTradeDay((String) o[1]);
|
||||
amountList.add(countDateVO);
|
||||
}
|
||||
map.put("productCount", tuple == null ? 0 : tuple.get(0, BigDecimal.class));
|
||||
map.put("productSum", tuple == null ? 0 : tuple.get(1, BigDecimal.class));
|
||||
map.put("productSum", tuple == null ? 0 : tuple.get(1, BigInteger.class));
|
||||
map.put("numList", numList);
|
||||
map.put("amountList", amountList);
|
||||
return map;
|
||||
@@ -201,12 +207,17 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
startTime = DateUtil.getBeginDayOfYear();
|
||||
endTime = DateUtil.getEndDayOfYear();
|
||||
} else if (day == 1) {
|
||||
|
||||
startTime = DateUtil.getDayBegin();
|
||||
log.info("1天时间"+startTime.toString());
|
||||
endTime = DateUtil.getDayEnd();
|
||||
log.info("1天时间末"+endTime.toString());
|
||||
} else {
|
||||
throw new BadRequestException("日期有误");
|
||||
}
|
||||
List<Object[]> objects = shopUserDutyDetailRepository.searchByDutyId(shopId, startTime, endTime, currentPage, currentSize);
|
||||
Pageable pageable = PageRequest.of(0, 5);
|
||||
List<Object[]> objects = tbOrderInfoRepository.queryTbOrderPayCountByDayExt(shopId, startTime, endTime, currentPage, currentSize);
|
||||
|
||||
List<ProductExtVO> list = new ArrayList<>();
|
||||
for (Object[] o : objects) {
|
||||
ProductExtVO productVO = new ProductExtVO();
|
||||
@@ -216,12 +227,18 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
productVO.setAmount((BigDecimal) o[3]);
|
||||
list.add(productVO);
|
||||
}
|
||||
//汇总数据
|
||||
Tuple tuple = shopUserDutyDetailRepository.searchByDutyIdSum(shopId, startTime, endTime);
|
||||
|
||||
//分页数据
|
||||
Tuple tuple1 = shopUserDutyDetailRepository.searchCount(shopId, startTime, endTime);
|
||||
map.put("productCount", tuple == null ? 0 : tuple.get(0, BigDecimal.class));
|
||||
map.put("productSum", tuple == null ? 0 : tuple.get(1, BigDecimal.class));
|
||||
Tuple tuple1 = detailRepository.searchCount(shopId, startTime, endTime);
|
||||
//销售数量
|
||||
Tuple payCount = detailRepository.sumByShopId(shopId, startTime, endTime);
|
||||
//销售金额
|
||||
Long startTimeLong = DateUtil.convertDateToTimestamp(startTime);
|
||||
Long endTimeLong = DateUtil.convertDateToTimestamp(endTime);
|
||||
Tuple paySum = tbOrderInfoRepository.queryPaySumByDayAll(shopId.toString(), startTimeLong, endTimeLong);
|
||||
|
||||
map.put("productCount", payCount == null ? 0 : payCount.get(0, BigDecimal.class));
|
||||
map.put("productSum", paySum == null ? 0 : paySum.get(0,BigDecimal.class));
|
||||
map.put("totalProduct", list);
|
||||
map.put("total", tuple1 == null ? 0 : tuple1.get(0, BigInteger.class));
|
||||
return map;
|
||||
@@ -242,7 +259,8 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
throw new BadRequestException("日期有误");
|
||||
}
|
||||
|
||||
List<Object[]> objects = shopUserDutyRepository.sumByDate(shopId, startTime, endTime);
|
||||
List<Object[]> objects = tbOrderInfoRepository.queryTbOrderPaySumByDay(shopId.toString(), startTime, endTime);
|
||||
|
||||
//根据时间的销量
|
||||
List<SumDateVO> sumDateVOList = new ArrayList<>();
|
||||
for (Object[] o : objects) {
|
||||
@@ -278,8 +296,6 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
// 将SumDateVO对象添加到列表中
|
||||
sumDateList.add(sumDateVO);
|
||||
}
|
||||
|
||||
|
||||
sumDateList.sort((a, b) -> a.getTradeDay().compareTo(b.getTradeDay()));
|
||||
map.put("total", sumDateList);
|
||||
return map;
|
||||
@@ -288,8 +304,8 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
@Override
|
||||
public Map<String, Object> selectSummaryToday(Integer shopId) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
Tuple tuple = shopUserDutyRepository.sumByShopIdToday(shopId, DateUtil.getDayBegin(), DateUtil.getDayEnd());
|
||||
map.put("paymentsNumberToday", tuple == null ? 0L : tuple.get(0, Long.class));
|
||||
Tuple tuple = tbOrderInfoRepository.sumByShopIdToday(shopId.toString(), DateUtil.getDayBegin(), DateUtil.getDayEnd());
|
||||
map.put("paymentsNumberToday", tuple == null ? 0L : tuple.get(0, BigInteger.class));
|
||||
map.put("totalSalesToday", tuple == null ? new BigDecimal("0") : tuple.get(1, BigDecimal.class));
|
||||
Tuple tuple1 = tbShopUserRepository.searchByCountToday(shopId.toString(), DateUtil.getTodayStartTimestamp(), DateUtil.getTodayEndTimestamp());
|
||||
map.put("userToday", tuple1.get(0, Long.class));
|
||||
|
||||
Reference in New Issue
Block a user