Commit d942f839 authored by zuoyh's avatar zuoyh

Merge remote-tracking branch 'origin/order_received_statistics' into order_received_statistics

parents b111e4b2 6ed0c570
...@@ -2,7 +2,6 @@ package com.xxfc.platform.order.biz; ...@@ -2,7 +2,6 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Lists;
import com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum; import com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum;
import com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics; import com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics;
import com.xxfc.platform.order.mapper.OrderRentVehicleReceivedStatisticsMapper; import com.xxfc.platform.order.mapper.OrderRentVehicleReceivedStatisticsMapper;
...@@ -12,7 +11,6 @@ import com.xxfc.platform.order.pojo.dto.OrderDTO; ...@@ -12,7 +11,6 @@ import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO; import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -62,25 +60,29 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi ...@@ -62,25 +60,29 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
//数据处理 状态组合 按支付状态分组 而后按组合状态 //数据处理 状态组合 按支付状态分组 而后按组合状态
Map<Boolean, Map<String, List<OrderDTO>>> stateGroupMap = orderDTOS.stream().peek(x -> { Map<Boolean, Map<String, List<OrderDTO>>> stateGroupMap = orderDTOS.stream().peek(x -> {
x.setStateGroup(String.format("%d-%d-%d-%d", x.getCompanyId(), x.getOrderOrigin(), x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY : x.getPayWay(), x.getStatus())); x.setStateGroup(String.format("%d-%d-%d-%d", x.getCompanyId(), x.getOrderOrigin(), x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY : x.getPayWay(),x.getHasPay()));
stisticsActiveState.add(x.getStateGroup()); stisticsActiveState.add(x.getStateGroup());
}) })
.collect(Collectors.partitioningBy(x -> Objects.isNull(x.getPayWay()), Collectors.groupingBy(OrderDTO::getStateGroup, Collectors.toList()))); .collect(Collectors.partitioningBy(x -> Objects.nonNull(x.getPayWay()), Collectors.groupingBy(OrderDTO::getStateGroup, Collectors.toList())));
//订单账目信息 //订单账目信息
List<OrderAccountBo> orderAccountBoList = orderAccountBiz.selectByDate(startDate, endDate); List<OrderAccountBo> orderAccountBoList = orderAccountBiz.selectByDate(startDate, endDate);
//账目数据处理 状态组合 //账目数据处理 状态组合
Map<String, List<OrderAccountBo>> ordersMap = orderAccountBoList.stream().peek(x -> { Map<String, List<OrderAccountBo>> ordersMap = orderAccountBoList.stream().peek(x -> {
x.setStateGroup(String.format("%d-%d-%d-%d", x.getCompanyId(), x.getOrderOrigin(), x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY : x.getPayWay(), x.getStatus())); x.setStateGroup(String.format("%d-%d-%d-%d", x.getCompanyId(), x.getOrderOrigin(), x.getPayWay() == null ? StatisticsStatusEnum.NO_PAY_WAY : x.getPayWay(),x.getHasPay()));
}).collect(Collectors.groupingBy(OrderAccountBo::getStateGroup, Collectors.toList())); }).collect(Collectors.groupingBy(OrderAccountBo::getStateGroup, Collectors.toList()));
BigDecimal globalTotalAmount = BigDecimal.ZERO;
//已经支付单 //已经支付单
Set<Map.Entry<String, List<OrderAccountBo>>> ordersSet = ordersMap.entrySet(); Set<Map.Entry<String, List<OrderAccountBo>>> ordersSet = ordersMap.entrySet();
for (Map.Entry<String, List<OrderAccountBo>> orderEntry : ordersSet) { for (Map.Entry<String, List<OrderAccountBo>> orderEntry : ordersSet) {
String orderKey = orderEntry.getKey(); String orderKey = orderEntry.getKey();
List<OrderAccountBo> orderAccountBos = orderEntry.getValue(); List<OrderAccountBo> orderAccountBos = orderEntry.getValue();
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatistics = StatisticsStatusEnum.wrapStatisticsObject(startDate, orderKey, new OrderRentVehicleReceivedStatistics());
BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal refundAmount = BigDecimal.ZERO; BigDecimal refundAmount = BigDecimal.ZERO;
for (OrderAccountBo orderAccountBo : orderAccountBos) { for (OrderAccountBo orderAccountBo : orderAccountBos) {
OrderAccountDetail accountDetailEntity = orderAccountBo.getAccountDetailEntity(); OrderAccountDetail accountDetailEntity = orderAccountBo.getAccountDetailEntity();
if (orderAccountBo.getAccountType() == PAY_ORDER) { if (orderAccountBo.getAccountType() == PAY_ORDER) {
...@@ -89,10 +91,15 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi ...@@ -89,10 +91,15 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
refundAmount.add(accountDetailEntity.getOrderAmount()).add(accountDetailEntity.getDepositAmount()); refundAmount.add(accountDetailEntity.getOrderAmount()).add(accountDetailEntity.getDepositAmount());
} }
} }
boolean flag = stateGroupMap == null ? false : stateGroupMap.get(Boolean.TRUE) == null ? false : stateGroupMap.get(Boolean.TRUE).get(orderKey)==null?false:true;
if (flag){
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatistics = StatisticsStatusEnum.wrapStatisticsObject(startDate, orderKey, new OrderRentVehicleReceivedStatistics());
orderRentVehicleReceivedStatistics.setTotalAmount(totalAmount.subtract(refundAmount)); orderRentVehicleReceivedStatistics.setTotalAmount(totalAmount.subtract(refundAmount));
Long totalQuantity = stateGroupMap == null ? 0L : stateGroupMap.get(Boolean.TRUE) == null ? 0L : stateGroupMap.get(Boolean.TRUE).get(orderKey)==null?0:stateGroupMap.get(Boolean.TRUE).get(orderKey).size(); orderRentVehicleReceivedStatistics.setTotalQuantity(stateGroupMap.get(Boolean.TRUE).get(orderKey).size());
orderRentVehicleReceivedStatistics.setTotalQuantity(totalQuantity.intValue());
orderRentVehicleReceivedStatisticsList.add(orderRentVehicleReceivedStatistics); orderRentVehicleReceivedStatisticsList.add(orderRentVehicleReceivedStatistics);
}
globalTotalAmount.add(totalAmount.subtract(refundAmount));
} }
//未支付单 //未支付单
...@@ -102,7 +109,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi ...@@ -102,7 +109,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
//查询分公司ids //查询分公司ids
List<Integer> companyIds = vehicleFeign.findCompanyIdsByAreaId(null); List<Integer> companyIds = vehicleFeign.findCompanyIdsByAreaId(null);
//创建剩余状态组合的租车统计对象 //创建剩余状态组合的租车统计对象
List<OrderRentVehicleReceivedStatistics> otherStatisticsStateGroupList = createOtherStatisticsStateGroupList(startDate, stisticsActiveState, companyIds); List<OrderRentVehicleReceivedStatistics> otherStatisticsStateGroupList = createOtherStatisticsStateGroupList(startDate,globalTotalAmount,stisticsActiveState, companyIds);
orderRentVehicleReceivedStatisticsList.addAll(otherStatisticsStateGroupList); orderRentVehicleReceivedStatisticsList.addAll(otherStatisticsStateGroupList);
//保存 //保存
insertMemberReceivedStatisticsBatch(orderRentVehicleReceivedStatisticsList); insertMemberReceivedStatisticsBatch(orderRentVehicleReceivedStatisticsList);
...@@ -136,11 +143,13 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi ...@@ -136,11 +143,13 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
* 创建剩余状态数据 * 创建剩余状态数据
* *
* @param startDate 时间 * @param startDate 时间
* @param totalAmount 订单状态
* @param statisticsStateGroups 状态组合 集合 * @param statisticsStateGroups 状态组合 集合
* @param companyIds 公司ids * @param companyIds 公司ids
* @return * @return
*/ */
private List<OrderRentVehicleReceivedStatistics> createOtherStatisticsStateGroupList(Date startDate, private List<OrderRentVehicleReceivedStatistics> createOtherStatisticsStateGroupList(Date startDate,
BigDecimal totalAmount,
List<String> statisticsStateGroups, List<String> statisticsStateGroups,
List<Integer> companyIds) { List<Integer> companyIds) {
...@@ -152,7 +161,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi ...@@ -152,7 +161,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
//统计对象的生成 //统计对象的生成
otherStatisticsStateGroup.parallelStream().map(stateGroup -> { otherStatisticsStateGroup.parallelStream().map(stateGroup -> {
OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatisticsClone = StatisticsStatusEnum.wrapStatisticsObject(startDate, stateGroup, ObjectUtil.cloneByStream(orderRentVehicleReceivedStatistics)); OrderRentVehicleReceivedStatistics orderRentVehicleReceivedStatisticsClone = StatisticsStatusEnum.wrapStatisticsObject(startDate, stateGroup, ObjectUtil.cloneByStream(orderRentVehicleReceivedStatistics));
orderRentVehicleReceivedStatisticsClone.setTotalAmount(BigDecimal.ZERO); orderRentVehicleReceivedStatisticsClone.setTotalAmount(totalAmount);
orderRentVehicleReceivedStatisticsClone.setTotalQuantity(0); orderRentVehicleReceivedStatisticsClone.setTotalQuantity(0);
orderRentVehicleReceivedStatisticsList.add(orderRentVehicleReceivedStatisticsClone); orderRentVehicleReceivedStatisticsList.add(orderRentVehicleReceivedStatisticsClone);
return orderRentVehicleReceivedStatisticsClone; return orderRentVehicleReceivedStatisticsClone;
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
bo.`status`, bo.`status`,
bo.order_origin, bo.order_origin,
bo.pay_way, bo.pay_way,
bo.has_pay,
brvd.start_company_id AS `companyId` brvd.start_company_id AS `companyId`
FROM FROM
`order_account` AS `oa` `order_account` AS `oa`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment