Jelajahi Sumber

Merge branch 'feature/0703' into master_saas

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java
#	mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml
yuanliang 2 tahun lalu
induk
melakukan
6ecdc92006

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/VipGroupBuyParamsDto.java

@@ -34,5 +34,5 @@ public class VipGroupBuyParamsDto extends BaseEntity {
     private Integer userId;
 
     @ApiModelProperty(value = "是否继续支付")
-    private Boolean continuePay;
+    private Boolean continuePay = false;
 }

+ 92 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/AppVersionInfoBak.java

@@ -3,12 +3,14 @@ package com.ym.mec.biz.dal.entity;
 import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
+import java.util.Date;
+
 /**
  * 对应数据库表(app_version_info):
  */
-@Data
 public class AppVersionInfoBak {
 
+	/**  */
 	private Integer id;
 
 	/** 平台(andorid/ios) */
@@ -37,7 +39,95 @@ public class AppVersionInfoBak {
 
 	/**  */
 	private java.util.Date createTime;
-			
+
+	public boolean isForceUpdate() {
+		return isForceUpdate;
+	}
+
+	public void setForceUpdate(boolean forceUpdate) {
+		isForceUpdate = forceUpdate;
+	}
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+
+	public Integer getId(){
+		return this.id;
+	}
+
+	public void setPlatform(String platform){
+		this.platform = platform;
+	}
+
+	public String getPlatform(){
+		return this.platform;
+	}
+
+	public void setVersion(String version){
+		this.version = version;
+	}
+
+	public String getVersion(){
+		return this.version;
+	}
+
+	public void setStatus(String status){
+		this.status = status;
+	}
+
+	public String getStatus(){
+		return this.status;
+	}
+
+	public void setIsForceUpdate(boolean isForceUpdate){
+		this.isForceUpdate = isForceUpdate;
+	}
+
+	public boolean getIsForceUpdate(){
+		return this.isForceUpdate;
+	}
+
+	public void setDescription(String description){
+		this.description = description;
+	}
+
+	public String getDescription(){
+		return this.description;
+	}
+
+	public void setDownloadUrl(String downloadUrl){
+		this.downloadUrl = downloadUrl;
+	}
+
+	public String getDownloadUrl(){
+		return this.downloadUrl;
+	}
+
+	public void setOperatorId(Integer operatorId){
+		this.operatorId = operatorId;
+	}
+
+	public Integer getOperatorId(){
+		return this.operatorId;
+	}
+
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/IndexBaseMonthDataService.java

@@ -23,6 +23,7 @@ public interface IndexBaseMonthDataService extends BaseService<Long, IndexBaseMo
 
     List<DecimalMapDto> indexCoop(String organId, String startTime, String endTime);
 
+
     void indexBaseDataTask(Integer tenantId, String month, Set<IndexDataType> dataTypes);
 
     Map<String, Object> getIndexErrData(String organId, IndexErrorType errorType);

+ 6 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -930,8 +930,8 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         exportTeacherSalaryDtos.addAll(courseScheduleTeacherSalaryDao.exportMusicTeacherSalary(params));
         //vip课
         List<ExportTeacherSalaryDto> exportVipTeacherSalaryDtos = courseScheduleTeacherSalaryDao.exportVipTeacherSalary(params);
-        //获取有奖励的vip课  .collect(Collectors.toMap(Group::getId, group -> group));
-        List<TaskRewardsRulesDto> rewardsRulesDtos = courseScheduleRewardsRulesService.queryVipGroupTeacherClassTimesByMonth(month);
+        //获取有奖励的vip课
+        /*List<TaskRewardsRulesDto> rewardsRulesDtos = courseScheduleRewardsRulesService.queryVipGroupTeacherClassTimesByMonth(month);
         Map<Integer,Double> rewardMap = new HashMap<>(1000);
         Map<Integer,String> rewardNameMap = new HashMap<>(1000);
         if(rewardsRulesDtos != null && rewardsRulesDtos.size() > 0){
@@ -1013,7 +1013,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         exportVipTeacherSalaryDtos.forEach(e->{
             e.setRewards(rewardMap.get(e.getCourseScheduleId()));
             e.setActiveName(rewardNameMap.get(e.getCourseScheduleId()));
-        });
+        });*/
         exportTeacherSalaryDtos.addAll(exportVipTeacherSalaryDtos);
         //vip课(梯度课酬)
         //陪练课
@@ -1021,10 +1021,12 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 
         Set<Long> allCourseIds = exportTeacherSalaryDtos.stream().map(ExportTeacherSalaryDto::getCourseScheduleId).collect(Collectors.toSet());
         Map<Long, BigDecimal> courseIncomeMap = new HashMap<>();
+        Map<Long, Integer> courseStudentNumMap = new HashMap<>();
         if(!CollectionUtils.isEmpty(allCourseIds)){
             List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseScheduleIds(new ArrayList<>(allCourseIds));
             if(!CollectionUtils.isEmpty(courseScheduleStudentPayments)){
                 courseIncomeMap = courseScheduleStudentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getCourseScheduleId, Collectors.mapping(CourseScheduleStudentPayment::getActualPrice, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
+                courseStudentNumMap = courseScheduleStudentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getCourseScheduleId,Collectors.collectingAndThen(Collectors.toList(),v->v.size())));
             }
         }
 //        Map<Long,BigDecimal> courseCast = MapUtil.convertIntegerMap(cloudTeacherFreeCourseDao.queryMapByClassDate(month));
@@ -1037,6 +1039,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
             }else{
                 exportTeacherSalaryDto.setCourseIncome(courseIncomeMap.get(exportTeacherSalaryDto.getCourseScheduleId()));
             }
