New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.ExcelExportUtil; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.vo.GrantMoneyVO; |
| | | import com.stylefeng.guns.modular.system.vo.GrantVO; |
| | | import com.stylefeng.guns.modular.system.vo.PlatformVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 控制器 |
| | | * |
| | | * @author fengshuonan |
| | | * @Date 2021-04-22 10:53:34 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/subsidy") |
| | | public class TSubsidyController extends BaseController { |
| | | |
| | | private String PREFIX = "/system/subsidy/"; |
| | | |
| | | @RequestMapping("/grant") |
| | | public String index( Model model) { |
| | | return PREFIX + "grant.html"; |
| | | } |
| | | @RequestMapping("/use") |
| | | public String watter( Model model) { |
| | | return PREFIX + "use.html"; |
| | | } |
| | | @Autowired |
| | | private IIncomeService tIncomeService; |
| | | @Autowired |
| | | private ITOrderPrivateCarService orderPrivateCarService; |
| | | @Autowired |
| | | private ITOrderLogisticsService orderLogisticsService; |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | @Autowired |
| | | private ISettlementRecordService settlementRecordService; |
| | | |
| | | @Autowired |
| | | private ISettlementDetailService settlementDetailService; |
| | | @Autowired |
| | | private ITDriverService driverService; |
| | | @Autowired |
| | | private ITPubTransactionDetailsService pubTransactionDetailsService; |
| | | @Autowired |
| | | private ITPubWithdrawalService pubWithdrawalService; |
| | | @Autowired |
| | | private IPaymentRecordService paymentRecordService; |
| | | @Autowired |
| | | private ITUserService appUserService; |
| | | @Autowired |
| | | private IUserCouponRecordService userCouponRecordService; |
| | | @Autowired |
| | | private IUserRedPacketRecordService userRedPacketRecordService; |
| | | @Autowired |
| | | private IDriverActivityHistoryService driverActivityHistoryService; |
| | | @Autowired |
| | | private IUserActivityRedenvelopeService userActivityRedenvelopeService; |
| | | @Autowired |
| | | private IUserActivityService userActivityService; |
| | | @Autowired |
| | | private ISysCouponActivityService sysCouponActivityService; |
| | | @Autowired |
| | | private ISysCouponRecordService sysCouponRecordService; |
| | | @Autowired |
| | | private IUserActivityDiscount1Service userActivityDiscount1Service; |
| | | /** |
| | | * 使用补贴统计 |
| | | */ |
| | | @RequestMapping(value = "/use/list") |
| | | @ResponseBody |
| | | public Object list1(Integer time,String insertTime,Integer type) { |
| | | if (time == null){ |
| | | time = 1; |
| | | } |
| | | String beginTime = null; |
| | | String endTime = null; |
| | | LocalDateTime start =null; |
| | | LocalDateTime end =null; |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | if (ToolUtil.isNotEmpty(insertTime)){ |
| | | beginTime = insertTime.split(" - ")[0]; |
| | | endTime = insertTime.split(" - ")[1]; |
| | | LocalDate s = LocalDate.parse(beginTime); |
| | | LocalDate e = LocalDate.parse(endTime); |
| | | start = s.atStartOfDay(); |
| | | end = e.atTime(LocalTime.MAX); |
| | | }else if (time!=null) { |
| | | switch (time) { |
| | | case 1: |
| | | // 获取当天的 00:00:00 和 23:59:59 |
| | | LocalDateTime startOfDay = today.atStartOfDay(); |
| | | LocalDateTime endOfDay = today.atTime(LocalTime.MAX); |
| | | start = startOfDay; |
| | | end = endOfDay; |
| | | break; |
| | | case 2: |
| | | // 获取本周第一天的日期和时间 |
| | | LocalDate firstDayOfWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); |
| | | LocalDateTime startOfWeek = firstDayOfWeek.atStartOfDay(); |
| | | |
| | | // 获取本周最后一天的日期和时间 |
| | | LocalDate lastDayOfWeek = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); |
| | | LocalDateTime endOfWeek = lastDayOfWeek.atTime(LocalTime.MAX); |
| | | start = startOfWeek; |
| | | end = endOfWeek; |
| | | break; |
| | | case 3: |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDateTime startOfMonth = firstDayOfMonth.atStartOfDay(); |
| | | |
| | | // 获取本月最后一天的日期和时间 |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime endOfMonth = lastDayOfMonth.atTime(LocalTime.MAX); |
| | | start = startOfMonth; |
| | | end = endOfMonth; |
| | | break; |
| | | case 4: |
| | | // 获取本年第一天的日期和时间 |
| | | LocalDate firstDayOfYear = LocalDate.of(today.getYear(), Month.JANUARY, 1); |
| | | LocalDateTime startOfYear = firstDayOfYear.atStartOfDay(); |
| | | // 获取本年最后一天的日期和时间 |
| | | LocalDate lastDayOfYear = LocalDate.of(today.getYear(), Month.DECEMBER, 31); |
| | | LocalDateTime endOfYear = lastDayOfYear.atTime(LocalTime.MAX); |
| | | start = startOfYear; |
| | | end = endOfYear; |
| | | break; |
| | | } |
| | | } |
| | | Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 列表res |
| | | List<GrantVO> res = new ArrayList<>(); |
| | | // 专车订单 |
| | | List<TOrderPrivateCar> tOrderPrivateCars = new ArrayList<>(); |
| | | // 小件物流 |
| | | List<TOrderLogistics> tOrderLogistics = new ArrayList<>(); |
| | | // 优惠券领取记录 |
| | | List<TOrderPrivateCar> userCouponRecords = new ArrayList<>(); |
| | | List<TOrderLogistics> userCouponRecords1 = new ArrayList<>(); |
| | | // 红包领取记录 |
| | | List<TOrderPrivateCar> userRedPacketRecords = new ArrayList<>(); |
| | | List<TOrderLogistics> userRedPacketRecords1 = new ArrayList<>(); |
| | | // 司机消费 |
| | | List<TPubTransactionDetails> driverActivityHistories = new ArrayList<>(); |
| | | // 司机提现 |
| | | List<TPubWithdrawal> driverWithdrawal = new ArrayList<>(); |
| | | // 司机提现wrapper |
| | | Wrapper<TPubWithdrawal> driverWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("userType", 2) |
| | | .between("handleTime", start, end); |
| | | // 专车wrapper |
| | | Wrapper<TOrderPrivateCar> between = new EntityWrapper<TOrderPrivateCar>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("activityId") |
| | | .isNotNull("discountMoney") |
| | | .between("insertTime", start, end); |
| | | // 小件物流wrapper |
| | | Wrapper<TOrderLogistics> between1 = new EntityWrapper<TOrderLogistics>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("activityId") |
| | | .isNotNull("discountMoney") |
| | | .between("insertTime", start, end); |
| | | // 已使用优惠券记录wrapper |
| | | Wrapper<TOrderPrivateCar> between2 = new EntityWrapper<TOrderPrivateCar>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("couponId") |
| | | .isNotNull("couponMoney") |
| | | .between("insertTime", start, end); |
| | | Wrapper<TOrderLogistics> between22 = new EntityWrapper<TOrderLogistics>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("couponId") |
| | | .isNotNull("couponMoney") |
| | | .between("insertTime", start, end); |
| | | // 已使用红包记录wrapper |
| | | Wrapper<TOrderPrivateCar> between3 = new EntityWrapper<TOrderPrivateCar>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("redPacketId") |
| | | .isNotNull("redPacketMoney") |
| | | .between("insertTime", start, end); |
| | | Wrapper<TOrderLogistics> between33 = new EntityWrapper<TOrderLogistics>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("redPacketId") |
| | | .isNotNull("redPacketMoney") |
| | | .between("insertTime", start, end); |
| | | // 司机已消费金额 |
| | | Wrapper<TPubTransactionDetails> between4 = new EntityWrapper<TPubTransactionDetails>() |
| | | .eq("state", 2) |
| | | .eq("type", 1) |
| | | .eq("userType", 2) |
| | | .ne("orderType", 2) |
| | | .ne("orderType", 3) |
| | | .between("insertTime", start, end); |
| | | if (type!=null){ |
| | | switch (type){ |
| | | case 1: |
| | | // 红包 |
| | | userRedPacketRecords = orderPrivateCarService.selectList(between3); |
| | | userRedPacketRecords1 = orderLogisticsService.selectList(between33); |
| | | break; |
| | | case 2: |
| | | userCouponRecords = orderPrivateCarService.selectList(between2); |
| | | userCouponRecords1 = orderLogisticsService.selectList(between22); |
| | | // 优惠券 |
| | | break; |
| | | case 3: |
| | | // 司机消费记录 |
| | | driverActivityHistories = pubTransactionDetailsService.selectList(between4); |
| | | |
| | | driverWithdrawal = pubWithdrawalService.selectList(driverWrapper); |
| | | break; |
| | | case 4: |
| | | // 专车订单 |
| | | tOrderPrivateCars = orderPrivateCarService.selectList(between); |
| | | // 小件物流订单 |
| | | tOrderLogistics = orderLogisticsService.selectList(between1); |
| | | break; |
| | | } |
| | | }else{ |
| | | // 红包 |
| | | userRedPacketRecords = orderPrivateCarService.selectList(between3); |
| | | userRedPacketRecords1 = orderLogisticsService.selectList(between33); |
| | | // 优惠券 |
| | | userCouponRecords = orderPrivateCarService.selectList(between2); |
| | | userCouponRecords1 = orderLogisticsService.selectList(between22); |
| | | // 专车订单 |
| | | tOrderPrivateCars = orderPrivateCarService.selectList(between); |
| | | // 小件物流订单 |
| | | tOrderLogistics = orderLogisticsService.selectList(between1); |
| | | // 消费 |
| | | driverActivityHistories = pubTransactionDetailsService.selectList(between4); |
| | | driverWithdrawal = pubWithdrawalService.selectList(driverWrapper); |
| | | } |
| | | |
| | | // 已发放补贴总额 |
| | | BigDecimal total = new BigDecimal("0"); |
| | | // 已使用折扣总额(用户端) |
| | | BigDecimal discount = new BigDecimal("0"); |
| | | // 已使用红包总额(用户端) |
| | | BigDecimal redPackage = new BigDecimal("0"); |
| | | // 已使用优惠券总额(用户端) |
| | | BigDecimal coupon = new BigDecimal("0"); |
| | | // 已使用司机奖励总额(司机端) |
| | | BigDecimal driver = new BigDecimal("0"); |
| | | // 司机已消费 |
| | | BigDecimal driverConsume = new BigDecimal("0"); |
| | | // 司机已提现 |
| | | BigDecimal driverWithdrawal1 = new BigDecimal("0"); |
| | | // 查询已使用折扣总额 |
| | | for (TOrderPrivateCar tOrderPrivateCar : tOrderPrivateCars) { |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | grantVO.setType("折扣"); |
| | | grantVO.setAmount(tOrderPrivateCar.getDiscountMoney().toString()); |
| | | TUser tUser = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | grantVO.setRemark("订单号:"+tOrderPrivateCar.getOrderNum()); |
| | | |
| | | } |
| | | for (TOrderLogistics tOrderPrivateCar : tOrderLogistics) { |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | grantVO.setType("折扣"); |
| | | grantVO.setAmount(tOrderPrivateCar.getDiscountMoney().toString()); |
| | | TUser tUser = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | grantVO.setRemark("订单号:"+tOrderPrivateCar.getOrderNum()); |
| | | } |
| | | // 查询已领取红包总额 |
| | | for (TOrderPrivateCar userRedPacketRecord : userRedPacketRecords) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userRedPacketRecord.getInsertTime())); |
| | | grantVO.setType("红包"); |
| | | grantVO.setAmount(userRedPacketRecord.getPayMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userRedPacketRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | grantVO.setRemark("订单号:"+userRedPacketRecord.getOrderNum()); |
| | | res.add(grantVO); |
| | | redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getPayMoney().toString())); |
| | | } |
| | | for (TOrderLogistics userRedPacketRecord : userRedPacketRecords1) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userRedPacketRecord.getInsertTime())); |
| | | grantVO.setType("红包"); |
| | | grantVO.setAmount(userRedPacketRecord.getPayMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userRedPacketRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | grantVO.setRemark("订单号:"+userRedPacketRecord.getOrderNum()); |
| | | res.add(grantVO); |
| | | redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getPayMoney().toString())); |
| | | } |
| | | // 查询已领取优惠券总额 |
| | | for (TOrderPrivateCar userCouponRecord : userCouponRecords) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getPayMoney().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())); |
| | | res.add(grantVO); |
| | | } |
| | | for (TOrderLogistics userCouponRecord : userCouponRecords1) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getPayMoney().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())); |
| | | res.add(grantVO); |
| | | } |
| | | // 已领取司机奖励 |
| | | // for (DriverActivityHistory driverActivityHistory : driverActivityHistories) { |
| | | // GrantVO grantVO = new GrantVO(); |
| | | // grantVO.setInsertTime(format.format(driverActivityHistory.getInsertTime())); |
| | | // grantVO.setType("司机奖励"); |
| | | // grantVO.setAmount(driverActivityHistory.getMoney().toString()); |
| | | // TDriver tDriver = driverService.selectById(driverActivityHistory.getDriverId()); |
| | | // if (tDriver!=null){ |
| | | // grantVO.setName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | // } |
| | | // Integer type1 = driverActivityHistory.getType(); |
| | | // switch (type1){ |
| | | // case 1: |
| | | // grantVO.setRemark("邀请司机注册"); |
| | | // break; |
| | | // case 2: |
| | | // grantVO.setRemark("邀请用户注册"); |
| | | // break; |
| | | // case 3: |
| | | // grantVO.setRemark("累计在线"); |
| | | // break; |
| | | // case 4: |
| | | // grantVO.setRemark("订单量"); |
| | | // break; |
| | | // } |
| | | // driver = driver.add(new BigDecimal(driverActivityHistory.getMoney().toString())); |
| | | // res.add(grantVO); |
| | | // } |
| | | total = total.add(redPackage).add(coupon).add(discount).add(driver); |
| | | return res; |
| | | } |
| | | @RequestMapping(value = "/use/getCount") |
| | | @ResponseBody |
| | | public Object getCount1(Integer time,String insertTime,Integer type) { |
| | | GrantMoneyVO result = new GrantMoneyVO(); |
| | | if (time == null){ |
| | | time = 1; |
| | | } |
| | | String beginTime = null; |
| | | String endTime = null; |
| | | LocalDateTime start =null; |
| | | LocalDateTime end =null; |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | if (ToolUtil.isNotEmpty(insertTime)){ |
| | | beginTime = insertTime.split(" - ")[0]; |
| | | endTime = insertTime.split(" - ")[1]; |
| | | LocalDate s = LocalDate.parse(beginTime); |
| | | LocalDate e = LocalDate.parse(endTime); |
| | | start = s.atStartOfDay(); |
| | | end = e.atTime(LocalTime.MAX); |
| | | }else if (time!=null) { |
| | | switch (time) { |
| | | case 1: |
| | | // 获取当天的 00:00:00 和 23:59:59 |
| | | LocalDateTime startOfDay = today.atStartOfDay(); |
| | | LocalDateTime endOfDay = today.atTime(LocalTime.MAX); |
| | | start = startOfDay; |
| | | end = endOfDay; |
| | | break; |
| | | case 2: |
| | | // 获取本周第一天的日期和时间 |
| | | LocalDate firstDayOfWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); |
| | | LocalDateTime startOfWeek = firstDayOfWeek.atStartOfDay(); |
| | | |
| | | // 获取本周最后一天的日期和时间 |
| | | LocalDate lastDayOfWeek = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); |
| | | LocalDateTime endOfWeek = lastDayOfWeek.atTime(LocalTime.MAX); |
| | | start = startOfWeek; |
| | | end = endOfWeek; |
| | | break; |
| | | case 3: |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDateTime startOfMonth = firstDayOfMonth.atStartOfDay(); |
| | | |
| | | // 获取本月最后一天的日期和时间 |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime endOfMonth = lastDayOfMonth.atTime(LocalTime.MAX); |
| | | start = startOfMonth; |
| | | end = endOfMonth; |
| | | break; |
| | | case 4: |
| | | // 获取本年第一天的日期和时间 |
| | | LocalDate firstDayOfYear = LocalDate.of(today.getYear(), Month.JANUARY, 1); |
| | | LocalDateTime startOfYear = firstDayOfYear.atStartOfDay(); |
| | | // 获取本年最后一天的日期和时间 |
| | | LocalDate lastDayOfYear = LocalDate.of(today.getYear(), Month.DECEMBER, 31); |
| | | LocalDateTime endOfYear = lastDayOfYear.atTime(LocalTime.MAX); |
| | | start = startOfYear; |
| | | end = endOfYear; |
| | | break; |
| | | } |
| | | } |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 列表res |
| | | List<GrantVO> res = new ArrayList<>(); |
| | | // 专车订单 |
| | | List<TOrderPrivateCar> tOrderPrivateCars = new ArrayList<>(); |
| | | // 小件物流 |
| | | List<TOrderLogistics> tOrderLogistics = new ArrayList<>(); |
| | | // 优惠券领取记录 |
| | | List<UserCouponRecord> userCouponRecords = new ArrayList<>(); |
| | | // 红包领取记录 |
| | | List<UserRedPacketRecord> userRedPacketRecords = new ArrayList<>(); |
| | | // 司机奖励 |
| | | List<DriverActivityHistory> driverActivityHistories = new ArrayList<>(); |
| | | |
| | | // 专车wrapper |
| | | Wrapper<TOrderPrivateCar> between = new EntityWrapper<TOrderPrivateCar>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("activityId") |
| | | .isNotNull("discountMoney") |
| | | .between("insertTime", start, end); |
| | | // 小件物流wrapper |
| | | Wrapper<TOrderLogistics> between1 = new EntityWrapper<TOrderLogistics>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("activityId") |
| | | .isNotNull("discountMoney") |
| | | .between("insertTime", start, end); |
| | | // 优惠券领取记录wrapper |
| | | Wrapper<UserCouponRecord> between2 = new EntityWrapper<UserCouponRecord>() |
| | | .ne("couponUseType", 2) |
| | | .ne("couponUseType", 3) |
| | | .between("insertTime", start, end); |
| | | // 红包领取记录wrapper |
| | | Wrapper<UserRedPacketRecord> between3 = new EntityWrapper<UserRedPacketRecord>() |
| | | .ne("orderType", 2) |
| | | .ne("orderType", 3) |
| | | .between("insertTime", start, end); |
| | | // 司机奖励 |
| | | Wrapper<DriverActivityHistory> between4 = new EntityWrapper<DriverActivityHistory>() |
| | | .eq("carryOut", 2) |
| | | .between("insertTime", start, end); |
| | | if (type!=null){ |
| | | |
| | | switch (type){ |
| | | case 1: |
| | | // 红包 |
| | | userRedPacketRecords = userRedPacketRecordService.selectList(between3); |
| | | break; |
| | | case 2: |
| | | userCouponRecords = userCouponRecordService.selectList(between2); |
| | | // 优惠券 |
| | | break; |
| | | case 3: |
| | | // 司机奖励 |
| | | driverActivityHistories = driverActivityHistoryService.selectList(between4); |
| | | break; |
| | | case 4: |
| | | // 专车订单 |
| | | tOrderPrivateCars = orderPrivateCarService.selectList(between); |
| | | // 小件物流订单 |
| | | tOrderLogistics = orderLogisticsService.selectList(between1); |
| | | break; |
| | | } |
| | | }else{ |
| | | // 专车订单 |
| | | tOrderPrivateCars = orderPrivateCarService.selectList(between); |
| | | // 小件物流订单 |
| | | tOrderLogistics = orderLogisticsService.selectList(between1); |
| | | // 司机奖励 |
| | | driverActivityHistories = driverActivityHistoryService.selectList(between4); |
| | | userCouponRecords = userCouponRecordService.selectList(between2); |
| | | userRedPacketRecords = userRedPacketRecordService.selectList(between3); |
| | | } |
| | | |
| | | // 已发放补贴总额 |
| | | BigDecimal total = new BigDecimal("0"); |
| | | // 已使用折扣总额(用户端) |
| | | BigDecimal discount = new BigDecimal("0"); |
| | | // 已领取红包总额(用户端) |
| | | BigDecimal redPackage = new BigDecimal("0"); |
| | | // 已领取优惠券总额(用户端) |
| | | BigDecimal coupon = new BigDecimal("0"); |
| | | // 已领取司机奖励总额(司机端) |
| | | BigDecimal driver = new BigDecimal("0"); |
| | | // 查询已使用折扣总额 |
| | | for (TOrderPrivateCar tOrderPrivateCar : tOrderPrivateCars) { |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | grantVO.setType("折扣"); |
| | | grantVO.setAmount(tOrderPrivateCar.getDiscountMoney().toString()); |
| | | TUser tUser = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectById(tOrderPrivateCar.getActivityId()); |
| | | if (userActivityDiscount1!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityDiscount1.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | } |
| | | for (TOrderLogistics tOrderPrivateCar : tOrderLogistics) { |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | grantVO.setType("折扣"); |
| | | grantVO.setAmount(tOrderPrivateCar.getDiscountMoney().toString()); |
| | | TUser tUser = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectById(tOrderPrivateCar.getActivityId()); |
| | | if (userActivityDiscount1!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityDiscount1.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | } |
| | | // 查询已领取红包总额 |
| | | for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userRedPacketRecord.getInsertTime())); |
| | | grantVO.setType("红包"); |
| | | grantVO.setAmount(userRedPacketRecord.getMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userRedPacketRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityRedenvelope userActivityRedenvelope = |
| | | userActivityRedenvelopeService.selectById(userRedPacketRecord.getRedPacketActivityId()); |
| | | if (userActivityRedenvelope!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityRedenvelope.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | res.add(grantVO); |
| | | redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getMoney().toString())); |
| | | } |
| | | // 查询已领取优惠券总额 |
| | | for (UserCouponRecord userCouponRecord : userCouponRecords) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userCouponRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | SysCouponRecord sysCouponRecord = |
| | | sysCouponRecordService.selectById(userCouponRecord.getCouponId()); |
| | | if (sysCouponRecord!=null){ |
| | | grantVO.setRemark(sysCouponRecord.getName()); |
| | | } |
| | | coupon = coupon.add(new BigDecimal(userCouponRecord.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | // 已领取司机奖励 |
| | | for (DriverActivityHistory driverActivityHistory : driverActivityHistories) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(driverActivityHistory.getInsertTime())); |
| | | grantVO.setType("司机奖励"); |
| | | grantVO.setAmount(driverActivityHistory.getMoney().toString()); |
| | | TDriver tDriver = driverService.selectById(driverActivityHistory.getDriverId()); |
| | | if (tDriver!=null){ |
| | | grantVO.setName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | } |
| | | Integer type1 = driverActivityHistory.getType(); |
| | | switch (type1){ |
| | | case 1: |
| | | grantVO.setRemark("邀请司机注册"); |
| | | break; |
| | | case 2: |
| | | grantVO.setRemark("邀请用户注册"); |
| | | break; |
| | | case 3: |
| | | grantVO.setRemark("累计在线"); |
| | | break; |
| | | case 4: |
| | | grantVO.setRemark("订单量"); |
| | | break; |
| | | } |
| | | driver = driver.add(new BigDecimal(driverActivityHistory.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | total = total.add(redPackage).add(coupon).add(discount).add(driver); |
| | | result.setTotal(total); |
| | | result.setDiscount(discount); |
| | | result.setCoupon(coupon); |
| | | result.setDriver(driver); |
| | | result.setRedPackage(redPackage); |
| | | return result; |
| | | } |
| | | /** |
| | | * 发放补贴统计 |
| | | */ |
| | | @RequestMapping(value = "/grant/list") |
| | | @ResponseBody |
| | | public Object list(Integer time,String insertTime,Integer type) { |
| | | if (time == null){ |
| | | time = 1; |
| | | } |
| | | String beginTime = null; |
| | | String endTime = null; |
| | | LocalDateTime start =null; |
| | | LocalDateTime end =null; |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | if (ToolUtil.isNotEmpty(insertTime)){ |
| | | beginTime = insertTime.split(" - ")[0]; |
| | | endTime = insertTime.split(" - ")[1]; |
| | | LocalDate s = LocalDate.parse(beginTime); |
| | | LocalDate e = LocalDate.parse(endTime); |
| | | start = s.atStartOfDay(); |
| | | end = e.atTime(LocalTime.MAX); |
| | | }else if (time!=null) { |
| | | switch (time) { |
| | | case 1: |
| | | // 获取当天的 00:00:00 和 23:59:59 |
| | | LocalDateTime startOfDay = today.atStartOfDay(); |
| | | LocalDateTime endOfDay = today.atTime(LocalTime.MAX); |
| | | start = startOfDay; |
| | | end = endOfDay; |
| | | break; |
| | | case 2: |
| | | // 获取本周第一天的日期和时间 |
| | | LocalDate firstDayOfWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); |
| | | LocalDateTime startOfWeek = firstDayOfWeek.atStartOfDay(); |
| | | |
| | | // 获取本周最后一天的日期和时间 |
| | | LocalDate lastDayOfWeek = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); |
| | | LocalDateTime endOfWeek = lastDayOfWeek.atTime(LocalTime.MAX); |
| | | start = startOfWeek; |
| | | end = endOfWeek; |
| | | break; |
| | | case 3: |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDateTime startOfMonth = firstDayOfMonth.atStartOfDay(); |
| | | |
| | | // 获取本月最后一天的日期和时间 |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime endOfMonth = lastDayOfMonth.atTime(LocalTime.MAX); |
| | | start = startOfMonth; |
| | | end = endOfMonth; |
| | | break; |
| | | case 4: |
| | | // 获取本年第一天的日期和时间 |
| | | LocalDate firstDayOfYear = LocalDate.of(today.getYear(), Month.JANUARY, 1); |
| | | LocalDateTime startOfYear = firstDayOfYear.atStartOfDay(); |
| | | // 获取本年最后一天的日期和时间 |
| | | LocalDate lastDayOfYear = LocalDate.of(today.getYear(), Month.DECEMBER, 31); |
| | | LocalDateTime endOfYear = lastDayOfYear.atTime(LocalTime.MAX); |
| | | start = startOfYear; |
| | | end = endOfYear; |
| | | break; |
| | | } |
| | | } |
| | | Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 列表res |
| | | List<GrantVO> res = new ArrayList<>(); |
| | | // 专车订单 |
| | | List<TOrderPrivateCar> tOrderPrivateCars = new ArrayList<>(); |
| | | // 小件物流 |
| | | List<TOrderLogistics> tOrderLogistics = new ArrayList<>(); |
| | | // 优惠券领取记录 |
| | | List<UserCouponRecord> userCouponRecords = new ArrayList<>(); |
| | | // 红包领取记录 |
| | | List<UserRedPacketRecord> userRedPacketRecords = new ArrayList<>(); |
| | | // 司机奖励 |
| | | List<DriverActivityHistory> driverActivityHistories = new ArrayList<>(); |
| | | |
| | | // 专车wrapper |
| | | Wrapper<TOrderPrivateCar> between = new EntityWrapper<TOrderPrivateCar>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("activityId") |
| | | .isNotNull("discountMoney") |
| | | .between("insertTime", start, end); |
| | | // 小件物流wrapper |
| | | Wrapper<TOrderLogistics> between1 = new EntityWrapper<TOrderLogistics>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("activityId") |
| | | .isNotNull("discountMoney") |
| | | .between("insertTime", start, end); |
| | | // 优惠券领取记录wrapper |
| | | Wrapper<UserCouponRecord> between2 = new EntityWrapper<UserCouponRecord>() |
| | | .ne("couponUseType", 2) |
| | | .ne("couponUseType", 3) |
| | | .between("insertTime", start, end); |
| | | // 红包领取记录wrapper |
| | | Wrapper<UserRedPacketRecord> between3 = new EntityWrapper<UserRedPacketRecord>() |
| | | .ne("orderType", 2) |
| | | .ne("orderType", 3) |
| | | .between("insertTime", start, end); |
| | | // 司机奖励 |
| | | Wrapper<DriverActivityHistory> between4 = new EntityWrapper<DriverActivityHistory>() |
| | | .eq("carryOut", 2) |
| | | .between("insertTime", start, end); |
| | | if (type!=null){ |
| | | |
| | | switch (type){ |
| | | case 1: |
| | | // 红包 |
| | | userRedPacketRecords = userRedPacketRecordService.selectList(between3); |
| | | break; |
| | | case 2: |
| | | userCouponRecords = userCouponRecordService.selectList(between2); |
| | | // 优惠券 |
| | | break; |
| | | case 3: |
| | | // 司机奖励 |
| | | driverActivityHistories = driverActivityHistoryService.selectList(between4); |
| | | break; |
| | | case 4: |
| | | // 专车订单 |
| | | tOrderPrivateCars = orderPrivateCarService.selectList(between); |
| | | // 小件物流订单 |
| | | tOrderLogistics = orderLogisticsService.selectList(between1); |
| | | break; |
| | | } |
| | | }else{ |
| | | // 专车订单 |
| | | tOrderPrivateCars = orderPrivateCarService.selectList(between); |
| | | // 小件物流订单 |
| | | tOrderLogistics = orderLogisticsService.selectList(between1); |
| | | // 司机奖励 |
| | | driverActivityHistories = driverActivityHistoryService.selectList(between4); |
| | | userCouponRecords = userCouponRecordService.selectList(between2); |
| | | userRedPacketRecords = userRedPacketRecordService.selectList(between3); |
| | | } |
| | | |
| | | // 已发放补贴总额 |
| | | BigDecimal total = new BigDecimal("0"); |
| | | // 已使用折扣总额(用户端) |
| | | BigDecimal discount = new BigDecimal("0"); |
| | | // 已领取红包总额(用户端) |
| | | BigDecimal redPackage = new BigDecimal("0"); |
| | | // 已领取优惠券总额(用户端) |
| | | BigDecimal coupon = new BigDecimal("0"); |
| | | // 已领取司机奖励总额(司机端) |
| | | BigDecimal driver = new BigDecimal("0"); |
| | | // 查询已使用折扣总额 |
| | | for (TOrderPrivateCar tOrderPrivateCar : tOrderPrivateCars) { |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | grantVO.setType("折扣"); |
| | | grantVO.setAmount(tOrderPrivateCar.getDiscountMoney().toString()); |
| | | TUser tUser = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectById(tOrderPrivateCar.getActivityId()); |
| | | if (userActivityDiscount1!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityDiscount1.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | } |
| | | for (TOrderLogistics tOrderPrivateCar : tOrderLogistics) { |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | grantVO.setType("折扣"); |
| | | grantVO.setAmount(tOrderPrivateCar.getDiscountMoney().toString()); |
| | | TUser tUser = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectById(tOrderPrivateCar.getActivityId()); |
| | | if (userActivityDiscount1!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityDiscount1.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | } |
| | | // 查询已领取红包总额 |
| | | for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userRedPacketRecord.getInsertTime())); |
| | | grantVO.setType("红包"); |
| | | grantVO.setAmount(userRedPacketRecord.getMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userRedPacketRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityRedenvelope userActivityRedenvelope = |
| | | userActivityRedenvelopeService.selectById(userRedPacketRecord.getRedPacketActivityId()); |
| | | if (userActivityRedenvelope!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityRedenvelope.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | res.add(grantVO); |
| | | redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getMoney().toString())); |
| | | } |
| | | // 查询已领取优惠券总额 |
| | | for (UserCouponRecord userCouponRecord : userCouponRecords) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userCouponRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | SysCouponRecord sysCouponRecord = |
| | | sysCouponRecordService.selectById(userCouponRecord.getCouponId()); |
| | | if (sysCouponRecord!=null){ |
| | | grantVO.setRemark(sysCouponRecord.getName()); |
| | | } |
| | | coupon = coupon.add(new BigDecimal(userCouponRecord.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | // 已领取司机奖励 |
| | | for (DriverActivityHistory driverActivityHistory : driverActivityHistories) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(driverActivityHistory.getInsertTime())); |
| | | grantVO.setType("司机奖励"); |
| | | grantVO.setAmount(driverActivityHistory.getMoney().toString()); |
| | | TDriver tDriver = driverService.selectById(driverActivityHistory.getDriverId()); |
| | | if (tDriver!=null){ |
| | | grantVO.setName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | } |
| | | Integer type1 = driverActivityHistory.getType(); |
| | | switch (type1){ |
| | | case 1: |
| | | grantVO.setRemark("邀请司机注册"); |
| | | break; |
| | | case 2: |
| | | grantVO.setRemark("邀请用户注册"); |
| | | break; |
| | | case 3: |
| | | grantVO.setRemark("累计在线"); |
| | | break; |
| | | case 4: |
| | | grantVO.setRemark("订单量"); |
| | | break; |
| | | } |
| | | driver = driver.add(new BigDecimal(driverActivityHistory.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | total = total.add(redPackage).add(coupon).add(discount).add(driver); |
| | | return res; |
| | | } |
| | | @RequestMapping(value = "/grant/getCount") |
| | | @ResponseBody |
| | | public Object getCount(Integer time,String insertTime,Integer type) { |
| | | GrantMoneyVO result = new GrantMoneyVO(); |
| | | if (time == null){ |
| | | time = 1; |
| | | } |
| | | String beginTime = null; |
| | | String endTime = null; |
| | | LocalDateTime start =null; |
| | | LocalDateTime end =null; |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | if (ToolUtil.isNotEmpty(insertTime)){ |
| | | beginTime = insertTime.split(" - ")[0]; |
| | | endTime = insertTime.split(" - ")[1]; |
| | | LocalDate s = LocalDate.parse(beginTime); |
| | | LocalDate e = LocalDate.parse(endTime); |
| | | start = s.atStartOfDay(); |
| | | end = e.atTime(LocalTime.MAX); |
| | | }else if (time!=null) { |
| | | switch (time) { |
| | | case 1: |
| | | // 获取当天的 00:00:00 和 23:59:59 |
| | | LocalDateTime startOfDay = today.atStartOfDay(); |
| | | LocalDateTime endOfDay = today.atTime(LocalTime.MAX); |
| | | start = startOfDay; |
| | | end = endOfDay; |
| | | break; |
| | | case 2: |
| | | // 获取本周第一天的日期和时间 |
| | | LocalDate firstDayOfWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); |
| | | LocalDateTime startOfWeek = firstDayOfWeek.atStartOfDay(); |
| | | |
| | | // 获取本周最后一天的日期和时间 |
| | | LocalDate lastDayOfWeek = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); |
| | | LocalDateTime endOfWeek = lastDayOfWeek.atTime(LocalTime.MAX); |
| | | start = startOfWeek; |
| | | end = endOfWeek; |
| | | break; |
| | | case 3: |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDateTime startOfMonth = firstDayOfMonth.atStartOfDay(); |
| | | |
| | | // 获取本月最后一天的日期和时间 |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime endOfMonth = lastDayOfMonth.atTime(LocalTime.MAX); |
| | | start = startOfMonth; |
| | | end = endOfMonth; |
| | | break; |
| | | case 4: |
| | | // 获取本年第一天的日期和时间 |
| | | LocalDate firstDayOfYear = LocalDate.of(today.getYear(), Month.JANUARY, 1); |
| | | LocalDateTime startOfYear = firstDayOfYear.atStartOfDay(); |
| | | // 获取本年最后一天的日期和时间 |
| | | LocalDate lastDayOfYear = LocalDate.of(today.getYear(), Month.DECEMBER, 31); |
| | | LocalDateTime endOfYear = lastDayOfYear.atTime(LocalTime.MAX); |
| | | start = startOfYear; |
| | | end = endOfYear; |
| | | break; |
| | | } |
| | | } |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 列表res |
| | | List<GrantVO> res = new ArrayList<>(); |
| | | // 专车订单 |
| | | List<TOrderPrivateCar> tOrderPrivateCars = new ArrayList<>(); |
| | | // 小件物流 |
| | | List<TOrderLogistics> tOrderLogistics = new ArrayList<>(); |
| | | // 优惠券领取记录 |
| | | List<UserCouponRecord> userCouponRecords = new ArrayList<>(); |
| | | // 红包领取记录 |
| | | List<UserRedPacketRecord> userRedPacketRecords = new ArrayList<>(); |
| | | // 司机奖励 |
| | | List<DriverActivityHistory> driverActivityHistories = new ArrayList<>(); |
| | | |
| | | // 专车wrapper |
| | | Wrapper<TOrderPrivateCar> between = new EntityWrapper<TOrderPrivateCar>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("activityId") |
| | | .isNotNull("discountMoney") |
| | | .between("insertTime", start, end); |
| | | // 小件物流wrapper |
| | | Wrapper<TOrderLogistics> between1 = new EntityWrapper<TOrderLogistics>() |
| | | .eq("state", 8) |
| | | .eq("state", 9) |
| | | .isNotNull("activityId") |
| | | .isNotNull("discountMoney") |
| | | .between("insertTime", start, end); |
| | | // 优惠券领取记录wrapper |
| | | Wrapper<UserCouponRecord> between2 = new EntityWrapper<UserCouponRecord>() |
| | | .ne("couponUseType", 2) |
| | | .ne("couponUseType", 3) |
| | | .between("insertTime", start, end); |
| | | // 红包领取记录wrapper |
| | | Wrapper<UserRedPacketRecord> between3 = new EntityWrapper<UserRedPacketRecord>() |
| | | .ne("orderType", 2) |
| | | .ne("orderType", 3) |
| | | .between("insertTime", start, end); |
| | | // 司机奖励 |
| | | Wrapper<DriverActivityHistory> between4 = new EntityWrapper<DriverActivityHistory>() |
| | | .eq("carryOut", 2) |
| | | .between("insertTime", start, end); |
| | | if (type!=null){ |
| | | |
| | | switch (type){ |
| | | case 1: |
| | | // 红包 |
| | | userRedPacketRecords = userRedPacketRecordService.selectList(between3); |
| | | break; |
| | | case 2: |
| | | userCouponRecords = userCouponRecordService.selectList(between2); |
| | | // 优惠券 |
| | | break; |
| | | case 3: |
| | | // 司机奖励 |
| | | driverActivityHistories = driverActivityHistoryService.selectList(between4); |
| | | break; |
| | | case 4: |
| | | // 专车订单 |
| | | tOrderPrivateCars = orderPrivateCarService.selectList(between); |
| | | // 小件物流订单 |
| | | tOrderLogistics = orderLogisticsService.selectList(between1); |
| | | break; |
| | | } |
| | | }else{ |
| | | // 专车订单 |
| | | tOrderPrivateCars = orderPrivateCarService.selectList(between); |
| | | // 小件物流订单 |
| | | tOrderLogistics = orderLogisticsService.selectList(between1); |
| | | // 司机奖励 |
| | | driverActivityHistories = driverActivityHistoryService.selectList(between4); |
| | | userCouponRecords = userCouponRecordService.selectList(between2); |
| | | userRedPacketRecords = userRedPacketRecordService.selectList(between3); |
| | | } |
| | | |
| | | // 已发放补贴总额 |
| | | BigDecimal total = new BigDecimal("0"); |
| | | // 已使用折扣总额(用户端) |
| | | BigDecimal discount = new BigDecimal("0"); |
| | | // 已领取红包总额(用户端) |
| | | BigDecimal redPackage = new BigDecimal("0"); |
| | | // 已领取优惠券总额(用户端) |
| | | BigDecimal coupon = new BigDecimal("0"); |
| | | // 已领取司机奖励总额(司机端) |
| | | BigDecimal driver = new BigDecimal("0"); |
| | | // 查询已使用折扣总额 |
| | | for (TOrderPrivateCar tOrderPrivateCar : tOrderPrivateCars) { |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | grantVO.setType("折扣"); |
| | | grantVO.setAmount(tOrderPrivateCar.getDiscountMoney().toString()); |
| | | TUser tUser = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectById(tOrderPrivateCar.getActivityId()); |
| | | if (userActivityDiscount1!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityDiscount1.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | } |
| | | for (TOrderLogistics tOrderPrivateCar : tOrderLogistics) { |
| | | discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString())); |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | grantVO.setType("折扣"); |
| | | grantVO.setAmount(tOrderPrivateCar.getDiscountMoney().toString()); |
| | | TUser tUser = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectById(tOrderPrivateCar.getActivityId()); |
| | | if (userActivityDiscount1!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityDiscount1.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | } |
| | | // 查询已领取红包总额 |
| | | for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userRedPacketRecord.getInsertTime())); |
| | | grantVO.setType("红包"); |
| | | grantVO.setAmount(userRedPacketRecord.getMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userRedPacketRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | UserActivityRedenvelope userActivityRedenvelope = |
| | | userActivityRedenvelopeService.selectById(userRedPacketRecord.getRedPacketActivityId()); |
| | | if (userActivityRedenvelope!=null){ |
| | | UserActivity userActivity = userActivityService.selectById(userActivityRedenvelope.getUserActivityId()); |
| | | if (userActivity!=null){ |
| | | grantVO.setRemark(userActivity.getName()); |
| | | } |
| | | } |
| | | res.add(grantVO); |
| | | redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getMoney().toString())); |
| | | } |
| | | // 查询已领取优惠券总额 |
| | | for (UserCouponRecord userCouponRecord : userCouponRecords) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime())); |
| | | grantVO.setType("优惠券"); |
| | | grantVO.setAmount(userCouponRecord.getMoney().toString()); |
| | | TUser tUser = appUserService.selectById(userCouponRecord.getUserId()); |
| | | if (tUser!=null){ |
| | | grantVO.setName(tUser.getNickName()); |
| | | } |
| | | SysCouponRecord sysCouponRecord = |
| | | sysCouponRecordService.selectById(userCouponRecord.getCouponId()); |
| | | if (sysCouponRecord!=null){ |
| | | grantVO.setRemark(sysCouponRecord.getName()); |
| | | } |
| | | coupon = coupon.add(new BigDecimal(userCouponRecord.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | // 已领取司机奖励 |
| | | for (DriverActivityHistory driverActivityHistory : driverActivityHistories) { |
| | | GrantVO grantVO = new GrantVO(); |
| | | grantVO.setInsertTime(format.format(driverActivityHistory.getInsertTime())); |
| | | grantVO.setType("司机奖励"); |
| | | grantVO.setAmount(driverActivityHistory.getMoney().toString()); |
| | | TDriver tDriver = driverService.selectById(driverActivityHistory.getDriverId()); |
| | | if (tDriver!=null){ |
| | | grantVO.setName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | } |
| | | Integer type1 = driverActivityHistory.getType(); |
| | | switch (type1){ |
| | | case 1: |
| | | grantVO.setRemark("邀请司机注册"); |
| | | break; |
| | | case 2: |
| | | grantVO.setRemark("邀请用户注册"); |
| | | break; |
| | | case 3: |
| | | grantVO.setRemark("累计在线"); |
| | | break; |
| | | case 4: |
| | | grantVO.setRemark("订单量"); |
| | | break; |
| | | } |
| | | driver = driver.add(new BigDecimal(driverActivityHistory.getMoney().toString())); |
| | | res.add(grantVO); |
| | | } |
| | | total = total.add(redPackage).add(coupon).add(discount).add(driver); |
| | | result.setTotal(total); |
| | | result.setDiscount(discount); |
| | | result.setCoupon(coupon); |
| | | result.setDriver(driver); |
| | | result.setRedPackage(redPackage); |
| | | return result; |
| | | } |
| | | } |