| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | |
| | | import java.time.*; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | // 司机消费 |
| | | List<BalanceUsageRecord> balanceUsageRecords = new ArrayList<>(); |
| | | // 司机提现 |
| | | List<BalanceUsageRecord> driverWithdrawal = new ArrayList<>(); |
| | | List<TPubWithdrawal> driverWithdrawal = new ArrayList<>(); |
| | | |
| | | Wrapper<TPubWithdrawal> driverWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | ; |
| | |
| | | // 司机已消费金额 |
| | | Wrapper<BalanceUsageRecord> between4 = new EntityWrapper<BalanceUsageRecord>() |
| | | ; |
| | | // 司机提现 |
| | | Wrapper<BalanceUsageRecord> between44 = new EntityWrapper<BalanceUsageRecord>() |
| | | ; |
| | | if (time!=null && time == 5){ |
| | | driverWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("userType", 2) |
| | | ; |
| | | if (time == 5 && !StringUtils.hasLength(insertTime)){ |
| | | // 专车wrapper |
| | | between = new EntityWrapper<TOrderPrivateCar>() |
| | | .isNotNull("activityId") |
| | |
| | | between4 = new EntityWrapper<BalanceUsageRecord>() |
| | | .ne("purpose", 6); |
| | | // 司机提现 |
| | | between44 = new EntityWrapper<BalanceUsageRecord>() |
| | | .eq("purpose", 6); |
| | | driverWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("type",1) |
| | | .eq("userType", 2) |
| | | ; |
| | | }else{ |
| | | driverWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("type",1) |
| | | .eq("userType", 2) |
| | | .between("handleTime", start, end); |
| | | .between("insertTime", start, end); |
| | | // 专车wrapper |
| | | between = new EntityWrapper<TOrderPrivateCar>() |
| | | .isNotNull("activityId") |
| | |
| | | between4 = new EntityWrapper<BalanceUsageRecord>() |
| | | .ne("purpose", 6) |
| | | .between("createTime", start, end); |
| | | // 司机提现 |
| | | between44 = new EntityWrapper<BalanceUsageRecord>() |
| | | .eq("purpose", 6) |
| | | .between("createTime", start, end); |
| | | |
| | | |
| | | } |
| | | // 司机提现wrapper |
| | | if (type!=null){ |
| | |
| | | case 3: |
| | | // 司机消费记录 |
| | | balanceUsageRecords = balanceUsageRecordService.selectList(between4); |
| | | |
| | | driverWithdrawal = balanceUsageRecordService.selectList(between44); |
| | | driverWithdrawal = pubWithdrawalService.selectList(driverWrapper); |
| | | break; |
| | | case 4: |
| | | // 专车订单 |
| | |
| | | // 消费 |
| | | balanceUsageRecords = balanceUsageRecordService.selectList(between4); |
| | | // 提现 |
| | | driverWithdrawal = balanceUsageRecordService.selectList(between44); |
| | | driverWithdrawal = pubWithdrawalService.selectList(driverWrapper); |
| | | } |
| | | |
| | | // 已发放补贴总额 |
| | |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getPayMoney().toString()); |
| | | grantVO.setAmount(userCouponRecord.getCouponMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userCouponRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getPayMoney().toString()); |
| | | grantVO.setAmount(userCouponRecord.getCouponMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userCouponRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | |
| | | res.add(grantVO); |
| | | } |
| | | // 司机提现 |
| | | for (BalanceUsageRecord balanceUsageRecord : driverWithdrawal) { |
| | | for (TPubWithdrawal balanceUsageRecord : driverWithdrawal) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(balanceUsageRecord.getCreateTime())); |
| | | grantVO.setInsertTime(format.format(balanceUsageRecord.getInsertTime())); |
| | | grantVO.setType("司机奖励"); |
| | | grantVO.setAmount(balanceUsageRecord.getMoney().toString()); |
| | | TDriver tUser = driverService.selectById(balanceUsageRecord.getDriverId()); |
| | | TDriver tUser = driverService.selectById(balanceUsageRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getFirstName()+tUser.getLastName()); |
| | | } |
| | | switch (balanceUsageRecord.getPurpose()){ |
| | | case 6: |
| | | grantVO.setRemark("司机提现"); |
| | | break; |
| | | } |
| | | grantVO.setRemark("司机提现"); |
| | | driverWithdrawal1 = driverWithdrawal1.add(new BigDecimal(balanceUsageRecord.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | |
| | | driver = driverConsume.add(driverWithdrawal1); |
| | | return res; |
| | | } |
| | | |
| | | @RequestMapping(value = "/use/getCount") |
| | | @ResponseBody |
| | | public Object getCount1(Integer time,String insertTime,Integer type) { |
| | |
| | | // 司机消费 |
| | | List<BalanceUsageRecord> balanceUsageRecords = new ArrayList<>(); |
| | | // 司机提现 |
| | | List<BalanceUsageRecord> driverWithdrawal = new ArrayList<>(); |
| | | List<TPubWithdrawal> driverWithdrawal = new ArrayList<>(); |
| | | Wrapper<TPubWithdrawal> driverWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | ; |
| | | // 专车wrapper |
| | |
| | | // 司机提现 |
| | | Wrapper<BalanceUsageRecord> between44 = new EntityWrapper<BalanceUsageRecord>() |
| | | ; |
| | | if (time!=null && time == 5){ |
| | | if (time == 5 && !StringUtils.hasLength(insertTime)){ |
| | | driverWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("type",1) |
| | | .eq("userType", 2) |
| | | ; |
| | | .between("insertTime", start, end); |
| | | // 专车wrapper |
| | | between = new EntityWrapper<TOrderPrivateCar>() |
| | | .isNotNull("activityId") |
| | |
| | | // 司机已消费金额 |
| | | between4 = new EntityWrapper<BalanceUsageRecord>() |
| | | .ne("purpose", 6); |
| | | // 司机提现 |
| | | between44 = new EntityWrapper<BalanceUsageRecord>() |
| | | .eq("purpose", 6); |
| | | |
| | | }else{ |
| | | driverWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("type",1) |
| | | .eq("userType", 2) |
| | | .between("handleTime", start, end); |
| | | .between("insertTime", start, end); |
| | | // 专车wrapper |
| | | between = new EntityWrapper<TOrderPrivateCar>() |
| | | .isNotNull("activityId") |
| | |
| | | between4 = new EntityWrapper<BalanceUsageRecord>() |
| | | .ne("purpose", 6) |
| | | .between("createTime", start, end); |
| | | // 司机提现 |
| | | between44 = new EntityWrapper<BalanceUsageRecord>() |
| | | .eq("purpose", 6) |
| | | .between("createTime", start, end); |
| | | } |
| | | |
| | | if (type!=null){ |
| | |
| | | // 司机消费记录 |
| | | balanceUsageRecords = balanceUsageRecordService.selectList(between4); |
| | | |
| | | driverWithdrawal = balanceUsageRecordService.selectList(between44); |
| | | // 司机提现记录 |
| | | driverWithdrawal = pubWithdrawalService.selectList(driverWrapper); |
| | | break; |
| | | case 4: |
| | | // 专车订单 |
| | |
| | | // 消费 |
| | | balanceUsageRecords = balanceUsageRecordService.selectList(between4); |
| | | // 提现 |
| | | driverWithdrawal = balanceUsageRecordService.selectList(between44); |
| | | driverWithdrawal = pubWithdrawalService.selectList(driverWrapper); |
| | | } |
| | | |
| | | // 已发放补贴总额 |
| | |
| | | } |
| | | grantVO.setRemark("订单号:"+userRedPacketRecord.getOrderNum()); |
| | | res.add(grantVO); |
| | | redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getPayMoney().toString())); |
| | | redPackage = redPackage.add(new BigDecimal(temp.toString())); |
| | | } |
| | | for (TOrderLogistics userRedPacketRecord : userRedPacketRecords1) { |
| | | if (userRedPacketRecord.getState() != 9 &&userRedPacketRecord.getState() != 8){ |
| | |
| | | } |
| | | grantVO.setRemark("订单号:"+userRedPacketRecord.getOrderNum()); |
| | | res.add(grantVO); |
| | | redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getPayMoney().toString())); |
| | | redPackage = redPackage.add(new BigDecimal(temp.toString())); |
| | | } |
| | | // 查询已领取优惠券总额 |
| | | for (TOrderPrivateCar userCouponRecord : userCouponRecords) { |
| | |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getPayMoney().toString()); |
| | | grantVO.setAmount(userCouponRecord.getCouponMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userCouponRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | grantVO.setRemark("订单号:"+userCouponRecord.getOrderNum()); |
| | | coupon = coupon.add(new BigDecimal(userCouponRecord.getPayMoney().toString())); |
| | | coupon = coupon.add(new BigDecimal(userCouponRecord.getCouponMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | for (TOrderLogistics userCouponRecord : userCouponRecords1) { |
| | |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getPayMoney().toString()); |
| | | grantVO.setAmount(userCouponRecord.getCouponMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userCouponRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | grantVO.setRemark("订单号:"+userCouponRecord.getOrderNum()); |
| | | coupon = coupon.add(new BigDecimal(userCouponRecord.getPayMoney().toString())); |
| | | coupon = coupon.add(new BigDecimal(userCouponRecord.getCouponMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | // 司机消费奖励 |
| | |
| | | res.add(grantVO); |
| | | } |
| | | // 司机提现 |
| | | for (BalanceUsageRecord balanceUsageRecord : driverWithdrawal) { |
| | | for (TPubWithdrawal balanceUsageRecord : driverWithdrawal) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(balanceUsageRecord.getCreateTime())); |
| | | grantVO.setInsertTime(format.format(balanceUsageRecord.getInsertTime())); |
| | | grantVO.setType("司机奖励"); |
| | | grantVO.setAmount(balanceUsageRecord.getMoney().toString()); |
| | | TDriver tUser = driverService.selectById(balanceUsageRecord.getDriverId()); |
| | | TDriver tUser = driverService.selectById(balanceUsageRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getFirstName()+tUser.getLastName()); |
| | | } |
| | | switch (balanceUsageRecord.getPurpose()){ |
| | | case 6: |
| | | grantVO.setRemark("司机提现"); |
| | | break; |
| | | } |
| | | grantVO.setRemark("司机提现"); |
| | | driverWithdrawal1 = driverWithdrawal1.add(new BigDecimal(balanceUsageRecord.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | |
| | | // 总额 |
| | | total = total.add(redPackage).add(coupon).add(discount).add(driverConsume).add(driverWithdrawal1); |
| | | // 已使用司机奖励合计 |
| | |
| | | useMoneyVO.setDriver(driver); |
| | | useMoneyVO.setDriverWithdrawal(driverWithdrawal1); |
| | | useMoneyVO.setDriverConsume(driverConsume); |
| | | |
| | | return useMoneyVO; |
| | | } |
| | | |
| | |
| | | // 司机奖励 |
| | | Wrapper<DriverActivityHistory> between4 = new EntityWrapper<DriverActivityHistory>() |
| | | ; |
| | | if (time == 5){ |
| | | if (time == 5 && !StringUtils.hasLength(insertTime)){ |
| | | // 专车wrapper |
| | | between = new EntityWrapper<TOrderPrivateCar>() |
| | | .isNotNull("discountMoney") |
| | |
| | | BigDecimal driver = new BigDecimal("0"); |
| | | // 查询已使用折扣总额 |
| | | for (TOrderPrivateCar tOrderPrivateCar : tOrderPrivateCars) { |
| | | if (tOrderPrivateCar.getDiscountMoney()==null){ |
| | | if (tOrderPrivateCar.getDiscountMoney()==null || tOrderPrivateCar.getDiscountMoney() == 0){ |
| | | continue; |
| | | } |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | |
| | | res.add(grantVO); |
| | | } |
| | | for (TOrderLogistics tOrderPrivateCar : tOrderLogistics) { |
| | | if (tOrderPrivateCar.getDiscountMoney()==null){ |
| | | if (tOrderPrivateCar.getDiscountMoney()==null || tOrderPrivateCar.getDiscountMoney() == 0){ |
| | | continue; |
| | | } |
| | | |
| | |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | SysCouponRecord sysCouponRecord = |
| | | sysCouponRecordService.selectById(userCouponRecord.getCouponId()); |
| | | if (sysCouponRecord!=null){ |
| | | grantVO.setRemark(sysCouponRecord.getName()); |
| | | SysCouponActivity sysCouponActivity = sysCouponActivityService.selectById(userCouponRecord.getCouponActivityId()); |
| | | if (sysCouponActivity!=null){ |
| | | grantVO.setRemark(sysCouponActivity.getName()); |
| | | } |
| | | coupon = coupon.add(new BigDecimal(userCouponRecord.getMoney().toString())); |
| | | res.add(grantVO); |
| | |
| | | driver = driver.add(new BigDecimal(driverActivityHistory.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | List<GrantVO> sortedList = res.stream() |
| | | .sorted((o1, o2) -> o2.getInsertTime().compareTo(o1.getInsertTime())) |
| | | .collect(Collectors.toList()); |
| | | total = total.add(redPackage).add(coupon).add(discount).add(driver); |
| | | return res; |
| | | return sortedList; |
| | | } |
| | | @RequestMapping(value = "/grant/getCount") |
| | | @ResponseBody |
| | |
| | | // 司机奖励 |
| | | Wrapper<DriverActivityHistory> between4 = new EntityWrapper<DriverActivityHistory>() |
| | | ; |
| | | if (time == 5){ |
| | | if (time == 5 && !StringUtils.hasLength(insertTime)){ |
| | | // 专车wrapper |
| | | between = new EntityWrapper<TOrderPrivateCar>() |
| | | .isNotNull("discountMoney") |