| | |
| | | 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.modular.system.service.IIncomeService; |
| | | 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.PlatformMoneyVO; |
| | | import com.stylefeng.guns.modular.system.vo.PlatformVO; |
| | | import com.stylefeng.guns.modular.system.vo.WaterMoneyVO; |
| | | import com.stylefeng.guns.modular.system.vo.WaterVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | * @Date 2021-04-22 10:53:34 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/platform/commission") |
| | | @RequestMapping("/platform") |
| | | public class PlatformController extends BaseController { |
| | | |
| | | private String PREFIX = "/system/platform/"; |
| | | |
| | | @Autowired |
| | | private IIncomeService tIncomeService; |
| | | |
| | | @Autowired |
| | | private ITOrderPrivateCarService orderPrivateCarService; |
| | | @Autowired |
| | | private ITOrderLogisticsService orderLogisticsService; |
| | | /** |
| | | * 跳转到首页 |
| | | */ |
| | | @RequestMapping("") |
| | | @RequestMapping("/commission") |
| | | public String index( Model model) { |
| | | return PREFIX + "commission.html"; |
| | | } |
| | | @RequestMapping("/water") |
| | | public String watter( Model model) { |
| | | return PREFIX + "watter.html"; |
| | | } |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | @Autowired |
| | | private ISettlementRecordService settlementRecordService; |
| | | |
| | | @Autowired |
| | | private ISettlementDetailService settlementDetailService; |
| | | @Autowired |
| | | private ITDriverService driverService; |
| | | |
| | | public static void main(String[] args) { |
| | | // 获取今天的日期 |
| | | LocalDate today = LocalDate.now(); |
| | | // 获取本周第一天的日期和时间 |
| | | 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); |
| | | |
| | | // 获取本月第一天的日期和时间 |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDateTime startOfMonth = firstDayOfMonth.atStartOfDay(); |
| | | |
| | | // 获取本月最后一天的日期和时间 |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime endOfMonth = lastDayOfMonth.atTime(LocalTime.MAX); |
| | | |
| | | // 获取本年第一天的日期和时间 |
| | | 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); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * |
| | | * 计算金额 |
| | | * @param time |
| | | * @param insertTime |
| | | * @param state |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/commission/getCount") |
| | | @ResponseBody |
| | | public Object getCount(Integer time,String insertTime,Integer state) { |
| | | 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; |
| | | } |
| | | } |
| | | List<Income> incomes = new ArrayList<>(); |
| | | List<SettlementDetail> settlementDetails = new ArrayList<>(); |
| | | if (state!=null){ |
| | | switch (state){ |
| | | case 1: |
| | | // 已结算 |
| | | // 查询已结算的 |
| | | incomes = tIncomeService.selectList(new EntityWrapper<Income>() |
| | | .eq("userType", 2) |
| | | .ne("type", 1) |
| | | .isNotNull("orderType") |
| | | .between("insertTime", start, end)); |
| | | |
| | | |
| | | break; |
| | | case 2: |
| | | // 未结算 |
| | | |
| | | break; |
| | | } |
| | | }else{ |
| | | incomes = tIncomeService.selectList(new EntityWrapper<Income>() |
| | | .eq("userType", 2) |
| | | .ne("type", 1) |
| | | .isNotNull("orderType") |
| | | .between("insertTime", start, end)); |
| | | } |
| | | |
| | | |
| | | List<PlatformVO> res = new ArrayList<>(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | // 已结算金额 |
| | | BigDecimal balance = new BigDecimal("0"); |
| | | // 未结算金额 |
| | | BigDecimal unBalance = new BigDecimal("0"); |
| | | // 查询所有已结算的订单 |
| | | for (Income income : incomes) { |
| | | PlatformVO platformVO = new PlatformVO(); |
| | | platformVO.setState(1); |
| | | switch (income.getOrderType()){ |
| | | case 1: |
| | | // 查询订单信息 |
| | | TOrderPrivateCar tOrderPrivateCar = orderPrivateCarService.selectById(income.getIncomeId()); |
| | | if (tOrderPrivateCar==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderPrivateCar.getOrderNum()); |
| | | TDriver tDriver = driverService.selectById(tOrderPrivateCar.getDriverId()); |
| | | if (tDriver != null){ |
| | | platformVO.setDriverName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | platformVO.setDriverPhone(tDriver.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderPrivateCar.getRemark()); |
| | | if (income.getInsertTime()!=null){ |
| | | platformVO.setEndTime(format.format(income.getInsertTime())); |
| | | } |
| | | platformVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | String string = income.getMoney().toString(); |
| | | BigDecimal bigDecimal1 = new BigDecimal(string); |
| | | platformVO.setMoney(bigDecimal1); |
| | | if (tOrderPrivateCar.getPayType() == null){ |
| | | continue; |
| | | } |
| | | switch (tOrderPrivateCar.getPayType()){ |
| | | case 1: |
| | | platformVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | platformVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | platformVO.setPayType("余额支付"); |
| | | break; |
| | | case 4: |
| | | platformVO.setPayType("现金支付"); |
| | | break; |
| | | } |
| | | // 专车订单 |
| | | balance = balance.add(new BigDecimal(income.getMoney())); |
| | | res.add(platformVO); |
| | | break; |
| | | case 4: |
| | | // 小件物流 |
| | | // 查询订单信息 |
| | | TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(income.getIncomeId()); |
| | | if (tOrderLogistics==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderLogistics.getOrderNum()); |
| | | TDriver tDriver1 = driverService.selectById(tOrderLogistics.getDriverId()); |
| | | if (tDriver1!=null){ |
| | | platformVO.setDriverName(tDriver1.getFirstName()+tDriver1.getLastName()); |
| | | platformVO.setDriverPhone(tDriver1.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderLogistics.getRemark()); |
| | | platformVO.setMoney(new BigDecimal(income.getMoney())); |
| | | if (income.getInsertTime()!=null){ |
| | | platformVO.setEndTime(format.format(income.getInsertTime())); |
| | | } |
| | | platformVO.setInsertTime(format.format(tOrderLogistics.getInsertTime())); |
| | | if (tOrderLogistics.getPayType() == null){ |
| | | continue; |
| | | } |
| | | switch (tOrderLogistics.getPayType()){ |
| | | case 1: |
| | | platformVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | platformVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | platformVO.setPayType("余额支付"); |
| | | break; |
| | | case 4: |
| | | platformVO.setPayType("现金支付"); |
| | | break; |
| | | } |
| | | // 专车订单 |
| | | balance = balance.add(new BigDecimal(income.getMoney())); |
| | | res.add(platformVO); |
| | | break; |
| | | } |
| | | } |
| | | EntityWrapper<SettlementDetail> settlementDetailEntityWrapper = new EntityWrapper<>(); |
| | | settlementDetailEntityWrapper.between("createTime", start, end); |
| | | settlementDetails = settlementDetailService.selectList(settlementDetailEntityWrapper); |
| | | // 查询所有现金支付的订单 |
| | | for (SettlementDetail settlementDetail : settlementDetails) { |
| | | PlatformVO platformVO = new PlatformVO(); |
| | | switch (settlementDetail.getOrderType()){ |
| | | case 1: |
| | | // 专车订单 |
| | | TOrderPrivateCar tOrderPrivateCar = orderPrivateCarService.selectById(settlementDetail.getOrderId()); |
| | | if (tOrderPrivateCar==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderPrivateCar.getOrderNum()); |
| | | TDriver tDriver = driverService.selectById(tOrderPrivateCar.getDriverId()); |
| | | if (tDriver!=null){ |
| | | platformVO.setDriverName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | platformVO.setDriverPhone(tDriver.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderPrivateCar.getRemark()); |
| | | |
| | | platformVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | String string = settlementDetail.getPrice().toString(); |
| | | BigDecimal bigDecimal1 = new BigDecimal(string); |
| | | platformVO.setMoney(bigDecimal1); |
| | | platformVO.setPayType("现金支付"); |
| | | |
| | | // 查询是否结算 |
| | | SettlementRecord settlementRecord = settlementRecordService.selectById(settlementDetail.getSettlementRecordId()); |
| | | if (state!=null){ |
| | | if (state == 1){ |
| | | // 查询已结算的 |
| | | if (settlementRecord.getPaymentStatus() == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | if (state == 2){ |
| | | // 查询未结算的 |
| | | if (settlementRecord.getPaymentStatus() == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (settlementRecord.getPaymentStatus() == 2){ |
| | | // 已结算 |
| | | platformVO.setState(1); |
| | | balance = balance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | if (settlementRecord.getDay()!=null){ |
| | | platformVO.setEndTime(format.format(settlementRecord.getDay())); |
| | | } |
| | | }else{ |
| | | // 未结算 |
| | | platformVO.setState(2); |
| | | unBalance = unBalance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | } |
| | | res.add(platformVO); |
| | | break; |
| | | case 4: |
| | | // 小件物流 |
| | | // 查询订单信息 |
| | | TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(settlementDetail.getOrderId()); |
| | | if (tOrderLogistics==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderLogistics.getOrderNum()); |
| | | TDriver tDriver1 = driverService.selectById(tOrderLogistics.getDriverId()); |
| | | if (tDriver1!=null){ |
| | | platformVO.setDriverName(tDriver1.getFirstName()+tDriver1.getLastName()); |
| | | platformVO.setDriverPhone(tDriver1.getPhone()); |
| | | } |
| | | platformVO.setRemark(tOrderLogistics.getRemark()); |
| | | String string1 = settlementDetail.getPrice().toString(); |
| | | BigDecimal bigDecimal2 = new BigDecimal(string1); |
| | | platformVO.setMoney(bigDecimal2); |
| | | platformVO.setInsertTime(format.format(tOrderLogistics.getInsertTime())); |
| | | platformVO.setPayType("现金支付"); |
| | | // 查询是否结算 |
| | | SettlementRecord settlementRecord1 = settlementRecordService.selectById(settlementDetail.getSettlementRecordId()); |
| | | if (state!=null){ |
| | | if (state == 1){ |
| | | // 查询已结算的 |
| | | if (settlementRecord1.getPaymentStatus() == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | if (state == 2){ |
| | | // 查询未结算的 |
| | | if (settlementRecord1.getPaymentStatus() == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (settlementRecord1.getPaymentStatus() == 2){ |
| | | // 已结算 |
| | | platformVO.setState(1); |
| | | balance = balance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | if (settlementRecord1.getDay()!=null){ |
| | | platformVO.setEndTime(format.format(settlementRecord1.getDay())); |
| | | } |
| | | }else{ |
| | | // 未结算 |
| | | platformVO.setState(2); |
| | | unBalance = unBalance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | } |
| | | res.add(platformVO); |
| | | break; |
| | | } |
| | | } |
| | | PlatformMoneyVO platformMoneyVO = new PlatformMoneyVO(); |
| | | // 计算佣金总额 |
| | | BigDecimal add = unBalance.add(balance); |
| | | BigDecimal bigDecimal = add.setScale(2, RoundingMode.HALF_UP); |
| | | BigDecimal bigDecimal1 = unBalance.setScale(2, RoundingMode.HALF_UP); |
| | | BigDecimal bigDecimal2 = balance.setScale(2, RoundingMode.HALF_UP); |
| | | platformMoneyVO.setTotal(bigDecimal); |
| | | platformMoneyVO.setBalance(bigDecimal2); |
| | | platformMoneyVO.setUnBalance(bigDecimal1); |
| | | return platformMoneyVO; |
| | | } |
| | | |
| | | /** |
| | | * 第三方流水统计 获取金额 |
| | | * @param time |
| | | * @param insertTime |
| | | * @param |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/water/getCount") |
| | | @ResponseBody |
| | | public Object getCount1(Integer time,String insertTime,Integer payType,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; |
| | | } |
| | | } |
| | | List<Income> incomes = new ArrayList<>(); |
| | | List<SettlementDetail> settlementDetails = new ArrayList<>(); |
| | | // 用户订单记录 |
| | | List<TPubTransactionDetails> tOrderPrivateCars = new ArrayList<>(); |
| | | // 用户充值 |
| | | List<TPubTransactionDetails> tPubTransactionDetails = new ArrayList<>(); |
| | | // 司机提现 |
| | | List<TPubWithdrawal> driver = new ArrayList<>(); |
| | | // 用户提现 |
| | | List<TPubWithdrawal> user = new ArrayList<>(); |
| | | // 余额充值wrapper |
| | | Wrapper<TPubTransactionDetails> orderType = new EntityWrapper<TPubTransactionDetails>() |
| | | .eq("orderType", 5) |
| | | .between("insertTime",start,end); |
| | | // 用户提现wrapper |
| | | Wrapper<TPubWithdrawal> userWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("userType", 1) |
| | | .between("handleTime", start, end); |
| | | // 司机提现wrapper |
| | | Wrapper<TPubWithdrawal> between = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("userType", 2) |
| | | .between("handleTime", start, end); |
| | | // 用户订单wrapper |
| | | // Wrapper<PaymentRecord> between1 = new EntityWrapper<PaymentRecord>() |
| | | // .eq("type", 1) |
| | | // .eq("category", 1) |
| | | // .ne("orderType", 3) |
| | | // .ne("orderType", 5) |
| | | // .ne("orderType", 6) |
| | | // .between("insertTime", start, end); |
| | | // 用户订单wrapper |
| | | Wrapper<TPubTransactionDetails> between1 = new EntityWrapper<TPubTransactionDetails>() |
| | | .in("orderType", Arrays.asList(1, 4)) |
| | | .between("insertTime", start, end); |
| | | |
| | | if (type != null){ |
| | | switch (type){ |
| | | case 1: |
| | | // 只查询用户订单 |
| | | tOrderPrivateCars = pubTransactionDetailsService.selectList(between1); |
| | | break; |
| | | case 2: |
| | | // 只查询用户充值 |
| | | tPubTransactionDetails = pubTransactionDetailsService.selectList(orderType); |
| | | break; |
| | | case 3: |
| | | // 只查询司机已结算的 |
| | | incomes = tIncomeService.selectList(new EntityWrapper<Income>() |
| | | .eq("userType", 2) |
| | | .ne("type", 1) |
| | | .isNotNull("orderType") |
| | | .between("insertTime", start, end)); |
| | | break; |
| | | case 4: |
| | | if(payType!=null && payType == 2){ |
| | | break; |
| | | } |
| | | driver = pubWithdrawalService.selectList(between); |
| | | // 只查询司机提现 |
| | | break; |
| | | case 5: |
| | | if(payType!=null && payType == 2){ |
| | | break; |
| | | } |
| | | // 只查询用户提现 |
| | | user = pubWithdrawalService.selectList(userWrapper); |
| | | break; |
| | | } |
| | | }else{ |
| | | tOrderPrivateCars = pubTransactionDetailsService.selectList(between1); |
| | | tPubTransactionDetails = pubTransactionDetailsService.selectList(orderType); |
| | | incomes = tIncomeService.selectList(new EntityWrapper<Income>() |
| | | .eq("userType", 2) |
| | | .ne("type", 1) |
| | | .isNotNull("orderType") |
| | | .between("insertTime", start, end)); |
| | | driver = pubWithdrawalService.selectList(between); |
| | | user = pubWithdrawalService.selectList(userWrapper); |
| | | } |
| | | List<WaterVO> res = new ArrayList<>(); |
| | | // List<PlatformVO> res = new ArrayList<>(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 司机结算金额 |
| | | BigDecimal balance = new BigDecimal("0"); |
| | | // 用户消费金额 |
| | | BigDecimal userConsume = new BigDecimal("0"); |
| | | // 用户充值金额 |
| | | BigDecimal userRecharge = new BigDecimal("0"); |
| | | // 司机提现金额 |
| | | BigDecimal driverWithdrawal = new BigDecimal("0"); |
| | | // 用户提现金额 |
| | | BigDecimal userWithdrawal = new BigDecimal("0"); |
| | | // 用户订单消费 |
| | | |
| | | for (TPubTransactionDetails tOrderPrivateCar : tOrderPrivateCars) { |
| | | WaterVO waterVO = new WaterVO(); |
| | | waterVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | waterVO.setType("用户订单消费"); |
| | | switch (tOrderPrivateCar.getOrderType()){ |
| | | case 1: |
| | | // 专车 |
| | | TOrderPrivateCar tOrderPrivateCar1 = orderPrivateCarService.selectById(tOrderPrivateCar.getOrderId()); |
| | | if (tOrderPrivateCar1 != null){ |
| | | waterVO.setCode(tOrderPrivateCar1.getOrderNum()); |
| | | String string = tOrderPrivateCar.getMoney().toString(); |
| | | waterVO.setMoney(new BigDecimal(string)); |
| | | }else{ |
| | | waterVO.setMoney(new BigDecimal("0")); |
| | | } |
| | | TUser user1 = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (user1!=null){ |
| | | waterVO.setName(user1.getNickName()); |
| | | waterVO.setPhone(user1.getPhone()); |
| | | } |
| | | |
| | | if (tOrderPrivateCar1 != null){ |
| | | if (tOrderPrivateCar1.getPayType()!=null){ |
| | | switch (tOrderPrivateCar1.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | |
| | | case 4: |
| | | continue; |
| | | } |
| | | }else{ |
| | | continue; |
| | | } |
| | | }else{ |
| | | continue; |
| | | } |
| | | if (tOrderPrivateCar1 != null){ |
| | | waterVO.setRemark(tOrderPrivateCar1.getRemark()); |
| | | } |
| | | res.add(waterVO); |
| | | userConsume = userConsume.add(new BigDecimal(tOrderPrivateCar.getMoney().toString())); |
| | | break; |
| | | case 4: |
| | | // 小件物流 |
| | | TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(tOrderPrivateCar.getOrderId()); |
| | | if (tOrderLogistics != null){ |
| | | waterVO.setCode(tOrderLogistics.getOrderNum()); |
| | | String string = tOrderPrivateCar.getMoney().toString(); |
| | | waterVO.setMoney(new BigDecimal(string)); |
| | | }else{ |
| | | waterVO.setMoney(new BigDecimal("0")); |
| | | } |
| | | TUser user2 = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (user2!=null){ |
| | | waterVO.setName(user2.getNickName()); |
| | | waterVO.setPhone(user2.getPhone()); |
| | | } |
| | | waterVO.setType("用户订单消费"); |
| | | if (tOrderLogistics != null){ |
| | | if (tOrderLogistics.getPayType()!=null){ |
| | | switch (tOrderLogistics.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | |
| | | case 4: |
| | | continue; |
| | | } |
| | | }else{ |
| | | continue; |
| | | } |
| | | }else{ |
| | | continue; |
| | | } |
| | | if (tOrderLogistics != null){ |
| | | waterVO.setRemark(tOrderLogistics.getRemark()); |
| | | } |
| | | res.add(waterVO); |
| | | userConsume = userConsume.add(new BigDecimal(tOrderPrivateCar.getMoney().toString())); |
| | | break; |
| | | } |
| | | } |
| | | // 司机提现 |
| | | for (TPubWithdrawal tPubWithdrawal : driver) { |
| | | if(payType!=null && payType == 2){ |
| | | break; |
| | | } |
| | | WaterVO waterVO = new WaterVO(); |
| | | waterVO.setInsertTime(format.format(tPubWithdrawal.getHandleTime())); |
| | | waterVO.setCode(tPubWithdrawal.getCode()); |
| | | TDriver tDriver = driverService.selectById(tPubWithdrawal.getUserId()); |
| | | if (tDriver!=null){ |
| | | waterVO.setName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | waterVO.setPhone(tDriver.getPhone()); |
| | | } |
| | | |
| | | waterVO.setMoney(tPubWithdrawal.getMoney()); |
| | | waterVO.setPayType("银行卡支付"); |
| | | waterVO.setType("司机提现"); |
| | | waterVO.setRemark(tPubWithdrawal.getRemark()); |
| | | res.add(waterVO); |
| | | driverWithdrawal = driverWithdrawal.add(tPubWithdrawal.getMoney()); |
| | | } |
| | | // 用户提现 |
| | | for (TPubWithdrawal tPubWithdrawal : user) { |
| | | if(payType!=null && payType == 2){ |
| | | break; |
| | | } |
| | | WaterVO waterVO = new WaterVO(); |
| | | waterVO.setInsertTime(format.format(tPubWithdrawal.getHandleTime())); |
| | | waterVO.setCode(tPubWithdrawal.getCode()); |
| | | TUser user2 = appUserService.selectById(tPubWithdrawal.getUserId()); |
| | | if (user2!=null){ |
| | | waterVO.setName(user2.getNickName()); |
| | | waterVO.setPhone(user2.getPhone()); |
| | | } |
| | | waterVO.setMoney(tPubWithdrawal.getMoney()); |
| | | waterVO.setPayType("银行卡支付"); |
| | | waterVO.setType("用户提现"); |
| | | waterVO.setRemark(tPubWithdrawal.getRemark()); |
| | | res.add(waterVO); |
| | | userWithdrawal = userWithdrawal.add(tPubWithdrawal.getMoney()); |
| | | } |
| | | // 查询用户充值 |
| | | for (TPubTransactionDetails tPubTransactionDetail : tPubTransactionDetails) { |
| | | WaterVO waterVO = new WaterVO(); |
| | | Integer orderId = tPubTransactionDetail.getOrderId(); |
| | | PaymentRecord paymentRecord = paymentRecordService.selectById(orderId); |
| | | if (paymentRecord!=null){ |
| | | waterVO.setInsertTime(format.format(paymentRecord.getInsertTime())); |
| | | waterVO.setCode(paymentRecord.getCode()); |
| | | if (paymentRecord.getPayType()!=null){ |
| | | switch (paymentRecord.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("银行卡支付"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | waterVO.setMoney(new BigDecimal(paymentRecord.getAmount().toString())); |
| | | }else{ |
| | | continue; |
| | | } |
| | | if (paymentRecord.getUserId()!=null){ |
| | | TUser user2 = appUserService.selectById(paymentRecord.getUserId()); |
| | | if (user2!=null){ |
| | | waterVO.setName(user2.getNickName()); |
| | | waterVO.setPhone(user2.getPhone()); |
| | | } |
| | | } |
| | | |
| | | waterVO.setType("用户充值"); |
| | | waterVO.setRemark(tPubTransactionDetail.getRemark()); |
| | | res.add(waterVO); |
| | | userRecharge = userRecharge.add(new BigDecimal(paymentRecord.getAmount().toString())); |
| | | } |
| | | // 查询所有已结算的订单 |
| | | for (Income income : incomes) { |
| | | WaterVO platformVO = new WaterVO(); |
| | | platformVO.setType("司机结算"); |
| | | switch (income.getOrderType()){ |
| | | case 1: |
| | | // 查询订单信息 |
| | | TOrderPrivateCar tOrderPrivateCar = orderPrivateCarService.selectById(income.getIncomeId()); |
| | | if (tOrderPrivateCar==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderPrivateCar.getOrderNum()); |
| | | TDriver tDriver = driverService.selectById(tOrderPrivateCar.getDriverId()); |
| | | if (tDriver != null){ |
| | | platformVO.setName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | platformVO.setPhone(tDriver.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderPrivateCar.getRemark()); |
| | | if (income.getInsertTime()!=null){ |
| | | platformVO.setInsertTime(format.format(income.getInsertTime())); |
| | | } |
| | | platformVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | if (tOrderPrivateCar.getOrderMoney() != null){ |
| | | String string = tOrderPrivateCar.getOrderMoney().toString(); |
| | | BigDecimal bigDecimal1 = new BigDecimal(string); |
| | | platformVO.setMoney(bigDecimal1); |
| | | }else{ |
| | | continue; |
| | | } |
| | | |
| | | if (tOrderPrivateCar.getPayType() == null){ |
| | | continue; |
| | | } |
| | | switch (tOrderPrivateCar.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | platformVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | platformVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | case 4: |
| | | continue; |
| | | } |
| | | |
| | | // 专车订单 |
| | | String string4 = tOrderPrivateCar.getOrderMoney().toString(); |
| | | balance = balance.add(new BigDecimal(string4)); |
| | | res.add(platformVO); |
| | | break; |
| | | case 4: |
| | | // 小件物流 |
| | | // 查询订单信息 |
| | | TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(income.getIncomeId()); |
| | | if (tOrderLogistics==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderLogistics.getOrderNum()); |
| | | TDriver tDriver1 = driverService.selectById(tOrderLogistics.getDriverId()); |
| | | if (tDriver1!=null){ |
| | | platformVO.setName(tDriver1.getFirstName()+tDriver1.getLastName()); |
| | | platformVO.setPhone(tDriver1.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderLogistics.getRemark()); |
| | | platformVO.setMoney(new BigDecimal(income.getMoney())); |
| | | if (income.getInsertTime()!=null){ |
| | | platformVO.setInsertTime(format.format(income.getInsertTime())); |
| | | } |
| | | platformVO.setInsertTime(format.format(tOrderLogistics.getInsertTime())); |
| | | if (tOrderLogistics.getPayType() == null){ |
| | | continue; |
| | | } |
| | | switch (tOrderLogistics.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | platformVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | platformVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | |
| | | case 4: |
| | | continue; |
| | | } |
| | | String string1 = tOrderLogistics.getOrderMoney().toString(); |
| | | // 小件物流订单 |
| | | balance = balance.add(new BigDecimal(string1)); |
| | | res.add(platformVO); |
| | | break; |
| | | } |
| | | } |
| | | // EntityWrapper<SettlementDetail> settlementDetailEntityWrapper = new EntityWrapper<>(); |
| | | // settlementDetailEntityWrapper.between("createTime", start, end); |
| | | // settlementDetails = settlementDetailService.selectList(settlementDetailEntityWrapper); |
| | | // // 查询所有现金支付的订单 |
| | | // for (SettlementDetail settlementDetail : settlementDetails) { |
| | | // WaterVO platformVO = new WaterVO(); |
| | | // switch (settlementDetail.getOrderType()){ |
| | | // case 1: |
| | | // // 专车订单 |
| | | // TOrderPrivateCar tOrderPrivateCar = orderPrivateCarService.selectById(settlementDetail.getOrderId()); |
| | | // if (tOrderPrivateCar==null){ |
| | | // continue; |
| | | // } |
| | | // platformVO.setCode(tOrderPrivateCar.getOrderNum()); |
| | | // TDriver tDriver = driverService.selectById(tOrderPrivateCar.getDriverId()); |
| | | // if (tDriver!=null){ |
| | | // platformVO.setDriverName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | // platformVO.setDriverPhone(tDriver.getPhone()); |
| | | // } |
| | | // platformVO.setRemark(tOrderPrivateCar.getRemark()); |
| | | // platformVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | // String string = settlementDetail.getPrice().toString(); |
| | | // BigDecimal bigDecimal1 = new BigDecimal(string); |
| | | // platformVO.setMoney(bigDecimal1); |
| | | // platformVO.setPayType("现金支付"); |
| | | // // 查询是否结算 |
| | | // SettlementRecord settlementRecord = settlementRecordService.selectById(settlementDetail.getSettlementRecordId()); |
| | | // |
| | | // if (settlementRecord.getPaymentStatus() == 1){ |
| | | // continue; |
| | | // } |
| | | // |
| | | // // 已结算 |
| | | // platformVO.setState(1); |
| | | // balance = balance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | // if (settlementRecord.getDay()!=null){ |
| | | // platformVO.setInsertTime(format.format(settlementRecord.getDay())); |
| | | // } |
| | | // |
| | | // res.add(platformVO); |
| | | // break; |
| | | // case 4: |
| | | // // 小件物流 |
| | | // // 查询订单信息 |
| | | // TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(settlementDetail.getOrderId()); |
| | | // if (tOrderLogistics==null){ |
| | | // continue; |
| | | // } |
| | | // platformVO.setCode(tOrderLogistics.getOrderNum()); |
| | | // TDriver tDriver1 = driverService.selectById(tOrderLogistics.getDriverId()); |
| | | // if (tDriver1!=null){ |
| | | // platformVO.setDriverName(tDriver1.getFirstName()+tDriver1.getLastName()); |
| | | // platformVO.setDriverPhone(tDriver1.getPhone()); |
| | | // } |
| | | // platformVO.setRemark(tOrderLogistics.getRemark()); |
| | | // String string1 = settlementDetail.getPrice().toString(); |
| | | // BigDecimal bigDecimal2 = new BigDecimal(string1); |
| | | // platformVO.setMoney(bigDecimal2); |
| | | // platformVO.setInsertTime(format.format(tOrderLogistics.getInsertTime())); |
| | | // platformVO.setPayType("现金支付"); |
| | | // // 查询是否结算 |
| | | // SettlementRecord settlementRecord1 = settlementRecordService.selectById(settlementDetail.getSettlementRecordId()); |
| | | // if (payType!=null){ |
| | | // if (payType == 1){ |
| | | // // 查询已结算的 |
| | | // if (settlementRecord1.getPaymentStatus() == 1){ |
| | | // continue; |
| | | // } |
| | | // } |
| | | // if (payType == 2){ |
| | | // // 查询未结算的 |
| | | // if (settlementRecord1.getPaymentStatus() == 2){ |
| | | // continue; |
| | | // } |
| | | // } |
| | | // } |
| | | // if (settlementRecord1.getPaymentStatus() == 2){ |
| | | // // 已结算 |
| | | // platformVO.setState(1); |
| | | // balance = balance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | // if (settlementRecord1.getDay()!=null){ |
| | | // platformVO.setInsertTime(format.format(settlementRecord1.getDay())); |
| | | // } |
| | | // }else{ |
| | | // // 未结算 |
| | | // platformVO.setState(2); |
| | | // unBalance = unBalance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | // } |
| | | // res.add(platformVO); |
| | | // break; |
| | | // } |
| | | // } |
| | | // 计算佣金总额 |
| | | // BigDecimal add = unBalance.add(balance); |
| | | Collections.sort(res, Comparator.comparing(WaterVO::getInsertTime).reversed()); |
| | | WaterMoneyVO waterMoneyVO = new WaterMoneyVO(); |
| | | BigDecimal add = userRecharge.add(userConsume).add(balance).subtract(driverWithdrawal).subtract(userWithdrawal); |
| | | waterMoneyVO.setTotal(add); |
| | | waterMoneyVO.setUserOrder(userConsume); |
| | | waterMoneyVO.setUserCharge(userRecharge); |
| | | waterMoneyVO.setBalance(balance); |
| | | waterMoneyVO.setDriverWithdrawal(driverWithdrawal); |
| | | waterMoneyVO.setUserWithdrawal(userWithdrawal); |
| | | return waterMoneyVO; |
| | | } |
| | | /** |
| | | * 第三方流水统计获取列表 |
| | | */ |
| | | |
| | | @Autowired |
| | | private ITPubTransactionDetailsService pubTransactionDetailsService; |
| | | @Autowired |
| | | private ITPubWithdrawalService pubWithdrawalService; |
| | | @Autowired |
| | | private IPaymentRecordService paymentRecordService; |
| | | @Autowired |
| | | private ITUserService appUserService; |
| | | @RequestMapping(value = "/water/list") |
| | | @ResponseBody |
| | | public Object list1(Integer time,String insertTime,Integer payType,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; |
| | | } |
| | | } |
| | | List<Income> incomes = new ArrayList<>(); |
| | | List<SettlementDetail> settlementDetails = new ArrayList<>(); |
| | | // 用户订单记录 |
| | | List<TPubTransactionDetails> tOrderPrivateCars = new ArrayList<>(); |
| | | // 用户充值 |
| | | List<TPubTransactionDetails> tPubTransactionDetails = new ArrayList<>(); |
| | | // 司机提现 |
| | | List<TPubWithdrawal> driver = new ArrayList<>(); |
| | | // 用户提现 |
| | | List<TPubWithdrawal> user = new ArrayList<>(); |
| | | // 余额充值wrapper |
| | | Wrapper<TPubTransactionDetails> orderType = new EntityWrapper<TPubTransactionDetails>() |
| | | .eq("orderType", 5) |
| | | .between("insertTime",start,end); |
| | | // 用户提现wrapper |
| | | Wrapper<TPubWithdrawal> userWrapper = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("userType", 1) |
| | | .between("handleTime", start, end); |
| | | // 司机提现wrapper |
| | | Wrapper<TPubWithdrawal> between = new EntityWrapper<TPubWithdrawal>() |
| | | .eq("state", 2) |
| | | .eq("userType", 2) |
| | | .between("handleTime", start, end); |
| | | // 用户订单wrapper |
| | | // Wrapper<PaymentRecord> between1 = new EntityWrapper<PaymentRecord>() |
| | | // .eq("type", 1) |
| | | // .eq("category", 1) |
| | | // .ne("orderType", 3) |
| | | // .ne("orderType", 5) |
| | | // .ne("orderType", 6) |
| | | // .between("insertTime", start, end); |
| | | // 用户订单wrapper |
| | | Wrapper<TPubTransactionDetails> between1 = new EntityWrapper<TPubTransactionDetails>() |
| | | .in("orderType", Arrays.asList(1, 4)) |
| | | .between("insertTime", start, end); |
| | | |
| | | if (type != null){ |
| | | switch (type){ |
| | | case 1: |
| | | // 只查询用户订单 |
| | | tOrderPrivateCars = pubTransactionDetailsService.selectList(between1); |
| | | break; |
| | | case 2: |
| | | // 只查询用户充值 |
| | | tPubTransactionDetails = pubTransactionDetailsService.selectList(orderType); |
| | | break; |
| | | case 3: |
| | | // 只查询司机已结算的 |
| | | incomes = tIncomeService.selectList(new EntityWrapper<Income>() |
| | | .eq("userType", 2) |
| | | .ne("type", 1) |
| | | .isNotNull("orderType") |
| | | .between("insertTime", start, end)); |
| | | break; |
| | | case 4: |
| | | if(payType!=null && payType == 2){ |
| | | break; |
| | | } |
| | | driver = pubWithdrawalService.selectList(between); |
| | | // 只查询司机提现 |
| | | break; |
| | | case 5: |
| | | if(payType!=null && payType == 2){ |
| | | break; |
| | | } |
| | | // 只查询用户提现 |
| | | user = pubWithdrawalService.selectList(userWrapper); |
| | | break; |
| | | } |
| | | }else{ |
| | | tOrderPrivateCars = pubTransactionDetailsService.selectList(between1); |
| | | tPubTransactionDetails = pubTransactionDetailsService.selectList(orderType); |
| | | incomes = tIncomeService.selectList(new EntityWrapper<Income>() |
| | | .eq("userType", 2) |
| | | .ne("type", 1) |
| | | .isNotNull("orderType") |
| | | .between("insertTime", start, end)); |
| | | driver = pubWithdrawalService.selectList(between); |
| | | user = pubWithdrawalService.selectList(userWrapper); |
| | | } |
| | | List<WaterVO> res = new ArrayList<>(); |
| | | // List<PlatformVO> res = new ArrayList<>(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 司机结算金额 |
| | | BigDecimal balance = new BigDecimal("0"); |
| | | // 用户消费金额 |
| | | BigDecimal userConsume = new BigDecimal("0"); |
| | | // 用户充值金额 |
| | | BigDecimal userRecharge = new BigDecimal("0"); |
| | | // 司机提现金额 |
| | | BigDecimal driverWithdrawal = new BigDecimal("0"); |
| | | // 用户提现金额 |
| | | BigDecimal userWithdrawal = new BigDecimal("0"); |
| | | // 用户订单消费 |
| | | |
| | | for (TPubTransactionDetails tOrderPrivateCar : tOrderPrivateCars) { |
| | | WaterVO waterVO = new WaterVO(); |
| | | waterVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | waterVO.setType("用户订单消费"); |
| | | switch (tOrderPrivateCar.getOrderType()){ |
| | | case 1: |
| | | // 专车 |
| | | TOrderPrivateCar tOrderPrivateCar1 = orderPrivateCarService.selectById(tOrderPrivateCar.getOrderId()); |
| | | if (tOrderPrivateCar1 != null){ |
| | | waterVO.setCode(tOrderPrivateCar1.getOrderNum()); |
| | | String string = tOrderPrivateCar.getMoney().toString(); |
| | | waterVO.setMoney(new BigDecimal(string)); |
| | | }else{ |
| | | waterVO.setMoney(new BigDecimal("0")); |
| | | } |
| | | TUser user1 = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (user1!=null){ |
| | | waterVO.setName(user1.getNickName()); |
| | | waterVO.setPhone(user1.getPhone()); |
| | | } |
| | | |
| | | if (tOrderPrivateCar1 != null){ |
| | | if (tOrderPrivateCar1.getPayType()!=null){ |
| | | switch (tOrderPrivateCar1.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | |
| | | case 4: |
| | | continue; |
| | | } |
| | | }else{ |
| | | continue; |
| | | } |
| | | }else{ |
| | | continue; |
| | | } |
| | | if (tOrderPrivateCar1 != null){ |
| | | waterVO.setRemark(tOrderPrivateCar1.getRemark()); |
| | | } |
| | | res.add(waterVO); |
| | | userConsume = userConsume.add(new BigDecimal(tOrderPrivateCar.getMoney().toString())); |
| | | break; |
| | | case 4: |
| | | // 小件物流 |
| | | TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(tOrderPrivateCar.getOrderId()); |
| | | if (tOrderLogistics != null){ |
| | | waterVO.setCode(tOrderLogistics.getOrderNum()); |
| | | String string = tOrderPrivateCar.getMoney().toString(); |
| | | waterVO.setMoney(new BigDecimal(string)); |
| | | }else{ |
| | | waterVO.setMoney(new BigDecimal("0")); |
| | | } |
| | | TUser user2 = appUserService.selectById(tOrderPrivateCar.getUserId()); |
| | | if (user2!=null){ |
| | | waterVO.setName(user2.getNickName()); |
| | | waterVO.setPhone(user2.getPhone()); |
| | | } |
| | | waterVO.setType("用户订单消费"); |
| | | if (tOrderLogistics != null){ |
| | | if (tOrderLogistics.getPayType()!=null){ |
| | | switch (tOrderLogistics.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | |
| | | case 4: |
| | | continue; |
| | | } |
| | | }else{ |
| | | continue; |
| | | } |
| | | }else{ |
| | | continue; |
| | | } |
| | | if (tOrderLogistics != null){ |
| | | waterVO.setRemark(tOrderLogistics.getRemark()); |
| | | } |
| | | res.add(waterVO); |
| | | userConsume = userConsume.add(new BigDecimal(tOrderPrivateCar.getMoney().toString())); |
| | | break; |
| | | } |
| | | } |
| | | // 司机提现 |
| | | for (TPubWithdrawal tPubWithdrawal : driver) { |
| | | if(payType!=null && payType == 2){ |
| | | break; |
| | | } |
| | | WaterVO waterVO = new WaterVO(); |
| | | waterVO.setInsertTime(format.format(tPubWithdrawal.getHandleTime())); |
| | | waterVO.setCode(tPubWithdrawal.getCode()); |
| | | TDriver tDriver = driverService.selectById(tPubWithdrawal.getUserId()); |
| | | if (tDriver!=null){ |
| | | waterVO.setName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | waterVO.setPhone(tDriver.getPhone()); |
| | | } |
| | | |
| | | waterVO.setMoney(tPubWithdrawal.getMoney()); |
| | | waterVO.setPayType("银行卡支付"); |
| | | waterVO.setType("司机提现"); |
| | | waterVO.setRemark(tPubWithdrawal.getRemark()); |
| | | res.add(waterVO); |
| | | driverWithdrawal = driverWithdrawal.add(tPubWithdrawal.getMoney()); |
| | | } |
| | | // 用户提现 |
| | | for (TPubWithdrawal tPubWithdrawal : user) { |
| | | if(payType!=null && payType == 2){ |
| | | break; |
| | | } |
| | | WaterVO waterVO = new WaterVO(); |
| | | waterVO.setInsertTime(format.format(tPubWithdrawal.getHandleTime())); |
| | | waterVO.setCode(tPubWithdrawal.getCode()); |
| | | TUser user2 = appUserService.selectById(tPubWithdrawal.getUserId()); |
| | | if (user2!=null){ |
| | | waterVO.setName(user2.getNickName()); |
| | | waterVO.setPhone(user2.getPhone()); |
| | | } |
| | | waterVO.setMoney(tPubWithdrawal.getMoney()); |
| | | waterVO.setPayType("银行卡支付"); |
| | | waterVO.setType("用户提现"); |
| | | waterVO.setRemark(tPubWithdrawal.getRemark()); |
| | | res.add(waterVO); |
| | | userWithdrawal = userWithdrawal.add(tPubWithdrawal.getMoney()); |
| | | } |
| | | // 查询用户充值 |
| | | for (TPubTransactionDetails tPubTransactionDetail : tPubTransactionDetails) { |
| | | WaterVO waterVO = new WaterVO(); |
| | | Integer orderId = tPubTransactionDetail.getOrderId(); |
| | | PaymentRecord paymentRecord = paymentRecordService.selectById(orderId); |
| | | if (paymentRecord!=null){ |
| | | waterVO.setInsertTime(format.format(paymentRecord.getInsertTime())); |
| | | waterVO.setCode(paymentRecord.getCode()); |
| | | if (paymentRecord.getPayType()!=null){ |
| | | switch (paymentRecord.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | waterVO.setPayType("银行卡支付"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | waterVO.setMoney(new BigDecimal(paymentRecord.getAmount().toString())); |
| | | }else{ |
| | | continue; |
| | | } |
| | | if (paymentRecord.getUserId()!=null){ |
| | | TUser user2 = appUserService.selectById(paymentRecord.getUserId()); |
| | | if (user2!=null){ |
| | | waterVO.setName(user2.getNickName()); |
| | | waterVO.setPhone(user2.getPhone()); |
| | | } |
| | | } |
| | | |
| | | waterVO.setType("用户充值"); |
| | | waterVO.setRemark(tPubTransactionDetail.getRemark()); |
| | | res.add(waterVO); |
| | | userRecharge = userRecharge.add(new BigDecimal(paymentRecord.getAmount().toString())); |
| | | } |
| | | // 查询所有已结算的订单 |
| | | for (Income income : incomes) { |
| | | WaterVO platformVO = new WaterVO(); |
| | | platformVO.setType("司机结算"); |
| | | switch (income.getOrderType()){ |
| | | case 1: |
| | | // 查询订单信息 |
| | | TOrderPrivateCar tOrderPrivateCar = orderPrivateCarService.selectById(income.getIncomeId()); |
| | | if (tOrderPrivateCar==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderPrivateCar.getOrderNum()); |
| | | TDriver tDriver = driverService.selectById(tOrderPrivateCar.getDriverId()); |
| | | if (tDriver != null){ |
| | | platformVO.setName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | platformVO.setPhone(tDriver.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderPrivateCar.getRemark()); |
| | | if (income.getInsertTime()!=null){ |
| | | platformVO.setInsertTime(format.format(income.getInsertTime())); |
| | | } |
| | | platformVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | if (tOrderPrivateCar.getOrderMoney() != null){ |
| | | String string = tOrderPrivateCar.getOrderMoney().toString(); |
| | | BigDecimal bigDecimal1 = new BigDecimal(string); |
| | | platformVO.setMoney(bigDecimal1); |
| | | }else{ |
| | | continue; |
| | | } |
| | | |
| | | if (tOrderPrivateCar.getPayType() == null){ |
| | | continue; |
| | | } |
| | | switch (tOrderPrivateCar.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | platformVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | platformVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | case 4: |
| | | continue; |
| | | } |
| | | |
| | | // 专车订单 |
| | | String string4 = tOrderPrivateCar.getOrderMoney().toString(); |
| | | balance = balance.add(new BigDecimal(string4)); |
| | | res.add(platformVO); |
| | | break; |
| | | case 4: |
| | | // 小件物流 |
| | | // 查询订单信息 |
| | | TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(income.getIncomeId()); |
| | | if (tOrderLogistics==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderLogistics.getOrderNum()); |
| | | TDriver tDriver1 = driverService.selectById(tOrderLogistics.getDriverId()); |
| | | if (tDriver1!=null){ |
| | | platformVO.setName(tDriver1.getFirstName()+tDriver1.getLastName()); |
| | | platformVO.setPhone(tDriver1.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderLogistics.getRemark()); |
| | | platformVO.setMoney(new BigDecimal(income.getMoney())); |
| | | if (income.getInsertTime()!=null){ |
| | | platformVO.setInsertTime(format.format(income.getInsertTime())); |
| | | } |
| | | platformVO.setInsertTime(format.format(tOrderLogistics.getInsertTime())); |
| | | if (tOrderLogistics.getPayType() == null){ |
| | | continue; |
| | | } |
| | | switch (tOrderLogistics.getPayType()){ |
| | | case 1: |
| | | if (payType!=null){ |
| | | if (payType == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | platformVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | if (payType!=null){ |
| | | if (payType == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | platformVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | |
| | | case 4: |
| | | continue; |
| | | } |
| | | String string1 = tOrderLogistics.getOrderMoney().toString(); |
| | | // 小件物流订单 |
| | | balance = balance.add(new BigDecimal(string1)); |
| | | res.add(platformVO); |
| | | break; |
| | | } |
| | | } |
| | | // EntityWrapper<SettlementDetail> settlementDetailEntityWrapper = new EntityWrapper<>(); |
| | | // settlementDetailEntityWrapper.between("createTime", start, end); |
| | | // settlementDetails = settlementDetailService.selectList(settlementDetailEntityWrapper); |
| | | // // 查询所有现金支付的订单 |
| | | // for (SettlementDetail settlementDetail : settlementDetails) { |
| | | // WaterVO platformVO = new WaterVO(); |
| | | // switch (settlementDetail.getOrderType()){ |
| | | // case 1: |
| | | // // 专车订单 |
| | | // TOrderPrivateCar tOrderPrivateCar = orderPrivateCarService.selectById(settlementDetail.getOrderId()); |
| | | // if (tOrderPrivateCar==null){ |
| | | // continue; |
| | | // } |
| | | // platformVO.setCode(tOrderPrivateCar.getOrderNum()); |
| | | // TDriver tDriver = driverService.selectById(tOrderPrivateCar.getDriverId()); |
| | | // if (tDriver!=null){ |
| | | // platformVO.setDriverName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | // platformVO.setDriverPhone(tDriver.getPhone()); |
| | | // } |
| | | // platformVO.setRemark(tOrderPrivateCar.getRemark()); |
| | | // platformVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | // String string = settlementDetail.getPrice().toString(); |
| | | // BigDecimal bigDecimal1 = new BigDecimal(string); |
| | | // platformVO.setMoney(bigDecimal1); |
| | | // platformVO.setPayType("现金支付"); |
| | | // // 查询是否结算 |
| | | // SettlementRecord settlementRecord = settlementRecordService.selectById(settlementDetail.getSettlementRecordId()); |
| | | // |
| | | // if (settlementRecord.getPaymentStatus() == 1){ |
| | | // continue; |
| | | // } |
| | | // |
| | | // // 已结算 |
| | | // platformVO.setState(1); |
| | | // balance = balance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | // if (settlementRecord.getDay()!=null){ |
| | | // platformVO.setInsertTime(format.format(settlementRecord.getDay())); |
| | | // } |
| | | // |
| | | // res.add(platformVO); |
| | | // break; |
| | | // case 4: |
| | | // // 小件物流 |
| | | // // 查询订单信息 |
| | | // TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(settlementDetail.getOrderId()); |
| | | // if (tOrderLogistics==null){ |
| | | // continue; |
| | | // } |
| | | // platformVO.setCode(tOrderLogistics.getOrderNum()); |
| | | // TDriver tDriver1 = driverService.selectById(tOrderLogistics.getDriverId()); |
| | | // if (tDriver1!=null){ |
| | | // platformVO.setDriverName(tDriver1.getFirstName()+tDriver1.getLastName()); |
| | | // platformVO.setDriverPhone(tDriver1.getPhone()); |
| | | // } |
| | | // platformVO.setRemark(tOrderLogistics.getRemark()); |
| | | // String string1 = settlementDetail.getPrice().toString(); |
| | | // BigDecimal bigDecimal2 = new BigDecimal(string1); |
| | | // platformVO.setMoney(bigDecimal2); |
| | | // platformVO.setInsertTime(format.format(tOrderLogistics.getInsertTime())); |
| | | // platformVO.setPayType("现金支付"); |
| | | // // 查询是否结算 |
| | | // SettlementRecord settlementRecord1 = settlementRecordService.selectById(settlementDetail.getSettlementRecordId()); |
| | | // if (payType!=null){ |
| | | // if (payType == 1){ |
| | | // // 查询已结算的 |
| | | // if (settlementRecord1.getPaymentStatus() == 1){ |
| | | // continue; |
| | | // } |
| | | // } |
| | | // if (payType == 2){ |
| | | // // 查询未结算的 |
| | | // if (settlementRecord1.getPaymentStatus() == 2){ |
| | | // continue; |
| | | // } |
| | | // } |
| | | // } |
| | | // if (settlementRecord1.getPaymentStatus() == 2){ |
| | | // // 已结算 |
| | | // platformVO.setState(1); |
| | | // balance = balance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | // if (settlementRecord1.getDay()!=null){ |
| | | // platformVO.setInsertTime(format.format(settlementRecord1.getDay())); |
| | | // } |
| | | // }else{ |
| | | // // 未结算 |
| | | // platformVO.setState(2); |
| | | // unBalance = unBalance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | // } |
| | | // res.add(platformVO); |
| | | // break; |
| | | // } |
| | | // } |
| | | // 计算佣金总额 |
| | | // BigDecimal add = unBalance.add(balance); |
| | | Collections.sort(res, Comparator.comparing(WaterVO::getInsertTime).reversed()); |
| | | |
| | | return res; |
| | | } |
| | | /** |
| | | * 获取列表 |
| | | */ |
| | | @RequestMapping(value = "/list") |
| | | @RequestMapping(value = "/commission/list") |
| | | @ResponseBody |
| | | public Object list(Integer time,String insertTime,Integer state) { |
| | | if (time == null){ |
| | | time = 1; |
| | | } |
| | | String beginTime = null; |
| | | String endTime = null; |
| | | if (SinataUtil.isNotEmpty(insertTime)){ |
| | | // 如果筛选了时间 将time设置为null |
| | | time = null; |
| | | String[] timeArray = insertTime.split(" - "); |
| | | beginTime = timeArray[0]; |
| | | endTime = timeArray[1]; |
| | | 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; |
| | | } |
| | | } |
| | | return null; |
| | | // Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage(); |
| | | // page.setRecords(tIncomeService.getList(page,id)); |
| | | // return super.packForBT(page); |
| | | Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage(); |
| | | List<Income> incomes = new ArrayList<>(); |
| | | List<SettlementDetail> settlementDetails = new ArrayList<>(); |
| | | if (state!=null){ |
| | | switch (state){ |
| | | case 1: |
| | | // 已结算 |
| | | // 查询已结算的 |
| | | incomes = tIncomeService.selectList(new EntityWrapper<Income>() |
| | | .eq("userType", 2) |
| | | .ne("type", 1) |
| | | .isNotNull("orderType") |
| | | .between("insertTime", start, end)); |
| | | |
| | | |
| | | break; |
| | | case 2: |
| | | // 未结算 |
| | | |
| | | break; |
| | | } |
| | | }else{ |
| | | incomes = tIncomeService.selectList(new EntityWrapper<Income>() |
| | | .eq("userType", 2) |
| | | .ne("type", 1) |
| | | .isNotNull("orderType") |
| | | .between("insertTime", start, end)); |
| | | } |
| | | |
| | | |
| | | List<PlatformVO> res = new ArrayList<>(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | // 已结算金额 |
| | | BigDecimal balance = new BigDecimal("0"); |
| | | // 未结算金额 |
| | | BigDecimal unBalance = new BigDecimal("0"); |
| | | // 查询所有已结算的订单 |
| | | for (Income income : incomes) { |
| | | PlatformVO platformVO = new PlatformVO(); |
| | | platformVO.setState(1); |
| | | switch (income.getOrderType()){ |
| | | case 1: |
| | | // 查询订单信息 |
| | | TOrderPrivateCar tOrderPrivateCar = orderPrivateCarService.selectById(income.getIncomeId()); |
| | | if (tOrderPrivateCar==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderPrivateCar.getOrderNum()); |
| | | TDriver tDriver = driverService.selectById(tOrderPrivateCar.getDriverId()); |
| | | if (tDriver != null){ |
| | | platformVO.setDriverName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | platformVO.setDriverPhone(tDriver.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderPrivateCar.getRemark()); |
| | | if (income.getInsertTime()!=null){ |
| | | platformVO.setEndTime(format.format(income.getInsertTime())); |
| | | } |
| | | platformVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | String string = income.getMoney().toString(); |
| | | BigDecimal bigDecimal1 = new BigDecimal(string); |
| | | platformVO.setMoney(bigDecimal1); |
| | | if (tOrderPrivateCar.getPayType() == null){ |
| | | continue; |
| | | } |
| | | switch (tOrderPrivateCar.getPayType()){ |
| | | case 1: |
| | | platformVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | platformVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | platformVO.setPayType("余额支付"); |
| | | break; |
| | | case 4: |
| | | platformVO.setPayType("现金支付"); |
| | | break; |
| | | } |
| | | // 专车订单 |
| | | balance = balance.add(new BigDecimal(income.getMoney())); |
| | | res.add(platformVO); |
| | | break; |
| | | case 4: |
| | | // 小件物流 |
| | | // 查询订单信息 |
| | | TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(income.getIncomeId()); |
| | | if (tOrderLogistics==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderLogistics.getOrderNum()); |
| | | TDriver tDriver1 = driverService.selectById(tOrderLogistics.getDriverId()); |
| | | if (tDriver1!=null){ |
| | | platformVO.setDriverName(tDriver1.getFirstName()+tDriver1.getLastName()); |
| | | platformVO.setDriverPhone(tDriver1.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderLogistics.getRemark()); |
| | | platformVO.setMoney(new BigDecimal(income.getMoney())); |
| | | if (income.getInsertTime()!=null){ |
| | | platformVO.setEndTime(format.format(income.getInsertTime())); |
| | | } |
| | | platformVO.setInsertTime(format.format(tOrderLogistics.getInsertTime())); |
| | | if (tOrderLogistics.getPayType() == null){ |
| | | continue; |
| | | } |
| | | switch (tOrderLogistics.getPayType()){ |
| | | case 1: |
| | | platformVO.setPayType("手机支付"); |
| | | break; |
| | | case 2: |
| | | platformVO.setPayType("银行卡支付"); |
| | | break; |
| | | case 3: |
| | | platformVO.setPayType("余额支付"); |
| | | break; |
| | | case 4: |
| | | platformVO.setPayType("现金支付"); |
| | | break; |
| | | } |
| | | // 专车订单 |
| | | balance = balance.add(new BigDecimal(income.getMoney())); |
| | | res.add(platformVO); |
| | | break; |
| | | } |
| | | } |
| | | EntityWrapper<SettlementDetail> settlementDetailEntityWrapper = new EntityWrapper<>(); |
| | | settlementDetailEntityWrapper.between("createTime", start, end); |
| | | settlementDetails = settlementDetailService.selectList(settlementDetailEntityWrapper); |
| | | // 查询所有现金支付的订单 |
| | | for (SettlementDetail settlementDetail : settlementDetails) { |
| | | PlatformVO platformVO = new PlatformVO(); |
| | | switch (settlementDetail.getOrderType()){ |
| | | case 1: |
| | | // 专车订单 |
| | | TOrderPrivateCar tOrderPrivateCar = orderPrivateCarService.selectById(settlementDetail.getOrderId()); |
| | | if (tOrderPrivateCar==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderPrivateCar.getOrderNum()); |
| | | TDriver tDriver = driverService.selectById(tOrderPrivateCar.getDriverId()); |
| | | if (tDriver!=null){ |
| | | platformVO.setDriverName(tDriver.getFirstName()+tDriver.getLastName()); |
| | | platformVO.setDriverPhone(tDriver.getPhone()); |
| | | } |
| | | |
| | | platformVO.setRemark(tOrderPrivateCar.getRemark()); |
| | | |
| | | platformVO.setInsertTime(format.format(tOrderPrivateCar.getInsertTime())); |
| | | String string = settlementDetail.getPrice().toString(); |
| | | BigDecimal bigDecimal1 = new BigDecimal(string); |
| | | platformVO.setMoney(bigDecimal1); |
| | | platformVO.setPayType("现金支付"); |
| | | |
| | | // 查询是否结算 |
| | | SettlementRecord settlementRecord = settlementRecordService.selectById(settlementDetail.getSettlementRecordId()); |
| | | if (state!=null){ |
| | | if (state == 1){ |
| | | // 查询已结算的 |
| | | if (settlementRecord.getPaymentStatus() == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | if (state == 2){ |
| | | // 查询未结算的 |
| | | if (settlementRecord.getPaymentStatus() == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (settlementRecord.getPaymentStatus() == 2){ |
| | | // 已结算 |
| | | platformVO.setState(1); |
| | | balance = balance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | if (settlementRecord.getDay()!=null){ |
| | | platformVO.setEndTime(format.format(settlementRecord.getDay())); |
| | | } |
| | | }else{ |
| | | // 未结算 |
| | | platformVO.setState(2); |
| | | unBalance = unBalance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | } |
| | | res.add(platformVO); |
| | | break; |
| | | case 4: |
| | | // 小件物流 |
| | | // 查询订单信息 |
| | | TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(settlementDetail.getOrderId()); |
| | | if (tOrderLogistics==null){ |
| | | continue; |
| | | } |
| | | platformVO.setCode(tOrderLogistics.getOrderNum()); |
| | | TDriver tDriver1 = driverService.selectById(tOrderLogistics.getDriverId()); |
| | | if (tDriver1!=null){ |
| | | platformVO.setDriverName(tDriver1.getFirstName()+tDriver1.getLastName()); |
| | | platformVO.setDriverPhone(tDriver1.getPhone()); |
| | | } |
| | | platformVO.setRemark(tOrderLogistics.getRemark()); |
| | | String string1 = settlementDetail.getPrice().toString(); |
| | | BigDecimal bigDecimal2 = new BigDecimal(string1); |
| | | platformVO.setMoney(bigDecimal2); |
| | | platformVO.setInsertTime(format.format(tOrderLogistics.getInsertTime())); |
| | | platformVO.setPayType("现金支付"); |
| | | // 查询是否结算 |
| | | SettlementRecord settlementRecord1 = settlementRecordService.selectById(settlementDetail.getSettlementRecordId()); |
| | | if (state!=null){ |
| | | if (state == 1){ |
| | | // 查询已结算的 |
| | | if (settlementRecord1.getPaymentStatus() == 1){ |
| | | continue; |
| | | } |
| | | } |
| | | if (state == 2){ |
| | | // 查询未结算的 |
| | | if (settlementRecord1.getPaymentStatus() == 2){ |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (settlementRecord1.getPaymentStatus() == 2){ |
| | | // 已结算 |
| | | platformVO.setState(1); |
| | | balance = balance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | if (settlementRecord1.getDay()!=null){ |
| | | platformVO.setEndTime(format.format(settlementRecord1.getDay())); |
| | | } |
| | | }else{ |
| | | // 未结算 |
| | | platformVO.setState(2); |
| | | unBalance = unBalance.add(new BigDecimal(settlementDetail.getPrice())); |
| | | } |
| | | res.add(platformVO); |
| | | break; |
| | | } |
| | | } |
| | | Collections.sort(res, Comparator.comparing(PlatformVO::getInsertTime).reversed()); |
| | | // 计算佣金总额 |
| | | BigDecimal add = unBalance.add(balance); |
| | | |
| | | return res; |
| | | } |
| | | |
| | | } |