Commit 0dae2279 authored by hanfeng's avatar hanfeng

添加车辆信息下载

parent a1b5e552
......@@ -62,10 +62,17 @@ public class DailyVehicleOrderStatistics extends DailyOrderStatistics {
@Column(name = "default_money ")
private BigDecimal defaultMoney ;
// /**
// * 消费金总额
// */
// @Column(name = "total_expenditure")
// private BigDecimal totalExpenditure;
/**
* 消费金总额
* 订单补偿
*/
@Column(name = "total_expenditure")
private BigDecimal totalExpenditure;
@Column(name = "order_compensation")
private BigDecimal orderCompensation;
}
......@@ -62,8 +62,8 @@ public class OrderStatistics {
private BigDecimal totalDefaultMoney;
/**
* 历史实际消费总额
* 订单补偿总额
*/
@ApiModelProperty(value = "历史实际消费总额")
private BigDecimal totalExpenditure;
@ApiModelProperty(value = "订单补偿总额")
private BigDecimal orderCompensation;
}
......@@ -25,7 +25,6 @@ public class DailyOrderStatisticsBiz extends BaseBiz<DailyOrderStatisticsMapper,
@Autowired
private DailyMembersOrderStatisticsBiz membersStatisticsBiz;
// @Scheduled(cron = "0 0 2 * * ?")
public boolean statisticalOrder(Integer day){
boolean vehicleFlag = vehicleStatisticsBiz.saveDailyVehicleOrderRecord(day);
boolean travelFlag = travelStatisticsBiz.saveDailyTravelOrderRecord(day);
......
......@@ -30,6 +30,7 @@ import tk.mybatis.mapper.weekend.WeekendSqls;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* 每日租车订单统计
......@@ -351,9 +352,52 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
private DailyVehicleOrderStatistics getStatisticsByOrderAccountDetail(Map<Integer, List<OrderAccountDTO>> map) {
//获取收入金额
DailyVehicleOrderStatistics orderStatistics = getGmvAndSecurityDeposit(map);
//设置补偿总额
orderStatistics.setOrderCompensation(getOrderCompensation(map));
//获取扣款和退还金额
refundAndDeductions(map, orderStatistics);
return orderStatistics;
}
/**
*
* 获取订单补偿金额(该状态发生在退还部分款时,补偿订单款=单实际产生订单款+退还-支付订单款)
* @param map
* @return
*/
private BigDecimal getOrderCompensation(Map<Integer, List<OrderAccountDTO>> map) {
//获取当天部分押金退款(203)数据
List<OrderAccountDTO> orderAccountDTOS = map.get((AccountTypeEnum.OUT_PART_DEPOSIT.getCode()));
if (CollectionUtils.isEmpty(orderAccountDTOS)) {
return BigDecimal.ZERO;
}
ArrayList<OrderAccountDetail> orderAccountDetail = getOrderAccountDetail(orderAccountDTOS);
//获取订单支付总额
BigDecimal payment = orderAccountDetail
.parallelStream()
.map(OrderAccountDetail::getOriginOrderAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
//获取订单退还总额
BigDecimal giveBack = orderAccountDetail
.parallelStream()
.map(OrderAccountDetail::getOrderAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
//获取明细集合
ArrayList<OrderAccountDeduction> orderAccountDeductions = Lists.newArrayList();
orderAccountDetail
.parallelStream()
.map(OrderAccountDetail::getDeductions)
.forEach(list->orderAccountDeductions.addAll(list));
//获取订单实际款
BigDecimal actual = orderAccountDeductions
.parallelStream()
.filter(o -> DeductionTypeEnum.CONSUME.getCode().equals(o.getType()))
.map(OrderAccountDeduction::getAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
return actual.add(giveBack).subtract(payment);
}
......@@ -395,10 +439,11 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
types.add(DeductionTypeEnum.VIOLATE_DELAY.getCode());
orderStatistics.setDefaultMoney(get(OrderAccountDeductions, types));
//消费金额
orderStatistics.setTotalExpenditure(get(OrderAccountDeductions, new ArrayList<Integer>() {{
add(DeductionTypeEnum.CONSUME.getCode());
}}));
// orderStatistics.setTotalExpenditure(get(OrderAccountDeductions, new ArrayList<Integer>() {{
// add(DeductionTypeEnum.CONSUME.getCode());
// }}));
}
}
}
......
......@@ -53,7 +53,7 @@ public class OrderStatisticsBiz extends BaseBiz<OrderStatisticsMapper, OrderStat
setAdditionalIndemnity(vehicle.getTotalCompensation()
.add(vehicle.getTotalForfeit())
.add(vehicle.getTotalDefaultMoney())
.add(vehicle.getTotalExpenditure().subtract(vehicle.getTotalGmv()).add(vehicle.getTotalReturnGmv())));
.add(vehicle.getOrderCompensation()));
setTotalOutstandingDeposit(vehicle.getTotalSecurityDeposit()
.subtract(vehicle.getTotalRefundSecurityDeposit())
.subtract(getAdditionalIndemnity()));
......
......@@ -118,7 +118,7 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
setAdditionalIndemnity(vehicle.getTotalCompensation()
.add(vehicle.getTotalForfeit())
.add(vehicle.getTotalDefaultMoney())
.add(vehicle.getTotalExpenditure().subtract(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv())))
.add(vehicle.getOrderCompensation())
);
setTotalOutstandingDeposit(vehicle.getTotalSecurityDeposit()
.subtract(vehicle.getTotalRefundSecurityDeposit())
......@@ -147,7 +147,6 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
if (TYPE_TOTAL.equals(type)) {
return ObjectRestResponse.succ(baseBiz.getTotalOrder(companyId));
}
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "参数错误!");
} catch (Exception e) {
e.printStackTrace();
......
......@@ -64,7 +64,7 @@ public class ServiceTest {
@Test
public void handlerTeset() {
handler.execute(null);
handler.execute("2019-08-01");
}
......
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