Commit 17e81367 authored by hanfeng's avatar hanfeng

修改订单统计

parent 22cbafc9
......@@ -66,4 +66,18 @@ public class OrderStatistics {
*/
@ApiModelProperty(value = "历史订单补偿总额")
private BigDecimal totalOrderCompensation=BigDecimal.ZERO;
@Override
public String toString() {
return "OrderStatistics{" +
"totalGmv=" + totalGmv +
", totalSecurityDeposit=" + totalSecurityDeposit +
", totalRefundSecurityDeposit=" + totalRefundSecurityDeposit +
", totalCompensation=" + totalCompensation +
", totalForfeit=" + totalForfeit +
", totalReturnGmv=" + totalReturnGmv +
", totalDefaultMoney=" + totalDefaultMoney +
", totalOrderCompensation=" + totalOrderCompensation +
'}';
}
}
......@@ -2,17 +2,134 @@ package com.xxfc.platform.order.pojo.account;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xxfc.platform.order.entity.OrderAccount;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author Administrator
*/
@Data
public class OrderAccountDTO extends OrderAccount {
public class OrderAccountDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键")
private Integer id;
/**
* 订单id
*/
@Column(name = "order_id")
@ApiModelProperty(value = "订单id")
private Integer orderId;
/**
* 账款对应的流水号
*/
@Column(name = "trade_no")
@ApiModelProperty(value = "账款对应的流水号")
private String tradeNo;
/**
* 记账时间
*/
@Column(name = "account_time")
@ApiModelProperty(value = "记账时间")
private Long accountTime;
/**
* 记帐类型 101--订单支付;201--取消订单退款;202--全部押金退款;203--部分押金退款;204--剩余押金退款
*/
@Column(name = "account_type")
@ApiModelProperty(value = "记帐类型 101--订单支付;201--取消订单退款;202--全部押金退款;203--部分押金退款;204--剩余押金退款")
private Integer accountType;
/**
* 账款状态 1--成功;2--失败
*/
@Column(name = "account_status")
@ApiModelProperty(value = "账款状态 1--成功;2--失败")
private Integer accountStatus;
/**
* 账款金额
*/
@Column(name = "account_amount")
@ApiModelProperty(value = "账款金额")
private BigDecimal accountAmount;
/**
* 账款说明
*/
@Column(name = "account_desc")
@ApiModelProperty(value = "账款说明")
private String accountDesc;
/**
* 账款详情
*/
@Column(name = "account_detail")
@ApiModelProperty(value = "账款详情")
private String accountDetail;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 原金额
*/
@Column(name = "original_amount")
@ApiModelProperty(value = "原金额")
private BigDecimal originalAmount;
/**
* 扣除金额
*/
@Column(name = "deduct_amount")
@ApiModelProperty(value = "扣除金额")
private BigDecimal deductAmount;
@Column(name = "companyId")
private Integer companyId;
@Column(name = "oneDay")
private String oneDay;
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("OrderAccountDTO{");
sb.append("id=").append(id);
sb.append(", orderId=").append(orderId);
sb.append(", tradeNo='").append(tradeNo).append('\'');
sb.append(", accountTime=").append(accountTime);
sb.append(", accountType=").append(accountType);
sb.append(", accountStatus=").append(accountStatus);
sb.append(", accountAmount=").append(accountAmount);
sb.append(", accountDesc='").append(accountDesc).append('\'');
sb.append(", accountDetail='").append(accountDetail).append('\'');
sb.append(", crtTime=").append(crtTime);
sb.append(", originalAmount=").append(originalAmount);
sb.append(", deductAmount=").append(deductAmount);
sb.append(", companyId=").append(companyId);
sb.append(", oneDay='").append(oneDay).append('\'');
sb.append('}');
return sb.toString();
}
}
......@@ -81,9 +81,12 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta
public DailyMembersOrderStatistics statistics(Term term) {
List<OrderAccountDTO> accountList = accountBiz.getOrderAccountByOrderType(term);
log.error("Members:accountList:"+accountList);
if (CollectionUtils.isNotEmpty(accountList)) {
DailyMembersOrderStatistics orderStatistics = new DailyMembersOrderStatistics();
ArrayList<OrderAccountDetail> orderAccountDetails = getOrderAccountDetail(accountList);
if (CollectionUtils.isNotEmpty(orderAccountDetails)) {
//获取订单总额
BigDecimal gmv = getOrderAmountTotal(orderAccountDetails);
......@@ -135,7 +138,7 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta
private ArrayList<OrderAccountDetail> getOrderAccountDetail(List<OrderAccountDTO> orderAccountDTOS) {
ArrayList<OrderAccountDetail> arrayList = Lists.newArrayList();
orderAccountDTOS.parallelStream()
.map(OrderAccount::getAccountDetail)
.map(OrderAccountDTO::getAccountDetail)
.forEach(detail -> {
if (StringUtils.isNotBlank(detail)) {
arrayList.add(JSONUtil.toBean(detail, OrderAccountDetail.class));
......
......@@ -101,6 +101,7 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
public List<DailyTravelOrderStatistics> getDailyTravelOrderStatistics(Term term) {
//获取当天所有订单账目
List<OrderAccountDTO> accountList = accountBiz.getOrderAccountByOrderType(term);
log.error("accountList:"+accountList);
if (CollectionUtils.isEmpty(accountList)) {
return null;
}
......@@ -220,8 +221,8 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
*/
private ArrayList<OrderAccountDetail> getOrderAccountDetail(List<OrderAccountDTO> orderAccountDTOS) {
ArrayList<OrderAccountDetail> arrayList = Lists.newArrayList();
orderAccountDTOS.parallelStream()
.map(OrderAccount::getAccountDetail)
orderAccountDTOS.stream()
.map(OrderAccountDTO::getAccountDetail)
.forEach(detail -> {
if (StringUtils.isNotBlank(detail)) {
arrayList.add(JSONUtil.toBean(detail, OrderAccountDetail.class));
......@@ -252,7 +253,7 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
*/
private List<OrderAccountDeduction> gettDeductions(ArrayList<OrderAccountDetail> orderAccountDetails) {
ArrayList<OrderAccountDeduction> arrayList = Lists.newArrayList();
orderAccountDetails.parallelStream().map(OrderAccountDetail::getDeductions).forEach(e->arrayList.addAll(e));
orderAccountDetails.stream().map(OrderAccountDetail::getDeductions).forEach(e->arrayList.addAll(e));
return arrayList;
}
......
......@@ -67,6 +67,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
* @return
*/
private BigDecimal get(List<OrderAccountDeduction> list, List<Integer> types) {
return list.parallelStream()
.filter(el -> types.contains(el.getType()))
.map(OrderAccountDeduction::getAmount)
......@@ -150,6 +151,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
public List<DailyVehicleOrderStatistics> getDailyVehicleOrderRecord(Term term) {
//获取当天所有订单账目
List<OrderAccountDTO> accountList = accountBiz.getOrderAccountByOrderType(term);
log.error("record:"+accountList);
if (CollectionUtils.isEmpty(accountList)) {
return null;
}
......@@ -267,13 +269,21 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
private void refundAndDeductions(Map<Integer, List<OrderAccountDTO>> map, DailyVehicleOrderStatistics orderStatistics) {
ArrayList<OrderAccountDTO> arrayList = Lists.newArrayList();
for (Integer key : map.keySet()) {
if (!key.equals(AccountTypeEnum.IN_ORDER_PAY.getCode())) {
List<OrderAccountDTO> orderAccountDTOS = map.get(key);
log.error(orderAccountDTOS.toString());
arrayList.addAll(map.get(key));
}
}
if (CollectionUtils.isNotEmpty(arrayList)) {
ArrayList<OrderAccountDetail> orderAccountDetail = getOrderAccountDetail(arrayList);
if (CollectionUtils.isNotEmpty(orderAccountDetail)) {
log.error( "orderAccountDetail"+orderAccountDetail);
//获取退还订总额
BigDecimal returnGmv = getOrderAmountTotal(orderAccountDetail);
orderStatistics.setReturnGmv(returnGmv);
......@@ -318,6 +328,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
ArrayList<OrderAccountDetail> orderAccountDetails = getOrderAccountDetail(orderAccountDTOS);
if (CollectionUtils.isNotEmpty(orderAccountDetails)) {
System.out.println(orderAccountDetails);
//获取订单总额
BigDecimal gmv = getOrderAmountTotal(orderAccountDetails);
orderStatistics.setGmv(gmv);
......@@ -350,9 +361,10 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
* @return
*/
private BigDecimal getOrderAmountTotal(ArrayList<OrderAccountDetail> orderAccountDetails) {
return orderAccountDetails.stream()
BigDecimal reduce = orderAccountDetails.stream()
.map(OrderAccountDetail::getOrderAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
return reduce;
}
/**
......@@ -363,7 +375,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
*/
private List<OrderAccountDeduction> gettDeductions(ArrayList<OrderAccountDetail> orderAccountDetails) {
ArrayList<OrderAccountDeduction> arrayList = Lists.newArrayList();
orderAccountDetails.parallelStream().map(OrderAccountDetail::getDeductions).forEach(e -> arrayList.addAll(e));
orderAccountDetails.stream().map(OrderAccountDetail::getDeductions).forEach(e -> arrayList.addAll(e));
return arrayList;
}
......@@ -375,8 +387,8 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
*/
private ArrayList<OrderAccountDetail> getOrderAccountDetail(List<OrderAccountDTO> orderAccountDTOS) {
ArrayList<OrderAccountDetail> arrayList = Lists.newArrayList();
orderAccountDTOS.parallelStream()
.map(OrderAccount::getAccountDetail)
orderAccountDTOS.stream()
.map(OrderAccountDTO::getAccountDetail)
.forEach(detail -> {
if (StringUtils.isNotBlank(detail)) {
arrayList.add(JSONUtil.toBean(detail, OrderAccountDetail.class));
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.order.mapper.OrderAccountMapper">
<select id="getOrderAccountByOrderType" resultType="com.xxfc.platform.order.pojo.account.OrderAccountDTO">
<select id="getOrderAccountByOrderType" parameterType="com.xxfc.platform.order.pojo.Term" resultType="com.xxfc.platform.order.pojo.account.OrderAccountDTO">
SELECT
<if test="subdivide !=null and subdivide ==1">
date( FROM_UNIXTIME( a.crt_time / 1000 ) ) as oneDay,
......
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