| | |
| | | import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.dao.*; |
| | | import com.stylefeng.guns.modular.system.enums.OrderStateEnum; |
| | | import com.stylefeng.guns.modular.system.enums.PayStatusEnum; |
| | | import com.stylefeng.guns.modular.system.enums.StatusEnum; |
| | | import com.stylefeng.guns.modular.system.enums.UserTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.ITDriverService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.system.service.ITRegionService; |
| | | import org.apache.poi.hdf.extractor.TC; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.Period; |
| | | import java.time.ZoneId; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private ITRegionService itRegionService; |
| | | @Autowired |
| | | private HttpUtils httpUtils; |
| | | |
| | | @Autowired |
| | | private TRechargeRecordMapper tRechargeRecordMapper; |
| | | @Autowired |
| | | private TCashWithdrawalMapper tCashWithdrawalMapper; |
| | | |
| | | @Override |
| | | public EntityWrapper<TDriver> getPageList(String createTime, String phone, Integer status) { |
| | |
| | | TDriverResp tDriverResp = new TDriverResp(); |
| | | BeanUtils.copyProperties(tDriver,tDriverResp); |
| | | |
| | | // 设置余额 |
| | | tDriverResp.setBalance(tDriver.getBackgroundBalance().add(tDriver.getBalance())); |
| | | if(Objects.nonNull(tDriver.getBackgroundBalance()) && Objects.nonNull(tDriver.getBalance())){ |
| | | // 设置余额 |
| | | tDriverResp.setBalance(tDriver.getBackgroundBalance().add(tDriver.getBalance())); |
| | | } |
| | | |
| | | // 所属代理商 |
| | | TAgent tAgent = tAgentMapper.selectById(tDriver.getAgentId()); |
| | |
| | | tDriverResp.setBranchName(tBranchOffice.getPrincipal()); |
| | | } |
| | | //累计订单量 |
| | | List<TOrder> cumulativeOrderCount = tOrders.stream().filter(order -> order.getDriverId().equals(tDriver.getId()) |
| | | List<TOrder> cumulativeOrderCount = tOrders.stream().filter(order -> tDriver.getId().equals(order.getDriverId()) |
| | | && order.getState().equals(OrderStateEnum.WAIT_EVALUATED.getCode()) && order.getState().equals(OrderStateEnum.FINISH.getCode())).collect(Collectors.toList()); |
| | | tDriverResp.setCumulativeOrderCount(cumulativeOrderCount.size()); |
| | | //当月订单量 |
| | | List<TOrder> monthOrderCount = tOrders.stream().filter(order -> order.getDriverId().equals(tDriver.getId()) |
| | | List<TOrder> monthOrderCount = tOrders.stream().filter(order -> tDriver.getId().equals(order.getDriverId()) |
| | | && order.getState().equals(OrderStateEnum.WAIT_EVALUATED.getCode()) && order.getState().equals(OrderStateEnum.FINISH.getCode()) |
| | | && new SimpleDateFormat("yyyyMM").format(order.getCreateTime()).equals(monthDate)).collect(Collectors.toList()); |
| | | tDriverResp.setMonthOrderCount(monthOrderCount.size()); |
| | |
| | | |
| | | if(!CollectionUtils.isEmpty(tOrders)){ |
| | | //累计订单量 |
| | | List<TOrder> cumulativeOrderCount = tOrders.stream().filter(order -> order.getDriverId().equals(tDriver.getId()) |
| | | List<TOrder> cumulativeOrderCount = tOrders.stream().filter(order -> tDriver.getId().equals(order.getDriverId()) |
| | | && order.getState().equals(OrderStateEnum.WAIT_EVALUATED.getCode()) && order.getState().equals(OrderStateEnum.FINISH.getCode())).collect(Collectors.toList()); |
| | | model.addAttribute("cumulativeOrderCount",cumulativeOrderCount.size()); |
| | | //当月订单量 |
| | | List<TOrder> monthOrderCount = tOrders.stream().filter(order -> order.getDriverId().equals(tDriver.getId()) |
| | | List<TOrder> monthOrderCount = tOrders.stream().filter(order -> tDriver.getId().equals(order.getDriverId()) |
| | | && order.getState().equals(OrderStateEnum.WAIT_EVALUATED.getCode()) && order.getState().equals(OrderStateEnum.FINISH.getCode()) |
| | | && new SimpleDateFormat("yyyyMM").format(order.getCreateTime()).equals(monthDate)).collect(Collectors.toList()); |
| | | model.addAttribute("monthOrderCount",monthOrderCount.size()); |
| | | // 拒单次数 |
| | | List<TOrderRefusal> driverRefusalList = tOrderRefusalMapper.selectList(new EntityWrapper<TOrderRefusal>().eq("driver_id", tDriver.getId())); |
| | | model.addAttribute("refusalCount",driverRefusalList.size()); |
| | | // todo 累计收入 |
| | | model.addAttribute("cumulativeIncome",0); |
| | | // 累计收入 司机提现记录加上余额减去充值金额,为累计收入 |
| | | List<TCashWithdrawal> tCashWithdrawals = tCashWithdrawalMapper.selectList(new EntityWrapper<TCashWithdrawal>() |
| | | .eq("type", UserTypeEnum.DRIVER.getCode()) |
| | | .eq("userDriverId", tDriver.getId()) |
| | | .eq("state", 2)); |
| | | BigDecimal balance = tDriver.getBalance(); |
| | | if(!CollectionUtils.isEmpty(tCashWithdrawals)){ |
| | | Optional<BigDecimal> reduce = tCashWithdrawals.stream().map(TCashWithdrawal::getAmount).reduce(BigDecimal::add); |
| | | if(reduce.isPresent()){ |
| | | balance = balance.add(reduce.get()); |
| | | } |
| | | } |
| | | List<TRechargeRecord> tRechargeRecords = tRechargeRecordMapper.selectList(new EntityWrapper<TRechargeRecord>() |
| | | .eq("type", UserTypeEnum.DRIVER.getCode()) |
| | | .eq("userId", tDriver.getId()) |
| | | .eq("payType", 1) |
| | | .eq("payStatus", PayStatusEnum.FINISH.getCode())); |
| | | if(!CollectionUtils.isEmpty(tRechargeRecords)){ |
| | | Optional<BigDecimal> reduce = tRechargeRecords.stream().map(TRechargeRecord::getAmount).reduce(BigDecimal::add); |
| | | if(reduce.isPresent()){ |
| | | balance = balance.subtract(reduce.get()); |
| | | } |
| | | } |
| | | // 减去充值金额 |
| | | model.addAttribute("cumulativeIncome",balance); |
| | | }else { |
| | | model.addAttribute("cumulativeOrderCount",0); |
| | | model.addAttribute("monthOrderCount",0); |
| | |
| | | // 通过省市查询代理商 |
| | | List<TAgent> tAgent = tAgentMapper.selectList(new EntityWrapper<TAgent>().eq("provinceCode", province.getCode()) |
| | | .eq("cityCode", city.getCode()) |
| | | .eq("status", 1) |
| | | .eq("status", StatusEnum.NORMAL.getCode()) |
| | | .last("LIMIT 1")); |
| | | if(!CollectionUtils.isEmpty(tAgent)){ |
| | | tDriver.setAgentId(tAgent.get(0).getId()); |
| | |
| | | // 通过省市区查询分公司 |
| | | List<TBranchOffice> tBranchOffice = tBranchOfficeMapper.selectList(new EntityWrapper<TBranchOffice>().eq("provinceCode", province.getCode()) |
| | | .eq("cityCode", city.getCode()) |
| | | .eq("status", 1) |
| | | .eq("status", StatusEnum.NORMAL.getCode()) |
| | | .eq("districtCode", area.getCode()) |
| | | .last("LIMIT 1")); |
| | | if(!CollectionUtils.isEmpty(tBranchOffice)){ |
| | |
| | | // commissionResp.setAccumulatedCommission(BigDecimal.ZERO); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void getDataStatistics(Integer agentId, Model model,Map<String, Object> map) { |
| | | // 司机总数 |
| | | Integer driverTotal = tDriverMapper.selectCount(new EntityWrapper<TDriver>() |
| | | .eq("agentId", agentId)); |
| | | // 司机最近一月数量 |
| | | LocalDate now = LocalDate.now(); |
| | | LocalDate localDate = now.plusMonths(1); |
| | | Integer driverMonthTotal = tDriverMapper.selectCount(new EntityWrapper<TDriver>() |
| | | .eq("agentId", agentId) |
| | | .between("createTime", localDate, now)); |
| | | model.addAttribute("driverTotal",driverTotal); |
| | | model.addAttribute("driverMonthTotal",driverMonthTotal); |
| | | map.put("driverTotal",driverTotal); |
| | | map.put("driverMonthTotal",driverMonthTotal); |
| | | } |
| | | |
| | | @Override |
| | | public void getDataStatisticsByIds(List<Integer> ids, Model model, Map<String, Object> map) { |
| | | // 司机总数 |
| | | Integer driverTotal = tDriverMapper.selectCount(new EntityWrapper<TDriver>() |
| | | .in("agentId", ids)); |
| | | // 司机最近一月数量 |
| | | LocalDate now = LocalDate.now(); |
| | | LocalDate localDate = now.plusMonths(1); |
| | | Integer driverMonthTotal = tDriverMapper.selectCount(new EntityWrapper<TDriver>() |
| | | .in("agentId", ids) |
| | | .between("createTime", localDate, now)); |
| | | model.addAttribute("driverTotal",driverTotal); |
| | | model.addAttribute("driverMonthTotal",driverMonthTotal); |
| | | map.put("driverTotal",driverTotal); |
| | | map.put("driverMonthTotal",driverMonthTotal); |
| | | } |
| | | } |