| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.dao.RevenueMapper; |
| | | import com.supersavedriving.driver.modular.system.model.AppUser; |
| | | import com.supersavedriving.driver.modular.system.model.Driver; |
| | | import com.supersavedriving.driver.modular.system.model.Order; |
| | | import com.supersavedriving.driver.modular.system.model.Revenue; |
| | | import com.supersavedriving.driver.modular.system.service.IAppUserService; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverService; |
| | | import com.supersavedriving.driver.modular.system.service.IOrderService; |
| | | import com.supersavedriving.driver.modular.system.service.IRevenueService; |
| | | import com.supersavedriving.driver.modular.system.warpper.CommissionListWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.PerformanceRankingWarpper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 收入记录 |
| | |
| | | */ |
| | | @Service |
| | | public class RevenueServiceImpl extends ServiceImpl<RevenueMapper, Revenue> implements IRevenueService { |
| | | |
| | | @Autowired |
| | | private IOrderService orderService; |
| | | |
| | | @Autowired |
| | | private IAppUserService appUserService; |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取司机佣金记录 |
| | | * @param driverId |
| | | * @param time |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<CommissionListWarpper> queryCommissionList(Integer driverId, String time, Integer pageNum, Integer pageSize) throws Exception { |
| | | pageNum = (pageNum - 1) * pageSize; |
| | | Wrapper<Revenue> wrapper = new EntityWrapper<Revenue>().eq("userType", 2) |
| | | .eq("userId", driverId); |
| | | if(ToolUtil.isNotEmpty(time)){ |
| | | wrapper.eq("DATE_FORMAT(createTime, '%Y年%m月')", time); |
| | | } |
| | | List<Revenue> revenues = this.selectList(wrapper.last(" order by createTime desc limit " + pageNum + ", " + pageSize)); |
| | | List<CommissionListWarpper> list = new ArrayList<>(); |
| | | for (Revenue revenue : revenues) { |
| | | CommissionListWarpper commissionListWarpper = new CommissionListWarpper(); |
| | | commissionListWarpper.setCreateTime(revenue.getCreateTime().getTime()); |
| | | commissionListWarpper.setAmount(revenue.getAmount()); |
| | | commissionListWarpper.setUserType(revenue.getType()); |
| | | list.add(commissionListWarpper); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取司机总收入 |
| | | * @param driverId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public Double queryTotalAmount(Integer driverId) throws Exception { |
| | | return this.baseMapper.queryTotalAmount(driverId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取司机佣金收入排行 |
| | | * @param time |
| | | * @param dayType |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PerformanceRankingWarpper> queryDriverRank(Integer type, String time, Integer dayType) { |
| | | return this.baseMapper.queryDriverRank(type, time, dayType); |
| | | } |
| | | } |