Commit b72593bf authored by jiaorz's avatar jiaorz

Merge branch 'order_received_statistics' into dev

# Conflicts:
#	xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/biz/BaseOrderBiz.java
#	xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/mapper/BaseOrderMapper.java
#	xx-order/xx-order-server/src/test/java/ServiceTest.java
parents e8d5dff5 281f23d8
package com.github.wxiaoqi.security.common.enumconstant;
import org.assertj.core.util.Lists;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/13 17:23
*/
public enum LevelEnum {
DIAMOND(3,"钻石"),
GOLD(2,"黄金"),
GENERAL(1,"普通");
LevelEnum(Integer level, String desc) {
this.level = level;
this.desc = desc;
}
public static LevelEnum getLevelEnumByLevel(Integer level){
return levelMap.get(level);
}
private Integer level;
private String desc;
private static Map<Integer, LevelEnum> levelMap;
public static List<Integer> levels;
static {
levelMap = EnumSet.allOf(LevelEnum.class).stream().collect(Collectors.toMap(LevelEnum::getLevel, Function.identity()));
levels = Lists.newArrayList(levelMap.keySet());
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.github.wxiaoqi.security.common.util;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/20 19:59
*/
public class CollectorsUtil {
static final Set<Collector.Characteristics> CH_NOID = Collections.emptySet();
private CollectorsUtil() {
}
@SuppressWarnings("unchecked")
private static <I, R> Function<I, R> castingIdentity() {
return i -> (R) i;
}
/**
* Simple implementation class for {@code Collector}.
*
* @param <T>
* the type of elements to be collected
* @param <R>
* the type of the result
*/
static class CollectorImpl<T, A, R> implements Collector<T, A, R> {
private final Supplier<A> supplier;
private final BiConsumer<A, T> accumulator;
private final BinaryOperator<A> combiner;
private final Function<A, R> finisher;
private final Set<Characteristics> characteristics;
CollectorImpl(Supplier<A> supplier, BiConsumer<A, T> accumulator, BinaryOperator<A> combiner,
Function<A, R> finisher, Set<Characteristics> characteristics) {
this.supplier = supplier;
this.accumulator = accumulator;
this.combiner = combiner;
this.finisher = finisher;
this.characteristics = characteristics;
}
CollectorImpl(Supplier<A> supplier, BiConsumer<A, T> accumulator, BinaryOperator<A> combiner,
Set<Characteristics> characteristics) {
this(supplier, accumulator, combiner, castingIdentity(), characteristics);
}
@Override
public BiConsumer<A, T> accumulator() {
return accumulator;
}
@Override
public Supplier<A> supplier() {
return supplier;
}
@Override
public BinaryOperator<A> combiner() {
return combiner;
}
@Override
public Function<A, R> finisher() {
return finisher;
}
@Override
public Set<Characteristics> characteristics() {
return characteristics;
}
}
public static <T> Collector<T, ?, BigDecimal> summingBigDecimal(ToBigDecimalFunction<? super T> mapper) {
return new CollectorImpl<>(() -> new BigDecimal[1], (a, t) -> {
if (a[0] == null) {
a[0] = BigDecimal.ZERO;
}
a[0] = a[0].add(mapper.applyAsBigDecimal(t));
}, (a, b) -> {
a[0] = a[0].add(b[0]);
return a;
}, a -> a[0], CH_NOID);
}
}
package com.github.wxiaoqi.security.common.util;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/20 20:25
*/
@FunctionalInterface
public interface ToBigDecimalFunction<T> {
BigDecimal applyAsBigDecimal(T value);
}
...@@ -10,7 +10,7 @@ spring: ...@@ -10,7 +10,7 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://10.5.52.4:3307/xxfc_uccn?useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://10.5.52.3:3306/xxfc_order?useUnicode=true&characterEncoding=UTF-8
username: root username: root
password: sslcloud123*() password: sslcloud123*()
jackson: jackson:
......
#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F #\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F
#\u5305\u540D #\u5305\u540D
package=com.xxfc.platform.uccn package=com.xxfc.platform.order
#\u4F5C\u8005 #\u4F5C\u8005
author=libin author=libin
#Email #Email
......
package com.xxfc.platform.order.Utils; package com.xxfc.platform.order.Utils;
import org.joda.time.DateTime;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -108,4 +112,51 @@ public class OrderDateUtils { ...@@ -108,4 +112,51 @@ public class OrderDateUtils {
cal.setTimeInMillis(System.currentTimeMillis()); cal.setTimeInMillis(System.currentTimeMillis());
return cal.get(Calendar.YEAR); return cal.get(Calendar.YEAR);
} }
public static LocalDate dateToLocalDate(Date date) {
return LocalDate.from(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
}
public static Date localDateToDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
/**
* 获取当天的开始时间
* @return
*/
public static long getStartOfDay() {
return getStartOfDay(new Date());
}
/**
* 获取某天的开始时间
* @param date
* @return
*/
public static long getStartOfDay(Date date) {
DateTime dateTime = new DateTime(date);
DateTime startOfDay = dateTime.withTimeAtStartOfDay();
return startOfDay.getMillis();
}
/**
* 获取当天的结束时间
* @return
*/
public static long getEndOfDay() {
return getEndOfDay(new Date());
}
/**
* 获取某天的结束时间
* @param date
* @return
*/
public static long getEndOfDay(Date date) {
DateTime dateTime = new DateTime(date);
DateTime endOfDay = dateTime.millisOfDay().withMaximumValue();
return endOfDay.getMillis();
}
} }
package com.xxfc.platform.order.bo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/23 14:39
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class CompanyPerformanceBo {
private Date date;
private Integer year;
private String month;
private String weekOfYear;
private Integer companyId;
private String companyName;
private BigDecimal memberAmount;
private BigDecimal rentVehilceAmount;
private BigDecimal travelAmount;
private BigDecimal noDeductibleAmount;
private Integer rentDays;
private BigDecimal extralAmount;
private Integer departureNum;
private Integer arrivalNum;
private Date startDate;
private Date endDate;
}
package com.xxfc.platform.order.contant.enumerate; package com.xxfc.platform.order.contant.enumerate;
import org.assertj.core.util.Lists;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public enum DeductionTypeEnum { public enum DeductionTypeEnum {
...@@ -22,19 +26,48 @@ public enum DeductionTypeEnum { ...@@ -22,19 +26,48 @@ public enum DeductionTypeEnum {
* 类型描述 * 类型描述
*/ */
private String desc; private String desc;
/**
* 违约相关code
*/
public static List<Integer> lateFeeCode;
/**
* 定损相关code
*/
public static List<Integer> lossSpecifiedCode;
/**
* 违章相关code
*/
public static List<Integer> breakRulesRegulationCode;
/**
*消费金额相关code
*/
public static List<Integer> consumerCode;
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>(); private static Map<Integer, String> codeAndDesc = new HashMap<Integer, String>();
//Maps.newHashMap();
static{ static {
for(DeductionTypeEnum enumE : DeductionTypeEnum.values()){ for (DeductionTypeEnum enumE : DeductionTypeEnum.values()) {
codeAndDesc.put(enumE.getCode(),enumE.getDesc()); codeAndDesc.put(enumE.getCode(), enumE.getDesc());
} }
lateFeeCode = Lists.newArrayList(VIOLATE_CANCEL.getCode(),
VIOLATE_ADVANCE.getCode(),
VIOLATE_DELAY.getCode(),
VIOLATE_CHANGE_C.getCode());
lossSpecifiedCode = Lists.newArrayList(DAMAGES.getCode());
breakRulesRegulationCode = Lists.newArrayList(
VIOLATE_TRAFFIC_DEDUCT.getCode()
);
consumerCode = Lists.newArrayList(CONSUME.getCode());
} }
DeductionTypeEnum(Integer code, String desc){ DeductionTypeEnum(Integer code, String desc) {
this.code=code; this.code = code;
this.desc=desc; this.desc = desc;
} }
public Integer getCode() { public Integer getCode() {
...@@ -53,7 +86,7 @@ public enum DeductionTypeEnum { ...@@ -53,7 +86,7 @@ public enum DeductionTypeEnum {
this.desc = desc; this.desc = desc;
} }
public static Boolean exists(Integer code){ public static Boolean exists(Integer code) {
return codeAndDesc.containsKey(code); return codeAndDesc.containsKey(code);
} }
} }
\ No newline at end of file
package com.xxfc.platform.order.contant.enumerate;
import com.xxfc.platform.order.entity.OrderReceivedStatistics;
import com.xxfc.platform.order.entity.OrderReceivedStatisticsBase;
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;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/11 10:36
*/
public enum OrderReceivedStatisticsSignEnum {
ORDER_TOTAL_AMOUNT("aa_ota","订单总额"){
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K,V)->{
List<OrderReceivedStatistics> orderReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
BigDecimal totalAmount = orderReceivedStatisticsList.stream().map(x -> x.getTotalAmount()).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
OrderReceivedStatistics orderReceivedStatistics = orderReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics,totalAmount,null);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(),orderReceivedStatisticsVos);
return resultMap;
}
},
ORDER_TOTAL_QUANTITY("ab_otq","订单量"){
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K,V)->{
List<OrderReceivedStatistics> orderReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
Integer totalQuantity = orderReceivedStatisticsList.stream().map(x -> x.getTotalQuantity()).reduce(0, (x, y) -> x+y);
OrderReceivedStatistics orderReceivedStatistics = orderReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics,null,totalQuantity);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(),orderReceivedStatisticsVos);
return resultMap;
}
},
ORDER_AVG_QUANTITY("ac_oavgq","订单arpu"){
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K,V)->{
List<OrderReceivedStatistics> orderReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
Integer avgQuantity = orderReceivedStatisticsList.stream().map(x -> x.getTotalQuantity()).reduce(0, (x, y) -> x+y)/V.size();
OrderReceivedStatistics orderReceivedStatistics = orderReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics,null,avgQuantity);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(),orderReceivedStatisticsVos);
return resultMap;
}
};
private String sign;
private String desc;
private static Map<String,OrderReceivedStatisticsSignEnum> orderReceivedStatisticsSignEnumMap;
static {
orderReceivedStatisticsSignEnumMap = EnumSet.allOf(OrderReceivedStatisticsSignEnum.class).stream().collect(Collectors.toMap(OrderReceivedStatisticsSignEnum::getSign, Function.identity()));
}
OrderReceivedStatisticsSignEnum(String sign, String desc) {
this.sign = sign;
this.desc = desc;
}
/**
* 统计项
* @param orderMap
* @return
*/
abstract Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object,List<OrderReceivedStatisticsBase>> orderMap);
public static Map<String, List<OrderReceivedStatisticsVo>> orderReceivedStatistics(Map<Object,List<OrderReceivedStatisticsBase>> orderMap,List<String> signs){
Map<String,List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>(signs.size());
for (String sign : signs) {
OrderReceivedStatisticsSignEnum orderReceivedStatisticsSignEnum = orderReceivedStatisticsSignEnumMap.get(sign);
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap = orderReceivedStatisticsSignEnum.wrapToMap(orderMap);
resultMap.putAll(wrapToMap);
}
return resultMap;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.xxfc.platform.order.contant.enumerate;
import com.xxfc.platform.order.entity.OrderReceivedStatisticsBase;
import com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics;
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;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/11 10:36
*/
public enum OrderRentVehicleReceivedStatisticsSignEnum{
RENT_VEHICLE_TOTAL_AMOUNT("ba_rvta","租车订单总额"){
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K,V)->{
List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
BigDecimal totalAmount = orderRentVehicleReceivedStatisticsList.stream().map(x -> x.getTotalAmount()).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
OrderRentVehicleReceivedStatistics orderReceivedStatistics = orderRentVehicleReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics,totalAmount,null);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(),orderReceivedStatisticsVos);
return resultMap;
}
},
RENT_VEHICLE_TOTAL_QUANTITY("bb_rvtq","租车订单量") {
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K,V)->{
List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
Integer totalQuantity = orderRentVehicleReceivedStatisticsList.stream().map(x -> x.getTotalQuantity()).reduce(0, (x, y) -> x+y);
OrderRentVehicleReceivedStatistics orderReceivedStatistics = orderRentVehicleReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics,null,totalQuantity);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(),orderReceivedStatisticsVos);
return resultMap;
}
},
RENT_VEHICLE_AVG_QUANTITY("bc_rvavgq","租车订单arpu") {
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
AtomicReference<Integer> divisorAtomicReference = new AtomicReference<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K,V)->{
List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
Integer divisor = divisorAtomicReference.get();
if (Objects.isNull(divisor)){
divisor = orderRentVehicleReceivedStatisticsList.get(0).getDivisor();
divisorAtomicReference.set(divisor);
}
Integer avgQuantity = orderRentVehicleReceivedStatisticsList.stream().map(x -> x.getTotalQuantity()).reduce(0, (x, y) -> x+y)/divisor;
OrderRentVehicleReceivedStatistics orderReceivedStatistics = orderRentVehicleReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics,null,avgQuantity);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(),orderReceivedStatisticsVos);
return resultMap;
}
};
private String sign;
private String desc;
private static Map<String,OrderRentVehicleReceivedStatisticsSignEnum> orderRentVehicleReceivedStatisticsSignEnumMap;
static {
orderRentVehicleReceivedStatisticsSignEnumMap = EnumSet.allOf(OrderRentVehicleReceivedStatisticsSignEnum.class).stream().collect(Collectors.toMap(OrderRentVehicleReceivedStatisticsSignEnum::getSign, Function.identity()));
}
OrderRentVehicleReceivedStatisticsSignEnum(String sign, String desc) {
this.sign = sign;
this.desc = desc;
}
/**
* 统计项
* @param orderMap
* @return
*/
abstract Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object,List<OrderReceivedStatisticsBase>> orderMap);
public static Map<String, List<OrderReceivedStatisticsVo>> orderMemberstatisticsMap(Map<Object, List<OrderReceivedStatisticsBase>> orderRentVehiclestatisticsMap, List<String> signs) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>(signs.size());
for (String sign : signs) {
OrderRentVehicleReceivedStatisticsSignEnum orderRentVehicleReceivedStatisticsSignEnum = orderRentVehicleReceivedStatisticsSignEnumMap.get(sign);
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap = orderRentVehicleReceivedStatisticsSignEnum.wrapToMap(orderRentVehiclestatisticsMap);
resultMap.putAll(wrapToMap);
}
return resultMap;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.xxfc.platform.order.contant.enumerate;
import com.xxfc.platform.order.entity.OrderReceivedStatisticsBase;
import com.xxfc.platform.order.entity.OrderTourReceivedStatistics;
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;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/11 10:36
*/
public enum OrderTourReceivedStatisticsSignEnum {
TOUR_TOTAL_AMOUNT("ca_tta", "旅游订单总额") {
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K, V) -> {
List<OrderTourReceivedStatistics> orderTourReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
BigDecimal totalAmount = orderTourReceivedStatisticsList.stream().map(x -> x.getTotalAmount()).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
OrderTourReceivedStatistics orderReceivedStatistics = orderTourReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics, totalAmount, null);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(), orderReceivedStatisticsVos);
return resultMap;
}
},
TOUR_TOTAL_QUANTITY("cb_ttq", "旅游订单量") {
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K, V) -> {
List<OrderTourReceivedStatistics> orderTourReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
Integer totalQuantity = orderTourReceivedStatisticsList.stream().map(x -> x.getTotalQuantity()).reduce(0, (x, y) -> x + y);
OrderTourReceivedStatistics orderReceivedStatistics = orderTourReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics, null, totalQuantity);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(), orderReceivedStatisticsVos);
return resultMap;
}
},
TOUR_AVG_QUANTITY("cd_tavgq", "旅游订单arpu") {
@Override
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>();
AtomicReference<Integer> divisorAtomicReference = new AtomicReference<>();
List<OrderReceivedStatisticsVo> orderReceivedStatisticsVos = new ArrayList<>();
orderMap.forEach((K, V) -> {
List<OrderTourReceivedStatistics> orderTourReceivedStatisticsList = ReceivedStatisticsEnum.convertToTargetBean(V);
Integer divisor = divisorAtomicReference.get();
if (Objects.isNull(divisor)){
divisor = orderTourReceivedStatisticsList.get(0).getDivisor();
divisorAtomicReference.set(divisor);
}
Integer avgQuantity = orderTourReceivedStatisticsList.stream().map(x -> x.getTotalQuantity()).reduce(0, (x, y) -> x + y) / divisor;
OrderTourReceivedStatistics orderReceivedStatistics = orderTourReceivedStatisticsList.get(0);
OrderReceivedStatisticsVo receivedStatisticsVo = ReceivedStatisticsEnum.createOrderReceivedStatistics(orderReceivedStatistics, null, avgQuantity);
orderReceivedStatisticsVos.add(receivedStatisticsVo);
});
resultMap.put(getSign(), orderReceivedStatisticsVos);
return resultMap;
}
};
private String sign;
private String desc;
private static Map<String, OrderTourReceivedStatisticsSignEnum> orderTourReceivedStatisticsSignEnumMap;
static {
orderTourReceivedStatisticsSignEnumMap = EnumSet.allOf(OrderTourReceivedStatisticsSignEnum.class).stream().collect(Collectors.toMap(OrderTourReceivedStatisticsSignEnum::getSign, Function.identity()));
}
OrderTourReceivedStatisticsSignEnum(String sign, String desc) {
this.sign = sign;
this.desc = desc;
}
/**
* 统计项
*
* @param orderMap
* @return
*/
abstract Map<String, List<OrderReceivedStatisticsVo>> wrapToMap(Map<Object, List<OrderReceivedStatisticsBase>> orderMap);
public static Map<String, List<OrderReceivedStatisticsVo>> orderMemberstatisticsMap(Map<Object, List<OrderReceivedStatisticsBase>> orderTourstatisticsMap, List<String> signs) {
Map<String, List<OrderReceivedStatisticsVo>> resultMap = new HashMap<>(signs.size());
for (String sign : signs) {
OrderTourReceivedStatisticsSignEnum orderTourReceivedStatisticsSignEnum = orderTourReceivedStatisticsSignEnumMap.get(sign);
Map<String, List<OrderReceivedStatisticsVo>> wrapToMap = orderTourReceivedStatisticsSignEnum.wrapToMap(orderTourstatisticsMap);
resultMap.putAll(wrapToMap);
}
return resultMap;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.xxfc.platform.order.contant.enumerate;
import com.xxfc.platform.order.entity.OrderReceivedStatisticsBase;
import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsVo;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/11 15:25
*/
public enum ReceivedStatisticsEnum {
DAY(1, "按日统计") {
@Override
Map<Object, List<OrderReceivedStatisticsBase>> wrapMap(List<? extends OrderReceivedStatisticsBase> orderReceivedStatisticsBases) {
if (CollectionUtils.isEmpty(orderReceivedStatisticsBases)) {
return Collections.EMPTY_MAP;
}
return orderReceivedStatisticsBases.stream().peek(x -> {
((OrderReceivedStatisticsBase) x).setDivisor(1);
}).collect(Collectors.groupingBy(OrderReceivedStatisticsBase::getDate, Collectors.toList()));
}
},
WEEK(2, "按周统计") {
@Override
Map<Object, List<OrderReceivedStatisticsBase>> wrapMap(List<? extends OrderReceivedStatisticsBase> orderReceivedStatisticsBases) {
if (CollectionUtils.isEmpty(orderReceivedStatisticsBases)) {
return Collections.EMPTY_MAP;
}
return orderReceivedStatisticsBases.stream().peek(x -> ((OrderReceivedStatisticsBase) x).setDivisor(7)).collect(Collectors.groupingBy(OrderReceivedStatisticsBase::getWeekOfYear, Collectors.toList()));
}
},
MONTH(3, "按月统计") {
@Override
Map<Object, List<OrderReceivedStatisticsBase>> wrapMap(List<? extends OrderReceivedStatisticsBase> orderReceivedStatisticsBases) {
if (CollectionUtils.isEmpty(orderReceivedStatisticsBases)) {
return Collections.EMPTY_MAP;
}
return orderReceivedStatisticsBases.stream().peek(x -> {
OrderReceivedStatisticsBase orderReceivedStatisticsBase = (OrderReceivedStatisticsBase) x;
orderReceivedStatisticsBase.setDate(null);
orderReceivedStatisticsBase.setWeekOfYear(null);
LocalDate localDate = LocalDate.of(Integer.valueOf(orderReceivedStatisticsBase.getYear()),
Integer.valueOf(orderReceivedStatisticsBase.getMonth().replace(orderReceivedStatisticsBase.getYear(), "")), 1);
int lastDay = localDate.with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth();
orderReceivedStatisticsBase.setDivisor(lastDay);
}).collect(Collectors.groupingBy(OrderReceivedStatisticsBase::getMonth, Collectors.toList()));
}
};
private int wayCode;
private String value;
private static Map<Integer, ReceivedStatisticsEnum> statisticsEnumMap;
static {
statisticsEnumMap = EnumSet.allOf(ReceivedStatisticsEnum.class).stream().collect(Collectors.toMap(ReceivedStatisticsEnum::getWayCode, Function.identity()));
}
ReceivedStatisticsEnum(int wayCode, String value) {
this.wayCode = wayCode;
this.value = value;
}
/**
* 统计方式
*
* @param orderReceivedStatisticsBases
* @return
*/
abstract Map<Object, List<OrderReceivedStatisticsBase>> wrapMap(List<? extends OrderReceivedStatisticsBase> orderReceivedStatisticsBases);
public static Map<Object, List<OrderReceivedStatisticsBase>> orderstatistics(List<? extends OrderReceivedStatisticsBase> orderReceivedStatisticsBases, int wayCode) {
ReceivedStatisticsEnum statisticsEnum = createInstance(wayCode);
return statisticsEnum.wrapMap(orderReceivedStatisticsBases);
}
private static ReceivedStatisticsEnum createInstance(int wayCode) {
return statisticsEnumMap.get(wayCode);
}
/**
* 类型转换
*
* @param source
* @param <T>
* @return
*/
public static <T> List<T> convertToTargetBean(List<? extends OrderReceivedStatisticsBase> source) {
return source.stream().map(x -> (T) x).collect(Collectors.toList());
}
public static OrderReceivedStatisticsVo createOrderReceivedStatistics(OrderReceivedStatisticsBase orderReceivedStatisticsBase, BigDecimal amount, Integer quantity) {
return OrderReceivedStatisticsVo.builder()
.date(orderReceivedStatisticsBase.getDate())
.month(orderReceivedStatisticsBase.getMonth())
.weekOfYear(orderReceivedStatisticsBase.getWeekOfYear())
.year(orderReceivedStatisticsBase.getYear())
.orderNum(quantity)
.orderAmount(amount)
.build();
}
public int getWayCode() {
return wayCode;
}
public void setWayCode(int wayCode) {
this.wayCode = wayCode;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.xxfc.platform.order.contant.enumerate;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import com.xxfc.platform.order.entity.OrderReceivedStatisticsBase;
import org.apache.commons.collections4.CollectionUtils;
import org.assertj.core.util.Lists;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.WeekFields;
import java.util.*;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/14 14:28
*/
public enum StatisticsStatusEnum {
;
public static final int DEFAULT_COMPANY=1;
public static final int ORDER_MEMBER_TYPE=3;
public static final int ORDER_RENT_VEHICLE_TYPE=1;
public static final int ORDER_TOUR_TYPE=2;
public static final int NO_PAY_WAY=0;
public static final Integer DEFAULT_SQL_SIZE=1000;
public static final String ORDER_AMOUNT="order_amount";
public static final String LATEFEE_AMOUNT="late_fee";
public static final String ORDER_REFUND_AMOUNT="order_refund_amount";
public static final String ORDER_DEPOSIT_AMOUNT="order_deposit_amount";
public static final String COMPANY_DEFAULT="欣新房车控股集团";
public static final String NO_DEDUCTIBLE_AMOUNT="damageSafeAmount";
public static final String PARMAM_JSON="paramJson";
public static final int DAMAGE_SAFE=1;
public static List<String> orderStates;
public static List<String> orderOrigins;
public static List<String> orderPayWays;
static {
// 0 未支付 1 已支付
orderStates = Lists.newArrayList("0","1");
// 1 app 2 小程序 3 其他
orderOrigins = Lists.newArrayList("1","2","3");
// 1 微信 2 支付宝 0不需要支付(使用了优惠券之类的)或未支付
orderPayWays = Lists.newArrayList("1","2","0");
}
public static List<String> statisticsSateGroupWithCompanys(List<Integer> companyIdList){
List<String> orderStatisticsStateGroups = new ArrayList<>();
List<String> stateGroup = statisticsStateGroup();
for (String stgp : stateGroup) {
for (Integer companyId : companyIdList) {
// 公司id-订单来源-支付方式-订单状态
orderStatisticsStateGroups.add(String.format("%d-%s",companyId,stgp));
}
}
return orderStatisticsStateGroups;
}
public static List<String> statisticsStateGroup(){
List<String> orderStatisticsStateGroups = new ArrayList<>();
for (String orderOrigin : orderOrigins) {
for (String orderPayWay : orderPayWays) {
for (String orderState : orderStates) {
//订单来源-支付方式-订单状态
orderStatisticsStateGroups.add(String.format("%s-%s-%s",orderOrigin,orderPayWay,orderState));
}
}
}
return orderStatisticsStateGroups;
}
public static List<String> getOtherStatisticsStateGroup(List<Integer> companyIdList,List<String> statisticsStates){
List<String> stateGroupList = CollectionUtils.isEmpty(companyIdList)?statisticsStateGroup():statisticsSateGroupWithCompanys(companyIdList);
stateGroupList.removeAll(statisticsStates);
return stateGroupList;
}
public static<T extends OrderReceivedStatisticsBase> T wrapStatisticsObject(Date date, String stateGroup, Map<Integer,String> companyMap, T targetObj){
LocalDate localDate = LocalDate.from(new Date().toInstant().atZone(ZoneId.systemDefault()));
String year = String.valueOf(localDate.getYear());
String month = String.format("%s%d", year, localDate.getMonthValue());
String weekOfYear = String.format("%s%d", year,localDate.get(WeekFields.of(Locale.CHINESE).weekOfYear()));
String[] status = stateGroup.split("-");
targetObj.setCrtTime(new Date());
targetObj.setCompanyId(Integer.valueOf(status[0]));
String companyName = Objects.isNull(companyMap)?COMPANY_DEFAULT: StringUtils.hasText(companyMap.get(targetObj.getCompanyId()))?companyMap.get(targetObj.getCompanyId()):COMPANY_DEFAULT;
targetObj.setCompanyName(companyName);
targetObj.setHasPay(Integer.valueOf(status[3]));
targetObj.setOrderOrigin(Integer.valueOf(status[1]));
targetObj.setPayWay(Integer.valueOf(status[2]));
targetObj.setDate(date);
targetObj.setYear(year);
targetObj.setMonth(month);
targetObj.setWeekOfYear(weekOfYear);
targetObj.setExtraAmount(BigDecimal.ZERO);
targetObj.setLateFeeAmount(BigDecimal.ZERO);
targetObj.setTotalAmount(BigDecimal.ZERO);
targetObj.setTotalQuantity(0);
targetObj.setOrderRefundAmount(BigDecimal.ZERO);
targetObj.setStateGroup(stateGroup);
return targetObj;
}
}
package com.xxfc.platform.order.entity; package com.xxfc.platform.order.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.assertj.core.util.Lists;
import tk.mybatis.mapper.annotation.Version; import tk.mybatis.mapper.annotation.Version;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/** /**
* *
......
package com.xxfc.platform.order.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 会员订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
@Data
@Table(name = "order_member_received_statistics")
public class OrderMemberReceivedStatistics extends OrderReceivedStatisticsBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 普通会员订单总额
*/
@Column(name = "toal_common_ammount")
@ApiModelProperty(value = "普通会员订单总额")
private BigDecimal toalCommonAmmount;
/**
* 普通会员订单总量
*/
@Column(name = "total_common_quantity")
@ApiModelProperty(value = "普通会员订单总量")
private Integer totalCommonQuantity;
/**
* 黄金会员订单总额
*/
@Column(name = "total_gold_amount")
@ApiModelProperty(value = "黄金会员订单总额")
private BigDecimal totalGoldAmount;
/**
* 黄金会员订单总量
*/
@Column(name = "total_gold_quantity")
@ApiModelProperty(value = "黄金会员订单总量")
private Integer totalGoldQuantity;
/**
* 钻石会员订单总额
*/
@Column(name = "total_diamond_ammount")
@ApiModelProperty(value = "钻石会员订单总额")
private BigDecimal totalDiamondAmmount;
/**
* 钻石会员订单总量
*/
@Column(name = "total_diamond_quantity")
@ApiModelProperty(value = "钻石会员订单总量")
private Integer totalDiamondQuantity;
}
package com.xxfc.platform.order.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 全部订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
@Data
@Table(name = "order_received_statistics")
public class OrderReceivedStatistics extends OrderReceivedStatisticsBase implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "member_amount")
@ApiModelProperty("会员费")
private BigDecimal memberAmount;
@Column(name = "travel_amount")
@ApiModelProperty("旅游费")
private BigDecimal travelAmount;
@Column(name = "rent_vehicle_amount")
@ApiModelProperty("租车费")
private BigDecimal rentVehicleAmount;
@Column(name = "no_deductible_amount")
@ApiModelProperty("不计免赔费")
private BigDecimal noDeductibleAmount;
@Column(name = "no_deductible_refund_amount")
@ApiModelProperty("不计免赔退款费用")
private BigDecimal noDeductibleRefundAmount;
@Column(name = "deposit_amount")
@ApiModelProperty("押金")
private BigDecimal depositAmount;
@Column(name = "deposit_refund_amount")
@ApiModelProperty("押金退款")
private BigDecimal depositRefundAmount;
@Column(name = "break_rules_regulation_amount")
@ApiModelProperty("违章金")
private BigDecimal breakRulesRegulationAmount;
@Column(name = "loss_specified_amount")
@ApiModelProperty("定损金")
private BigDecimal lossSpecifiedAmount;
}
package com.xxfc.platform.order.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/11 15:49
*/
@Data
public class OrderReceivedStatisticsBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY,generator = "JDBC")
@ApiModelProperty("")
protected Long id;
/**
* 年份
*/
@Column(name = "year")
@ApiModelProperty(value = "年份")
protected String year;
/**
* 月份
*/
@Column(name = "month")
@ApiModelProperty(value = "月份----->201908")
protected String month;
/**
* 年月日
*/
@Column(name = "date")
@ApiModelProperty(value = "年月日")
protected Date date;
/**
* 1周年的第几周
*/
@Column(name = "week_of_year")
@ApiModelProperty(value = "1周年的第几周--->201922")
protected String weekOfYear;
/**
* 订单总额
*/
@Column(name = "total_amount")
@ApiModelProperty(value = "订单总额(不包含押金)")
protected BigDecimal totalAmount;
/**
* 订单总量
*/
@Column(name = "total_quantity")
@ApiModelProperty(value = "订单总量")
protected Integer totalQuantity;
@Column(name = "has_pay")
@ApiModelProperty(value = "是否支付 1已经支付 0未支付")
protected Integer hasPay;
/**
* '支付来源 1--app;2--小程序',
*/
@Column(name = "order_origin")
@ApiModelProperty(value = " '支付来源 1--app;2--小程序',")
protected Integer orderOrigin;
/**
* 支付方式 '1:微信公众号支付 2.支付宝即时到账,3,银联'
*/
@Column(name = "pay_way")
@ApiModelProperty(value = "支付方式 '1:微信公众号支付 2.支付宝即时到账,3,银联'")
protected Integer payWay;
@Column(name = "company_id")
@ApiModelProperty(value = "分公司id")
protected Integer companyId;
@Column(name = "company_name")
@ApiModelProperty("分公司名称")
protected String companyName;
@ApiModelProperty("违约金")
@Column(name = "late_fee_amount")
protected BigDecimal lateFeeAmount;
@ApiModelProperty("订单退款")
@Column(name = "order_refund_amount")
protected BigDecimal orderRefundAmount;
@ApiModelProperty("额外费用")
@Column(name = "extra_amount")
protected BigDecimal extraAmount;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true)
protected Date crtTime;
@Transient
protected Integer divisor;
@Transient
private String stateGroup;
}
package com.xxfc.platform.order.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 租车订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
@Data
@Table(name = "order_rent_vehicle_received_statistics")
public class OrderRentVehicleReceivedStatistics extends OrderReceivedStatisticsBase implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "deposit_amount")
@ApiModelProperty("押金")
private BigDecimal depositAmount;
@Column(name = "deposit_refund_amount")
@ApiModelProperty("押金退款")
private BigDecimal depositRefundAmount;
@Column(name = "break_rules_regulation_amount")
@ApiModelProperty("违章金")
private BigDecimal breakRulesRegulationAmount;
@Column(name = "loss_specified_amount")
@ApiModelProperty("定损金")
private BigDecimal lossSpecifiedAmount;
@Column(name = "no_deductible_amount")
@ApiModelProperty("不计免赔费用")
private BigDecimal noDeductibleAmount;
@Column(name = "no_deductible_refund_amount")
@ApiModelProperty("不计免赔费用")
private BigDecimal noDeductibleRefundAmount;
}
package com.xxfc.platform.order.entity;
import lombok.Data;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 旅游订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
@Data
@Table(name = "order_tour_received_statistics")
public class OrderTourReceivedStatistics extends OrderReceivedStatisticsBase implements Serializable {
private static final long serialVersionUID = 1L;
}
package com.xxfc.platform.order.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@Table(name = "order_vehicle_service_statistics")
@Data
public class OrderVehicleServiceStatistics {
@Id
private Integer id;
@Column(name = "company_id")
private Integer companyId;
/**
* 出车服务次数
*/
@Column(name = "departure_num")
private Integer departureNum;
/**
* 收车服务次数
*/
@Column(name = "arrival_num")
private Integer arrivalNum;
@Column(name = "count_year")
private String countYear;
@Column(name = "count_month")
private String countMonth;
@Column(name = "count_date")
private Date countDate;
@Column(name = "count_week")
private String countWeek;
/**
* 租车使用天数
*/
@Column(name = "rent_num")
private Integer rentNum;
}
\ No newline at end of file
package com.xxfc.platform.order.pojo;
import lombok.Data;
import java.util.Date;
@Data
public class CountVehicleServiceNumVo {
//年
private String countYear;
//年月
private String countMonth;
//年周
private String countWeek;
//天
private String countDay;
//日期
private Date countDate;
//公司ID
private Integer companyId;
//出车服务次数
private Integer departureNum;
//收车服务次数
private Integer arrivalNum;
//租车天数
private Integer rentNum;
}
package com.xxfc.platform.order.pojo.account;
import com.alibaba.fastjson.JSON;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import lombok.Data;
import org.springframework.util.StringUtils;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/14 19:16
*/
@Data
public class OrderAccountBo extends OrderDTO {
private Integer accountType;
private String accountDetail;
private OrderAccountDetail accountDetailEntity;
public OrderAccountDetail getAccountDetailEntity() {
return StringUtils.hasText(accountDetail)? JSON.parseObject(accountDetail,OrderAccountDetail.class):new OrderAccountDetail();
}
}
package com.xxfc.platform.order.pojo.account; package com.xxfc.platform.order.pojo.account;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.xxfc.platform.order.entity.OrderAccount; import com.xxfc.platform.order.entity.OrderAccount;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
...@@ -112,6 +114,7 @@ public class OrderAccountDTO implements Serializable { ...@@ -112,6 +114,7 @@ public class OrderAccountDTO implements Serializable {
private String oneDay; private String oneDay;
@Override @Override
public String toString() { public String toString() {
final StringBuffer sb = new StringBuffer("OrderAccountDTO{"); final StringBuffer sb = new StringBuffer("OrderAccountDTO{");
......
package com.xxfc.platform.order.pojo.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/23 14:36
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class CompanyPerformanceFindDTO extends PageParam {
private Date startDate;
private Date endDate;
@ApiModelProperty("统计方式 1:日 2:周 3:月")
@NotNull(message = "统计方式不能为null")
private Integer statisticalWay;
private String companyName;
}
package com.xxfc.platform.order.pojo.dto;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.common.enumconstant.LevelEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/13 15:58
*/
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class OrderDTO {
protected Integer id;
protected Integer type;
protected Integer status;
protected BigDecimal orderAmount;
protected BigDecimal realAmount;
protected Integer orderOrigin;
protected Integer payWay;
protected Integer companyId;
protected String stateGroup;
protected Integer hasPay;
private JSONObject data;
private Integer damageSafe;
private BigDecimal deposit;
/**
* 费用其他明细 租车使用
*/
protected String costDetailExtend;
/**
* 会员相关
*/
protected Integer memberLevel;
protected LevelEnum levelEnum;
public LevelEnum getLevelEnum(){
return LevelEnum.getLevelEnumByLevel(this.memberLevel);
}
public JSONObject getData() {
return StringUtils.hasText(costDetailExtend)?JSONUtil.parseObj(costDetailExtend):new JSONObject();
}
}
package com.xxfc.platform.order.pojo.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/11 9:49
*/
@Data
@ApiModel("统计查询")
public class OrderReceivedStatisticsFindDTO {
@ApiModelProperty("统计的开始时间 yyyy-MM-dd")
private Date startDate;
@ApiModelProperty("统计的结束时间 yyyy-MM-dd")
private Date endDate;
@ApiModelProperty("统计方式 1:日 2:周 3:月")
@NotNull(message = "统计方式不能为null")
private Integer statisticalWay;
@ApiModelProperty("订单状态 0:未完成 1:已完成")
private Integer orderState;
@ApiModelProperty("订单来源 1:app 2:小程序 3:后台")
private Integer orderOrigin;
@ApiModelProperty("支付方式 1:微信公众号支付 2:支付宝即时到账,3:银联")
private Integer payWay;
@ApiModelProperty("统计项标识")
@NotNull(message = "统计标识不能为null")
private List<String> statisticalSigns;
private List<Integer> companyId;
}
package com.xxfc.platform.order.pojo.order;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/20 19:11
*/
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class CompanyAmountBo {
private Integer companyId;
private BigDecimal amount;
}
package com.xxfc.platform.order.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/11 10:09
*/
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class OrderReceivedStatisticsVo {
private String year;
@ApiModelProperty("日期-->日统计方式")
private Date date;
@ApiModelProperty("第几周---->周统计方式")
private String weekOfYear;
@ApiModelProperty("月统计")
private String month;
@ApiModelProperty("订单总额|实际收入|平均收入")
private BigDecimal orderAmount;
@ApiModelProperty("订单总量|订单平均量")
private Integer orderNum;
}
...@@ -13,7 +13,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -13,7 +13,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = { @SpringBootApplication(scanBasePackages = {
"com.xxfc.platform", "com.xxfc.platform",
"com.github.wxiaoqi.security.common.handler", "com.github.wxiaoqi.security.common.handler",
"com.github.wxiaoqi.security.common.log" "com.github.wxiaoqi.security.common.log",
"com.github.wxiaoqi.security.common.support"
}) })
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableScheduling @EnableScheduling
......
...@@ -30,6 +30,7 @@ import com.xxfc.platform.order.pojo.account.OrderAccountDetail; ...@@ -30,6 +30,7 @@ import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO; import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo; import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO; import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO; import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.OrderListVo; import com.xxfc.platform.order.pojo.order.OrderListVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
...@@ -53,6 +54,7 @@ import com.xxfc.platform.vehicle.pojo.CompanyDetail; ...@@ -53,6 +54,7 @@ import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.util.DistanceUtil; import com.xxfc.platform.vehicle.util.DistanceUtil;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
...@@ -888,10 +890,6 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -888,10 +890,6 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
public UserFeign getUserFeign() { public UserFeign getUserFeign() {
return userFeign; return userFeign;
} }
/** /**
* 订单查询类 * 订单查询类
*/ */
...@@ -914,4 +912,13 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -914,4 +912,13 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return Lists.newArrayList(); return Lists.newArrayList();
} }
public List<OrderDTO> selectOrdersByTypeAndTime(List<Integer> types, Date startDate, Date endDate) {
List<OrderDTO> orderDTOS = mapper.selectOrdersByTypeAndTime(types,startDate,endDate);
return CollectionUtils.isEmpty(orderDTOS)?Collections.EMPTY_LIST:orderDTOS;
}
public List<OrderPageVO> selectAllRentVehicleOrder(Map<String, Object> paramMap) {
return mapper.selectAllRentVehicleOrder(paramMap);
}
} }
\ No newline at end of file
package com.xxfc.platform.order.biz;
import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.contant.enumerate.ReceivedStatisticsEnum;
import com.xxfc.platform.order.pojo.dto.CompanyPerformanceFindDTO;
import com.xxfc.platform.order.bo.CompanyPerformanceBo;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/23 14:48
*/
@Transactional(rollbackFor = Exception.class)
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CompanyPerformanceBiz {
private final OrderReceivedStatisticsBiz orderReceivedStatisticsBiz;
private final VehicleFeign vehicleFeign;
public PageDataVO<CompanyPerformanceBo> selectCompanyPerformancePage(CompanyPerformanceFindDTO companyPerformanceFindDTO) {
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
PageDataVO<CompanyPerformanceBo> pageDataVO = new PageDataVO<>();
//日统计
if (companyPerformanceFindDTO.getStatisticalWay() == ReceivedStatisticsEnum.DAY.getWayCode()) {
pageDataVO = orderReceivedStatisticsBiz.selectCompanyPerformanceWithDayPage(companyPerformanceFindDTO);
}
//按周
if (companyPerformanceFindDTO.getStatisticalWay() == ReceivedStatisticsEnum.WEEK.getWayCode()) {
pageDataVO = orderReceivedStatisticsBiz.selectCompanyPerformanceWithWeekPage(companyPerformanceFindDTO);
}
//按月
if (companyPerformanceFindDTO.getStatisticalWay() == ReceivedStatisticsEnum.MONTH.getWayCode()) {
pageDataVO = orderReceivedStatisticsBiz.selectCompanyPerformanceWithMonthPage(companyPerformanceFindDTO);
}
List<CompanyPerformanceBo> data = pageDataVO.getData();
if (CollectionUtils.isEmpty(data)) {
return pageDataVO;
}
for (CompanyPerformanceBo companyPerformanceBo : data) {
String companyName = companyMap == null ? "" : companyMap.get(companyPerformanceBo.getCompanyId());
companyPerformanceBo.setCompanyName(companyName);
if (companyPerformanceFindDTO.getStatisticalWay() == ReceivedStatisticsEnum.WEEK.getWayCode()) {
Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.set(Calendar.YEAR, companyPerformanceBo.getYear());
cal.set(Calendar.WEEK_OF_YEAR, Integer.valueOf(companyPerformanceBo.getWeekOfYear().replace("" + companyPerformanceBo.getYear(), "")));
cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
Date startDate = cal.getTime();
cal.add(Calendar.DAY_OF_WEEK, 6);
Date endDate = cal.getTime();
companyPerformanceBo.setStartDate(DateUtil.beginOfDay(startDate));
companyPerformanceBo.setEndDate(DateUtil.beginOfDay(endDate));
}
}
return pageDataVO;
}
}
...@@ -18,6 +18,7 @@ import com.xxfc.platform.order.entity.*; ...@@ -18,6 +18,7 @@ import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.OrderAccountMapper; import com.xxfc.platform.order.mapper.OrderAccountMapper;
import com.xxfc.platform.order.pojo.DedDetailDTO; import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.Term; import com.xxfc.platform.order.pojo.Term;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO; import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction; import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
...@@ -31,6 +32,7 @@ import com.xxfc.platform.universal.entity.Dictionary; ...@@ -31,6 +32,7 @@ import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.OrderRefundVo; import com.xxfc.platform.universal.vo.OrderRefundVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.jexl2.MapContext; import org.apache.commons.jexl2.MapContext;
import org.mockito.internal.util.collections.Sets; import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -38,9 +40,7 @@ import org.springframework.stereotype.Service; ...@@ -38,9 +40,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Set;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE; import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE; import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
...@@ -649,4 +649,14 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -649,4 +649,14 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
orderMsgBiz.handelMsgDeposit(orvd, baseOrder, userFeign.userDetailById(baseOrder.getUserId()).getData()); orderMsgBiz.handelMsgDeposit(orvd, baseOrder, userFeign.userDetailById(baseOrder.getUserId()).getData());
} }
/**
*根据开始与结束时间查询账目
* @param startDate
* @param endDate
* @return
*/
public List<OrderAccountBo> selectByTypeAndDate(Integer orderType,Date startDate, Date endDate) {
List<OrderAccountBo> accountBos = mapper.selectOrderAccountByOrderTypeAndStartTimeAndEndTime(orderType,startDate.getTime(),endDate.getTime());
return CollectionUtils.isEmpty(accountBos)? Collections.EMPTY_LIST:accountBos;
}
} }
\ No newline at end of file
package com.xxfc.platform.order.biz;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import org.springframework.stereotype.Service;
import com.xxfc.platform.order.entity.OrderTourReceivedStatistics;
import com.xxfc.platform.order.mapper.OrderTourReceivedStatisticsMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 旅游订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderTourReceivedStatisticsBiz extends BaseBiz<OrderTourReceivedStatisticsMapper,OrderTourReceivedStatistics> {
public List<OrderTourReceivedStatistics> selectOrderReceivedStatistics(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO) {
return mapper.selectOrderTourReceivedStatistics(orderReceivedStatisticsFindDTO);
}
}
\ No newline at end of file
package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.order.Utils.OrderDateUtils;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.contant.enumerate.CrosstownTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.entity.OrderVehicleServiceStatistics;
import com.xxfc.platform.order.mapper.OrderVehicleServiceStatisticsMapper;
import com.xxfc.platform.order.pojo.CountVehicleServiceNumVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto;
import com.xxfc.platform.universal.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class OrderVehicleServiceStatisticsBiz extends BaseBiz<OrderVehicleServiceStatisticsMapper, OrderVehicleServiceStatistics> {
@Autowired
BaseOrderBiz baseOrderBiz;
@Autowired
OrderVehicleCrosstownBiz orderVehicleCrosstownBiz;
@Autowired
OrderCalculateBiz orderCalculateBiz;
Map<Integer, Map<String, Integer>> mapMap = new HashMap<>();
//获取订单,解析租车天数
//根据订单状态,待出行的添加一天,出行中的加一天,已完成的判断订单时间和实际结束时间如果实际结束天数大于订单天数,则需要加一天
public void getAllOrder(DateTime dateTime) {
Date nowTime = DateTime.now().minusDays(1).toDate();
if (dateTime != null) {
nowTime = dateTime.minusDays(1).toDate();
}
String timeStr = DateUtil.dateToStr(nowTime, "yyyy-MM-dd");
//以公司ID为key, 日期+次数为value组成map
Map<String, Object> param = new HashMap<>();
param.put("startTime", OrderDateUtils.getStartOfDay(nowTime));
param.put("endTime", OrderDateUtils.getEndOfDay(nowTime));
param.put("status", 1);
List<OrderPageVO> orderPageVOS = baseOrderBiz.selectAllRentVehicleOrder(param);
if (orderPageVOS != null && orderPageVOS.size() > 0) {
orderPageVOS.parallelStream().forEach(result -> {
if (result.getOrderRentVehicleDetail() != null) {
Map<String, Integer> dateNumMap = mapMap.getOrDefault(result.getOrderRentVehicleDetail().getStartCompanyId(), new HashMap<>());
if (result.getStatus() == OrderStatusEnum.ORDER_TOSTART.getCode() || result.getStatus() == OrderStatusEnum.ORDER_WAIT.getCode()) {//待出行或者出行中
dateNumMap.put(timeStr, dateNumMap.getOrDefault(timeStr, 0) + 1);
}
if (result.getStatus() == OrderStatusEnum.ORDER_TOSTART.getCode() || result.getStatus() == OrderStatusEnum.ORDER_FIXED_LOSS.getCode()) {//已完成或者定损中
//判断租车时间是否小于实际用车时间
//实际预定天数
Integer bookDays = result.getOrderRentVehicleDetail().getDayNum();
//实际使用天数
Integer actualUsedDays = result.getOrderRentVehicleDetail().getUsedDay();
Long startTime = result.getOrderRentVehicleDetail().getStartTime();
if (actualUsedDays == null) {//字段为空,重新计算天数
//查询还车时间
OrderVehicleCrosstownDto orderVehicleCrosstownDto = new OrderVehicleCrosstownDto();
orderVehicleCrosstownDto.setOrderId(result.getId());
List<OrderVehicleCrosstownDto> list = orderVehicleCrosstownBiz.selectByOrderId(orderVehicleCrosstownDto);
if(list != null && list.size() > 0) {
list.parallelStream().forEach(order -> {
//获取还车时间
if (order.getType() == CrosstownTypeEnum.ARRIVE.getCode() || order.getType() == CrosstownTypeEnum.FIXED_LOSS.getCode() || order.getType() == CrosstownTypeEnum.FIXED_LOSS_NOW.getCode()) {
Long endTime = order.getCrtTime();
int userUsedDay = orderCalculateBiz.getIncludeDays(startTime, endTime);
if (bookDays < userUsedDay) { //实际使用天数>预定天数,还车当天+1
dateNumMap.put(timeStr, dateNumMap.getOrDefault(timeStr, 0) + 1);
}
}
});
} else { //还车记录不存在,异常数据
log.info("还车记录不存在,异常数据, {}", result.toString());
}
}
}
mapMap.put(result.getOrderRentVehicleDetail().getStartCompanyId(), dateNumMap);
}
});
}
log.info("统计数据,Map = {}", mapMap);
}
public void countVehicleServiceNum(DateTime dateTime) {
Date nowTime = DateTime.now().minusDays(1).toDate();
if (dateTime != null) {
nowTime = dateTime.minusDays(1).toDate();
}
Map<String, Object> map = new HashMap<>();
map.put("startTime", OrderDateUtils.getStartOfDay(nowTime));
map.put("endTime", OrderDateUtils.getEndOfDay(nowTime));
List<CountVehicleServiceNumVo> list = mapper.countVehicleServiceNum(map);
if (list != null && list.size() > 0) {
list.parallelStream().forEach(result -> {
OrderVehicleServiceStatistics orderVehicleServiceStatistics = new OrderVehicleServiceStatistics();
log.info(result.toString());
BeanUtil.copyProperties(result, orderVehicleServiceStatistics, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
String dateStr = result.getCountYear() +"-"+ result.getCountMonth() +"-"+ result.getCountDay();
DateTime date = DateTime.parse(dateStr);
orderVehicleServiceStatistics.setCountDate(date.toDate());
orderVehicleServiceStatistics.setCountMonth(result.getCountYear() + result.getCountMonth());
orderVehicleServiceStatistics.setCountWeek(result.getCountYear() + result.getCountWeek());
add(orderVehicleServiceStatistics);
});
}
}
public void add(OrderVehicleServiceStatistics orderVehicleServiceStatistics) {
if(orderVehicleServiceStatistics != null) {
OrderVehicleServiceStatistics oldValue = mapper.selectByCompanyIdAndDate(orderVehicleServiceStatistics);
if (oldValue == null) {
insertSelectiveRe(orderVehicleServiceStatistics);
} else {
BeanUtil.copyProperties(orderVehicleServiceStatistics, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
updateSelectiveByIdRe(oldValue);
}
}
}
//添加记录
public void addAll() {
DateTime dateTime = DateTime.parse("2019-08-01");
for(DateTime curDate = dateTime.plusDays(1); curDate.compareTo(DateTime.now()) < 0; curDate = curDate.plusDays(1)) {
countVehicleServiceNum(curDate);
getAllOrder(curDate);
}
if (MapUtils.isNotEmpty(mapMap)) {
for (Map.Entry<Integer, Map<String, Integer>> entry : mapMap.entrySet()) {
if (MapUtils.isNotEmpty(entry.getValue())) {
OrderVehicleServiceStatistics orderVehicleServiceStatistics = new OrderVehicleServiceStatistics();
orderVehicleServiceStatistics.setCompanyId(entry.getKey());
for (Map.Entry<String, Integer> values : entry.getValue().entrySet()) {
if (StringUtils.isNotBlank(values.getKey()) && StringUtils.isNotBlank(values.getValue() + "")) {
DateTime dateTime1 = DateTime.parse(values.getKey());
orderVehicleServiceStatistics.setCountDate(dateTime1.toDate());
orderVehicleServiceStatistics.setRentNum(values.getValue());
orderVehicleServiceStatistics.setCountYear(dateTime1.getYear() + "");
orderVehicleServiceStatistics.setCountMonth(dateTime1.getYear() + "" + dateTime1.getMonthOfYear() + "");
orderVehicleServiceStatistics.setCountWeek(dateTime1.getYear() + "" + dateTime1.getWeekOfWeekyear() + "");
add(orderVehicleServiceStatistics);
}
}
}
}
}
}
}
package com.xxfc.platform.order.jobhandler;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.xxfc.platform.order.biz.OrderMemberReceivedStatisticsBiz;
import com.xxfc.platform.order.biz.OrderReceivedStatisticsBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleReceivedStatisticsBiz;
import com.xxfc.platform.order.biz.OrderTourReceivedStatisticsBiz;
import com.xxfc.platform.order.entity.OrderMemberReceivedStatistics;
import com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics;
import com.xxfc.platform.order.entity.OrderTourReceivedStatistics;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author libin
* @version 1.0
* @description 订单统计 定时任务
* @data 2019/11/11 11:09
*/
@JobHandler(value = "orderReceivedStatisticsJobHandler")
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class OrderReceivedStatisticsJobHandler extends IJobHandler {
private final OrderReceivedStatisticsBiz orderReceivedStatisticsBiz;
private final OrderRentVehicleReceivedStatisticsBiz orderRentVehicleReceivedStatisticsBiz;
private final OrderTourReceivedStatisticsBiz orderTourReceivedStatisticsBiz;
private final OrderMemberReceivedStatisticsBiz orderMemberReceivedStatisticsBiz;
private final VehicleFeign vehicleFeign;
@Override
public ReturnT<String> execute(String arg) throws Exception {
DateTime yesterday = DateUtil.yesterday();
if (StringUtils.hasText(arg)){
yesterday = DateUtil.parse(arg,"yyyy-MM-dd");
}
Date startDate = DateUtil.beginOfDay(yesterday).toJdkDate();
Date endDate = DateUtil.endOfDay(yesterday).toJdkDate();
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
//旅游订单
List<OrderTourReceivedStatistics> orderTourReceivedStatisticsList = Collections.EMPTY_LIST;
//租车订单
List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatisticsList = orderRentVehicleReceivedStatisticsBiz.orderRentVehicleReceivedStatistics(startDate, endDate, companyMap);
//会员订单
List<OrderMemberReceivedStatistics> orderMemberReceivedStatisticsList = orderMemberReceivedStatisticsBiz.orderMemberReceivedStatistics(startDate, endDate, companyMap);
//订单
orderReceivedStatisticsBiz.orderReceivedStatistics(orderMemberReceivedStatisticsList,
orderTourReceivedStatisticsList,
orderRentVehicleReceivedStatisticsList,
startDate);
return new ReturnT<>(ReturnT.SUCCESS_CODE,"订单统计成功执行");
}
}
...@@ -4,6 +4,7 @@ import com.xxfc.platform.order.entity.BaseOrder; ...@@ -4,6 +4,7 @@ import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.pojo.bg.BgOrderListVo; import com.xxfc.platform.order.pojo.bg.BgOrderListVo;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo; import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO; import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.order.OrderListVo; import com.xxfc.platform.order.pojo.order.OrderListVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
...@@ -36,6 +37,9 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> { ...@@ -36,6 +37,9 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> {
List<MemberOrderBo> findMemberOrders(MemberOrderFindDTO memberOrderFindDTO); List<MemberOrderBo> findMemberOrders(MemberOrderFindDTO memberOrderFindDTO);
List<OrderDTO> selectOrdersByTypeAndTime(@Param("types") List<Integer> types,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
public List<BgOrderListVo> getAllOrderList(Map<String, Object> paramMap); public List<BgOrderListVo> getAllOrderList(Map<String, Object> paramMap);
......
package com.xxfc.platform.order.mapper; package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderAccount; import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.pojo.Term; import com.xxfc.platform.order.pojo.Term;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO; import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import org.apache.ibatis.annotations.Param; import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import tk.mybatis.mapper.common.Mapper; import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List; import java.util.List;
/** /**
* 订单帐目 * 订单帐目
* *
* @author zhoujw * @author zhoujw
* @email 18178966185@163.com * @email 18178966185@163.com
* @date 2019-09-09 15:51:16 * @date 2019-09-09 15:51:16
...@@ -19,4 +20,8 @@ import java.util.List; ...@@ -19,4 +20,8 @@ import java.util.List;
public interface OrderAccountMapper extends Mapper<OrderAccount> { public interface OrderAccountMapper extends Mapper<OrderAccount> {
List<OrderAccountDTO> getOrderAccountByOrderType(Term term); List<OrderAccountDTO> getOrderAccountByOrderType(Term term);
List<OrderAccountBo> selectOrderAccountByOrderTypeAndStartTimeAndEndTime(@Param("orderType") Integer orderType,
@Param("startTime") long startTime,
@Param("endTime") long endTime);
} }
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderMemberReceivedStatistics;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 会员订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
public interface OrderMemberReceivedStatisticsMapper extends Mapper<OrderMemberReceivedStatistics>, InsertListMapper<OrderMemberReceivedStatistics> {
List<OrderMemberReceivedStatistics> selectOrderMemberReceivedStatistics(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO);
void inserMemberReceivedtList(@Param("orderMembers") List<OrderMemberReceivedStatistics> orderMemberReceivedStatistics);
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.bo.CompanyPerformanceBo;
import com.xxfc.platform.order.entity.OrderReceivedStatistics;
import com.xxfc.platform.order.pojo.dto.CompanyPerformanceFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 全部订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
public interface OrderReceivedStatisticsMapper extends Mapper<OrderReceivedStatistics>, InsertListMapper<OrderReceivedStatistics> {
List<OrderReceivedStatistics> selectOrderReceivedStatisticsList(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO);
List<CompanyPerformanceBo> selectCompanyPerformanceWithDay(CompanyPerformanceFindDTO companyPerformanceFindDTO);
List<CompanyPerformanceBo> selectCompanyPerformanceWithMonth(CompanyPerformanceFindDTO companyPerformanceFindDTO);
List<CompanyPerformanceBo> selectCompanyPerformanceWithWeek(CompanyPerformanceFindDTO companyPerformanceFindDTO);
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 租车订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
public interface OrderRentVehicleReceivedStatisticsMapper extends Mapper<OrderRentVehicleReceivedStatistics>, InsertListMapper<OrderRentVehicleReceivedStatistics> {
List<OrderRentVehicleReceivedStatistics> selectOrderRentVehicleReceivedStatistics(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO);
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderTourReceivedStatistics;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 旅游订单统计
*
* @author libin
* @email 18178966185@163.com
* @date 2019-11-08 18:03:42
*/
public interface OrderTourReceivedStatisticsMapper extends Mapper<OrderTourReceivedStatistics> {
List<OrderTourReceivedStatistics> selectOrderTourReceivedStatistics(OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO);
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderVehicleServiceStatistics;
import com.xxfc.platform.order.pojo.CountVehicleServiceNumVo;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map;
/**
* 出车、收车服务次数统计
*/
public interface OrderVehicleServiceStatisticsMapper extends Mapper<OrderVehicleServiceStatistics> {
List<CountVehicleServiceNumVo> countVehicleServiceNum(Map<String, Object> param);
OrderVehicleServiceStatistics selectByCompanyIdAndDate(OrderVehicleServiceStatistics orderVehicleServiceStatistics);
}
\ No newline at end of file
package com.xxfc.platform.order.rest.background;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.biz.CompanyPerformanceBiz;
import com.xxfc.platform.order.pojo.dto.CompanyPerformanceFindDTO;
import com.xxfc.platform.order.bo.CompanyPerformanceBo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author libin
* @version 1.0
* @description 公司业绩查询
* @data 2019/11/23 14:32
*/
@RestController
@RequestMapping("/statistics")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CompanyOrderReceivedStatiscsAdminController {
private final CompanyPerformanceBiz companyPerformanceBiz;
@PostMapping("/company_performance")
public ObjectRestResponse<PageDataVO<CompanyPerformanceBo>> companyPerformance(@RequestBody CompanyPerformanceFindDTO companyPerformanceFindDTO){
PageDataVO<CompanyPerformanceBo> dataVO = companyPerformanceBiz.selectCompanyPerformancePage(companyPerformanceFindDTO);
return ObjectRestResponse.succ(dataVO);
}
}
package com.xxfc.platform.order.rest.background;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.annotation.BeanValid;
import com.github.wxiaoqi.security.common.annotation.SimpleValid;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.order.biz.OrderReceivedStatisticsBiz;
import com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO;
import com.xxfc.platform.order.pojo.vo.OrderReceivedStatisticsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @author libin
* @version 1.0
* @description 订单统计
* @data 2019/11/11 9:14
*/
@Slf4j
@Api(tags = "订单统计")
@RestController
@RequestMapping("admin/order/received_statistics")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class OrderReceivedStatisticsAdminController {
private final OrderReceivedStatisticsBiz orderReceivedStatisticsBiz;
@ApiOperation("订单统计")
@PostMapping("")
public ObjectRestResponse<Map<String, List<OrderReceivedStatisticsVo>>> orderReceivedStatistics(@RequestBody @SimpleValid OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO, UserDTO userDTO){
orderReceivedStatisticsFindDTO.setCompanyId(Arrays.asList(userDTO.getCompanyId()));
Map<String, List<OrderReceivedStatisticsVo>> orderReceivedStatisticsPageVo = orderReceivedStatisticsBiz.getOrderReceivedStatisticsResult(orderReceivedStatisticsFindDTO);
return ObjectRestResponse.succ(orderReceivedStatisticsPageVo);
}
@ApiOperation("订单统计excel导出下载")
@PostMapping(value = "/export",consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ObjectRestResponse<Void> exportOrderReceivedStatistics(@RequestBody @BeanValid OrderReceivedStatisticsFindDTO orderReceivedStatisticsFindDTO,UserDTO userDTO, HttpServletResponse response){
try {
orderReceivedStatisticsFindDTO.setCompanyId(Arrays.asList(userDTO.getCompanyId()));
String name = DateTimeFormatter.ofPattern("YYYYMMddHHmmss").format(LocalDateTime.now());
response.setContentType("application/vnd.ms-excel;charset=utf-8");
String filename = String.format("%s-OrderReceivedStatistics.xlsx",name);
response.setHeader("Content-Disposition","attachment;filename="+ new String(filename.getBytes(), "iso8859-1"));
ServletOutputStream outputStream = response.getOutputStream();
orderReceivedStatisticsBiz.exportOrderReceivedStatisticsData(orderReceivedStatisticsFindDTO,outputStream);
response.setCharacterEncoding("UTF-8");
return ObjectRestResponse.succ();
}catch (Exception ex){
log.error("导出数据失败【{}】",ex);
throw new BaseException("导出数据失败");
}
}
}
package com.xxfc.platform.order.rest.background;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.order.biz.OrderVehicleServiceStatisticsBiz;
import com.xxfc.platform.order.entity.OrderVehicleServiceStatistics;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/vehicle/serviceNum")
public class VehicleServiceNumController extends BaseController<OrderVehicleServiceStatisticsBiz, OrderVehicleServiceStatistics> {
@GetMapping(value = "/app/unauth/addAll")
public void addAll() {
baseBiz.addAll();
}
}
...@@ -6,6 +6,7 @@ import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel; ...@@ -6,6 +6,7 @@ import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface; import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.enumconstant.LevelEnum;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
...@@ -412,57 +413,27 @@ public class OrderMemberService extends AbstractOrderHandle<OrderMemberDetailBiz ...@@ -412,57 +413,27 @@ public class OrderMemberService extends AbstractOrderHandle<OrderMemberDetailBiz
BigDecimal totalAmount = baseOrders.stream().filter(x->x.getHasPay()==1).map(MemberOrderBo::getOrderAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y)); BigDecimal totalAmount = baseOrders.stream().filter(x->x.getHasPay()==1).map(MemberOrderBo::getOrderAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
memberOrderStatisticsBo.setTotalAmount(totalAmount); memberOrderStatisticsBo.setTotalAmount(totalAmount);
List<MemberOrderBo> diamondOrders = baseOrderMap.get(levelEnum.DIAMOND.getLevel()); List<MemberOrderBo> diamondOrders = baseOrderMap.get(LevelEnum.DIAMOND.getLevel());
memberOrderStatisticsBo.setDiamondOrderNum(diamondOrders==null?0:diamondOrders.size()); memberOrderStatisticsBo.setDiamondOrderNum(diamondOrders==null?0:diamondOrders.size());
List<MemberOrderBo> diamondHashPayOrders = baseOrderHasPayMap.get(levelEnum.DIAMOND.getLevel()); List<MemberOrderBo> diamondHashPayOrders = baseOrderHasPayMap.get(LevelEnum.DIAMOND.getLevel());
diamondHashPayOrders = diamondHashPayOrders==null?Collections.EMPTY_LIST:diamondHashPayOrders; diamondHashPayOrders = diamondHashPayOrders==null?Collections.EMPTY_LIST:diamondHashPayOrders;
BigDecimal diamondAmount = diamondHashPayOrders.stream().map(MemberOrderBo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal diamondAmount = diamondHashPayOrders.stream().map(MemberOrderBo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
memberOrderStatisticsBo.setTotalDiamondAmount(diamondAmount); memberOrderStatisticsBo.setTotalDiamondAmount(diamondAmount);
List<MemberOrderBo> goldOrders = baseOrderMap.get(levelEnum.GOLD.getLevel()); List<MemberOrderBo> goldOrders = baseOrderMap.get(LevelEnum.GOLD.getLevel());
memberOrderStatisticsBo.setGoldOrderNum(goldOrders==null?0:goldOrders.size()); memberOrderStatisticsBo.setGoldOrderNum(goldOrders==null?0:goldOrders.size());
List<MemberOrderBo> goldHasPayOrders = baseOrderHasPayMap.get(levelEnum.GOLD.getLevel()); List<MemberOrderBo> goldHasPayOrders = baseOrderHasPayMap.get(LevelEnum.GOLD.getLevel());
goldHasPayOrders = goldHasPayOrders==null?Collections.EMPTY_LIST:goldHasPayOrders; goldHasPayOrders = goldHasPayOrders==null?Collections.EMPTY_LIST:goldHasPayOrders;
BigDecimal goldAmount = goldHasPayOrders.stream().map(MemberOrderBo::getOrderAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y)); BigDecimal goldAmount = goldHasPayOrders.stream().map(MemberOrderBo::getOrderAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
memberOrderStatisticsBo.setTotalGoldAmount(goldAmount); memberOrderStatisticsBo.setTotalGoldAmount(goldAmount);
List<MemberOrderBo> generalOrders = baseOrderMap.get(levelEnum.GENERAL.getLevel()); List<MemberOrderBo> generalOrders = baseOrderMap.get(LevelEnum.GENERAL.getLevel());
memberOrderStatisticsBo.setGeneralOrderNum(generalOrders==null?0:generalOrders.size()); memberOrderStatisticsBo.setGeneralOrderNum(generalOrders==null?0:generalOrders.size());
List<MemberOrderBo> generalHasPayOrders = baseOrderHasPayMap.get(levelEnum.GENERAL.getLevel()); List<MemberOrderBo> generalHasPayOrders = baseOrderHasPayMap.get(LevelEnum.GENERAL.getLevel());
generalHasPayOrders = generalHasPayOrders==null?Collections.EMPTY_LIST:generalHasPayOrders; generalHasPayOrders = generalHasPayOrders==null?Collections.EMPTY_LIST:generalHasPayOrders;
BigDecimal generalAmount = generalHasPayOrders.stream().map(MemberOrderBo::getOrderAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y)); BigDecimal generalAmount = generalHasPayOrders.stream().map(MemberOrderBo::getOrderAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
memberOrderStatisticsBo.setTotalGeneralAmount(generalAmount); memberOrderStatisticsBo.setTotalGeneralAmount(generalAmount);
return memberOrderStatisticsBo; return memberOrderStatisticsBo;
} }
private enum levelEnum{
DIAMOND(3,"钻石"),
GOLD(2,"黄金"),
GENERAL(1,"普通");
levelEnum(Integer level,String desc) {
this.level = level;
this.desc = desc;
}
private Integer level;
private String desc;
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
} }
...@@ -116,14 +116,14 @@ ...@@ -116,14 +116,14 @@
<select id="listOrder" parameterType="Map" resultMap="orderListMap"> <select id="listOrder" parameterType="Map" resultMap="orderListMap">
select b.* select b.*
<if test="type==1"> <if test="type==1">
,i.detail as carArticlesJson ,i.detail as carArticlesJson
</if> </if>
from base_order b from base_order b
LEFT JOIN order_rent_vehicle_detail r on r.order_id = b.id LEFT JOIN order_rent_vehicle_detail r on r.order_id = b.id
LEFT JOIN order_tour_detail t on t.order_id = b.id LEFT JOIN order_tour_detail t on t.order_id = b.id
LEFT JOIN order_member_detail m on m.order_id = b.id LEFT JOIN order_member_detail m on m.order_id = b.id
<if test="type==1"> <if test="type==1">
LEFT JOIN (select * from order_item where type = 104) i on b.id = i.order_id LEFT JOIN (select * from order_item where type = 104) i on b.id = i.order_id
</if> </if>
<where> <where>
<if test="crtUser != null"> <if test="crtUser != null">
...@@ -329,12 +329,12 @@ ...@@ -329,12 +329,12 @@
select b.* select b.*
from base_order b from base_order b
LEFT JOIN order_rent_vehicle_detail r on r.order_id = b.id LEFT JOIN order_rent_vehicle_detail r on r.order_id = b.id
where b.type = 2 and b.status &gt;= 4 where b.type = 1 and b.status &gt;= 4
<if test="startTime != null and status == 1"> <if test="startTime != null and status == 1">
and r.start_time between #{startTime} and #{endTime} and r.start_time between #{startTime} and #{endTime}
</if> </if>
<if test="startTime != null and status == 2"> <if test="startTime != null and status == 2">
and r.start_time between #{startTime} and #{endTime} and r.end_time between #{startTime} and #{endTime}
</if> </if>
</select> </select>
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
</select> </select>
<select id="findMemberOrders" resultType="com.xxfc.platform.order.pojo.dto.MemberOrderBo"> <select id="findMemberOrders" resultType="com.xxfc.platform.order.pojo.dto.MemberOrderBo">
select bo.*,omd.member_level AS `memberLevel` from ( select bo.*,omd.member_level AS `memberLevel` from (
SELECT SELECT
`id`, `id`,
`no` AS `orderNo`, `no` AS `orderNo`,
...@@ -403,11 +403,28 @@ ...@@ -403,11 +403,28 @@
</foreach> </foreach>
</if> </if>
) AS `bo` ) AS `bo`
INNER JOIN (select * from `order_member_detail` where 1=1 INNER JOIN (select * from `order_member_detail` where 1=1
<if test="level!=null"> <if test="level!=null">
and `member_level`=#{level} and `member_level`=#{level}
</if> </if>
) AS `omd` ON omd.order_id=bo.id ) AS `omd` ON omd.order_id=bo.id
ORDER BY bo.`creatTime` DESC ORDER BY bo.`creatTime` DESC
</select> </select>
<select id="selectOrdersByTypeAndTime" resultType="com.xxfc.platform.order.pojo.dto.OrderDTO">
select bo.*,omd.memberLevel,IFNULL(IFNULL(orvd.start_company_id,otd.start_company_id),`parent_user_company_id`) AS `companyId`,orvd.deposit,orvd.cost_detail_extend AS `costDetailExtend` from (select `id`,`type`,`status`,`order_amount` AS `orderAmount`, `real_amount`AS
`realAmount`,`order_origin` AS `orderOrigin`, `has_pay` AS `hasPay`,
`pay_way` AS `payWay`
from `base_order` where (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreach collection="types"
item="type"
open="(" close=")"
separator=",">
#{type}
</foreach> ) AS `bo`
LEFT JOIN (select `order_id`,`start_company_id`,`deposit`,`cost_detail_extend` from `order_rent_vehicle_detail`) AS `orvd` ON
orvd.order_id=bo.id
LEFT JOIN (select `order_id`,`start_company_id` from `order_tour_detail`) AS `otd` ON otd.order_id=bo.id
LEFT JOIN (select `order_id`,`member_level` AS `memberLevel` from `order_member_detail`) AS `omd` ON
omd.order_id=bo.id;
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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"> <mapper namespace="com.xxfc.platform.order.mapper.OrderAccountMapper">
<select id="getOrderAccountByOrderType" parameterType="com.xxfc.platform.order.pojo.Term" 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 SELECT
<if test="subdivide !=null and subdivide ==1"> <if test="subdivide !=null and subdivide ==1">
date( FROM_UNIXTIME( a.crt_time / 1000 ) ) as oneDay, date( FROM_UNIXTIME( a.crt_time / 1000 ) ) as oneDay,
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
AND AND
b.type = #{orderType} b.type = #{orderType}
<if test="startTime != null"> <if test="startTime != null">
AND a.crt_time <![CDATA[>= ]]> #{startTime} AND a.crt_time <![CDATA[>= ]]> #{startTime}
</if> </if>
<if test="endTime != null"> <if test="endTime != null">
AND a.crt_time &gt; endTime AND a.crt_time &gt; endTime
...@@ -51,4 +52,26 @@ ...@@ -51,4 +52,26 @@
</if> </if>
</select> </select>
<select id="selectOrderAccountByOrderTypeAndStartTimeAndEndTime"
resultType="com.xxfc.platform.order.pojo.account.OrderAccountBo">
SELECT
oa.*,
bo.id,
bo.`status`,
bo.order_origin,
bo.pay_way,
bo.has_pay,
brvd.start_company_id AS `companyId`,
brvd.cost_detail_extend AS `costDetailExtend`,
brvd.damage_safe AS `damageSafe`,
omd.member_level AS `memberLevel`
FROM
`order_account` AS `oa`
LEFT JOIN `base_order` AS `bo` ON bo.id = oa.order_id
LEFT JOIN `order_rent_vehicle_detail` AS `brvd` ON brvd.order_id=oa.order_id
LEFT JOIN `order_member_detail` AS `omd` ON omd.order_id=oa.order_id
WHERE bo.type=#{orderType} AND `oa`.account_status=1 AND oa.`crt_time` BETWEEN #{startTime} AND #{endTime}
</select>
</mapper> </mapper>
\ No newline at end of file
<?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.OrderMemberReceivedStatisticsMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.OrderMemberReceivedStatistics" id="orderMemberReceivedStatisticsMap">
<result property="id" column="id"/>
<result property="year" column="year"/>
<result property="month" column="month"/>
<result property="date" column="date"/>
<result property="weekOfYear" column="week_of_year"/>
<result property="companyName" column="company_name"/>
<result property="extraAmount" column="extra_amount"/>
<result property="lateFeeAmount" column="late_fee_amount"/>
<result property="orderRefundAmount" column="order_refund_amount"/>
<result property="companyName" column="company_name"/>
<result property="totalAmount" column="total_amount"/>
<result property="toalCommonAmmount" column="toal_common_ammount"/>
<result property="totalCommonQuantity" column="total_common_quantity"/>
<result property="totalGoldAmount" column="total_gold_amount"/>
<result property="totalGoldQuantity" column="total_gold_quantity"/>
<result property="totalDiamondAmmount" column="total_diamond_ammount"/>
<result property="totalDiamondQuantity" column="total_diamond_quantity"/>
<result property="orderOrigin" column="order_origin"/>
<result property="hasPay" column="has_pay"/>
<result property="payWay" column="pay_way"/>
<result property="companyId" column="company_id"/>
<result property="crtTime" column="crt_time"/>
</resultMap>
<select id="selectOrderMemberReceivedStatistics" resultMap="orderMemberReceivedStatisticsMap">
select * from `order_member_received_statistics` where 1=1
<if test="orderState!=null">
and `is_finish`=#{orderState}
</if>
<if test="orderOrigin!=null">
and `order_origin`=#{orderOrigin}
</if>
<if test="payWay!=null">
and `pay_way`=#{payWay}
</if>
<if test="startDate!=null and endDate!=null">
and `date` between #{startDate} and #{endDate}
</if>
<if test="startDate!=null and endDate==null">
and <![CDATA[
`date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
and <![CDATA[
`date` <= #{endDate}
]]>
</if>
</select>
<delete id="inserMemberReceivedtList">
</delete>
</mapper>
\ No newline at end of file
<?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.OrderReceivedStatisticsMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.OrderReceivedStatistics" id="orderReceivedStatisticsMap">
<result property="id" column="id"/>
<result property="year" column="year"/>
<result property="month" column="month"/>
<result property="date" column="date"/>
<result property="weekOfYear" column="week_of_year"/>
<result property="breakRulesRegulationAmount" column="break_rules_regulation_amount"/>
<result property="companyName" column="company_name"/>
<result property="depositAmount" column="deposit_amount"/>
<result property="depositRefundAmount" column="deposit_refund_amount"/>
<result property="extraAmount" column="extra_amount"/>
<result property="lateFeeAmount" column="late_fee_amount" />
<result property="lossSpecifiedAmount" column="loss_specified_amount" />
<result property="memberAmount" column="member_amount" />
<result property="travelAmount" column="travel_amount"/>
<result property="rentVehicleAmount" column="rent_vehicle_amount"/>
<result property="noDeductibleAmount" column="no_deductible_amount"/>
<result property="noDeductibleRefundAmount" column="no_deductible_refund_amount"/>
<result property="orderRefundAmount" column="order_refund_amount"/>
<result property="totalAmount" column="total_amount"/>
<result property="totalQuantity" column="total_quantity"/>
<result property="orderOrigin" column="order_origin"/>
<result property="payWay" column="pay_way"/>
<result property="companyId" column="company_id"/>
<result property="crtTime" column="crt_time"/>
</resultMap>
<select id="selectOrderReceivedStatisticsList" resultMap="orderReceivedStatisticsMap">
select * from `order_received_statistics` where 1=1
<if test="orderState!=null">
and `is_finish`=#{orderState}
</if>
<if test="orderOrigin!=null">
and `order_origin`=#{orderOrigin}
</if>
<if test="payWay!=null">
and `pay_way`=#{payWay}
</if>
<if test="startDate!=null and endDate!=null">
and `date` between #{startDate} and #{endDate}
</if>
<if test="startDate!=null and endDate==null">
and <![CDATA[
`date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
and <![CDATA[
`date` <= #{endDate}
]]>
</if>
</select>
<!--按日统计-->
<select id="selectCompanyPerformanceWithDay" resultType="com.xxfc.platform.order.bo.CompanyPerformanceBo">
SELECT
ors.*,
IFNULL(ovss.departureNum,0),
IFNULL(ovss.rentDays,0),
IFNULL(ovss.arrivalNum,0)
FROM
(
SELECT
`company_id` AS `companyId`,
`year`,
`date`,
SUM(`member_amount` ) AS `memberAmount`,
SUM(`travel_amount` ) AS `travelAmount`,
SUM(`rent_vehicle_amount` ) AS `rentVehilceAmount`
FROM
`order_received_statistics`
WHERE 1=1
<if test="companyName!=null and companyName!=''">
AND `company_name` LIKE CONCAT('%',#{companyName},'%')
</if>
<if test="startDate!=null and endDate!=null">
AND `date` BETWEEN #{startDate} AND #{endDate}
</if>
<if test="startDate!=null and endDate==null">
AND <![CDATA[
`date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
AND <![CDATA[
`date` <= #{startDate}
]]>
</if>
GROUP BY
`company_id` ,
`year`,
`date`
) AS `ors`
LEFT JOIN (
SELECT
`company_id` AS `cyid`,
`count_date`,
IFNULL(SUM( `departure_num` ),0) AS `departureNum`,
IFNULL(SUM( `arrival_num` ),0) AS `arrivalNum`,
IFNULL(SUM( `rent_num` ),0) AS `rentDays`
FROM
`order_vehicle_service_statistics`
WHERE 1=1
<if test="startDate!=null and endDate!=null">
AND `count_date` BETWEEN #{startDate} AND #{endDate}
</if>
<if test="startDate!=null and endDate==null">
AND <![CDATA[
`count_date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
AND <![CDATA[
`count_date` <= #{startDate}
]]>
</if>
GROUP BY
`company_id`,
`count_year`,
`count_date`
) AS `ovss` ON ovss.cyid = ors.companyId
AND ovss.count_date = ors.date
</select>
<!--按月统计-->
<select id="selectCompanyPerformanceWithMonth"
resultType="com.xxfc.platform.order.bo.CompanyPerformanceBo">
SELECT
ors.*,
IFNULL(ovss.departureNum,0),
IFNULL(ovss.rentDays,0),
IFNULL(ovss.arrivalNum,0)
FROM
(
SELECT
company_id AS `companyId`,
`year`,
`month`,
COALESCE(SUM(`member_amount` ),0) AS `memberAmount`,
COALESCE(SUM(`travel_amount` ),0) AS `travelAmount`,
COALESCE(SUM(`rent_vehicle_amount` ),0) AS `rentVehilceAmount`
FROM
`order_received_statistics`
WHERE 1=1
<if test="companyName!=null and companyName!=''">
AND `company_name` LIKE CONCAT('%',#{companyName},'%')
</if>
<if test="startDate!=null and endDate!=null">
AND `date` BETWEEN #{startDate} AND #{endDate}
</if>
<if test="startDate!=null and endDate==null">
AND <![CDATA[
`date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
AND <![CDATA[
`date` <= #{startDate}
]]>
</if>
GROUP BY
company_id,
`year`,
`month`
) AS `ors`
LEFT JOIN (
SELECT
`company_id` AS `cyid`,
`count_month`,
COALESCE(SUM( `departure_num` ),0) AS `departureNum`,
COALESCE(SUM( `arrival_num` ),0) AS `arrivalNum`,
COALESCE(SUM( `rent_num` ),0) AS `rentDays`
FROM
`order_vehicle_service_statistics`
WHERE 1=1
<if test="startDate!=null and endDate!=null">
AND `count_date` BETWEEN #{startDate} AND #{endDate}
</if>
<if test="startDate!=null and endDate==null">
AND <![CDATA[
`count_date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
AND <![CDATA[
`count_date` <= #{startDate}
]]>
</if>
GROUP BY
`company_id`,
`count_year`,
`count_month`
) AS `ovss` ON ovss.cyid = ors.companyId
AND ovss.count_month = ors.month
</select>
<!--按周统计-->
<select id="selectCompanyPerformanceWithWeek" resultType="com.xxfc.platform.order.bo.CompanyPerformanceBo">
SELECT
ors.*,
IFNULL(ovss.departureNum,0),
IFNULL(ovss.rentDays,0),
IFNULL(ovss.arrivalNum,0)
FROM
(
SELECT
company_id AS `companyId`,
`year`,
`week_of_year` AS `weekOfYear`,
COALESCE(SUM(`member_amount` ),0) AS `memberAmount`,
COALESCE(SUM(`travel_amount` ),0) AS `travelAmount`,
COALESCE(SUM(`rent_vehicle_amount` ),0) AS `rentVehilceAmount`
FROM
`order_received_statistics`
WHERE 1=1
<if test="companyName!=null and companyName!=''">
AND `company_name` LIKE CONCAT('%',#{companyName},'%')
</if>
<if test="startDate!=null and endDate!=null">
AND `date` BETWEEN #{startDate} AND #{endDate}
</if>
<if test="startDate!=null and endDate==null">
AND <![CDATA[
`date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
AND <![CDATA[
`date` <= #{startDate}
]]>
</if>
GROUP BY
company_id,
`year`,
`week_of_year`
) AS `ors`
LEFT JOIN (
SELECT
`company_id` AS `cyid`,
`count_week`,
IFNULL(SUM( `departure_num` ),0) AS `departureNum`,
IFNULL(SUM( `arrival_num` ),0) AS `arrivalNum`,
IFNULL(SUM( `rent_num` ),0) AS `rentDays`
FROM
`order_vehicle_service_statistics`
WHERE 1=1
<if test="startDate!=null and endDate!=null">
AND `count_date` BETWEEN #{startDate} AND #{endDate}
</if>
<if test="startDate!=null and endDate==null">
AND <![CDATA[
`count_date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
AND <![CDATA[
`count_date` <= #{startDate}
]]>
</if>
GROUP BY
`company_id`,
`count_year`,
`count_week`
) AS `ovss` ON ovss.cyid = ors.companyId
AND ovss.count_week = ors.weekOfYear
</select>
</mapper>
\ No newline at end of file
<?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.OrderRentVehicleReceivedStatisticsMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics" id="orderRentVehicleReceivedStatisticsMap">
<result property="id" column="id"/>
<result property="year" column="year"/>
<result property="month" column="month"/>
<result property="date" column="date"/>
<result property="weekOfYear" column="week_of_year"/>
<result property="totalAmount" column="total_amount"/>
<result property="totalQuantity" column="total_quantity"/>
<result property="hasPay" column="has_pay"/>
<result property="orderOrigin" column="order_origin"/>
<result property="payWay" column="pay_way"/>
<result property="companyId" column="company_id"/>
<result property="crtTime" column="crt_time"/>
</resultMap>
<select id="selectOrderRentVehicleReceivedStatistics" resultMap="orderRentVehicleReceivedStatisticsMap">
select * from `order_rent_vehicle_received_statistics` where 1=1
<if test="orderState!=null">
and `is_finish`=#{orderState}
</if>
<if test="orderOrigin!=null">
and `order_origin`=#{orderOrigin}
</if>
<if test="payWay!=null">
and `pay_way`=#{payWay}
</if>
<if test="startDate!=null and endDate!=null">
and `date` between #{startDate} and #{endDate}
</if>
<if test="startDate!=null and endDate==null">
and <![CDATA[
`date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
and <![CDATA[
`date` <= #{endDate}
]]>
</if>
</select>
</mapper>
\ No newline at end of file
<?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.OrderTourReceivedStatisticsMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.OrderTourReceivedStatistics" id="orderTourReceivedStatisticsMap">
<result property="id" column="id"/>
<result property="year" column="year"/>
<result property="month" column="month"/>
<result property="date" column="date"/>
<result property="weekOfYear" column="week_of_year"/>
<result property="companyName" column="company_name"/>
<result property="extraAmount" column="extra_amount"/>
<result property="lateFeeAmount" column="late_fee_amount"/>
<result property="orderRefundAmount" column="order_refund_amount"/>
<result property="totalAmount" column="total_amount"/>
<result property="totalQuantity" column="total_quantity"/>
<result property="hasPay" column="has_pay"/>
<result property="orderOrigin" column="order_origin"/>
<result property="payWay" column="pay_way"/>
<result property="companyId" column="company_id"/>
<result property="crtTime" column="crt_time"/>
</resultMap>
<select id="selectOrderTourReceivedStatistics" resultMap="orderTourReceivedStatisticsMap">
select * from `order_tour_received_statistics` where 1=1
<if test="orderState!=null">
and `is_finish`=#{orderState}
</if>
<if test="orderOrigin!=null">
and `order_origin`=#{orderOrigin}
</if>
<if test="payWay!=null">
and `pay_way`=#{payWay}
</if>
<if test="startDate!=null and endDate!=null">
and `date` between #{startDate} and #{endDate}
</if>
<if test="startDate!=null and endDate==null">
and <![CDATA[
`date` >= #{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
and <![CDATA[
`date` <= #{endDate}
]]>
</if>
</select>
</mapper>
\ No newline at end of file
<?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.OrderVehicleServiceStatisticsMapper" >
<!--统计车辆服务次数-->
<select id="countVehicleServiceNum" parameterType="Map" resultType="com.xxfc.platform.order.pojo.CountVehicleServiceNumVo">
SELECT tmp1.countYear,tmp1.countMonth,tmp1.countDay, tmp1.companyId, tmp1.countWeek, tmp1.countNum as departureNum, tmp2.countNum as arrivalNum from (
SELECT YEAR(FROM_UNIXTIME(o.crt_time/1000)) as countYear, MONTH(FROM_UNIXTIME(o.crt_time/1000)) AS countMonth, DAY(FROM_UNIXTIME(o.crt_time/1000)) AS countDay, WEEK(FROM_UNIXTIME(o.crt_time/1000))as countWeek, o1.start_company_id as companyId, count(*) as countNum from order_vehicle_crosstown o
LEFT JOIN order_rent_vehicle_detail o1 on o.order_id = o1.order_id
where o.type = 1
<if test="startTime != null">
and o.crt_time &gt;= #{startTime} and o.crt_time &lt;= #{endTime}
</if>
GROUP BY companyId, countYear,countMonth,countDay,countWeek
) tmp1
LEFT JOIN
(SELECT YEAR(FROM_UNIXTIME(o.crt_time/1000)) as countYear, MONTH(FROM_UNIXTIME(o.crt_time/1000)) AS countMonth, DAY(FROM_UNIXTIME(o.crt_time/1000)) AS countDay, WEEK(FROM_UNIXTIME(o.crt_time/1000))as countWeek, o1.end_company_id as companyId, count(*) as countNum from order_vehicle_crosstown o
LEFT JOIN order_rent_vehicle_detail o1 on o.order_id = o1.order_id
where (o.type = 2 or o.type = 3)
<if test="startTime != null">
and o.crt_time &gt;= #{startTime} and o.crt_time &lt;= #{endTime}
</if>
GROUP BY companyId, countYear,countMonth,countDay,countWeek
) tmp2 on tmp1.companyId = tmp2.companyId
</select>
<select id="selectByCompanyIdAndDate" resultType="com.xxfc.platform.order.entity.OrderVehicleServiceStatistics" parameterType="com.xxfc.platform.order.entity.OrderVehicleServiceStatistics">
select * from order_vehicle_service_statistics where company_id = #{companyId} and count_date = #{countDate}
</select>
</mapper>
\ No newline at end of file
import com.xxfc.platform.order.OrderApplication; import com.xxfc.platform.order.OrderApplication;
import com.xxfc.platform.order.biz.DailyOrderStatisticsBiz; import com.xxfc.platform.order.biz.DailyOrderStatisticsBiz;
import com.xxfc.platform.order.biz.OrderStatisticsBiz;
import com.xxfc.platform.order.jobhandler.BaseOrderStatisticsJobHandler; import com.xxfc.platform.order.jobhandler.BaseOrderStatisticsJobHandler;
import com.xxfc.platform.order.pojo.HomePageOrderData;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -13,6 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; ...@@ -13,6 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Map;
/** /**
* @author libin * @author libin
...@@ -33,6 +32,16 @@ public class ServiceTest { ...@@ -33,6 +32,16 @@ public class ServiceTest {
@Autowired @Autowired
private BaseOrderStatisticsJobHandler handler; private BaseOrderStatisticsJobHandler handler;
@Autowired
private OrderMemberReceivedStatisticsBiz orderMemberReceivedStatisticsBiz;
@Autowired
private OrderRentVehicleReceivedStatisticsBiz orderRentVehicleReceivedStatisticsBiz;
@Autowired
private OrderReceivedStatisticsJobHandler orderReceivedStatisticsJobHandler;
@Autowired
private VehicleFeign vehicleFeign;
@Test @Test
public void testSchedu(){ public void testSchedu(){
......
...@@ -139,7 +139,7 @@ public interface VehicleFeign { ...@@ -139,7 +139,7 @@ public interface VehicleFeign {
public RestResponse<List<AccompanyingItemVo>> listAccompanyingItem(); public RestResponse<List<AccompanyingItemVo>> listAccompanyingItem();
@GetMapping("/branchCompany/findByAreaId") @GetMapping("/branchCompany/findByAreaId")
List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId") Integer areaId); List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId",required = false) Integer areaId);
@GetMapping("/branchCompany/company") @GetMapping("/branchCompany/company")
Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(@RequestParam(value = "companyIds") List<Integer> companyIds); Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(@RequestParam(value = "companyIds") List<Integer> companyIds);
...@@ -202,4 +202,6 @@ public interface VehicleFeign { ...@@ -202,4 +202,6 @@ public interface VehicleFeign {
@GetMapping(value = "/bookRecord/get") @GetMapping(value = "/bookRecord/get")
public ObjectRestResponse<List<BookRecordUpdateLog>> get(@RequestParam(value = "bookRecordId")Long bookRecordId); public ObjectRestResponse<List<BookRecordUpdateLog>> get(@RequestParam(value = "bookRecordId")Long bookRecordId);
@GetMapping("/branchCompany/company_info")
Map<Integer, String> findCompanyMap();
} }
...@@ -432,4 +432,13 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -432,4 +432,13 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public Map<Integer, String> selectCompanyMap() {
Example example = new Example(BranchCompany.class);
example.createCriteria().andEqualTo("isDel", 0);
List<BranchCompany> branchCompanies = mapper.selectByExample(example);
if (CollectionUtils.isEmpty(branchCompanies)){
return Collections.EMPTY_MAP;
}
return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId,BranchCompany::getName));
}
} }
...@@ -201,7 +201,7 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -201,7 +201,7 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
} }
@GetMapping("/findByAreaId") @GetMapping("/findByAreaId")
public List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId") Integer areaId){ public List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId",required = false) Integer areaId){
return baseBiz.selectCompanyIdsByAreaId(areaId); return baseBiz.selectCompanyIdsByAreaId(areaId);
} }
...@@ -227,4 +227,9 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -227,4 +227,9 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
return RestResponse.suc(baseBiz.getCompanyIds(dataZone,dataCompany)); return RestResponse.suc(baseBiz.getCompanyIds(dataZone,dataCompany));
} }
@GetMapping("/company_info")
public Map<Integer, String> findCompanyMap(){
return baseBiz.selectCompanyMap();
}
} }
...@@ -62,7 +62,10 @@ ...@@ -62,7 +62,10 @@
</if> </if>
</select> </select>
<select id="findCompanyIdsByAreaId" resultType="integer"> <select id="findCompanyIdsByAreaId" resultType="integer">
select `id` from `branch_company` where `zone_id`=#{areaId} select `id` from `branch_company` where `is_del`=0
<if test="areaId!=null">
and `zone_id`=#{areaId}
</if>
</select> </select>
<select id="findBranchCompanys" resultType="com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO"> <select id="findBranchCompanys" resultType="com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO">
......
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