From fca43b9a0021d580217e8dba2e7822b496ecf98b Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Tue, 18 Jun 2024 11:30:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=AF=B9=E8=B4=A6=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/EtReconciliationControllor.java | 48 +++ .../system/domain/vo/ReconciliationVo.java | 30 +- .../ruoyi/system/mapper/EtOrderMapper.java | 14 +- .../service/impl/EtOrderServiceImpl.java | 355 +++++++++++++----- .../service/impl/SysDeptServiceImpl.java | 2 +- .../java/com/ruoyi/system/task/EtTask.java | 2 +- .../mapper/system/AsDeviceMapper.xml | 8 +- .../mapper/system/EtOperatingAreaMapper.xml | 4 +- .../resources/mapper/system/EtOrderMapper.xml | 40 ++ 9 files changed, 393 insertions(+), 110 deletions(-) create mode 100644 electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtReconciliationControllor.java diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtReconciliationControllor.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtReconciliationControllor.java new file mode 100644 index 0000000..c3ea444 --- /dev/null +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtReconciliationControllor.java @@ -0,0 +1,48 @@ +package com.ruoyi.web.controller.system; + +import cn.hutool.core.util.StrUtil; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.domain.vo.ReconciliationVo; +import com.ruoyi.system.service.IEtOrderService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 对账Controller + * + * @author qiuzhenzhao + * @date 2024-06-17 + */ +@RestController +@RequestMapping("/system") +public class EtReconciliationControllor { + + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private IEtOrderService etOrderService; + + /** + * 查询对账列表 + */ + @PreAuthorize("@ss.hasPermi('system:reconciliation:list')") + @GetMapping("/reconciliation") + public AjaxResult list(String timeStart,String timeEnd) + { + logger.info("【收入对账】请求参数:timeStart={},timeEnd={}", timeStart,timeEnd); + if(StrUtil.isBlank(timeStart)){ + timeStart = DateUtils.getDate(); + } + if(StrUtil.isBlank(timeEnd)){ + timeEnd = DateUtils.getDate(); + } + ReconciliationVo reconciliation = etOrderService.reconciliation(timeStart,timeEnd,"1",null); + return AjaxResult.success(reconciliation); + } +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/ReconciliationVo.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/ReconciliationVo.java index 3e94077..bf6ccbd 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/ReconciliationVo.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/ReconciliationVo.java @@ -37,16 +37,40 @@ public class ReconciliationVo { //sn private String sn; - //支付金额 + //运营商名称dept + private String deptName; + + //运营区名称 + private String areaName; + +// //累计营收 +// private BigDecimal cumulativeRevenue = BigDecimal.ZERO; + + // 运营商分账 + private BigDecimal deptFee = BigDecimal.ZERO; + + // 合伙人分账 + private BigDecimal partnerFee = BigDecimal.ZERO; + + // 平台服务费 + private BigDecimal platformServiceFee = BigDecimal.ZERO; + + // 骑行订单说明 + private String ridingFee; + + // 调度费说明 + private String dispatchFee; + + //支付金额 新增 private BigDecimal payFee = BigDecimal.ZERO; - //已退款 + //已退款 退款 private BigDecimal refundFee= BigDecimal.ZERO; //手续费 private BigDecimal serviceFee= BigDecimal.ZERO; - //收入 + //收入--营收 private BigDecimal income= BigDecimal.ZERO; } } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java index e2d8c21..2ee3add 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java @@ -199,12 +199,12 @@ public interface EtOrderMapper /** * 支付金额 */ - BigDecimal getPayFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("sn") String sn); + BigDecimal getPayFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("sn") String sn, @Param("areaId") Long areaId); /** * 已退款 */ - BigDecimal getRefundFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("sn") String sn); + BigDecimal getRefundFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("sn") String sn, @Param("areaId") Long areaId); /** * 收入 @@ -243,4 +243,14 @@ public interface EtOrderMapper * @return 结果 */ int deleteEtOrderByOrderNo(String orderNo); + + /** + * 合伙人分账 + */ + BigDecimal getPartnerFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId); + + /** + * 平台服务费 + */ + BigDecimal getPlatformServiceFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java index c6956f5..8da4b6c 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java @@ -4,14 +4,14 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.constant.IotConstants; import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.domain.entity.AsUser; -import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.CommonUtil; import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.onenet.Token; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.vo.*; @@ -28,11 +28,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; import org.springframework.web.bind.annotation.RequestBody; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.*; @@ -85,6 +85,12 @@ public class EtOrderServiceImpl implements IEtOrderService @Autowired private CallbackService callbackService; + @Autowired + private ISysDeptService deptService; + + @Value("${et.handlingCharge}") + private String handlingCharge; + /** * 查询订单 * @@ -216,6 +222,7 @@ public class EtOrderServiceImpl implements IEtOrderService * 查询充值/退款订单列表 资本 capital flow 收支 业务 */ @Override + @DataScope(deptAlias = "d") public List rechargeList(EtOrder etOrder) { List rechargeVoList = new ArrayList<>(); etOrder.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID); @@ -558,108 +565,260 @@ public class EtOrderServiceImpl implements IEtOrderService } } +// /** +// * 收入对账 +// * type:1-按日期 2-按车辆 +// */ +// @SneakyThrows +// @Override +// public ReconciliationVo reconciliation(String timeStart, String timeEnd, String type,String sn) { +// ReconciliationVo reconciliationVo = new ReconciliationVo(); +// List reconciliations = new ArrayList<>(); +// if("1".equals(type)){//按日期 +// // 格式化日期 +// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); +// int page = 1; +// int limit = DateUtils.differentDaysByMillisecond(timeStart, timeEnd)+1; +// +// // 获取当前日期 +// Calendar calendar = Calendar.getInstance(); +// Date date1 = dateFormat.parse(timeEnd); +// calendar.setTime(date1); +// +// // 计算起始日期 +// calendar.add(Calendar.DATE, -(page - 1) * limit); +// Date startDate = calendar.getTime(); +// +// LoginUser loginUser = SecurityUtils.getLoginUser(); +// SysUser user = loginUser.getUser(); +// Long deptId = user.getDeptId(); +// List longs ; +// if(deptId == 100){//如果是创享管理员则展示所有数据 +// longs = etOperatingAreaService.selectAreaListByDeptId(null); +// }else{ +// longs = etOperatingAreaService.selectAreaListByDeptId(deptId); +// } +// for (int i = 0; i < limit; i++) { +// for(Long areaId : longs){ +// String formattedDate = dateFormat.format(startDate); +// String startDateStr = formattedDate + " "+ Constants.DATE_FORMAT_START_PEREND; +// String endDateStr = formattedDate + " " +Constants.DATE_FORMAT_END_PEREND; +// if(StrUtil.isNotBlank(timeStart) && StrUtil.isNotBlank(timeEnd)){ +// ReconciliationVo.Reconciliation reconciliation = new ReconciliationVo.Reconciliation(); +// reconciliation.setAreaName(etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId).getAreaName()); +// reconciliation.setDeptName(deptService.selectDeptById(deptId).getDeptName()); +// //获取当前日期的订单 +// reconciliation.setDay(formattedDate); +// BigDecimal payFee = etOrderMapper.getPayFee(startDateStr, endDateStr, null,areaId);// 新增 +// BigDecimal defaultPayFee = payFee != null ? payFee : BigDecimal.ZERO; +// reconciliation.setPayFee(defaultPayFee); +// BigDecimal refundFee = etOrderMapper.getRefundFee(startDateStr, endDateStr, null, areaId);// 退款 +// BigDecimal defaultRefundFee = refundFee != null ? refundFee : BigDecimal.ZERO; +// reconciliation.setRefundFee(defaultRefundFee); +// BigDecimal incomeFee = etOrderMapper.getIncome(startDateStr, endDateStr, null); // 营收 +// BigDecimal defaultIncomeFeeFee = incomeFee != null ? incomeFee : BigDecimal.ZERO; +// reconciliation.setIncome(defaultIncomeFeeFee); +// BigDecimal serviceFee = defaultPayFee.multiply(new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP)); +// reconciliation.setServiceFee(serviceFee);// 手续费 +// +// // 合伙人分账 +// BigDecimal partnerFee = etOrderMapper.getPartnerFee(startDateStr, endDateStr, areaId); +// reconciliation.setPartnerFee(partnerFee); +// // 运营商分账 +// BigDecimal platformServiceFee = etOrderMapper.getPlatformServiceFee(startDateStr, endDateStr, areaId); +// reconciliation.setPlatformServiceFee(platformServiceFee); +// reconciliations.add(reconciliation); +// } +// // 日期减一天 +// calendar.add(Calendar.DATE,-1); +// startDate = calendar.getTime(); +// } +// } +// reconciliationVo.setReconciliationList(reconciliations); +// //计算总收入 payFee +// // 使用Java 8 Stream API来计算payFee字段的总和 +// BigDecimal totalPayFee = reconciliations != null && !reconciliations.isEmpty() +// ? reconciliations.stream() +// .map(ReconciliationVo.Reconciliation::getPayFee) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// : null; +// reconciliationVo.setTotalPayFee(totalPayFee); +// +// BigDecimal totalRefundFee = reconciliations != null && !reconciliations.isEmpty() +// ? reconciliations.stream() +// .map(ReconciliationVo.Reconciliation::getRefundFee) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// : null; +// reconciliationVo.setTotalRefundFee(totalRefundFee); +// +// BigDecimal totalServiceFee = reconciliations != null && !reconciliations.isEmpty() +// ? reconciliations.stream() +// .map(ReconciliationVo.Reconciliation::getServiceFee) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// : null; +// reconciliationVo.setTotalServiceFee(totalServiceFee); +// +// BigDecimal totalIncome = reconciliations != null && !reconciliations.isEmpty() +// ? reconciliations.stream() +// .map(ReconciliationVo.Reconciliation::getIncome) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// : null; +// reconciliationVo.setTotalIncome(totalIncome); +// +// return reconciliationVo; +// }else { +// if(StrUtil.isBlank(sn)){ +// throw new ServiceException("类型为2时,车辆的sn必传"); +// } +// AsDevice asDevice = new AsDevice(); +// asDevice.setSn(sn); +// // 按车辆,先把所有车辆查出,如果参数中有车辆,就查出该车辆的按日期的订单 +// List asDevices = asDeviceService.selectAsDeviceList(asDevice); +// for(AsDevice asDevice1:asDevices){ +// String sn1 = asDevice1.getSn(); +// if(StrUtil.isNotBlank(sn1)){ +// //获取当前日期的订单 +// ReconciliationVo.Reconciliation reconciliation = new ReconciliationVo.Reconciliation(); +// reconciliation.setSn(sn1); +// reconciliation.setPayFee(etOrderMapper.getPayFee(timeStart,timeEnd,sn1,null)); +// reconciliation.setRefundFee(etOrderMapper.getRefundFee(timeStart,timeEnd,sn1,null)); +// reconciliation.setIncome(etOrderMapper.getIncome(timeStart,timeEnd,sn1)); +// reconciliations.add(reconciliation); +// } +// } +// reconciliationVo.setReconciliationList(reconciliations); +// return reconciliationVo; +// } +// } + /** * 收入对账 - * type:1-按日期 2-按车辆 + * type: 1-按日期 2-按车辆 */ @SneakyThrows - @Override - public ReconciliationVo reconciliation(String timeStart, String timeEnd, String type,String sn) { + public ReconciliationVo reconciliation(String timeStart, String timeEnd, String type, String sn) { ReconciliationVo reconciliationVo = new ReconciliationVo(); List reconciliations = new ArrayList<>(); - if("1".equals(type)){//按日期 - // 格式化日期 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - int page = 1; - int limit = DateUtils.differentDaysByMillisecond(timeStart, timeEnd)+1; - // 获取当前日期 - Calendar calendar = Calendar.getInstance(); - Date date1 = dateFormat.parse(timeEnd); - calendar.setTime(date1); - - // 计算起始日期 - calendar.add(Calendar.DATE, -(page - 1) * limit); - Date startDate = calendar.getTime(); - - for (int i = 0; i < limit; i++) { - String formattedDate = dateFormat.format(startDate); - String startDateStr = formattedDate + " "+ Constants.DATE_FORMAT_START_PEREND; - String endDateStr = formattedDate + " " +Constants.DATE_FORMAT_END_PEREND; - if(StrUtil.isNotBlank(timeStart) && StrUtil.isNotBlank(timeEnd)){ - //获取当前日期的订单 - ReconciliationVo.Reconciliation reconciliation = new ReconciliationVo.Reconciliation(); - reconciliation.setDay(formattedDate); - BigDecimal payFee = etOrderMapper.getPayFee(startDateStr, endDateStr, null); - BigDecimal defaultPayFee = payFee != null ? payFee : BigDecimal.ZERO; - reconciliation.setPayFee(defaultPayFee); - BigDecimal refundFee = etOrderMapper.getRefundFee(startDateStr, endDateStr, null); - BigDecimal defaultRefundFee = refundFee != null ? refundFee : BigDecimal.ZERO; - reconciliation.setRefundFee(defaultRefundFee); - BigDecimal incomeFee = etOrderMapper.getIncome(startDateStr, endDateStr, null); - BigDecimal defaultIncomeFeeFee = incomeFee != null ? incomeFee : BigDecimal.ZERO; - reconciliation.setIncome(defaultIncomeFeeFee); - reconciliations.add(reconciliation); - } - // 日期减一天 - calendar.add(Calendar.DATE,-1); - startDate = calendar.getTime(); - } - reconciliationVo.setReconciliationList(reconciliations); - //计算总收入 payFee - // 使用Java 8 Stream API来计算payFee字段的总和 - BigDecimal totalPayFee = reconciliations != null && !reconciliations.isEmpty() - ? reconciliations.stream() - .map(ReconciliationVo.Reconciliation::getPayFee) - .reduce(BigDecimal.ZERO, BigDecimal::add) - : null; - reconciliationVo.setTotalPayFee(totalPayFee); - - BigDecimal totalRefundFee = reconciliations != null && !reconciliations.isEmpty() - ? reconciliations.stream() - .map(ReconciliationVo.Reconciliation::getRefundFee) - .reduce(BigDecimal.ZERO, BigDecimal::add) - : null; - reconciliationVo.setTotalRefundFee(totalRefundFee); - - BigDecimal totalServiceFee = reconciliations != null && !reconciliations.isEmpty() - ? reconciliations.stream() - .map(ReconciliationVo.Reconciliation::getServiceFee) - .reduce(BigDecimal.ZERO, BigDecimal::add) - : null; - reconciliationVo.setTotalServiceFee(totalServiceFee); - - BigDecimal totalIncome = reconciliations != null && !reconciliations.isEmpty() - ? reconciliations.stream() - .map(ReconciliationVo.Reconciliation::getIncome) - .reduce(BigDecimal.ZERO, BigDecimal::add) - : null; - reconciliationVo.setTotalIncome(totalIncome); - - return reconciliationVo; - }else { - if(StrUtil.isBlank(sn)){ - throw new ServiceException("类型为2时,车辆的sn必传"); - } - AsDevice asDevice = new AsDevice(); - asDevice.setSn(sn); - // 按车辆,先把所有车辆查出,如果参数中有车辆,就查出该车辆的按日期的订单 - List asDevices = asDeviceService.selectAsDeviceList(asDevice); - for(AsDevice asDevice1:asDevices){ - String sn1 = asDevice1.getSn(); - if(StrUtil.isNotBlank(sn1)){ - //获取当前日期的订单 - ReconciliationVo.Reconciliation reconciliation = new ReconciliationVo.Reconciliation(); - reconciliation.setSn(sn1); - reconciliation.setPayFee(etOrderMapper.getPayFee(timeStart,timeEnd,sn1)); - reconciliation.setRefundFee(etOrderMapper.getRefundFee(timeStart,timeEnd,sn1)); - reconciliation.setIncome(etOrderMapper.getIncome(timeStart,timeEnd,sn1)); - reconciliations.add(reconciliation); - } - } - reconciliationVo.setReconciliationList(reconciliations); - return reconciliationVo; + if ("1".equals(type)) { + reconciliationVo = handleReconciliationByDate(timeStart, timeEnd, reconciliations); + } else if ("2".equals(type)) { + reconciliationVo = handleReconciliationByVehicle(timeStart, timeEnd, sn, reconciliations); + } else { + throw new ServiceException("Invalid type"); } + + return reconciliationVo; + } + + private ReconciliationVo handleReconciliationByDate(String timeStart, String timeEnd, List reconciliations) throws Exception { + ReconciliationVo reconciliationVo = new ReconciliationVo(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + int limit = DateUtils.differentDaysByMillisecond(timeStart, timeEnd) + 1; + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dateFormat.parse(timeEnd)); + List areaIds = getAreaIds(); + + for (int i = 0; i < limit; i++) { + String formattedDate = dateFormat.format(calendar.getTime()); + String startDateStr = formattedDate + " " + Constants.DATE_FORMAT_START_PEREND; + String endDateStr = formattedDate + " " + Constants.DATE_FORMAT_END_PEREND; + + if (StrUtil.isNotBlank(timeStart) && StrUtil.isNotBlank(timeEnd)) { + for (Long areaId : areaIds) { + reconciliations.add(createReconciliationByDate(formattedDate, startDateStr, endDateStr, areaId)); + } + } + + calendar.add(Calendar.DATE, -1); + } + + reconciliationVo.setReconciliationList(reconciliations); + calculateTotal(reconciliations, reconciliationVo); + + return reconciliationVo; + } + + private ReconciliationVo handleReconciliationByVehicle(String timeStart, String timeEnd, String sn, List reconciliations) { + if (StrUtil.isBlank(sn)) { + throw new ServiceException("类型为2时,车辆的sn必传"); + } + AsDevice device1 = new AsDevice(); + device1.setSn(sn); + List devices = asDeviceService.selectAsDeviceList(device1); + for (AsDevice device : devices) { + reconciliations.add(createReconciliationByVehicle(timeStart, timeEnd, device.getSn())); + } + + ReconciliationVo reconciliationVo = new ReconciliationVo(); + reconciliationVo.setReconciliationList(reconciliations); + return reconciliationVo; + } + + private ReconciliationVo.Reconciliation createReconciliationByDate(String formattedDate, String startDateStr, String endDateStr, Long areaId) { + ReconciliationVo.Reconciliation reconciliation = new ReconciliationVo.Reconciliation(); + StringBuilder ridingFee = new StringBuilder(); + StringBuilder dispatchFee = new StringBuilder(); + reconciliation.setAreaName(etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId).getAreaName()); + reconciliation.setDeptName(deptService.selectDeptById(SecurityUtils.getLoginUser().getUser().getDeptId()).getDeptName()); + reconciliation.setDay(formattedDate); + + BigDecimal payFee = defaultIfNull(etOrderMapper.getPayFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//新增 + BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//退款 + BigDecimal incomeFee = defaultIfNull(etOrderMapper.getIncome(startDateStr, endDateStr, null), BigDecimal.ZERO);//营收 + BigDecimal serviceFee = payFee.multiply(new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP));//手续费 + + reconciliation.setPayFee(payFee); + reconciliation.setRefundFee(refundFee); + reconciliation.setIncome(incomeFee); + reconciliation.setServiceFee(serviceFee); + + reconciliation.setPartnerFee(etOrderMapper.getPartnerFee(startDateStr, endDateStr, areaId)); + reconciliation.setPlatformServiceFee(etOrderMapper.getPlatformServiceFee(startDateStr, endDateStr, areaId)); + + ridingFee.append("营收:"+incomeFee +"元").append(System.lineSeparator()); + ridingFee.append("新增:"+payFee +"元").append(System.lineSeparator()); + ridingFee.append("退款:"+refundFee +"元").append(System.lineSeparator()); + ridingFee.append("手续费:"+serviceFee +"元").append(System.lineSeparator()); + reconciliation.setRidingFee(ridingFee.toString()); + + dispatchFee.append("营收:"+incomeFee +"元").append(System.lineSeparator()); + dispatchFee.append("新增:"+payFee +"元").append(System.lineSeparator()); + dispatchFee.append("退款:"+refundFee +"元").append(System.lineSeparator()); + dispatchFee.append("手续费:"+serviceFee +"元").append(System.lineSeparator()); + reconciliation.setDispatchFee(dispatchFee.toString()); + + return reconciliation; + } + + private ReconciliationVo.Reconciliation createReconciliationByVehicle(String timeStart, String timeEnd, String sn) { + ReconciliationVo.Reconciliation reconciliation = new ReconciliationVo.Reconciliation(); + reconciliation.setSn(sn); + reconciliation.setPayFee(etOrderMapper.getPayFee(timeStart, timeEnd, sn, null)); + reconciliation.setRefundFee(etOrderMapper.getRefundFee(timeStart, timeEnd, sn, null)); + reconciliation.setIncome(etOrderMapper.getIncome(timeStart, timeEnd, sn)); + return reconciliation; + } + + private List getAreaIds() { + Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId(); + return deptId == 100 ? etOperatingAreaService.selectAreaListByDeptId(null) : etOperatingAreaService.selectAreaListByDeptId(deptId); + } + + private void calculateTotal(List reconciliations, ReconciliationVo reconciliationVo) { + reconciliationVo.setTotalPayFee(calculateTotalField(reconciliations, ReconciliationVo.Reconciliation::getPayFee)); + reconciliationVo.setTotalRefundFee(calculateTotalField(reconciliations, ReconciliationVo.Reconciliation::getRefundFee)); + reconciliationVo.setTotalServiceFee(calculateTotalField(reconciliations, ReconciliationVo.Reconciliation::getServiceFee)); + reconciliationVo.setTotalIncome(calculateTotalField(reconciliations, ReconciliationVo.Reconciliation::getIncome)); + } + + private BigDecimal calculateTotalField(List reconciliations, java.util.function.Function getter) { + return reconciliations.stream().map(getter).reduce(BigDecimal.ZERO, BigDecimal::add); + } + + private BigDecimal defaultIfNull(BigDecimal value, BigDecimal defaultValue) { + return value != null ? value : defaultValue; } /** diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 4fc76cf..8f93e85 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -249,7 +249,7 @@ public class SysDeptServiceImpl implements ISysDeptService throw new ServiceException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); - if (dept.getIsUsePlatformApp().equals("true")) { + if (StrUtil.isNotBlank(dept.getIsUsePlatformApp()) && dept.getIsUsePlatformApp().equals("true")) { SysDept platform = deptMapper.selectDeptById(100L); dept.setAppid(platform.getAppid()); dept.setAppSecret(platform.getAppSecret()); diff --git a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java index 385d224..be8ad17 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java +++ b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java @@ -90,7 +90,7 @@ public class EtTask { * 3.启动时判断是否分账 */ @Transactional - @PostConstruct +// @PostConstruct public void init() { log.info("=========================启动业务处理========================="); log.info("=========================开始========================="); diff --git a/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml b/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml index 4eb6766..4a7ae82 100644 --- a/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/AsDeviceMapper.xml @@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and de.lock_status = #{lockStatus} ${params.dataScope} - order by de.create_time desc + order by de.sn diff --git a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml index a584bfb..98a31a8 100644 --- a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml @@ -255,6 +255,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select COALESCE(SUM(pay_fee), 0) from et_order and sn = #{sn} + and area_id = #{areaId} AND date_format(create_time,'%y%m%d') >= date_format(#{startDateStr},'%y%m%d') @@ -265,6 +266,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + +