Commit 982efcd3 authored by libin's avatar libin

Merge branch 'order_received_statistics'

parents ad728eb4 2084c5e2
package com.xxfc.platform.order.bo;
import cn.hutool.json.JSONObject;
import com.xxfc.platform.order.contant.enumerate.AccountTypeEnum;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
* @author libin
......@@ -40,6 +30,7 @@ public class FeeTypeBo implements Serializable {
private BigDecimal breakRulesRegulationAmount = BigDecimal.ZERO;
private BigDecimal lossSpecifiedAmount = BigDecimal.ZERO;
private BigDecimal extraAmount = BigDecimal.ZERO;
private BigDecimal extraNoDeductibleAmount = BigDecimal.ZERO;
}
......
......@@ -6,7 +6,6 @@ import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsVo;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
......
package com.xxfc.platform.order.contant.enumerate;
import cn.hutool.core.date.DateUtil;
import com.xxfc.platform.order.entity.OrderReceivedStatisticsBase;
import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsVo;
import org.springframework.util.CollectionUtils;
......@@ -29,6 +30,7 @@ public enum ReceivedStatisticsEnum {
}
return orderReceivedStatisticsBases.stream().peek(x -> {
((OrderReceivedStatisticsBase) x).setDivisor(1);
((OrderReceivedStatisticsBase) x).setDateStr(DateUtil.format(((OrderReceivedStatisticsBase) x).getDate(),"yyyy-MM-dd"));
}).collect(Collectors.groupingBy(OrderReceivedStatisticsBase::getDate, Collectors.toList()));
}
},
......@@ -106,6 +108,7 @@ public enum ReceivedStatisticsEnum {
.weekOfYear(orderReceivedStatisticsBase.getWeekOfYear())
.year(orderReceivedStatisticsBase.getYear())
.orderNum(quantity)
.dateStr(orderReceivedStatisticsBase.getDateStr())
.orderAmount(amount)
.build();
}
......
......@@ -96,7 +96,7 @@ public enum StatisticsStatusEnum {
x.getPayWay() == null ? NO_PAY_WAY : x.getPayWay()
, x.getHasPay()));
stisticsActiveState.add(x.getStateGroup());
}).collect(Collectors.partitioningBy(x -> Objects.nonNull(x.getPayWay()), Collectors.groupingBy(OrderDTO::getStateGroup, Collectors.toList())));
}).collect(Collectors.partitioningBy(x -> Objects.equals(x.getHasPay(),1), Collectors.groupingBy(OrderDTO::getStateGroup, Collectors.toList())));
return stateGroupMap == null ? Collections.EMPTY_MAP : stateGroupMap;
}
......@@ -132,12 +132,14 @@ public enum StatisticsStatusEnum {
if (orderAccountBo.getAccountType().equals(AccountTypeEnum.IN_ORDER_PAY.getCode())) {
//订单押金
feeTypeBo.setDepositAmount(feeTypeBo.getDepositAmount().add(accountDetailEntity.getDepositAmount()));
//订单金额(不包含免赔和押金)
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().add(accountDetailEntity.getOrderAmount()));
if (hasDamageSafe) {
BigDecimal dameSafeAmount = getDameSafeAmount(orderAccountBo.getData());
feeTypeBo.setNoDeductibleAmount(feeTypeBo.getNoDeductibleAmount().add(dameSafeAmount));
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().subtract(feeTypeBo.getNoDeductibleAmount()));
}
//订单金额(不包含免赔和押金)
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleAmount()));
} else {
//退款订单押金
feeTypeBo.setDepositRefundAmount(feeTypeBo.getDepositRefundAmount().add(accountDetailEntity.getDepositAmount()));
......@@ -182,6 +184,10 @@ public enum StatisticsStatusEnum {
feeTypeBo.setExtraAmount(feeTypeBo.getExtraAmount().add(extendAmount));
}
}
//其他费用-延迟用车不记免赔
if (Objects.equals(DeductionTypeEnum.OTHER_DELAY_SAFE.getCode(),deduction.getType())){
feeTypeBo.setExtraNoDeductibleAmount(feeTypeBo.getExtraNoDeductibleAmount().add(deductionAmount));
}
}
//退款订单金额(不包含免赔和押金)
feeTypeBo.setOrderRefundAmount(feeTypeBo.getOrderRefundAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleRefundAmount()));
......
......@@ -118,4 +118,7 @@ public class OrderReceivedStatisticsBase implements Serializable {
@Transient
private String stateGroup;
@Transient
private String dateStr;
}
......@@ -45,4 +45,6 @@ public class OrderRentVehicleReceivedStatistics extends OrderReceivedStatisticsB
@ApiModelProperty("不计免赔费用")
private BigDecimal noDeductibleRefundAmount;
@Column(name = "extra_no_deductible_amount")
private BigDecimal extraNoDeductibleAmount;
}
......@@ -23,6 +23,7 @@ public class OrderReceivedStatisticsVo {
private String year;
@ApiModelProperty("日期-->日统计方式")
private Date date;
private String dateStr;
@ApiModelProperty("第几周---->周统计方式")
private String weekOfYear;
@ApiModelProperty("月统计")
......
......@@ -31,7 +31,6 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;
/**
......@@ -155,6 +154,18 @@ public class OrderReceivedStatisticsBiz extends BaseBiz<OrderReceivedStatisticsM
dataCell.setCellStyle(cellStyle);
String sign = signs.get(cellIndex - 1);
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = data.get(sign);
if (ReceivedStatisticsEnum.DAY.getWayCode() == statisticalWay){
orderReceivedStatisticsVos.sort(Comparator.comparing(OrderReceivedStatisticsVo::getDate));
}
if (ReceivedStatisticsEnum.WEEK.getWayCode() == statisticalWay){
orderReceivedStatisticsVos.sort(Comparator.comparing(OrderReceivedStatisticsVo::getWeekOfYear));
}
if (ReceivedStatisticsEnum.MONTH.getWayCode() == statisticalWay){
orderReceivedStatisticsVos.sort(Comparator.comparing(OrderReceivedStatisticsVo::getMonth));
}
if (CollectionUtils.isEmpty(orderReceivedStatisticsVos) || i > orderReceivedStatisticsVos.size()) {
continue;
}
......
......@@ -42,7 +42,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
* @return
*/
public List<OrderRentVehicleReceivedStatistics> selectOrderReceivedStatisticsGroupByDate(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO) {
return mapper.selectOrderRentVehicleReceivedStatisticsGroupByDate(orderReceivedStatisticsFindDTO);
return mapper.selectOrderRentVehicleReceivedStatisticsGroupByDate(orderReceivedStatisticsFindDTO);
}
public List<OrderRentVehicleReceivedStatistics> selectOrderReceivedStatisticsGroupByMonth(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO) {
......@@ -102,7 +102,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
List<OrderRentVehicleReceivedStatistics> otherStatisticsStateGroupList = createOtherStatisticsStateGroupList(startDate, stisticsActiveState, companyMap);
orderRentVehicleReceivedStatisticsList.addAll(otherStatisticsStateGroupList);
//保存
StatisticsStatusEnum.insertReceivedStatisticsBatch(orderRentVehicleReceivedStatisticsList,mapper);
// StatisticsStatusEnum.insertReceivedStatisticsBatch(orderRentVehicleReceivedStatisticsList,mapper);
return orderRentVehicleReceivedStatisticsList;
}
......
......@@ -32,7 +32,7 @@ public class OrderTourReceivedStatisticsBiz extends BaseBiz<OrderTourReceivedSta
private final OrderAccountBiz orderAccountBiz;
public List<OrderTourReceivedStatistics> selectOrderReceivedStatisticsGroupByDate(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO) {
return mapper.selectOrderTourReceivedStatisticsGroupByDate(orderReceivedStatisticsFindDTO);
return mapper.selectOrderTourReceivedStatisticsGroupByDate(orderReceivedStatisticsFindDTO);
}
public List<OrderTourReceivedStatistics> selectOrderReceivedStatisticsGroupByMonth(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO) {
return mapper.selectOrderTourReceivedStatisticsGroupByMonth(orderReceivedStatisticsFindDTO);
......
......@@ -30,8 +30,8 @@
</resultMap>
<select id="selectOrderMemberReceivedStatisticsGroupByDate" resultType="com.xxfc.platform.order.entity.OrderMemberReceivedStatistics">
select `date`,`year`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity`,IFNULL(sum(`toal_common_ammount`),0) as `toalCommonAmmount`,
IFNULL(sum(`total_common_quantity`),0) as `totalCommonQuantity`,IFNULL(sum(`total_gold_amount`),0) as `totalGoldAmount`,IFNULL(sum(`total_gold_quantity`),0),
select `date`,`year`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity`,IFNULL(sum(`toal_common_ammount`),0) as `toalCommonAmmount`,
IFNULL(sum(`total_common_quantity`),0) as `totalCommonQuantity`,IFNULL(sum(`total_gold_amount`),0) as `totalGoldAmount`,IFNULL(sum(`total_gold_quantity`),0) as `totalGoldQuantity`,
IFNULL(sum(`total_diamond_ammount`),0) as `totalDiamondAmmount`,IFNULL(sum(`total_diamond_quantity`),0) as `totalDiamondQuantity` from `order_member_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
......@@ -60,8 +60,8 @@
</select>
<select id="selectOrderMemberReceivedStatisticsGroupByMonth" resultType="com.xxfc.platform.order.entity.OrderMemberReceivedStatistics">
select `year`,`month`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity`,IFNULL(sum(`toal_common_ammount`),0) as `toalCommonAmmount`,
IFNULL(sum(`total_common_quantity`),0) as `totalCommonQuantity`,IFNULL(sum(`total_gold_amount`),0) as `totalGoldAmount`,IFNULL(sum(`total_gold_quantity`),0),
select `year`,`month`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity`,IFNULL(sum(`toal_common_ammount`),0) as `toalCommonAmmount`,
IFNULL(sum(`total_common_quantity`),0) as `totalCommonQuantity`,IFNULL(sum(`total_gold_amount`),0) as `totalGoldAmount`,IFNULL(sum(`total_gold_quantity`),0) as `totalGoldQuantity`,
IFNULL(sum(`total_diamond_ammount`),0) as `totalDiamondAmmount`,IFNULL(sum(`total_diamond_quantity`),0) as `totalDiamondQuantity` from `order_member_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
......@@ -90,8 +90,8 @@
</select>
<select id="selectOrderMemberReceivedStatisticsGroupByWeekOfYear" resultType="com.xxfc.platform.order.entity.OrderMemberReceivedStatistics">
select `year`,`week_of_year`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity`,IFNULL(sum(`toal_common_ammount`),0) as `toalCommonAmmount`
,IFNULL(sum(`total_common_quantity`),0) as `totalCommonQuantity`,IFNULL(sum(`total_gold_amount`),0) as `totalGoldAmount`,IFNULL(sum(`total_gold_quantity`),0),
select `year`,`week_of_year`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity`,IFNULL(sum(`toal_common_ammount`),0) as `toalCommonAmmount`
,IFNULL(sum(`total_common_quantity`),0) as `totalCommonQuantity`,IFNULL(sum(`total_gold_amount`),0) as `totalGoldAmount`,IFNULL(sum(`total_gold_quantity`),0) as `totalGoldQuantity`,
IFNULL(sum(`total_diamond_ammount`),0) as `totalDiamondAmmount`,IFNULL(sum(`total_diamond_quantity`),0) as `totalDiamondQuantity` from `order_member_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
......
......@@ -32,7 +32,7 @@
</resultMap>
<select id="selectOrderReceivedStatisticsDateList" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`date`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
select `year`,`date`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -61,7 +61,7 @@
</select>
<select id="selectOrderReceivedStatisticsMonthList" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`month`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
select `year`,`month`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -90,7 +90,7 @@
</select>
<select id="selectOrderReceivedStatisticsWeekOfYearList" resultType="com.xxfc.platform.order.entity.OrderReceivedStatistics">
select `year`,`week_of_year`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
select `year`,`week_of_year`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......
......@@ -17,9 +17,20 @@
<result property="payWay" column="pay_way"/>
<result property="companyId" column="company_id"/>
<result property="crtTime" column="crt_time"/>
<result property="extraNoDeductibleAmount" column="extral_no_deductible_amount"/>
<result property="orderRefundAmount" column="order_refund_amount"/>
<result property="lateFeeAmount" column="late_fee_amount"/>
<result property="extraAmount" column="extra_amount"/>
<result property="companyName" column="company_name"/>
<result property="noDeductibleAmount" column="no_deductible_amount"/>
<result property="noDeductibleRefundAmount" column="no_deductible_refund_amount"/>
<result property="lossSpecifiedAmount" column="loss_specified_amount"/>
<result property="depositRefundAmount" column="deposit_refund_amount"/>
<result property="depositAmount" column="deposit_amount"/>
<result property="breakRulesRegulationAmount" column="break_rules_regulation_amount"/>
</resultMap>
<select id="selectOrderRentVehicleReceivedStatisticsGroupByDate" resultType="com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics">
select `year`,`date`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_rent_vehicle_received_statistics` where 1=1
select `year`,`date`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_rent_vehicle_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -47,7 +58,7 @@
</select>
<select id="selectOrderRentVehicleReceivedStatisticsGroupByMonth" resultType="com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics">
select `year`,`month`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_rent_vehicle_received_statistics` where 1=1
select `year`,`month`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_rent_vehicle_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -75,7 +86,7 @@
</select>
<select id="selectOrderRentVehicleReceivedStatisticsGroupByWeekOfYear" resultType="com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics">
select `year`,`week_of_year`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_rent_vehicle_received_statistics` where 1=1
select `year`,`week_of_year`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_rent_vehicle_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......
......@@ -24,7 +24,7 @@
</resultMap>
<select id="selectOrderTourReceivedStatisticsGroupByDate" resultType="com.xxfc.platform.order.entity.OrderTourReceivedStatistics">
select `year`,`date`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_tour_received_statistics` where 1=1
select `year`,`date`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_tour_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -52,7 +52,7 @@
</select>
<select id="selectOrderTourReceivedStatisticsGroupByMonth" resultType="com.xxfc.platform.order.entity.OrderTourReceivedStatistics">
select `year`,`month`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_tour_received_statistics` where 1=1
select `year`,`month`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_tour_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......@@ -80,7 +80,7 @@
</select>
<select id="selectOrderTourReceivedStatisticsGroupByWeekOfYear" resultType="com.xxfc.platform.order.entity.OrderTourReceivedStatistics">
select `year`,`week_of_year`,IFNULL(sum(`total_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_tour_received_statistics` where 1=1
select `year`,`week_of_year`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_tour_received_statistics` where 1=1
<if test="orderState!=null">
and `has_pay`=#{orderState}
</if>
......
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import com.xxfc.platform.order.OrderApplication;
import com.xxfc.platform.order.biz.*;
......@@ -16,8 +15,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Map;
......@@ -98,7 +95,7 @@ public class ServiceTest {
@Test
public void testMemberStatistics(){
Date date = DateTime.parse("2019-11-28").toDate();
Date date = DateTime.parse("2019-11-15").toDate();
Date startDate = DateUtil.beginOfDay(date).toJdkDate();
Date endDate = DateUtil.endOfDay(date).toJdkDate();
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
......@@ -107,7 +104,7 @@ public class ServiceTest {
@Test
public void testRentVehicleStatistics(){
Date date = DateTime.parse("2019-11-29").toDate();
Date date = DateTime.parse("2019-11-15").toDate();
Date startDate = DateUtil.beginOfDay(date).toJdkDate();
Date endDate = DateUtil.endOfDay(date).toJdkDate();
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
......@@ -128,14 +125,13 @@ public class ServiceTest {
public void testOrderReceivedStatisticsJobHandler(){
cn.hutool.core.date.DateTime dateTime = DateUtil.parse("2019-11-29", "yyyy-MM-dd");
// cn.hutool.core.date.DateTime offset = DateUtil.offset(dateTime, DateField.DAY_OF_MONTH, 1);
/* orderReceivedStatisticsJobHandler.execute("2019-11-29");*/
LocalDate startLocalDate = LocalDate.of(2019, 10, 1);
LocalDate endLocalDate = LocalDate.of(2019,11,30);
orderReceivedStatisticsJobHandler.execute("2019-11-15");
/* LocalDate startLocalDate = LocalDate.of(2019, 10, 01);
LocalDate endLocalDate = LocalDate.of(2019,12,19);
while (startLocalDate.isBefore(endLocalDate)){
String dateStr = startLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
startLocalDate = startLocalDate.plusDays(1);
orderReceivedStatisticsJobHandler.execute(dateStr);
}
}*/
}
}
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