| | |
| | | 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.domain.*; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.pojo.dto.AddAgreementDTO; |
| | | import com.ruoyi.system.pojo.dto.FinanceFlowsDTO; |
| | | import com.ruoyi.system.pojo.dto.OrderPageDTO; |
| | | import com.ruoyi.system.pojo.dto.WithdrawPageDTO; |
| | | 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; |
| | | @Autowired |
| | | private AppUserMapper appUserMapper; |
| | | @Autowired |
| | | private WithdrawMapper withdrawMapper; |
| | | |
| | | @Override |
| | | public IPage<OrderPageVO> getOrderPage(OrderPageDTO dto) { |
| | |
| | | |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void cancel(String id) { |
| | | Company company = companyMapper.selectById(id); |
| | |
| | | //未付款 直接取消订单 |
| | | order.setStatus(-1); |
| | | this.baseMapper.updateById(order); |
| | | //将分佣次数加回 |
| | | User user = appUserMapper.selectById(order.getUserId()); |
| | | user.setInviteNum(user.getInviteNum()+1); |
| | | appUserMapper.updateById(user); |
| | | //商品状态修改 |
| | | company.setStatus(1); |
| | | companyMapper.updateById(company); |
| | | }else{ |
| | | //退款 |
| | | order.setStatus(-1); |
| | | R r = refundPayMoney(order);//退款 |
| | | if (200 == r.getCode()) { |
| | | //退款成功 |
| | | order.setStatus(-1);//订单取消状态 |
| | | order.setIsRefund(1);//退款标志 |
| | | order.setRefundTime(LocalDateTime.now());//退款时间 |
| | | this.updateById(order); |
| | | //将分佣次数加回 |
| | | User user = appUserMapper.selectById(order.getUserId()); |
| | | user.setInviteNum(user.getInviteNum()+1); |
| | | appUserMapper.updateById(user); |
| | | //商品状态修改 |
| | | company.setStatus(1); |
| | | companyMapper.updateById(company); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public FinanceFlowsTopVO financeTop() { |
| | | return this.baseMapper.financeTop(); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<FinanceFlowsPageVO> flowsPage(FinanceFlowsDTO dto) { |
| | | IPage<FinanceFlowsPageVO> page = new Page<>(dto.getPageNum(), dto.getPageSize()); |
| | | Long total = this.baseMapper.countFlowsPage(dto); |
| | | IPage<FinanceFlowsPageVO> financeFlowsPageVOIPage = this.baseMapper.flowsPage(page, dto); |
| | | financeFlowsPageVOIPage.setTotal(total); |
| | | return financeFlowsPageVOIPage; |
| | | } |
| | | |
| | | |
| | | |
| | | } |