+            exportTeacherSalaryDto.setStudentNum(courseStudentNumMap.getOrDefault(exportTeacherSalaryDto.getCourseScheduleId(),0));
         }
 
         exportTeacherSalaryDtos.sort(Comparator.comparing(ExportTeacherSalaryDto::getTeacherId));

+ 130 - 56
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -22,6 +22,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+import com.ym.mec.util.web.EParallelStream;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -36,6 +37,7 @@ import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.enums.IndexDataType.*;
@@ -82,14 +84,6 @@ 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) {
@@ -121,7 +115,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		}
 
 		String startDate1 = startDate.toString() + " 00:00:00";
-		String endDate1 = endDate + " 23:59:59";
+		String endDate1 = endDate.toString() + " 23:59:59";;
 		List<Integer> arrayList = null;
 		if(!CollectionUtils.isEmpty(organIds)){
 			arrayList = new ArrayList<>(organIds);
@@ -356,6 +350,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 				result.add(indexBaseData);
 			}
 		}
+		System.out.println(System.currentTimeMillis());
 		return result;
 	}
 
@@ -385,55 +380,122 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		return decimalMapDtos1.stream().sorted(Comparator.comparing(DecimalMapDto::getAmount).reversed()).collect(Collectors.toList());
     }
 
+	public IndexBaseDto getIndexBaseDto(IndexDataType indexDataType, List<IndexBaseMonthData> renew, List<Organization> organs) {
+		// 将 renew 转换为 Map,以组织 ID 为键,IndexBaseMonthData 为值
+		Map<Integer, IndexBaseMonthData> renewMap = renew.stream()
+				.collect(Collectors.toMap(IndexBaseMonthData::getOrganId, Function.identity()));
+		BigDecimal reduce = renew.stream().map(e -> e.getPercent()).reduce(BigDecimal.ZERO, BigDecimal::add);
+		// 遍历 organs,根据组织 ID 获取对应的 IndexBaseMonthData,并进行处理
+		for (Organization organ : organs) {
+			IndexBaseMonthData indexBaseMonthData = renewMap.get(organ.getId());
+			if (indexBaseMonthData == null) {
+				indexBaseMonthData = new IndexBaseMonthData();
+				indexBaseMonthData.setOrganId(organ.getId());
+				renew.add(indexBaseMonthData);  // 将新的 IndexBaseMonthData 对象添加到 renew 集合中
+			}
+			indexBaseMonthData.setOrganName(organ.getName());
+			indexBaseMonthData.setDataType(indexDataType);
+			indexBaseMonthData.setTitle(indexDataType.getMsg());
+		}
+		return new IndexBaseDto(indexDataType,reduce,renew);
+	}
+
     //异步处理经营数据查询
 	public void syncOperation(String startDate1,String endDate1,List<Integer> arrayList,Integer tenantId,List<IndexBaseDto> indexBaseDtoList,Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap){
-		List<String> orderTypeList = new ArrayList<>();
-		orderTypeList.add("RENEW");orderTypeList.add("PRACTICE_GROUP_BUY");orderTypeList.add("PRACTICE_GROUP_RENEW");
-		orderTypeList.add("APPLY");orderTypeList.add("ADD_STUDENT");
-		CompletableFuture future1 = this.async(() -> {
-			List<IndexBaseMonthData> details = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, orderTypeList, tenantId);
-			if(!CollectionUtils.isEmpty(details)){
-				Map<String, List<IndexBaseMonthData>> collect = details.stream().collect(Collectors.groupingBy(e -> e.getOrderType()));
-				indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_RENEW_AMOUNT,collect.getOrDefault("RENEW", Lists.newArrayList())));
-				indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_PRACTICE_AMOUNT,collect.getOrDefault("PRACTICE_GROUP", Lists.newArrayList())));
-				indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_APPLY_AMOUNT,collect.getOrDefault("APPLY", Lists.newArrayList())));
-			}
-		});
-		CompletableFuture future2 = this.async(()->{
-			List<IndexBaseMonthData> details = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,orderTypeList,tenantId);
-			if(!CollectionUtils.isEmpty(details)){
-				Map<String, List<IndexBaseMonthData>> collect = details.stream().collect(Collectors.groupingBy(e -> e.getOrderType()));
-				typeDateMap.put(RENEW_AMOUNT,collect.getOrDefault("RENEW", Lists.newArrayList()));
-				typeDateMap.put(APPLY_AMOUNT,collect.getOrDefault("PRACTICE_GROUP", Lists.newArrayList()));
-				typeDateMap.put(PRACTICE_AMOUNT,collect.getOrDefault("APPLY", Lists.newArrayList()));
+//		System.out.println(System.currentTimeMillis());
+		List<Organization> organs = organizationService.findOrgans(arrayList, tenantId);
+		EParallelStream.getParallelStream().forEach(data->{
+			switch (data) {
+				case P1:
+				{
+					List<IndexBaseMonthData> renew = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, "RENEW", null, tenantId);
+					indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_RENEW_AMOUNT,renew,organs));
+				}
+					break;
+				case P2:
+				{
+					List<IndexBaseMonthData> details = indexBaseMonthDataDao.getOrganVipAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, tenantId);
+					indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_VIP_AMOUNT,details,organs));
+				}
+					break;
+				case P3:
+				{
+					List<IndexBaseMonthData> details = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, "PRACTICE_GROUP_BUY,PRACTICE_GROUP_RENEW", null, tenantId);
+					indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_PRACTICE_AMOUNT,details,organs));
+				}
+					break;
+				case P4:
+				{
+					List<IndexBaseMonthData> details = indexBaseMonthDataDao.getOrganOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, tenantId);
+					indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_OTHER_AMOUNT,details,organs));
+				}
+					break;
+				case P5:
+				{
+					List<IndexBaseMonthData> renewAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"RENEW",null,tenantId);
+					typeDateMap.put(RENEW_AMOUNT,renewAmount);
+				}
+					break;
+				case P6:
+				{
+					List<IndexBaseMonthData> vipAmount = indexBaseMonthDataDao.getVipAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId);
+					typeDateMap.put(VIP_AMOUNT,vipAmount);
+				}
+					break;
+				case P7:
+				{
+					typeDateMap.put(PRACTICE_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"PRACTICE_GROUP_BUY,PRACTICE_GROUP_RENEW",null,tenantId));
+				}
+				break;
+				case P8:
+				{
+					typeDateMap.put(OTHER_AMOUNT,indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId));
+				}
+					break;
+				case P9:
+				{
+					List<IndexBaseMonthData> details = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimely(startDate1, endDate1, arrayList, tenantId);
+					indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_TOTAL_AMOUNT,details,organs));
+				}
+					break;
+				case P10:
+				{
+					List<IndexBaseMonthData> apply = indexBaseMonthDataDao.getOrganTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList, "APPLY,ADD_STUDENT", null, tenantId);
+					indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_APPLY_AMOUNT,apply,organs));
+				}
+					break;
+				case P11:
+				{
+					indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId),organs));
+				}
+				break;
+				case P12:
+				{
+					indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_FINANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId),organs));
+				}
+					break;
+				case P13:
+                {
+					typeDateMap.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId));
+				}
+				break;
+				case P14:
+				{
+					typeDateMap.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId));
+				}
+					break;
+				case P15:
+				{
+					typeDateMap.put(APPLY_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,"APPLY,ADD_STUDENT",null,tenantId));
+				}
+					break;
+				case P16:
+				{
+					typeDateMap.put(IndexDataType.TOTAL_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate1, endDate1, arrayList,tenantId));
+				}
+					break;
 			}
 		});
-		CompletableFuture future3 = this.async(() -> {
-			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_VIP_AMOUNT,indexBaseMonthDataDao.getOrganVipAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId)));
-		});
-		CompletableFuture future4 = this.async(() -> {
-			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_OTHER_AMOUNT,indexBaseMonthDataDao.getOrganOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId)));
-		});
-		CompletableFuture future5 = this.async(() -> {
-			typeDateMap.put(VIP_AMOUNT,indexBaseMonthDataDao.getVipAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId));
-		});
-		CompletableFuture future6 = this.async(() -> {
-			typeDateMap.put(OTHER_AMOUNT,indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate1, endDate1, arrayList,tenantId));
-		});
-		CompletableFuture future7 = this.async(()->{
-			indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId)));
-			indexBaseDtoList.add(this.getIndexBaseDto(ORGAN_FINANCE_AMOUNT,indexBaseMonthDataDao.getOrganFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId)));
-		});
-		CompletableFuture future8 = this.async(()->{
-			typeDateMap.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate1, endDate1, arrayList,tenantId));
-			indexBaseDtoList.add(this.getIndexBaseDto(IndexDataType.ORGAN_TOTAL_AMOUNT,indexBaseMonthDataDao.getOrganTotalAmountDataWithTimely(startDate1, endDate1, arrayList,tenantId)));
-		});
-		CompletableFuture future9 = this.async(()->{
-			typeDateMap.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate1, endDate1, arrayList,tenantId));
-			typeDateMap.put(IndexDataType.TOTAL_AMOUNT,indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate1, endDate1, arrayList,tenantId));
-		});
-		future1.join();future2.join();future3.join();future4.join();
-		future5.join();future6.join();future7.join();future8.join();future9.join();
 	}
 
 	@Override
@@ -477,8 +539,8 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			if (transactionTeachers != null) {
 				for (SimpleUserDto transactionTeacher : transactionTeachers) {
 					Set<Integer> organIds = Arrays.stream(transactionTeacher.getOrganIds().split(","))
-												  .map(s -> Integer.valueOf(s))
-												  .collect(Collectors.toSet());
+							.map(s -> Integer.valueOf(s))
+							.collect(Collectors.toSet());
 					for (Integer organId : organIds) {
 						if (organTeacherNumMap.containsKey(organId)) {
 							organTeacherNumMap.put(organId, organTeacherNumMap.get(organId) + 1);
@@ -513,6 +575,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		if(CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(IndexDataType.PART_TIME_NUM)) {
 			saveData(indexBaseMonthDataDao.getTeacherData(dayStr, JobNatureEnum.PART_TIME, null,tenantId), dayStr, IndexDataType.PART_TIME_NUM, tenantId);
 		}
+//		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, null, true), dayStr, IndexDataType.DIMISSION_NUM);
 
 		//剩余课时
 		if(CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(IndexDataType.SURPLUS_COURSE_NUM)) {
@@ -542,6 +605,17 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.PRACTICE, CourseStatusEnum.OVER,tenantId), dayStr, IndexDataType.OVER_PRACTICE_COURSE_NUM, tenantId);
 		}
 
+		//经营数据
+
+//		List<IndexBaseMonthData> financePayData = indexBaseMonthDataDao.getFinancePayData(dayStr);
+//		List<IndexBaseMonthData> financeBalanceData = indexBaseMonthDataDao.getFinanceBalanceData(dayStr);
+//		List<IndexBaseMonthData> financeActualData = indexBaseMonthDataDao.getFinanceActualData(dayStr);
+//
+//		saveData(financePayData,dayStr,IndexDataType.FINANCE_PAY);
+//		saveData(financeBalanceData,dayStr,IndexDataType.FINANCE_BALANCE_AMOUNT);
+//		saveData(financeActualData,dayStr,IndexDataType.FINANCE_AMOUNT);
+//		saveData(totalAmountData,dayStr,IndexDataType.TOTAL_AMOUNT);
+
 		//业务数据
 		if(CollectionUtils.isEmpty(dataTypes)||dataTypes.contains(IndexDataType.HOMEWORK_CREATE_RATE)) {
 			saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, null,tenantId), monday.toString(), IndexDataType.HOMEWORK_CREATE_RATE, tenantId);

+ 5 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -220,7 +220,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     @Autowired
     private ImLiveRoomVideoService imLiveRoomVideoService;
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(VipGroup.class);
+    private static final Logger businessLogger = LoggerFactory.getLogger(VipGroup.class);
 
     @Override
     public BaseDAO<Long, VipGroup> getDAO() {
@@ -1524,7 +1524,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                     vipGroupApplyBaseInfoDto.getName());
         } catch (Exception e) {
             e.printStackTrace();
-            LOGGER.error("消息发送失败:{}", e);
+            businessLogger.error("消息发送失败:{}", e);
         }
         return BaseController.succeed(vipGroupApplyBaseInfoDto.getAuditStatus().getCode());
     }
@@ -2627,6 +2627,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
     public HttpResponseResult buyVipGroup(VipGroupBuyParamsDto vipGroupBuyParams) throws Exception {
+        businessLogger.info("buyVipGroup param:{}",vipGroupBuyParams.toString());
         SysUser user = sysUserService.getUser();
         vipGroupBuyParams.setUserId(user.getId());
         Integer userId = vipGroupBuyParams.getUserId();
@@ -2775,7 +2776,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         try {
             contractService.register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
         } catch (Exception e) {
-            LOGGER.error("[{}]课程购买协议生成错误:{}", vipGroup.getId(), e.getCause());
+            businessLogger.error("[{}]课程购买协议生成错误:{}", vipGroup.getId(), e.getCause());
         }
 
         String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
@@ -2990,7 +2991,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                 try {
                     contractService.transferVipGroupCoursesContract(userId, vipGroup.getId(), order.getType());
                 } catch (Exception e) {
-                    LOGGER.error(MessageFormatter.arrayFormat("课程[{}]购买协议错误:{}", vipGroup.getId(), e.getMessage()), e);
+                    businessLogger.error(MessageFormatter.arrayFormat("课程[{}]购买协议错误:{}", vipGroup.getId(), e.getMessage()), e);
                 }
             }
             if(groupType == LIVE){

+ 2 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -1117,7 +1117,8 @@
 		left join course_schedule_teacher_salary csts ON csts.course_schedule_id_ = cs.id_
 		LEFT JOIN teacher t ON t.id_ = csts.user_id_
 		where cs.class_date_ BETWEEN #{cutFirstDayOfMonth} AND #{cutLastDayOfMonth} AND cssp.actual_price_ > 0
-		AND cs.del_flag_ = 0 AND cs.is_lock_ = 0 and cs.pre_course_flag_ = 0 AND t.is_settlement_salary_ = 1 AND csts.settlement_time_ IS NOT NULL AND cs.tenant_id_ = 1
+		AND cs.del_flag_ = 0 AND cs.is_lock_ = 0 and cs.pre_course_flag_ = 0 AND t.is_settlement_salary_ = 1
+		AND csts.settlement_time_ IS NOT NULL AND cs.tenant_id_ = 1
 		group by cs.organ_id_
 	</select>
 

+ 13 - 16
mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml

@@ -735,7 +735,7 @@
 		CASE WHEN ta.complaints_status_=0 THEN '拒绝' WHEN ta.complaints_status_ = 1 THEN '通过'
 		WHEN ta.complaints_status_=2 THEN '待处理' WHEN ta.complaints_status_ = 3 THEN '已撤销' END complaints_status_,ta.dispose_content_,
 		ROUND((UNIX_TIMESTAMP(ta.sign_out_time_)-UNIX_TIMESTAMP(ta.sign_in_time_))/60) currentTime,
-		ta.sign_in_time_ signInTime,ta.sign_out_time_ signOutTime,COUNT(DISTINCT sp.id_) studentNum,ts.deduction_reason_
+		ta.sign_in_time_ signInTime,ta.sign_out_time_ signOutTime,ts.deduction_reason_
 		FROM course_schedule_teacher_salary ts
 		LEFT JOIN course_schedule cs ON ts.course_schedule_id_ = cs.id_
 		LEFT JOIN `teacher_attendance` ta ON ta.`teacher_id_` = ts.`user_id_` AND ta.`course_schedule_id_` = ts.`course_schedule_id_`
@@ -744,10 +744,10 @@
 		LEFT JOIN teacher t ON t.id_ = ts.user_id_
 		LEFT JOIN organization o ON o.id_ = t.organ_id_
 		LEFT JOIN school s ON s.id_ = cs.schoole_id_
-		LEFT JOIN course_schedule_student_payment sp ON sp.course_schedule_id_ = ts.course_schedule_id_
-		LEFT JOIN music_group mg ON (mg.id_ = ts.music_group_id_ AND ts.group_type_ = 'MUSIC')
-		LEFT JOIN organization mgo ON mgo.id_ = mg.organ_id_
-		WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{month} AND cs.`del_flag_` != 1 AND cs.group_type_ = 'MUSIC' AND ts.settlement_time_ IS NOT NULL
+		LEFT JOIN music_group mg ON mg.id_ = ts.music_group_id_ AND ts.group_type_ = 'MUSIC'
+		LEFT JOIN organization mgo ON mgo.id_ = cs.organ_id_
+		WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{month} AND cs.`del_flag_` = 0 AND cs.is_lock_ = 0 and cs.pre_course_flag_ = 0
+		AND cs.group_type_ = 'MUSIC' AND ts.settlement_time_ IS NOT NULL
 		AND t.is_settlement_salary_ = 1 and ts.tenant_id_ = #{tenantId}
 		<if test="courseTypeList != null">
 			and cs.type_ in (#{courseTypeList})
@@ -770,24 +770,22 @@
 		CASE WHEN ta.complaints_status_=0 THEN '拒绝' WHEN ta.complaints_status_ = 1 THEN '通过'
 		WHEN ta.complaints_status_=2 THEN '待处理' WHEN ta.complaints_status_ = 3 THEN '已撤销' END complaints_status_,ta.dispose_content_,
 		ROUND((UNIX_TIMESTAMP(ta.sign_out_time_)-UNIX_TIMESTAMP(ta.sign_in_time_))/60) currentTime,
-		ta.sign_in_time_ signInTime,ta.sign_out_time_ signOutTime,COUNT(DISTINCT sp.id_) studentNum,
+		ta.sign_in_time_ signInTime,ta.sign_out_time_ signOutTime,
 		vg.online_classes_unit_price_,vg.offline_classes_unit_price_,
 		GROUP_CONCAT(sa.sign_in_time_) studentSignInTime,GROUP_CONCAT(sa.sign_out_time_) studentSignOutTime,ts.deduction_reason_
 		FROM course_schedule_teacher_salary ts
 		LEFT JOIN course_schedule cs ON ts.course_schedule_id_ = cs.id_
 		LEFT JOIN `teacher_attendance` ta ON ta.`teacher_id_` = ts.`user_id_` AND ta.`course_schedule_id_` = ts.`course_schedule_id_`
-		LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
 		LEFT JOIN sys_user u ON ts.user_id_= u.id_
 		LEFT JOIN teacher t ON t.id_ = ts.user_id_
 		LEFT JOIN organization o ON o.id_ = t.organ_id_
 		LEFT JOIN school s ON s.id_ = cs.schoole_id_
-		LEFT JOIN course_schedule_student_payment sp ON sp.course_schedule_id_ = ts.course_schedule_id_
 		LEFT JOIN `student_attendance` sa ON sa.`course_schedule_id_` = ts.`course_schedule_id_`
 		LEFT JOIN vip_group vg ON (vg.id_ = ts.music_group_id_ AND ts.group_type_ = 'VIP')
 		LEFT JOIN vip_group_activity vga ON vg.vip_group_activity_id_ = vga.id_
-		LEFT JOIN organization vgo ON vgo.id_ = vg.organ_id_
+		LEFT JOIN organization vgo ON vgo.id_ = cs.organ_id_
 		left join vip_group_category vgc on vgc.id_ = vg.vip_group_category_id_
-		WHERE vg.organ_id_ != 41 AND DATE_FORMAT(cs.class_date_,'%Y-%m') = #{month} AND cs.`del_flag_` != 1
+		WHERE vg.organ_id_ != 41 AND DATE_FORMAT(cs.class_date_,'%Y-%m') = #{month} AND cs.`del_flag_` = 0 AND cs.is_lock_ = 0 and cs.pre_course_flag_ = 0
 		AND cs.group_type_ = 'VIP' AND ts.settlement_time_ IS NOT NULL
 		AND t.is_settlement_salary_ = 1 and ts.tenant_id_ = #{tenantId}
 		<if test="courseTypeList != null">
@@ -814,21 +812,20 @@
 		CASE WHEN ta.complaints_status_=0 THEN '拒绝' WHEN ta.complaints_status_ = 1 THEN '通过'
 		WHEN ta.complaints_status_=2 THEN '待处理' WHEN ta.complaints_status_ = 3 THEN '已撤销' END complaints_status_,ta.dispose_content_,
 		ROUND((UNIX_TIMESTAMP(ta.sign_out_time_)-UNIX_TIMESTAMP(ta.sign_in_time_))/60) currentTime,
-		ta.sign_in_time_ signInTime,ta.sign_out_time_ signOutTime,COUNT(DISTINCT sp.id_) studentNum,
+		ta.sign_in_time_ signInTime,ta.sign_out_time_ signOutTime,
 		GROUP_CONCAT(sa.sign_in_time_) studentSignInTime,GROUP_CONCAT(sa.sign_out_time_) studentSignOutTime,ts.deduction_reason_
 		FROM course_schedule_teacher_salary ts
 		LEFT JOIN course_schedule cs ON ts.course_schedule_id_ = cs.id_
 		LEFT JOIN `teacher_attendance` ta ON ta.`teacher_id_` = ts.`user_id_` AND ta.`course_schedule_id_` = ts.`course_schedule_id_`
-		LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
 		LEFT JOIN sys_user u ON ts.user_id_= u.id_
 		LEFT JOIN teacher t ON t.id_ = ts.user_id_
 		LEFT JOIN organization o ON o.id_ = t.organ_id_
 		LEFT JOIN school s ON s.id_ = cs.schoole_id_
-		LEFT JOIN course_schedule_student_payment sp ON sp.course_schedule_id_ = ts.course_schedule_id_
 		LEFT JOIN `student_attendance` sa ON sa.`course_schedule_id_` = ts.`course_schedule_id_`
-		LEFT JOIN practice_group pg ON (pg.id_ = ts.music_group_id_ AND ts.group_type_ = 'PRACTICE')
-		LEFT JOIN organization pgo ON pgo.id_ = pg.organ_id_
-		WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{month} AND cs.`del_flag_` != 1 AND cs.group_type_ = 'PRACTICE' AND ts.settlement_time_ IS NOT NULL
+		LEFT JOIN practice_group pg ON pg.id_ = ts.music_group_id_ AND ts.group_type_ = 'PRACTICE'
+		LEFT JOIN organization pgo ON pgo.id_ = cs.organ_id_
+		WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{month} AND cs.`del_flag_` = 0 AND cs.is_lock_ = 0 and cs.pre_course_flag_ = 0
+		AND cs.group_type_ = 'PRACTICE' AND ts.settlement_time_ IS NOT NULL
 		AND t.is_settlement_salary_ = 1 and ts.tenant_id_ = #{tenantId}
 		<if test="courseTypeList != null">
 			and cs.type_ in (#{courseTypeList})

+ 67 - 94
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -1395,9 +1395,9 @@
 	</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_,
-			   SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		SELECT spo.organ_id_,SUM(IFNULL(spo.balance_payment_amount_,0)) total_num_,
+		SUM(IFNULL(spo.balance_payment_amount_,0)) activate_num_,
+		SUM(IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
 		<if test="organIds!=null and organIds.size()>0">
@@ -1410,19 +1410,17 @@
 	</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 spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
-		WHERE o.tenant_id_ = #{tenantId}
+		SELECT SUM(IFNULL(spo.balance_payment_amount_,0)) percent_,spo.organ_id_
+		FROM student_payment_order spo
+		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
+		AND spo.tenant_id_ = #{tenantId}
 		<if test="organIds!=null and organIds.size() > 0">
-			AND o.id_ IN
+			AND spo.organ_id_ IN
 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 				#{organId}
 			</foreach>
 		</if>
-		GROUP BY o.id_ ORDER BY percent_ DESC
+		GROUP BY spo.organ_id_ ORDER BY percent_ DESC
 	</select>
 
 	<select id="getFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
@@ -1441,27 +1439,23 @@
 	</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 spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
-		WHERE o.tenant_id_ = #{tenantId}
+		SELECT SUM(spo.actual_amount_) percent_,spo.organ_id_
+		FROM student_payment_order spo
+		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
+		AND spo.tenant_id_ = #{tenantId}
 		<if test="organIds!=null and organIds.size()>0">
-			AND o.id_ IN
+			AND spo.organ_id_ IN
 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 				#{organId}
 			</foreach>
 		</if>
-		GROUP BY o.id_ ORDER BY percent_ DESC
+		GROUP BY spo.organ_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_,
-			   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) activate_num_,
-			   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_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,
+		SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) activate_num_,
+		SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
 		<if test="organIds!=null and organIds.size()>0">
@@ -1474,72 +1468,69 @@
 	</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 spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
-		WHERE o.tenant_id_ = #{tenantId}
+		SELECT SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,spo.organ_id_
+		FROM student_payment_order spo
+		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
+		AND spo.tenant_id_ = #{tenantId}
 		<if test="organIds!=null and organIds.size()>0">
-			AND o.id_ IN
+			AND spo.organ_id_ IN
 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 				#{organId}
 			</foreach>
 		</if>
-		GROUP BY o.id_ ORDER BY percent_ DESC
+		GROUP BY spo.organ_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_,
-			   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) activate_num_,
-			   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_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,
-		CASE WHEN spo.type_ IN ('RENEW') THEN 'RENEW' WHEN spo.type_ IN ('PRACTICE_GROUP_BUY', 'PRACTICE_GROUP_RENEW') THEN 'PRACTICE_GROUP' ELSE 'APPLY' END AS order_type_
+		SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,
+		SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) activate_num_,
+		SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
-		AND spo.type_ IN
-		<foreach collection="orderTypeList" open="(" close=")" item="orderType" separator=",">
-			#{orderType}
-		</foreach>
+		<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>
-		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),order_type_
+		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_,
-		CASE WHEN spo.type_ IN ('RENEW') THEN 'RENEW'
-		WHEN spo.type_ IN ('PRACTICE_GROUP_BUY', 'PRACTICE_GROUP_RENEW') THEN 'PRACTICE_GROUP'
-		ELSE 'APPLY' END AS order_type_
-		FROM organization o
-		LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_
-		AND spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
-		AND spo.type_ IN
-		<foreach collection="orderTypeList" open="(" close=")" item="orderType" separator=",">
-			#{orderType}
-		</foreach>
-		WHERE o.tenant_id_ = #{tenantId}
+		SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_
+		FROM student_payment_order spo
+		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ 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>
+		AND spo.tenant_id_ = #{tenantId}
 		<if test="organIds!=null and organIds.size()>0">
-			AND o.id_ IN
+			AND spo.organ_id_ IN
 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 				#{organId}
 			</foreach>
 		</if>
-		GROUP BY o.id_,order_type_ ORDER BY percent_ DESC
+		GROUP BY spo.organ_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_
+		SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 		FROM student_payment_order spo
 		LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
 		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
@@ -1552,8 +1543,7 @@
 		</if>
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 		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_
+		SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
 		,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
@@ -1569,8 +1559,8 @@
 	</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_
+		SELECT c.organ_id_,SUM(c.total_num_) percent_
+		FROM (SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) 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 spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
@@ -1583,8 +1573,7 @@
 		</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_
+		SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
 		AND spo.type_ = 'SMALL_CLASS_TO_BUY'
@@ -1595,21 +1584,13 @@
 			</foreach>
 		</if>
 		GROUP BY spo.organ_id_
-		)c ON c.organ_id_ = o.id_
-		WHERE o.tenant_id_ = #{tenantId}
-		<if test="organIds!=null and organIds.size()>0">
-			AND o.id_ IN
-			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
-				#{organId}
-			</foreach>
-		</if>
-		GROUP BY o.id_ ORDER BY percent_ DESC
+		)c
+		GROUP BY c.organ_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 +
-							   CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
+		SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
 		   ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
