Commit 48f39131 authored by libin's avatar libin

分公司统计

parent 9d57dcd7
...@@ -137,7 +137,6 @@ public enum StatisticsStatusEnum { ...@@ -137,7 +137,6 @@ public enum StatisticsStatusEnum {
feeTypeBo.setNoDeductibleAmount(feeTypeBo.getNoDeductibleAmount().add(dameSafeAmount)); feeTypeBo.setNoDeductibleAmount(feeTypeBo.getNoDeductibleAmount().add(dameSafeAmount));
} }
//订单金额(不包含免赔和押金) //订单金额(不包含免赔和押金)
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleAmount())); feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleAmount()));
} else { } else {
//退款订单押金 //退款订单押金
...@@ -154,7 +153,6 @@ public enum StatisticsStatusEnum { ...@@ -154,7 +153,6 @@ public enum StatisticsStatusEnum {
feeTypeBo.setNoDeductibleRefundAmount(feeTypeBo.getNoDeductibleRefundAmount().add(dameSafeAmount)); feeTypeBo.setNoDeductibleRefundAmount(feeTypeBo.getNoDeductibleRefundAmount().add(dameSafeAmount));
} }
} }
//遍历消费明细 //遍历消费明细
for (OrderAccountDeduction deduction : deductions) { for (OrderAccountDeduction deduction : deductions) {
BigDecimal deductionAmount = deduction.getAmount(); BigDecimal deductionAmount = deduction.getAmount();
...@@ -189,6 +187,12 @@ public enum StatisticsStatusEnum { ...@@ -189,6 +187,12 @@ public enum StatisticsStatusEnum {
feeTypeBo.setOrderRefundAmount(feeTypeBo.getOrderRefundAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleRefundAmount())); feeTypeBo.setOrderRefundAmount(feeTypeBo.getOrderRefundAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleRefundAmount()));
} }
} }
//订单支付金额(不包含免赔,押金)减去退款的金额
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().subtract(feeTypeBo.getOrderRefundAmount()));
//订单押金减去退款押金
feeTypeBo.setDepositAmount(feeTypeBo.getDepositAmount().subtract(feeTypeBo.getDepositRefundAmount()));
//订单免赔金额减去退款的免赔金额
feeTypeBo.setNoDeductibleAmount(feeTypeBo.getNoDeductibleAmount().subtract(feeTypeBo.getDepositRefundAmount()));
return feeTypeBo; return feeTypeBo;
} }
......
...@@ -14,6 +14,7 @@ import com.xxfc.platform.order.pojo.dto.CompanyPerformanceFindDTO; ...@@ -14,6 +14,7 @@ import com.xxfc.platform.order.pojo.dto.CompanyPerformanceFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO; import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsVo; import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
...@@ -37,6 +38,7 @@ import java.util.stream.Collectors; ...@@ -37,6 +38,7 @@ import java.util.stream.Collectors;
* @email 18178966185@163.com * @email 18178966185@163.com
* @date 2019-11-08 18:03:42 * @date 2019-11-08 18:03:42
*/ */
@Slf4j
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
...@@ -263,66 +265,69 @@ public class OrderReceivedStatisticsBiz extends BaseBiz<OrderReceivedStatisticsM ...@@ -263,66 +265,69 @@ public class OrderReceivedStatisticsBiz extends BaseBiz<OrderReceivedStatisticsM
OrderReceivedStatistics orderReceivedStatistics = new OrderReceivedStatistics(); OrderReceivedStatistics orderReceivedStatistics = new OrderReceivedStatistics();
Set<Map.Entry<String, List<OrderRentVehicleReceivedStatistics>>> rentVehicleSet = rentVehicleMap.entrySet(); Set<Map.Entry<String, List<OrderRentVehicleReceivedStatistics>>> rentVehicleSet = rentVehicleMap.entrySet();
for (Map.Entry<String, List<OrderRentVehicleReceivedStatistics>> rentVehicleEntry : rentVehicleSet) { for (Map.Entry<String, List<OrderRentVehicleReceivedStatistics>> rentVehicleEntry : rentVehicleSet) {
String stateGroup = rentVehicleEntry.getKey(); try {
List<OrderRentVehicleReceivedStatistics> rentVehicleEntryValue = rentVehicleEntry.getValue(); String stateGroup = rentVehicleEntry.getKey();
//创建默认的订单统计对象并设置默认值 List<OrderRentVehicleReceivedStatistics> rentVehicleEntryValue = rentVehicleEntry.getValue();
OrderReceivedStatistics orderReceivedStatisticsClone = StatisticsStatusEnum.wrapStatisticsObject(date, stateGroup, Collections.EMPTY_MAP, ObjectUtil.clone(orderReceivedStatistics)); //创建默认的订单统计对象并设置默认值
//租车单 OrderReceivedStatistics orderReceivedStatisticsClone = StatisticsStatusEnum.wrapStatisticsObject(date, stateGroup, Collections.EMPTY_MAP, ObjectUtil.clone(orderReceivedStatistics));
OrderRentVehicleReceivedStatistics orderRentVehicle = rentVehicleEntryValue.get(0); //租车单
//会员单 OrderRentVehicleReceivedStatistics orderRentVehicle = rentVehicleEntryValue.get(0);
OrderMemberReceivedStatistics orderMember = memberMap.get(stateGroup).get(0); //会员单
//旅游单 OrderMemberReceivedStatistics orderMember = memberMap.get(stateGroup).get(0);
OrderTourReceivedStatistics orderTour = tourMap.get(stateGroup).get(0); //旅游单
//公司id OrderTourReceivedStatistics orderTour = tourMap.get(stateGroup).get(0);
orderReceivedStatisticsClone.setCompanyId(orderRentVehicle.getCompanyId()); //公司id
//公司名称 orderReceivedStatisticsClone.setCompanyId(orderRentVehicle.getCompanyId());
orderReceivedStatisticsClone.setCompanyName(orderRentVehicle.getCompanyName()); //公司名称
//押金 orderReceivedStatisticsClone.setCompanyName(orderRentVehicle.getCompanyName());
orderReceivedStatisticsClone.setDepositAmount(orderRentVehicle.getDepositAmount()); //押金
//退款押金 orderReceivedStatisticsClone.setDepositAmount(orderRentVehicle.getDepositAmount());
orderReceivedStatisticsClone.setDepositRefundAmount(orderRentVehicle.getDepositRefundAmount()); //退款押金
//定损 orderReceivedStatisticsClone.setDepositRefundAmount(orderRentVehicle.getDepositRefundAmount());
orderReceivedStatisticsClone.setLossSpecifiedAmount(orderRentVehicle.getLossSpecifiedAmount()); //定损
//违章 orderReceivedStatisticsClone.setLossSpecifiedAmount(orderRentVehicle.getLossSpecifiedAmount());
orderReceivedStatisticsClone.setBreakRulesRegulationAmount(orderRentVehicle.getBreakRulesRegulationAmount()); //违章
//免赔退款金额 orderReceivedStatisticsClone.setBreakRulesRegulationAmount(orderRentVehicle.getBreakRulesRegulationAmount());
orderReceivedStatisticsClone.setNoDeductibleRefundAmount(orderRentVehicle.getNoDeductibleRefundAmount()); //免赔退款金额
//免赔金额 orderReceivedStatisticsClone.setNoDeductibleRefundAmount(orderRentVehicle.getNoDeductibleRefundAmount());
orderReceivedStatisticsClone.setNoDeductibleAmount(orderRentVehicle.getNoDeductibleAmount()); //免赔金额
orderReceivedStatisticsClone.setNoDeductibleAmount(orderRentVehicle.getNoDeductibleAmount());
//旅游订单总额
orderReceivedStatisticsClone.setTravelAmount(orderTour.getTotalAmount()); //旅游订单总额
orderReceivedStatisticsClone.setTravelRefundAmount(orderTour.getOrderRefundAmount()); orderReceivedStatisticsClone.setTravelAmount(orderTour.getTotalAmount());
//会员订单总额 orderReceivedStatisticsClone.setTravelRefundAmount(orderTour.getOrderRefundAmount());
orderReceivedStatisticsClone.setMemberAmount(orderMember.getTotalAmount()); //会员订单总额
orderReceivedStatisticsClone.setMemberRefundAmout(orderMember.getOrderRefundAmount()); orderReceivedStatisticsClone.setMemberAmount(orderMember.getTotalAmount());
//租车订单总额 orderReceivedStatisticsClone.setMemberRefundAmout(orderMember.getOrderRefundAmount());
orderReceivedStatisticsClone.setRentVehicleAmount(orderRentVehicle.getTotalAmount()); //租车订单总额
orderReceivedStatisticsClone.setRentVehicleRefundAmount(orderRentVehicle.getOrderRefundAmount()); orderReceivedStatisticsClone.setRentVehicleAmount(orderRentVehicle.getTotalAmount());
//合计订单总额 orderReceivedStatisticsClone.setRentVehicleRefundAmount(orderRentVehicle.getOrderRefundAmount());
BigDecimal totalAmount = orderRentVehicle.getTotalAmount().add(orderTour.getTotalAmount()).add(orderMember.getTotalAmount()); //合计订单总额
//合计订单退款总额 BigDecimal totalAmount = orderRentVehicle.getTotalAmount().add(orderTour.getTotalAmount()).add(orderMember.getTotalAmount());
BigDecimal totalRefundAmount = orderRentVehicle.getOrderRefundAmount().add(orderTour.getOrderRefundAmount()).add(orderMember.getOrderRefundAmount()); //合计订单退款总额
//合计订单违约金 BigDecimal totalRefundAmount = orderRentVehicle.getOrderRefundAmount().add(orderTour.getOrderRefundAmount()).add(orderMember.getOrderRefundAmount());
BigDecimal lateFeeAmount = orderRentVehicle.getLateFeeAmount().add(orderTour.getLateFeeAmount()).add(orderMember.getLateFeeAmount()); //合计订单违约金
//合计额外费用 BigDecimal lateFeeAmount = orderRentVehicle.getLateFeeAmount().add(orderTour.getLateFeeAmount()).add(orderMember.getLateFeeAmount());
BigDecimal totalExtraAmount = orderRentVehicle.getExtraAmount().add(orderMember.getExtraAmount()).add(orderTour.getExtraAmount()); //合计额外费用
//会员订单量 BigDecimal totalExtraAmount = orderRentVehicle.getExtraAmount().add(orderMember.getExtraAmount()).add(orderTour.getExtraAmount());
orderReceivedStatisticsClone.setMemberQuantity(orderMember.getTotalQuantity()); //会员订单量
//旅游订单量 orderReceivedStatisticsClone.setMemberQuantity(orderMember.getTotalQuantity());
orderReceivedStatisticsClone.setTravelQuantity(orderTour.getTotalQuantity()); //旅游订单量
//租车订单量 orderReceivedStatisticsClone.setTravelQuantity(orderTour.getTotalQuantity());
orderReceivedStatisticsClone.setRentVehicleQuantity(orderRentVehicle.getTotalQuantity()); //租车订单量
//合计订单量 orderReceivedStatisticsClone.setRentVehicleQuantity(orderRentVehicle.getTotalQuantity());
Integer totalQuantity = orderRentVehicle.getTotalQuantity() + (orderTour.getTotalQuantity()) + orderMember.getTotalQuantity(); //合计订单量
Integer totalQuantity = orderRentVehicle.getTotalQuantity() + (orderTour.getTotalQuantity()) + orderMember.getTotalQuantity();
orderReceivedStatisticsClone.setExtraAmount(totalExtraAmount);
orderReceivedStatisticsClone.setLateFeeAmount(lateFeeAmount); orderReceivedStatisticsClone.setExtraAmount(totalExtraAmount);
orderReceivedStatisticsClone.setTotalAmount(totalAmount); orderReceivedStatisticsClone.setLateFeeAmount(lateFeeAmount);
orderReceivedStatisticsClone.setOrderRefundAmount(totalRefundAmount); orderReceivedStatisticsClone.setTotalAmount(totalAmount);
orderReceivedStatisticsClone.setTotalQuantity(totalQuantity); orderReceivedStatisticsClone.setOrderRefundAmount(totalRefundAmount);
orderReceivedStatisticsList.add(orderReceivedStatisticsClone); orderReceivedStatisticsClone.setTotalQuantity(totalQuantity);
orderReceivedStatisticsList.add(orderReceivedStatisticsClone);
}catch (Exception ex){
log.error("当前状态组合【{}】===日期【{}】",rentVehicleEntry.getKey(),rentVehicleEntry.getValue().get(0).getDate());
}
} }
//保存 //保存
StatisticsStatusEnum.insertReceivedStatisticsBatch(orderReceivedStatisticsList, mapper); StatisticsStatusEnum.insertReceivedStatisticsBatch(orderReceivedStatisticsList, mapper);
......
...@@ -71,11 +71,11 @@ ...@@ -71,11 +71,11 @@
`company_id` AS `companyId`, `company_id` AS `companyId`,
`year`, `year`,
`date`, `date`,
SUM(`member_amount`-`member_refund_amount`) AS `memberAmount`, SUM(`member_amount`) AS `memberAmount`,
SUM(`travel_amount`-`travel_refund_amount` ) AS `travelAmount`, SUM(`travel_amount`) AS `travelAmount`,
SUM(`rent_vehicle_amount`-`rent_vehicle_refund_amount`) AS `rentVehilceAmount`, SUM(`rent_vehicle_amount`) AS `rentVehilceAmount`,
SUM(`no_deductible_amount` - `no_deductible_refund_amount`) as `noDeductibleAmount`, SUM(`no_deductible_amount`) as `noDeductibleAmount`,
SUM(`deposit_amount` - `deposit_refund_amount`) as `depositAmount` SUM(`deposit_amount`) as `depositAmount`
FROM FROM
`order_received_statistics` WHERE `has_pay`=1 `order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''"> <if test="companyName!=null and companyName!=''">
...@@ -156,11 +156,11 @@ ...@@ -156,11 +156,11 @@
company_id AS `companyId`, company_id AS `companyId`,
`year`, `year`,
`month`, `month`,
SUM(`member_amount`-`member_refund_amount`) AS `memberAmount`, SUM(`member_amount`) AS `memberAmount`,
SUM(`travel_amount`-`travel_refund_amount` ) AS `travelAmount`, SUM(`travel_amount`) AS `travelAmount`,
SUM(`rent_vehicle_amount`-`rent_vehicle_refund_amount`) AS `rentVehilceAmount`, SUM(`rent_vehicle_amount`) AS `rentVehilceAmount`,
SUM(`no_deductible_amount` - `no_deductible_refund_amount`) as `noDeductibleAmount`, SUM(`no_deductible_amount`) as `noDeductibleAmount`,
SUM(`deposit_amount` - `deposit_refund_amount`) as `depositAmount` SUM(`deposit_amount`) as `depositAmount`
FROM FROM
`order_received_statistics` WHERE `has_pay`=1 `order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''"> <if test="companyName!=null and companyName!=''">
...@@ -240,11 +240,11 @@ ...@@ -240,11 +240,11 @@
company_id AS `companyId`, company_id AS `companyId`,
`year`, `year`,
`week_of_year` AS `weekOfYear`, `week_of_year` AS `weekOfYear`,
SUM(`member_amount`-`member_refund_amount`) AS `memberAmount`, SUM(`member_amount`) AS `memberAmount`,
SUM(`travel_amount`-`travel_refund_amount` ) AS `travelAmount`, SUM(`travel_amount`) AS `travelAmount`,
SUM(`rent_vehicle_amount`-`rent_vehicle_refund_amount`) AS `rentVehilceAmount`, SUM(`rent_vehicle_amount`) AS `rentVehilceAmount`,
SUM(`no_deductible_amount` - `no_deductible_refund_amount`) as `noDeductibleAmount`, SUM(`no_deductible_amount`) as `noDeductibleAmount`,
SUM(`deposit_amount` - `deposit_refund_amount`) as `depositAmount` SUM(`deposit_amount`) as `depositAmount`
FROM FROM
`order_received_statistics` WHERE `has_pay`=1 `order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''"> <if test="companyName!=null and companyName!=''">
...@@ -313,7 +313,7 @@ ...@@ -313,7 +313,7 @@
</select> </select>
<select id="selectCountByDate" resultType="int"> <select id="selectCountByDate" resultType="int">
select count(*) from (SELECT `date` FROM `order_received_statistics` WHERE `has_pay`=1 select count(0) from (SELECT `date` FROM `order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''"> <if test="companyName!=null and companyName!=''">
AND `company_name` LIKE CONCAT('%',#{companyName},'%') AND `company_name` LIKE CONCAT('%',#{companyName},'%')
</if> </if>
...@@ -341,7 +341,7 @@ ...@@ -341,7 +341,7 @@
</select> </select>
<select id="selectCountByMonth" resultType="int"> <select id="selectCountByMonth" resultType="int">
select count(*) from (SELECT `month` FROM `order_received_statistics` WHERE `has_pay`=1 select count(0) from (SELECT `month` FROM `order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''"> <if test="companyName!=null and companyName!=''">
AND `company_name` LIKE CONCAT('%',#{companyName},'%') AND `company_name` LIKE CONCAT('%',#{companyName},'%')
</if> </if>
...@@ -369,7 +369,7 @@ ...@@ -369,7 +369,7 @@
</select> </select>
<select id="selectCountByWeekOfYear" resultType="int"> <select id="selectCountByWeekOfYear" resultType="int">
select count(*) from (SELECT `week_of_year` FROM `order_received_statistics` WHERE `has_pay`=1 select count(0) from (SELECT `week_of_year` FROM `order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''"> <if test="companyName!=null and companyName!=''">
AND `company_name` LIKE CONCAT('%',#{companyName},'%') AND `company_name` LIKE CONCAT('%',#{companyName},'%')
</if> </if>
......
...@@ -98,7 +98,7 @@ public class ServiceTest { ...@@ -98,7 +98,7 @@ public class ServiceTest {
@Test @Test
public void testMemberStatistics(){ public void testMemberStatistics(){
Date date = DateTime.parse("2019-11-15").toDate(); Date date = DateTime.parse("2019-11-28").toDate();
Date startDate = DateUtil.beginOfDay(date).toJdkDate(); Date startDate = DateUtil.beginOfDay(date).toJdkDate();
Date endDate = DateUtil.endOfDay(date).toJdkDate(); Date endDate = DateUtil.endOfDay(date).toJdkDate();
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap(); Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
...@@ -126,17 +126,16 @@ public class ServiceTest { ...@@ -126,17 +126,16 @@ public class ServiceTest {
@Test @Test
@SneakyThrows @SneakyThrows
public void testOrderReceivedStatisticsJobHandler(){ public void testOrderReceivedStatisticsJobHandler(){
cn.hutool.core.date.DateTime dateTime = DateUtil.parse("2019-11-29", "yyyy-MM-dd"); /* 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); // cn.hutool.core.date.DateTime offset = DateUtil.offset(dateTime, DateField.DAY_OF_MONTH, 1);
orderReceivedStatisticsJobHandler.execute("2019-11-29"); orderReceivedStatisticsJobHandler.execute("2019-11-29");*/
/* LocalDate startLocalDate = LocalDate.of(2019, 10, 1); LocalDate startLocalDate = LocalDate.of(2019, 10, 1);
LocalDate endLocalDate = LocalDate.of(2019,11,29); LocalDate endLocalDate = LocalDate.of(2019,11,28);
while (startLocalDate.isBefore(endLocalDate)){ while (startLocalDate.isBefore(endLocalDate)){
String dateStr = startLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String dateStr = startLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
startLocalDate = startLocalDate.plusDays(1); startLocalDate = startLocalDate.plusDays(1);
orderReceivedStatisticsJobHandler.execute(dateStr); 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