Commit 8041c29b authored by hanfeng's avatar hanfeng

修改订单统计

parent be9fce4c
......@@ -7,6 +7,7 @@ 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;
import java.util.Date;
......@@ -15,7 +16,9 @@ import java.util.Date;
* @author Administrator
*/
@Data
public class DailyOrderStatistics {
public class DailyOrderStatistics implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
......
......@@ -13,9 +13,15 @@ import java.math.BigDecimal;
@Data
@Table(name = "daily_travel_order_statistics")
public class DailyTravelOrderStatistics extends DailyOrderStatistics {
/**
* 违约总额
*/
@Column(name = "default_money ")
private BigDecimal defaultMoney ;
/**
* 退还订单金额
*/
@Column(name = "return_gmv")
private BigDecimal returnGmv;
}
......@@ -12,9 +12,12 @@ import java.math.BigDecimal;
*/
@Data
@ApiModel(value = "订单统计实体")
@ApiModel(value = "历史订单统计实体")
public class OrderStatistics {
/**
* 历史交总金额
*/
......@@ -22,38 +25,45 @@ public class OrderStatistics {
private BigDecimal totalGmv;
/**
* 押金总额
* 历史押金总额
*/
@ApiModelProperty(value = "押金总额")
@ApiModelProperty(value = "历史押金总额")
private BigDecimal totalSecurityDeposit;
/**
* 退还押金总额
* 历史退还押金总额
*/
@ApiModelProperty(value = "退还押金总额")
@ApiModelProperty(value = "历史退还押金总额")
private BigDecimal totalRefundSecurityDeposit;
/**
* 赔偿总额
* 历史赔偿总额
*/
@ApiModelProperty(value = "赔偿总额")
@ApiModelProperty(value = "历史赔偿总额")
private BigDecimal totalCompensation;
/**
* 违章总额
* 历史违章总额
*/
@ApiModelProperty(value = "违章总额")
@ApiModelProperty(value = "历史违章总额")
private BigDecimal totalForfeit;
/**
* 历史订单退款
*/
@ApiModelProperty(value = "历史订单退款")
private BigDecimal totalReturnGmv;
/**
* 月取消订单扣款总额
* 历史延期扣款总额
*/
@ApiModelProperty(value = "月取消订单扣款总额")
private BigDecimal totalPenalSum;
@ApiModelProperty(value = "历史延期扣款总额")
private BigDecimal totalDefaultMoney;
/**
* 月延期扣款总额
* 历史实际消费总额
*/
@ApiModelProperty(value = "月延期扣款总额")
private BigDecimal totalPostpone;
@ApiModelProperty(value = "实际消费总额")
private BigDecimal totalExpenditure;
}
package com.xxfc.platform.order.pojo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class HomePageOrderData {
/**
* 订单总额
*/
private BigDecimal totalOrders;
/**
* 为退还押金总额
*/
private BigDecimal totalOutstandingDeposit;
/**
* 额外赔款
*/
private BigDecimal additionalIndemnity;
}
......@@ -203,7 +203,13 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
if (CollectionUtils.isNotEmpty(orderAccountDetail)) {
List<OrderAccountDeduction> OrderAccountDeductions = gettDeductions(orderAccountDetail);
//获取违约总额
orderStatistics.setDefaultMoney(get(OrderAccountDeductions, DeductionTypeEnum.VIOLATE.getCode()));
BigDecimal bigDecimal = get(OrderAccountDeductions, new ArrayList<Integer>() {{
add(DeductionTypeEnum.VIOLATE_CANCEL.getCode());
}});
orderStatistics.setDefaultMoney(bigDecimal);
//订单退还总额
orderStatistics.setReturnGmv(orderStatistics.getGmv().subtract(bigDecimal));
}
}
......@@ -281,7 +287,7 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
* @param type 金额类型
* @return
*/
private BigDecimal get(List<OrderAccountDeduction> OrderAccountDeduction, Integer type) {
private BigDecimal get(List<OrderAccountDeduction> OrderAccountDeduction, List<Integer> type) {
return OrderAccountDeduction.parallelStream()
.filter(el -> el.getType().equals(type))
.map(com.xxfc.platform.order.pojo.account.OrderAccountDeduction::getAmount)
......
......@@ -214,12 +214,12 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
* 根据type获取对应的金额总和
*
* @param OrderAccountDeduction
* @param type 金额类型
* @param types 金额类型
* @return
*/
private BigDecimal get(List<OrderAccountDeduction> OrderAccountDeduction, Integer type) {
private BigDecimal get(List<OrderAccountDeduction> OrderAccountDeduction, List<Integer> types) {
return OrderAccountDeduction.parallelStream()
.filter(el -> el.getType().equals(type))
.filter(el -> types.contains(el))
.map(com.xxfc.platform.order.pojo.account.OrderAccountDeduction::getAmount)
.reduce(BigDecimal.ZERO,BigDecimal::add);
......@@ -360,14 +360,24 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
orderStatistics.setRefundSecurityDeposit(refundSecurityDeposit);
List<OrderAccountDeduction> OrderAccountDeductions = gettDeductions(orderAccountDetail);
//获取违章总额
orderStatistics.setViolationMoney(get(OrderAccountDeductions, DeductionTypeEnum.VIOLATE_TRAFFIC.getCode()));
orderStatistics.setViolationMoney(get(OrderAccountDeductions, new ArrayList<Integer>(){{
add(DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT.getCode());
}}));
//获取损坏赔偿总额
orderStatistics.setCompensation(get(OrderAccountDeductions, DeductionTypeEnum.DAMAGES.getCode()));
orderStatistics.setCompensation(get(OrderAccountDeductions,new ArrayList<Integer>(){{
add(DeductionTypeEnum.DAMAGES.getCode());
}} ));
//获取违约总额
orderStatistics.setDefaultMoney(get(OrderAccountDeductions, DeductionTypeEnum.VIOLATE.getCode()));
//获取违约总额
orderStatistics.setTotalExpenditure(get(OrderAccountDeductions,DeductionTypeEnum.EXTRA.getCode()));
ArrayList<Integer> types = Lists.newArrayList();
types.add(DeductionTypeEnum.VIOLATE_ADVANCE.getCode());
types.add(DeductionTypeEnum.VIOLATE_CANCEL.getCode());
types.add(DeductionTypeEnum.VIOLATE_DELAY.getCode());
orderStatistics.setDefaultMoney(get(OrderAccountDeductions,types));
//消费金额
orderStatistics.setTotalExpenditure(get(OrderAccountDeductions,new ArrayList<Integer>(){{
add(DeductionTypeEnum.EXTRA.getCode());
}}));
}
}
}
......
......@@ -245,9 +245,6 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
public void refundTrigger(BaseOrder baseOrder, OrderRentVehicleDetail orvd, BigDecimal residueAmount, BigDecimal originalRefundAmount, BigDecimal refundAmont, String refundDesc, Integer refundStatus, AccountTypeEnum accountTypeEnum, OrderAccountDetail oad) {
public void refundTrigger(BaseOrder baseOrder, OrderRentVehicleDetail orvd, BigDecimal residueAmount, BigDecimal originalRefundAmount, BigDecimal refundAmont, String refundDesc, Integer refundStatus, RefundTypeEnum refundTypeEnum, OrderAccountDetail oad) {
//退款子流程: 订单基础,退款描述,退款金额
refundSubProcess(baseOrder, refundDesc, originalRefundAmount, refundAmont, accountTypeEnum.getCode(), refundStatus, oad);
//设置剩余没有返还的钱
......@@ -376,4 +373,5 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
\ No newline at end of file
package com.xxfc.platform.order.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.OrderStatisticsMapper;
import com.xxfc.platform.order.pojo.HomePageOrderData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -26,37 +28,48 @@ public class OrderStatisticsBiz extends BaseBiz<OrderStatisticsMapper, OrderStat
@Autowired
private DailyMembersOrderStatisticsBiz membersBiz;
public OrderStatistics getTotalOrder(Integer companyId) {
OrderStatistics result = new OrderStatistics();
ArrayList<OrderStatistics> orderStatistics = new ArrayList<>();
public HomePageOrderData getTotalOrder(Integer companyId) {
HomePageOrderData result = new HomePageOrderData();
ArrayList<HomePageOrderData> orderStatistics = new ArrayList<>();
OrderStatistics vehicle = vehicleBiz.findAll(companyId);
if (vehicle != null) {
orderStatistics.add(vehicle);
HomePageOrderData data = new HomePageOrderData() {{
setTotalOrders(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv()));
setAdditionalIndemnity(vehicle.getTotalCompensation()
.add(vehicle.getTotalForfeit())
.add(vehicle.getTotalDefaultMoney())
.add(vehicle.getTotalExpenditure().subtract(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv())))
);
}};
orderStatistics.add(data);
}
OrderStatistics tour = TravelBiz.findAll(companyId);
if (vehicle != null) {
orderStatistics.add(tour);
HomePageOrderData data = new HomePageOrderData() {{
setTotalOrders(tour.getTotalGmv().subtract(tour.getTotalReturnGmv()));
setAdditionalIndemnity(tour.getTotalDefaultMoney());
}};
orderStatistics.add(data);
}
OrderStatistics member = membersBiz.findAll(companyId);
if (vehicle != null) {
orderStatistics.add(member);
}
HomePageOrderData data = new HomePageOrderData() {{
setTotalOrders(member.getTotalGmv().subtract(member.getTotalReturnGmv()));
result.setTotalGmv(orderStatistics.stream().map(OrderStatistics::getTotalGmv).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
}};
orderStatistics.add(data);
}
result.setTotalForfeit(orderStatistics.stream().map(OrderStatistics::getTotalForfeit).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalCompensation(orderStatistics.stream().map(OrderStatistics::getTotalCompensation).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalRefundSecurityDeposit(orderStatistics.stream().map(OrderStatistics::getTotalRefundSecurityDeposit).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalSecurityDeposit(orderStatistics.stream().map(OrderStatistics::getTotalSecurityDeposit).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalOrders(orderStatistics.stream().map(HomePageOrderData::getTotalOrders).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalPenalSum(orderStatistics.stream().map(OrderStatistics::getTotalPenalSum).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalOutstandingDeposit(orderStatistics.stream().map(HomePageOrderData::getTotalOutstandingDeposit).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalPostpone(orderStatistics.stream().map(OrderStatistics::getTotalPostpone).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setAdditionalIndemnity(orderStatistics.stream().map(HomePageOrderData::getAdditionalIndemnity).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
return result;
}
......
......@@ -12,6 +12,7 @@ import com.xxfc.platform.order.biz.DailyTravelOrderStatisticsBiz;
import com.xxfc.platform.order.biz.DailyVehicleOrderStatisticsBiz;
import com.xxfc.platform.order.biz.OrderStatisticsBiz;
import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.pojo.HomePageOrderData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -88,15 +89,28 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
if (TYPE_VEHICLE.equals(type)) {
OrderStatistics vehicle = vehicleBiz.findAll(companyId);
return ObjectRestResponse.succ(vehicle);
return ObjectRestResponse.succ(new HomePageOrderData(){{
setTotalOrders(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv()));
setAdditionalIndemnity(vehicle.getTotalCompensation()
.add(vehicle.getTotalForfeit())
.add(vehicle.getTotalDefaultMoney())
.add(vehicle.getTotalExpenditure().subtract(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv())))
);
}});
}
if (TYPE_TOUR.equals(type)) {
OrderStatistics tour = TravelBiz.findAll(companyId);
return ObjectRestResponse.succ(tour);
return ObjectRestResponse.succ(new HomePageOrderData(){{
setTotalOrders(tour.getTotalGmv().subtract(tour.getTotalReturnGmv()));
setAdditionalIndemnity(tour.getTotalDefaultMoney());
}});
}
if (TYPE_MEMBER.equals(type)) {
OrderStatistics member = membersBiz.findAll(companyId);
return ObjectRestResponse.succ(member);
return ObjectRestResponse.succ(new HomePageOrderData(){{
setTotalOrders(member.getTotalGmv().subtract(member.getTotalReturnGmv()));
}});
}
if (TYPE_TOTAL.equals(type)) {
......@@ -110,4 +124,6 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
}
}
}
......@@ -17,24 +17,13 @@
<select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics">
SELECT
IFNULL(sum(gmv),0) as totalGmv
IFNULL( sum( gmv ), 0 ) AS totalGmv
FROM
(
SELECT
ANY_VALUE(id) AS id ,
ANY_VALUE(branch_company_id) AS branch_company_id,
ANY_VALUE(one_day) AS one_day,
ANY_VALUE(gmv) AS gmv,
ANY_VALUE(crt_time) AS crt_time
FROM
daily_members_order_statistics
GROUP BY
one_day,branch_company_id
) m
daily_vehicle_order_statistics
WHERE
1=1
<if test="companyId != null">
and branch_company_id =#{companyId}
and branch_company_id = #{companyId}
</if>
</select>
......
......@@ -51,26 +51,15 @@
<select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics">
SELECT
IFNULL(sum(gmv),0) as totalGmv,
IFNULL(sum(penal_sum) ,0) as totalPenalSum
IFNULL( sum( gmv ), 0 ) AS totalGmv,
IFNULL( sum( default_money ), 0 ) AS totalDefaultMoney,
IFNULL( sum( return_gmv ), 0 ) AS totalReturnGmv
FROM
(
SELECT
ANY_VALUE(id) AS id,
ANY_VALUE(branch_company_id) AS branch_company_id,
ANY_VALUE(one_day) AS one_day,
ANY_VALUE(gmv) AS gmv,
ANY_VALUE(penal_sum) AS penal_sum,
ANY_VALUE(crt_time) AS crt_time
FROM
daily_travel_order_statistics
GROUP BY
one_day,branch_company_id
) o
daily_vehicle_order_statistics
WHERE
1=1
<if test="companyId != null">
and branch_company_id =#{companyId}
and branch_company_id = #{companyId}
</if>
</select>
......
......@@ -79,33 +79,19 @@
v.start_company_id
</select>
<!-- 获取赔偿和延期JSON字符串-->
<!-- -->
<select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics">
SELECT
IFNULL(sum(gmv),0) as totalGmv,
(IFNULL(sum(security_deposit),0)-IFNULL(sum(refund_security_deposit) ,0)) as totalSecurityDeposit,
IFNULL(sum(refund_security_deposit) ,0) as totalRefundSecurityDeposit,
IFNULL(sum(compensation) ,0) as totalCompensation,
IFNULL(sum(forfeit) ,0) as totalForfeit,
IFNULL(sum(penal_sum) ,0) as totalPenalSum,
IFNULL(sum(postpone) ,0) as totalPostpone
FROM
(
SELECT
ANY_VALUE(id) as id,
one_day,
branch_company_id,
ANY_VALUE(gmv) AS gmv,
ANY_VALUE(security_deposit) AS security_deposit,
ANY_VALUE(refund_security_deposit) AS refund_security_deposit,
ANY_VALUE(forfeit) AS forfeit,ANY_VALUE(penal_sum) AS penal_sum,
ANY_VALUE(postpone) AS postpone,ANY_VALUE(crt_time) AS crt_time,
ANY_VALUE(compensation) AS compensation
IFNULL( sum( gmv ), 0 ) AS totalGmv,
IFNULL( sum( security_deposit ), 0 ) AS totalSecurityDeposit,
IFNULL( sum( refund_security_deposit ), 0 ) AS totalRefundSecurityDeposit,
IFNULL( sum( forfeit ), 0 ) AS totalForfeit,
IFNULL( sum( compensation ), 0 ) AS totalCompensation,
IFNULL( sum( return_gmv ), 0 ) AS totalReturnGmv,
IFNULL( sum( default_money ), 0 ) AS totalDefaultMoney,
IFNULL( sum( total_expenditure ), 0 ) AS totalExpenditure
FROM
daily_vehicle_order_statistics
GROUP BY
one_day,branch_company_id
) a
WHERE
1=1
<if test="companyId != null">
......
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