@@ -1622,7 +1603,7 @@
 		</if>
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),spo.type_
 		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_,spo.type_
+		SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) 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 spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
@@ -1638,10 +1619,9 @@
 	</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_
+		SELECT c.organ_id_,SUM(c.total_num_) percent_
+		FROM (
+		SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,spo.type_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
 		AND spo.type_ NOT IN ('APPLY','ADD_STUDENT','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
@@ -1653,7 +1633,7 @@
 		</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_
+		SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) 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 spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
@@ -1665,15 +1645,8 @@
 			</foreach>
 		</if>
 		GROUP BY spo.organ_id_,spo.type_
-		)c ON c.organ_id_ = o.id_
-		WHERE o.tenant_id_ = #{tenantId}
-		<if test="organIds!=null and organIds.size()>0">
-			AND o.id_ IN
-			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
-				#{organId}
-			</foreach>
-		</if>
-		GROUP BY o.id_ ORDER BY percent_ DESC
+		)c
+		GROUP BY c.organ_id_ ORDER BY percent_ DESC
 	</select>
 
 	<sql id="queryTeacherServeInfoCondition">

+ 63 - 0
mec-util/src/main/java/com/ym/mec/util/web/EParallelStream.java

@@ -0,0 +1,63 @@
+package com.ym.mec.util.web;
+
+import com.google.common.collect.Lists;
+import lombok.Getter;
+
+import java.util.stream.Stream;
+
+/**
+ * Created by Eric.Shang on 2019-08-08.
+ */
+@Getter
+public enum EParallelStream {
+
+    P1(1, "P1"),
+    P2(2, "P2"),
+    P3(3, "P3"),
+    P4(4, "P4"),
+    P5(5, "P5"),
+    P6(6, "P6"),
+    P7(7, "P7"),
+    P8(8, "P8"),
+    P9(9, "P9"),
+    P10(10, "P10"),
+    P11(11, "P11"),
+    P12(12, "P12"),
+    P13(13, "P13"),
+    P14(14, "P14"),
+    P15(15, "P15"),
+    P16(16, "P16"),
+    ;
+
+    private final int value;
+    private final String name;
+
+    EParallelStream(int value, String name) {
+        this.value = value;
+        this.name = name;
+    }
+
+    /**
+     * 并发执行流程
+     * @param value 数据流
+     * @return EParallelStream
+     */
+    public static EParallelStream get(int value) {
+        EParallelStream[] values = EParallelStream.values();
+        for (EParallelStream item : values) {
+            if (item.getValue() == value) {
+                return item;
+            }
+        }
+        return P1;
+    }
+
+    /**
+     * 并发执行流程
+     * @return List<EParallelStream>
+     */
+    public static Stream<EParallelStream> getParallelStream() {
+
+        return Lists.newArrayList(EParallelStream.values()).parallelStream();
+    }
+}