| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.pojo.dto.AddAgreementDTO; |
| | | import com.ruoyi.system.pojo.dto.OrderPageDTO; |
| | | import com.ruoyi.system.pojo.model.DailyStatistics; |
| | | import com.ruoyi.system.pojo.model.DrawSheet; |
| | | import com.ruoyi.system.pojo.vo.*; |
| | | import com.ruoyi.system.service.AgreementService; |
| | | import com.ruoyi.system.service.OrderService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | private ScheduleMapper scheduleMapper; |
| | | @Resource |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | | private SystemConfigMapper systemConfigMapper; |
| | | |
| | | @Override |
| | | public IPage<OrderPageVO> getOrderPage(OrderPageDTO dto) { |
| | |
| | | this.updateById(order); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 返回订单支付金额 |
| | | */ |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public TodayStatisticsVO today() { |
| | | LocalDateTime startTime = LocalDate.now().atStartOfDay(); |
| | | LocalDateTime endTime =LocalDate.now().atTime(23, 59, 59); |
| | | return this.baseMapper.today(startTime, endTime); |
| | | } |
| | | |
| | | @Override |
| | | public IndexLineChartVO chart(LocalDate startDate, LocalDate endDate) { |
| | | // 查询数据库 |
| | | List<DailyStatistics> statisticsList = this.baseMapper.getDailyStatistics( |
| | | startDate.atStartOfDay(), |
| | | endDate.atTime(23, 59, 59) |
| | | ); |
| | | // 构建返回对象 |
| | | IndexLineChartVO vo = new IndexLineChartVO(); |
| | | vo.setDays(new ArrayList<>()); |
| | | vo.setTotalList(new ArrayList<>()); |
| | | vo.setProfitList(new ArrayList<>()); |
| | | // 按日期顺序填充数据 |
| | | LocalDate currentDate = startDate; |
| | | while (!currentDate.isAfter(endDate)) { |
| | | String dateStr = currentDate.format(DateTimeFormatter.ISO_LOCAL_DATE); |
| | | vo.getDays().add(currentDate); |
| | | |
| | | // 查找当天数据,若无则默认为0 |
| | | Optional<DailyStatistics> statOptional = statisticsList.stream() |
| | | .filter(s -> s.getDate().equals(dateStr)) |
| | | .findFirst(); |
| | | |
| | | DailyStatistics stat = statOptional.orElse( |
| | | new DailyStatistics(dateStr, BigDecimal.ZERO, BigDecimal.ZERO) |
| | | ); |
| | | |
| | | vo.getTotalList().add(stat.getTotalPrice()); |
| | | vo.getProfitList().add(stat.getPlatformCommission()); |
| | | |
| | | currentDate = currentDate.plusDays(1); |
| | | } |
| | | return vo; |
| | | |
| | | } |
| | | |
| | | |
| | | } |