1. 对账列表
This commit is contained in:
parent
34198da5c1
commit
fca43b9a00
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,16 +37,40 @@ public class ReconciliationVo {
|
||||||
//sn
|
//sn
|
||||||
private String 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 payFee = BigDecimal.ZERO;
|
||||||
|
|
||||||
//已退款
|
//已退款 退款
|
||||||
private BigDecimal refundFee= BigDecimal.ZERO;
|
private BigDecimal refundFee= BigDecimal.ZERO;
|
||||||
|
|
||||||
//手续费
|
//手续费
|
||||||
private BigDecimal serviceFee= BigDecimal.ZERO;
|
private BigDecimal serviceFee= BigDecimal.ZERO;
|
||||||
|
|
||||||
//收入
|
//收入--营收
|
||||||
private BigDecimal income= BigDecimal.ZERO;
|
private BigDecimal income= BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deleteEtOrderByOrderNo(String orderNo);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,14 @@ import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.ruoyi.common.annotation.DataScope;
|
import com.ruoyi.common.annotation.DataScope;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.IotConstants;
|
|
||||||
import com.ruoyi.common.constant.ServiceConstants;
|
import com.ruoyi.common.constant.ServiceConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
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.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.CommonUtil;
|
import com.ruoyi.common.utils.CommonUtil;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
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.common.utils.uuid.IdUtils;
|
||||||
import com.ruoyi.system.domain.*;
|
import com.ruoyi.system.domain.*;
|
||||||
import com.ruoyi.system.domain.vo.*;
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -85,6 +85,12 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
@Autowired
|
@Autowired
|
||||||
private CallbackService callbackService;
|
private CallbackService callbackService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
@Value("${et.handlingCharge}")
|
||||||
|
private String handlingCharge;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单
|
* 查询订单
|
||||||
*
|
*
|
||||||
|
@ -216,6 +222,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
* 查询充值/退款订单列表 资本 capital flow 收支 业务
|
* 查询充值/退款订单列表 资本 capital flow 收支 业务
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@DataScope(deptAlias = "d")
|
||||||
public List<RechargeVo> rechargeList(EtOrder etOrder) {
|
public List<RechargeVo> rechargeList(EtOrder etOrder) {
|
||||||
List<RechargeVo> rechargeVoList = new ArrayList<>();
|
List<RechargeVo> rechargeVoList = new ArrayList<>();
|
||||||
etOrder.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
|
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<ReconciliationVo.Reconciliation> 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<Long> 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<AsDevice> 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
|
@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();
|
ReconciliationVo reconciliationVo = new ReconciliationVo();
|
||||||
List<ReconciliationVo.Reconciliation> reconciliations = new ArrayList<>();
|
List<ReconciliationVo.Reconciliation> reconciliations = new ArrayList<>();
|
||||||
if("1".equals(type)){//按日期
|
|
||||||
// 格式化日期
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
int page = 1;
|
|
||||||
int limit = DateUtils.differentDaysByMillisecond(timeStart, timeEnd)+1;
|
|
||||||
|
|
||||||
// 获取当前日期
|
if ("1".equals(type)) {
|
||||||
Calendar calendar = Calendar.getInstance();
|
reconciliationVo = handleReconciliationByDate(timeStart, timeEnd, reconciliations);
|
||||||
Date date1 = dateFormat.parse(timeEnd);
|
} else if ("2".equals(type)) {
|
||||||
calendar.setTime(date1);
|
reconciliationVo = handleReconciliationByVehicle(timeStart, timeEnd, sn, reconciliations);
|
||||||
|
} else {
|
||||||
// 计算起始日期
|
throw new ServiceException("Invalid type");
|
||||||
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<AsDevice> 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return reconciliationVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ReconciliationVo handleReconciliationByDate(String timeStart, String timeEnd, List<ReconciliationVo.Reconciliation> 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<Long> 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<ReconciliationVo.Reconciliation> reconciliations) {
|
||||||
|
if (StrUtil.isBlank(sn)) {
|
||||||
|
throw new ServiceException("类型为2时,车辆的sn必传");
|
||||||
|
}
|
||||||
|
AsDevice device1 = new AsDevice();
|
||||||
|
device1.setSn(sn);
|
||||||
|
List<AsDevice> 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<Long> getAreaIds() {
|
||||||
|
Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
|
||||||
|
return deptId == 100 ? etOperatingAreaService.selectAreaListByDeptId(null) : etOperatingAreaService.selectAreaListByDeptId(deptId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateTotal(List<ReconciliationVo.Reconciliation> 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<ReconciliationVo.Reconciliation> reconciliations, java.util.function.Function<ReconciliationVo.Reconciliation, BigDecimal> getter) {
|
||||||
|
return reconciliations.stream().map(getter).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal defaultIfNull(BigDecimal value, BigDecimal defaultValue) {
|
||||||
|
return value != null ? value : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
throw new ServiceException("部门停用,不允许新增");
|
throw new ServiceException("部门停用,不允许新增");
|
||||||
}
|
}
|
||||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
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);
|
SysDept platform = deptMapper.selectDeptById(100L);
|
||||||
dept.setAppid(platform.getAppid());
|
dept.setAppid(platform.getAppid());
|
||||||
dept.setAppSecret(platform.getAppSecret());
|
dept.setAppSecret(platform.getAppSecret());
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class EtTask {
|
||||||
* 3.启动时判断是否分账
|
* 3.启动时判断是否分账
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@PostConstruct
|
// @PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
log.info("=========================启动业务处理=========================");
|
log.info("=========================启动业务处理=========================");
|
||||||
log.info("=========================开始=========================");
|
log.info("=========================开始=========================");
|
||||||
|
|
|
@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="lockStatus != null and lockStatus != ''"> and de.lock_status = #{lockStatus}</if>
|
<if test="lockStatus != null and lockStatus != ''"> and de.lock_status = #{lockStatus}</if>
|
||||||
<!-- 数据范围过滤 -->
|
<!-- 数据范围过滤 -->
|
||||||
${params.dataScope}
|
${params.dataScope}
|
||||||
order by de.create_time desc
|
order by de.sn
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAsDeviceListWithIsolate" parameterType="AsDevice" resultMap="AsDeviceResult">
|
<select id="selectAsDeviceListWithIsolate" parameterType="AsDevice" resultMap="AsDeviceResult">
|
||||||
|
@ -68,8 +68,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
left join sys_dept d on d.dept_id = ad.dept_id
|
left join sys_dept d on d.dept_id = ad.dept_id
|
||||||
where 1 = 1
|
where 1 = 1
|
||||||
<if test="deviceName != null and deviceName != ''"> and de.device_name like concat('%', #{deviceName}, '%')</if>
|
<if test="deviceName != null and deviceName != ''"> and de.device_name like concat('%', #{deviceName}, '%')</if>
|
||||||
<if test="mac != null and mac != ''"> and de.mac = #{mac}</if>
|
<if test="mac != null and mac != ''"> and de.mac like concat('%', #{mac}, '%')</if>
|
||||||
<if test="sn != null and sn != ''"> and de.sn = #{sn}</if>
|
<if test="sn != null and sn != ''"> and de.sn like concat('%', #{sn}, '%')</if>
|
||||||
<if test="vehicleNum != null and vehicleNum != ''"> and de.vehicle_num = #{vehicleNum}</if>
|
<if test="vehicleNum != null and vehicleNum != ''"> and de.vehicle_num = #{vehicleNum}</if>
|
||||||
<if test="areaId != null and areaId != ''"> and de.area_id = #{areaId}</if>
|
<if test="areaId != null and areaId != ''"> and de.area_id = #{areaId}</if>
|
||||||
<if test="modelId != null and modelId != ''"> and de.model_id = #{modelId}</if>
|
<if test="modelId != null and modelId != ''"> and de.model_id = #{modelId}</if>
|
||||||
|
@ -78,7 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="lockStatus != null and lockStatus != ''"> and de.lock_status = #{lockStatus}</if>
|
<if test="lockStatus != null and lockStatus != ''"> and de.lock_status = #{lockStatus}</if>
|
||||||
<!-- 数据范围过滤 -->
|
<!-- 数据范围过滤 -->
|
||||||
${params.dataScope}
|
${params.dataScope}
|
||||||
order by de.create_time desc
|
order by de.sn
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAsDeviceByDeviceId" parameterType="Long" resultMap="AsDeviceResult">
|
<select id="selectAsDeviceByDeviceId" parameterType="Long" resultMap="AsDeviceResult">
|
||||||
|
|
|
@ -82,7 +82,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
from et_operating_area a
|
from et_operating_area a
|
||||||
left join et_area_dept ad on ad.area_id = a.area_id
|
left join et_area_dept ad on ad.area_id = a.area_id
|
||||||
left join sys_dept d on d.dept_id = ad.dept_id
|
left join sys_dept d on d.dept_id = ad.dept_id
|
||||||
where d.dept_id = #{deptId}
|
<where>
|
||||||
|
<if test="deptId != null"> and d.dept_id = #{deptId}</if>
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -255,6 +255,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select COALESCE(SUM(pay_fee), 0) from et_order
|
select COALESCE(SUM(pay_fee), 0) from et_order
|
||||||
<where>
|
<where>
|
||||||
<if test="sn != null and sn != ''"> and sn = #{sn}</if>
|
<if test="sn != null and sn != ''"> and sn = #{sn}</if>
|
||||||
|
<if test="areaId != null"> and area_id = #{areaId}</if>
|
||||||
<if test="startDateStr != null and startDateStr != ''">
|
<if test="startDateStr != null and startDateStr != ''">
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{startDateStr},'%y%m%d')
|
AND date_format(create_time,'%y%m%d') >= date_format(#{startDateStr},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
|
@ -265,6 +266,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getPartnerFee" resultType="java.math.BigDecimal">
|
||||||
|
SELECT COALESCE
|
||||||
|
( SUM( dd.dividend_amount ), 0 )
|
||||||
|
FROM
|
||||||
|
et_dividend_detail dd
|
||||||
|
LEFT JOIN et_order o ON o.order_no = dd.order_no
|
||||||
|
<where>
|
||||||
|
<if test="areaId != null"> and o.area_id = #{areaId}</if>
|
||||||
|
<if test="startDateStr != null and startDateStr != ''">
|
||||||
|
AND date_format(o.create_time,'%y%m%d') >= date_format(#{startDateStr},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
<if test="endDateStr != null and endDateStr != ''">
|
||||||
|
AND date_format(o.create_time,'%y%m%d') <= date_format(#{endDateStr},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
AND o.status = 4 and o.type = 1 and o.paid = 1 and dd.partner_id is not null
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getPlatformServiceFee" resultType="java.math.BigDecimal">
|
||||||
|
SELECT COALESCE
|
||||||
|
( SUM( dd.dividend_amount ), 0 )
|
||||||
|
FROM
|
||||||
|
et_dividend_detail dd
|
||||||
|
LEFT JOIN et_order o ON o.order_no = dd.order_no
|
||||||
|
<where>
|
||||||
|
<if test="areaId != null"> and o.area_id = #{areaId}</if>
|
||||||
|
<if test="startDateStr != null and startDateStr != ''">
|
||||||
|
AND date_format(o.create_time,'%y%m%d') >= date_format(#{startDateStr},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
<if test="endDateStr != null and endDateStr != ''">
|
||||||
|
AND date_format(o.create_time,'%y%m%d') <= date_format(#{endDateStr},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
AND o.status = 4 and o.type = 1 and o.paid = 1 and dd.partner_id is null
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getIncome" resultType="java.math.BigDecimal">
|
<select id="getIncome" resultType="java.math.BigDecimal">
|
||||||
select COALESCE(SUM(pay_fee), 0) from et_order
|
select COALESCE(SUM(pay_fee), 0) from et_order
|
||||||
<where>
|
<where>
|
||||||
|
@ -284,6 +321,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select COALESCE(SUM(total_fee), 0) from et_order
|
select COALESCE(SUM(total_fee), 0) from et_order
|
||||||
<where>
|
<where>
|
||||||
<if test="sn != null and sn != ''"> and sn = #{sn}</if>
|
<if test="sn != null and sn != ''"> and sn = #{sn}</if>
|
||||||
|
<if test="areaId != null"> and area_id = #{areaId}</if>
|
||||||
<if test="startDateStr != null and startDateStr != ''">
|
<if test="startDateStr != null and startDateStr != ''">
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{startDateStr},'%y%m%d')
|
AND date_format(create_time,'%y%m%d') >= date_format(#{startDateStr},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
|
@ -486,4 +524,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<delete id="deleteEtOrderByOrderNo" parameterType="String">
|
<delete id="deleteEtOrderByOrderNo" parameterType="String">
|
||||||
delete from et_order where order_no = #{orderNo}
|
delete from et_order where order_no = #{orderNo}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user