Browse Source

Merge branch 'saas' of http://git.dayaedu.com/yonge/mec into saas_export

 Conflicts:
	mec-biz/src/main/java/com/ym/mec/biz/service/ExportFunction.java
zouxuan 3 years ago
parent
commit
1dc033609a

+ 26 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java

@@ -314,14 +314,26 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
                                                          @Param("endDate") String endDate,
                                                          @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
 
+    List<IndexBaseMonthData> getOrganFinancePayDataWithTimely(@Param("startDate") String startDate,
+                                                         @Param("endDate") String endDate,
+                                                         @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
+
     List<IndexBaseMonthData> getFinanceBalanceDataWithTimely(@Param("startDate") String startDate,
                                                              @Param("endDate") String endDate,
                                                              @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
 
+    List<IndexBaseMonthData> getOrganFinanceBalanceDataWithTimely(@Param("startDate") String startDate,
+                                                             @Param("endDate") String endDate,
+                                                             @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
+
     List<IndexBaseMonthData> getFinanceActualDataWithTimely(@Param("startDate") String startDate,
                                                             @Param("endDate") String endDate,
                                                             @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
 
+    List<IndexBaseMonthData> getOrganFinanceActualDataWithTimely(@Param("startDate") String startDate,
+                                                            @Param("endDate") String endDate,
+                                                            @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
+
     /**
      * @describe 各分部教师服务指标异常
      * @author Joburgess
@@ -334,20 +346,34 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
     List<IndexBaseMonthData> getTotalAmountDataWithTimely(@Param("startDate") String startDate,
                                                             @Param("endDate") String endDate,
                                                             @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
+    List<IndexBaseMonthData> getOrganTotalAmountDataWithTimely(@Param("startDate") String startDate,
+                                                            @Param("endDate") String endDate,
+                                                            @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
 
     List<IndexBaseMonthData> getTotalAmountDataWithTimelyDetails(@Param("startDate") String startDate,
                                                                  @Param("endDate") String endDate,
                                                                  @Param("organIds") List<Integer> organIds,
                                                                  @Param("orderType") String orderType,
                                                                  @Param("notOrderType") List<String> notOrderType,@Param("tenantId") Integer tenantId);
+    List<IndexBaseMonthData> getOrganTotalAmountDataWithTimelyDetails(@Param("startDate") String startDate,
+                                                                 @Param("endDate") String endDate,
+                                                                 @Param("organIds") List<Integer> organIds,
+                                                                 @Param("orderType") String orderType,
+                                                                 @Param("notOrderType") List<String> notOrderType,@Param("tenantId") Integer tenantId);
 
     List<IndexBaseMonthData> getVipAmountDataWithTimelyDetails(@Param("startDate") String startDate,
                                                                  @Param("endDate") String endDate,
                                                                  @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
+    List<IndexBaseMonthData> getOrganVipAmountDataWithTimelyDetails(@Param("startDate") String startDate,
+                                                                 @Param("endDate") String endDate,
+                                                                 @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
 
     List<IndexBaseMonthData> getOtherAmountDataWithTimelyDetails(@Param("startDate") String startDate,
                                                                  @Param("endDate") String endDate,
                                                                  @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
+    List<IndexBaseMonthData> getOrganOtherAmountDataWithTimelyDetails(@Param("startDate") String startDate,
+                                                                 @Param("endDate") String endDate,
+                                                                 @Param("organIds") List<Integer> organIds,@Param("tenantId") Integer tenantId);
 
     int countStudentErrorLeave(@Param("organIdList") Set<Integer> organIdList,
                                @Param("format") String format,

+ 3 - 12
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexBaseDto.java

@@ -26,16 +26,6 @@ public class IndexBaseDto {
 
     private List<IndexBaseMonthData> indexMonthDataDetail;
 
-    private List<IndexBaseMonthData> organIndexMonthData;
-
-    public List<IndexBaseMonthData> getOrganIndexMonthData() {
-        return organIndexMonthData;
-    }
-
-    public void setOrganIndexMonthData(List<IndexBaseMonthData> organIndexMonthData) {
-        this.organIndexMonthData = organIndexMonthData;
-    }
-
     public List<IndexBaseMonthData> getIndexMonthDataDetail() {
         return indexMonthDataDetail;
     }
@@ -62,8 +52,9 @@ public class IndexBaseDto {
         this.indexMonthData = indexMonthData;
     }
 
-    public IndexBaseDto(String title, BigDecimal percent, List<IndexBaseMonthData> indexMonthData) {
-        this.title = title;
+    public IndexBaseDto(IndexDataType dataType, BigDecimal percent, List<IndexBaseMonthData> indexMonthData) {
+        this.title = dataType.getMsg();
+        this.dataType = dataType;
         this.percent = percent;
         this.indexMonthData = indexMonthData;
     }

+ 14 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/IndexDataType.java

@@ -36,12 +36,11 @@ public enum IndexDataType implements BaseEnum<String, IndexDataType> {
     OVER_VIP_COURSE_NUM("OVER_VIP_COURSE_NUM", "已消耗VIP课时", false, false),
     OVER_PRACTICE_COURSE_NUM("OVER_PRACTICE_COURSE_NUM", "已消耗网管课时", false, false),
 
-    //经营数据
+    //经营数据(按天汇总)
     FINANCE_PAY("FINANCE_PAY","财务支出", false, false),
     FINANCE_BALANCE_AMOUNT("FINANCE_BALANCE_AMOUNT","余额收入", false, false),
     FINANCE_AMOUNT("FINANCE_AMOUNT","现金收入", false, false),
     TOTAL_AMOUNT("TOTAL_AMOUNT","总收入", false, false),
-
     //经营数据详情
     APPLY_AMOUNT("APPLY_AMOUNT","报名缴费收入", false, false),
     RENEW_AMOUNT("RENEW_AMOUNT","乐团续费收入", false, false),
@@ -50,6 +49,19 @@ public enum IndexDataType implements BaseEnum<String, IndexDataType> {
     OTHER_AMOUNT("OTHER_AMOUNT","其他收入", false, false),
     OTHER_AMOUNT_DETAIL("OTHER_AMOUNT_DETAIL","其他收入明细", false, false),
 
+    //经营数据(按分部汇总)
+    ORGAN_FINANCE_PAY("ORGAN_FINANCE_PAY","财务支出", false, false),
+    ORGAN_FINANCE_BALANCE_AMOUNT("ORGAN_FINANCE_BALANCE_AMOUNT","余额收入", false, false),
+    ORGAN_FINANCE_AMOUNT("ORGAN_FINANCE_AMOUNT","现金收入", false, false),
+    ORGAN_TOTAL_AMOUNT("ORGAN_TOTAL_AMOUNT","总收入", false, false),
+    //经营数据详情
+    ORGAN_APPLY_AMOUNT("ORGAN_APPLY_AMOUNT","报名缴费收入", false, false),
+    ORGAN_RENEW_AMOUNT("ORGAN_RENEW_AMOUNT","乐团续费收入", false, false),
+    ORGAN_VIP_AMOUNT("ORGAN_VIP_AMOUNT","VIP课收入", false, false),
+    ORGAN_PRACTICE_AMOUNT("ORGAN_PRACTICE_AMOUNT","网管课收入", false, false),
+    ORGAN_OTHER_AMOUNT("ORGAN_OTHER_AMOUNT","其他收入", false, false),
+    ORGAN_OTHER_AMOUNT_DETAIL("ORGAN_OTHER_AMOUNT_DETAIL","其他收入明细", false, false),
+
     //业务数据
     HOMEWORK_CREATE_RATE("HOMEWORK_CREATE_RATE","训练布置率", true, true),
     HOMEWORK_SUBMIT_RATE("HOMEWORK_SUBMIT_RATE","训练提交率", true, true),

+ 0 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/ExportFunction.java

@@ -1,7 +0,0 @@
-package com.ym.mec.biz.service;
-
-@FunctionalInterface
-public interface ExportFunction<R> {
-
-    void exportManagerDownload(R r);
-}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SingleReturnFunction.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.service;
+
+@FunctionalInterface
+public interface SingleReturnFunction<R> {
+
+    //单返回值函数
+    R get();
+}

+ 38 - 19
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -29,7 +29,6 @@ import java.time.DayOfWeek;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.enums.IndexDataType.*;
@@ -77,6 +76,15 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		return indexBaseMonthDataDao;
 	}
 
+	public IndexBaseDto getIndexBaseDto(IndexDataType indexDataType,List<IndexBaseMonthData> indexBaseMonthData) {
+		BigDecimal reduce = indexBaseMonthData.stream().map(e -> e.getPercent()).reduce(BigDecimal.ZERO, BigDecimal::add);
+		indexBaseMonthData.stream().forEach(e -> {
+			e.setDataType(indexDataType);
+			e.setTitle(indexDataType.getMsg());
+		});
+		return new IndexBaseDto(indexDataType,reduce,indexBaseMonthData);
+	}
+
 	@Override
 	public List<IndexBaseDto> getIndexBaseData(IndexDataQueryInfo queryInfo) {
 		List<IndexBaseDto> result = new ArrayList<>();
@@ -142,6 +150,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 
 		Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().filter(d->Objects.nonNull(d.getDataType())).collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
 
+		//按天汇总
 		if((CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(FINANCE_PAY.getCode())||dataTypes.contains(FINANCE_BALANCE_AMOUNT.getCode())||dataTypes.contains(FINANCE_AMOUNT.getCode())) && organIds != null){
 			List<IndexBaseMonthData> financePayDataWithTimely = indexBaseMonthDataDao.getFinancePayDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),queryInfo.getTenantId());
 			typeDateMap.put(IndexDataType.FINANCE_PAY,financePayDataWithTimely);
@@ -161,6 +170,29 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			List<IndexBaseMonthData> otherAmount = indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),queryInfo.getTenantId());
 			typeDateMap.put(OTHER_AMOUNT,otherAmount);
 		}
+		//按分部汇总
+		List<IndexBaseDto> indexBaseDtoList = new ArrayList<>();
+		if((CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(ORGAN_FINANCE_PAY.getCode())||dataTypes.contains(ORGAN_FINANCE_BALANCE_AMOUNT.getCode())||
+				dataTypes.contains(ORGAN_FINANCE_AMOUNT.getCode())) && organIds != null){
+			List<IndexBaseMonthData> financePayDataWithTimely = indexBaseMonthDataDao.getOrganFinancePayDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),queryInfo.getTenantId());
+			indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_FINANCE_PAY,financePayDataWithTimely));
+
+			indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceBalanceDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),queryInfo.getTenantId())));
+			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_FINANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceActualDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),queryInfo.getTenantId())));
+			List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),queryInfo.getTenantId());
+			indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_TOTAL_AMOUNT,totalAmountDataWithTimely));
+			//经营报表细化
+			List<IndexBaseMonthData> applyAmount = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),"APPLY,ADD_STUDENT",null,queryInfo.getTenantId());
+			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_APPLY_AMOUNT,applyAmount));
+			List<IndexBaseMonthData> renewAmount = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),"RENEW",null,queryInfo.getTenantId());
+			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_RENEW_AMOUNT,renewAmount));
+			List<IndexBaseMonthData> vipAmount = indexBaseMonthDataDao.getOrganVipAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),queryInfo.getTenantId());
+			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_VIP_AMOUNT,vipAmount));
+			List<IndexBaseMonthData> practiceAmount = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),"PRACTICE_GROUP_BUY,PRACTICE_GROUP_RENEW",null,queryInfo.getTenantId());
+			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_PRACTICE_AMOUNT,practiceAmount));
+			List<IndexBaseMonthData> otherAmount = indexBaseMonthDataDao.getOrganOtherAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),queryInfo.getTenantId());
+			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_OTHER_AMOUNT,otherAmount));
+		}
 
 		if(CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(MUSIC_GROUP_COURSE.getCode())||dataTypes.contains(VIP_GROUP_COURSE.getCode())
 				||dataTypes.contains(VIP_GROUP_ONLINE_COURSE.getCode())||dataTypes.contains(VIP_GROUP_OFFLINE_COURSE.getCode())
@@ -225,6 +257,9 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			if(typeDateMap.containsKey(dataType)||(!CollectionUtils.isEmpty(dataTypes)&&!dataTypes.contains(dataType.getCode()))){
 				continue;
 			}
+			if(dataType.equals(ORGAN_FINANCE_AMOUNT)){
+				continue;
+			}
 
 			IndexBaseMonthData indexBaseMonthData = new IndexBaseMonthData();
 			indexBaseMonthData.setMonth(Date.from(endDate.atStartOfDay(DateUtil.zoneId).toInstant()));
@@ -243,7 +278,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 
 		for (Map.Entry<IndexDataType, List<IndexBaseMonthData>> typeDateMapEntry : typeDateMap.entrySet()) {
 			List<IndexBaseMonthData> value = typeDateMapEntry.getValue();
-			Set<String> hasMonths = value.stream().map(d -> DateUtil.dateToString(d.getMonth(), "yyyy-MM-dd")).collect(Collectors.toSet());
+			Set<String> hasMonths = value.stream().filter(e->e.getMonth() != null).map(d -> DateUtil.dateToString(d.getMonth(), "yyyy-MM-dd")).collect(Collectors.toSet());
 			LocalDate currentMonthDate = startDate;
 			while (currentMonthDate.compareTo(endDate)<=0){
 				if((IndexDataType.HOMEWORK_CREATE_RATE.equals(typeDateMapEntry.getKey())
@@ -300,7 +335,6 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 					VIP_AMOUNT.equals(typeDateMapEntry.getKey()) ||
 					PRACTICE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
 					OTHER_AMOUNT.equals(typeDateMapEntry.getKey())){
-				indexBaseData.setOrganIndexMonthData(this.getOrganIndexMonthData(value,typeDateMapEntry.getKey()));
 				indexBaseData.setPercent(value.stream().map(IndexBaseMonthData::getPercent).reduce(BigDecimal.ZERO, BigDecimal::add));
 			}
 			if(IndexDataType.VIP_GROUP_COURSE.equals(typeDateMapEntry.getKey()) || VIP_GROUP_ONLINE_COURSE.equals(typeDateMapEntry.getKey()) ||
@@ -323,25 +357,10 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			}
 			result.add(indexBaseData);
 		}
+		result.addAll(indexBaseDtoList);
 		return result;
 	}
 
-	public List<IndexBaseMonthData> getOrganIndexMonthData(List<IndexBaseMonthData> organIndexMonthData,IndexDataType indexDataType) {
-		if (!CollectionUtils.isEmpty(organIndexMonthData)){
-			List<IndexBaseMonthData> collect = organIndexMonthData.stream().filter(e -> e.getOrganId() != null && e.getOrganId() != 0).collect(Collectors.toList());
-			if(!CollectionUtils.isEmpty(collect)){
-				Map<Integer, List<IndexBaseMonthData>> listMap = collect.stream().collect(Collectors.groupingBy(IndexBaseMonthData::getOrganId));
-				Set<Integer> organIds = listMap.keySet();
-				Map<Integer, String> organMap = organizationService.getMap("organization", "id_", "name_",
-						organIds, TenantContextHolder.getTenantId(), Integer.class, String.class);
-				Function<Integer,IndexBaseMonthData> fun = (organId) -> new IndexBaseMonthData(organId,organMap.get(organId),indexDataType,
-						listMap.get(organId).stream().map(e->e.getPercent()).reduce(BigDecimal.ZERO,BigDecimal::add));
-				return organIds.stream().map(fun::apply).collect(Collectors.toList());
-			}
-		}
-		return new ArrayList<>();
-	}
-
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void indexBaseDataTask(Integer tenantId, String dayStr, Set<IndexDataType> dataTypes) {

+ 15 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -1,7 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -314,7 +313,9 @@ public class PayServiceImpl implements PayService {
 									}
 									subBalance = subBalance.add(tempBalance);
 								}
-								tempCashAmount = spod.getPrice().subtract(tempBalance).multiply(groupPurchaseAmount).divide(totalGroupPurchaseAmount, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+								// tempCashAmount = spod.getPrice().subtract(tempBalance).multiply(groupPurchaseAmount).divide(totalGroupPurchaseAmount, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+								tempCashAmount = amount.multiply(spod.getPrice()).multiply(groupPurchaseAmount)
+										.divide(totalGroupPurchaseAmount.multiply(totalAmout), BigDecimal.ROUND_UP).setScale(2, BigDecimal.ROUND_UP);
 								if(subCashAmount.add(tempCashAmount).compareTo(amount) > 0){
 									tempCashAmount = amount.subtract(subCashAmount);
 								}
@@ -359,8 +360,10 @@ public class PayServiceImpl implements PayService {
 
     	            routeScaleDtoForGoodsSell = new RouteScaleDto();
     	            routeScaleDtoForGoodsSell.setAmount(subCashAmount);
+    	            routeScaleDtoForGoodsSell.setBalance(subBalance);
     	            routeScaleDtoForGoodsSell.setOrganId(sysPaymentConfig.getOrganId());
     	            routeScaleDtoForGoodsSell.setPayType(PaymentChannelEnum.ADAPAY);
+    	            routeScaleDtoForGoodsSell.setFeeType(FeeTypeEnum.SERVICE);
     	            routeScaleDtoForGoodsSell.setScale(100);
     	            routeScaleDtoForGoodsSell.setMerNo(goodsSellReceiptMerNo);
     	            routeScaleDtoForGoodsSell.setFeeFlag("Y");
@@ -409,15 +412,19 @@ public class PayServiceImpl implements PayService {
             checkMaxReceipt(routeScaleDto, routeScaleDto.getMerNo());
         }
         
-        if(routeScaleDtoForGoodsSell != null){
+        /*if(routeScaleDtoForGoodsSell != null){
         	routeScaleDtos.add(routeScaleDtoForGoodsSell);
-        }
+        }*/
         
         Map<String, Object> map = getPayRoute(amount, balanceAmount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routeScaleDtos, subCashAmount);
         
 		if (routeScaleDtoForGoodsSell != null) {
 			String routingMerNos = (String) map.get("routingMerNos");
-			List<String> list = new ArrayList<String>(Arrays.asList(routingMerNos.split(",")));
+			
+			List<String> list = new ArrayList<String>();
+			if(StringUtils.isNotBlank(routingMerNos)){
+				list = new ArrayList<String>(Arrays.asList(routingMerNos.split(",")));
+			}
 			if(!list.contains(routeScaleDtoForGoodsSell.getMerNo())){
 				list.add(routeScaleDtoForGoodsSell.getMerNo());
 			}
@@ -745,7 +752,7 @@ public class PayServiceImpl implements PayService {
                 routingMoney = amount.subtract(hasRouteMoney).setScale(2, BigDecimal.ROUND_HALF_UP);
             }
 
-            if (routingFee.compareTo(BigDecimal.ZERO) <= 0) {
+            if (routingMoney.compareTo(BigDecimal.ZERO) <= 0 && routeBalanceAmount.compareTo(BigDecimal.ZERO) <= 0) {
                 continue;
             }
 
@@ -868,10 +875,10 @@ public class PayServiceImpl implements PayService {
                 routeScaleDto.setSaleAmount(routingMoney);
             }
 
-            if (routeScaleDto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
+            /*if (routeScaleDto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
                 iterator.remove();
                 continue;
-            }
+            }*/
 
             for (SysPaymentConfig paymentConfigByOrganId : paymentConfigByOrganIds) {
                 if (!paymentConfigByOrganId.getOrganId().equals(routeScaleDto.getOrganId())) continue;

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -17,7 +17,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.dao.GoodsDao;
 import com.ym.mec.biz.dal.dao.MusicGroupDao;
 import com.ym.mec.biz.dal.dao.SellOrderDao;
@@ -31,7 +30,6 @@ import com.ym.mec.biz.dal.entity.SellOrder;
 import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
-import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.entity.SysUserCashAccountLog;
 import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.dal.enums.GoodsType;
@@ -575,11 +573,14 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             	detailTotalBalance = cloudBalanceIncome;
             }
             
-            if(detailTotalPrice.subtract(detailTotalBalance).subtract(cloudIncome).compareTo(BigDecimal.ZERO) < 0){
-            	sellAmount.put("actualAmount", BigDecimal.ZERO);
-            }else{
-            	sellAmount.put("actualAmount", detailTotalPrice.subtract(detailTotalBalance).subtract(cloudIncome));
+            BigDecimal actualAmount = detailTotalPrice.multiply(order.getActualAmount()).divide(totalPrice, 2, BigDecimal.ROUND_DOWN);
+            
+            if(actualAmount.subtract(cloudIncome).compareTo(BigDecimal.ZERO) < 0){
+            	actualAmount = cloudIncome;
             }
+            
+            //返回销售收入
+        	sellAmount.put("actualAmount", actualAmount.subtract(cloudIncome));
             sellAmount.put("balance", detailTotalBalance.subtract(cloudBalanceIncome));
             return sellAmount;
         }

+ 8 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -408,7 +408,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 	                }
 	                studentPaymentOrderDetail.setGoodsIdList(goodsIdStr);
 	                
-	                BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+	                BigDecimal tempPrice = BigDecimal.ZERO;
+	                if(totalGroupPurchasePrice.compareTo(BigDecimal.ZERO) > 0) {
+	                	tempPrice = studentPaymentOrder.getExpectAmount().multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+	                }
 	                
 	                if(totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0 || goodsIdsStr.split(",").length == studentPaymentOrderDetailList.size() + 1){
 	                	studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));
@@ -742,7 +745,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 	                }
 	                studentPaymentOrderDetail.setGoodsIdList(goodsIdStr);
 	                
-	                BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().subtract(repairPrice).multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+	                BigDecimal tempPrice = BigDecimal.ZERO;
+	                if(totalGroupPurchasePrice.compareTo(BigDecimal.ZERO) > 0) {
+	                	tempPrice = studentPaymentOrder.getExpectAmount().subtract(repairPrice).multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
+	                }
 	                
 	                if(totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0 || goodsIds.split(",").length == studentPaymentOrderDetailList.size()){
 	                	studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));

+ 152 - 0
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -11,6 +11,7 @@
 		<result column="month_" property="month" />
 		<result column="month_" property="monthStr" />
 		<result column="organ_id_" property="organId" />
+		<result column="organ_name_" property="organName" />
 		<result column="total_num_" property="totalNum" />
 		<result column="activate_num_" property="activateNum" />
 		<result column="percent_" property="percent" />
@@ -1342,6 +1343,21 @@
 			</if>
 		GROUP BY DATE_FORMAT(fe.create_time_,'%Y-%m-%d')
 	</select>
+
+	<select id="getOrganFinancePayDataWithTimely"  resultMap="IndexBaseMonthData">
+		SELECT SUM(fe.amount_) percent_,o.id_ organ_id_,o.name_ organ_name_
+		FROM organization o
+		LEFT JOIN financial_expenditure fe ON o.id_ = fe.organ_id_ AND fe.tenant_id_ = o.tenant_id_
+		AND DATE_FORMAT(fe.create_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} AND fe.del_flag_ = 0
+		<if test="organIds!=null and organIds.size()>0">
+			AND fe.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		WHERE o.tenant_id_ = #{tenantId}
+		GROUP BY o.id_ ORDER BY percent_ DESC
+	</select>
 	<select id="getFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
 		SELECT spo.organ_id_,SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
 			   SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
@@ -1356,6 +1372,21 @@
 		</if>
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 	</select>
+	<select id="getOrganFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
+		SELECT SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,
+		o.id_ organ_id_,o.name_ organ_name_
+		FROM organization o
+		LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
+		AND spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		<if test="organIds!=null and organIds.size() > 0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		WHERE o.tenant_id_ = #{tenantId}
+		GROUP BY o.id_ ORDER BY percent_ DESC
+	</select>
 	<select id="getFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
 		SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
 			   SUM(spo.actual_amount_) activate_num_,
@@ -1370,6 +1401,20 @@
 		</if>
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 	</select>
+	<select id="getOrganFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
+		SELECT SUM(spo.actual_amount_) percent_,o.id_ organ_id_,o.name_ organ_name_
+		FROM organization o
+		LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
+		AND spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		WHERE o.tenant_id_ = #{tenantId}
+		GROUP BY o.id_ ORDER BY percent_ DESC
+	</select>
 	<select id="getTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
 		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_,
@@ -1387,6 +1432,22 @@
 		</if>
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 	</select>
+	<select id="getOrganTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
+		SELECT 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) percent_,
+		    			   o.id_ organ_id_,o.name_ organ_name_
+		FROM organization o
+		LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
+		AND spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		WHERE o.tenant_id_ = #{tenantId}
+		GROUP BY o.id_ ORDER BY percent_ DESC
+	</select>
 	<select id="getTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
 		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_,
@@ -1414,6 +1475,32 @@
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 	</select>
 
+	<select id="getOrganTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
+		SELECT 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) percent_,
+		    			   o.id_ organ_id_,o.name_ organ_name_
+		FROM organization o
+		LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
+		AND spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		<if test="orderType != null">
+			AND FIND_IN_SET(spo.type_,#{orderType})
+		</if>
+		<if test="notOrderType != null">
+			AND spo.type_ NOT IN
+			<foreach collection="notOrderType" open="(" close=")" item="item" separator=",">
+				#{item}
+			</foreach>
+		</if>
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		WHERE o.tenant_id_ = #{tenantId}
+		GROUP BY o.id_ ORDER BY percent_ DESC
+	</select>
+
 	<select id="getVipAmountDataWithTimelyDetails" 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 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_
@@ -1445,6 +1532,38 @@
 		)c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d')
 	</select>
 
+	<select id="getOrganVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
+		SELECT o.id_ organ_id_,o.name_ organ_name_,SUM(c.total_num_) percent_ FROM organization o
+		LEFT JOIN (SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_
+		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} and spo.tenant_id_ = #{tenantId}
+		AND spo.type_ = 'DEGREE' AND spod.type_ IN ('THEORY_COURSE','VIP')
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY spo.organ_id_
+		UNION ALL
+		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_
+		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_ = 'SMALL_CLASS_TO_BUY'
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY spo.organ_id_
+		)c ON c.organ_id_ = o.id_
+		WHERE o.tenant_id_ = #{tenantId}
+		GROUP BY o.id_ ORDER BY percent_ DESC
+	</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_,c.type_ order_type_ FROM (
 		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
@@ -1476,6 +1595,39 @@
 		)c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d'),c.type_
 	</select>
 
+	<select id="getOrganOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
+		SELECT o.id_ organ_id_,o.name_ organ_name_,SUM(c.total_num_) percent_ FROM organization o
+		LEFT JOIN (
+		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_,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.tenant_id_ = #{tenantId}
+		AND spo.type_ NOT IN ('APPLY','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY spo.organ_id_,spo.type_
+		UNION ALL
+		SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,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}
+		AND spo.type_ = 'DEGREE' AND spod.type_ = 'DEGREE_REGISTRATION'
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY spo.organ_id_,spo.type_
+		)c ON c.organ_id_ = o.id_
+		WHERE o.tenant_id_ = #{tenantId}
+		GROUP BY o.id_ ORDER BY percent_ DESC
+	</select>
+
 	<sql id="queryTeacherServeInfoCondition">
 		<where>
 			 sees.tenant_id_ = #{tenantId}