Browse Source

首页经营数据其他金额细化

zouxuan 3 years ago
parent
commit
6add641e6e

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/IndexBaseMonthData.java

@@ -37,10 +37,20 @@ public class IndexBaseMonthData {
 
 	private String extendInfo;
 
+	private String orderType;
+
 	private Date createTime;
 
 	private Date updateTime;
 
+	public String getOrderType() {
+		return orderType;
+	}
+
+	public void setOrderType(String orderType) {
+		this.orderType = orderType;
+	}
+
 	public String getMonthStr() {
 		return monthStr;
 	}

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/IndexDataType.java

@@ -49,6 +49,7 @@ public enum IndexDataType implements BaseEnum<String, IndexDataType> {
     VIP_AMOUNT("VIP_AMOUNT","VIP课收入", false, false),
     PRACTICE_AMOUNT("PRACTICE_AMOUNT","网管课收入", false, false),
     OTHER_AMOUNT("OTHER_AMOUNT","其他收入", false, false),
+    OTHER_AMOUNT_DETAIL("OTHER_AMOUNT_DETAIL","其他收入明细", false, false),
 
     //业务数据
     HOMEWORK_CREATE_RATE("HOMEWORK_CREATE_RATE","训练布置率", true, true),

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -163,6 +163,18 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			typeDateMap.put(PRACTICE_AMOUNT,practiceAmount);
 			List<IndexBaseMonthData> otherAmount = indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
 			typeDateMap.put(OTHER_AMOUNT,otherAmount);
+			List<IndexBaseMonthData> otherAmountDetails = new ArrayList<>();
+			if(otherAmount != null && otherAmount.size() > 0){
+				Map<String, List<IndexBaseMonthData>> collect = otherAmount.stream().collect(Collectors.groupingBy(e -> e.getOrderType()));
+				collect.keySet().forEach(e->{
+					IndexBaseMonthData data = new IndexBaseMonthData();
+					data.setOrderType(e);
+					BigDecimal reduce = collect.get(e).stream().map(IndexBaseMonthData::getPercent).reduce(BigDecimal.ZERO, BigDecimal::add);
+					data.setPercent(reduce);data.setActivateNum(reduce);data.setTotalNum(reduce);
+					otherAmountDetails.add(data);
+				});
+			}
+			typeDateMap.put(OTHER_AMOUNT_DETAIL,otherAmountDetails);
 		}
 
 		if(CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(MUSIC_GROUP_COURSE.getCode())||dataTypes.contains(VIP_GROUP_COURSE.getCode())

+ 4 - 3
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -16,6 +16,7 @@
 		<result column="percent_" property="percent" />
 		<result column="data_type_" property="dataType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 		<result column="extend_info_" property="extendInfo"/>
+		<result column="order_type_" property="orderType"/>
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 	</resultMap>
@@ -1440,10 +1441,10 @@
 	</select>
 
 	<select id="getOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
-		SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_ FROM (
+		SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_,c.type_ FROM (
 		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 							   CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
-		   ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		   ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 		AND spo.type_ NOT IN ('APPLY','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
@@ -1455,7 +1456,7 @@
 		</if>
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 		UNION ALL
-		SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
 		FROM student_payment_order spo
 			   LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}