| 
					
				 | 
			
			
				@@ -1,12 +1,16 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Set; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.page.CloudTeacherOrderQueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.TenantConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.common.page.PageInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.util.collection.MapUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -15,10 +19,6 @@ import com.ym.mec.biz.dal.dao.CloudTeacherDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.CourseScheduleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.entity.CloudTeacher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.entity.CloudTeacherOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.entity.CourseSchedule; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.entity.StudentPaymentOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.PeriodEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.service.CloudTeacherOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.service.StudentService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,6 +40,8 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private StudentService studentService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TenantConfigService tenantConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public BaseDAO<Long, CloudTeacherOrder> getDAO() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -47,6 +49,54 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public PageInfo<CloudTeacherStudent> queryInactive(CloudTeacherOrderQueryInfo queryInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        PageInfo<CloudTeacherStudent> pageInfo = new PageInfo<CloudTeacherStudent>(queryInfo.getPage(), queryInfo.getRows()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> params = new HashMap<String, Object>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        MapUtil.populateMap(params, queryInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<CloudTeacherStudent> dataList = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int count = cloudTeacherOrderDao.findInactiveCount(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (count > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            pageInfo.setTotal(count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            params.put("offset", pageInfo.getOffset()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dataList = cloudTeacherOrderDao.queryInactive(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (count == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dataList = new ArrayList<CloudTeacherStudent>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        pageInfo.setRows(dataList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // List<TenantConfig> tenCfg = tenantConfigService.list(new Wrapper<TenantConfig>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (CloudTeacherStudent cst: dataList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (cst.getTime() == null) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            TenantConfig tenantConfig = tenantConfigService.getById(cst.getTenantId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            JSONObject cfg = JSON.parseObject(tenantConfig.getConfig()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            JSONObject memberConfig = (JSONObject) cfg.get("member_config"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (cst.getType() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double divide = memberConfig.getDouble("month_divide"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cst.setPrice(divide * cst.getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else if (cst.getType() == 2) { // 月 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double divide = memberConfig.getDouble("month_divide"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cst.setPrice(divide * cst.getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else if (cst.getType() == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double divide = memberConfig.getDouble("quarter_divide"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cst.setPrice(divide * cst.getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else if (cst.getType() == 4) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double divide = memberConfig.getDouble("half_year_divide"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cst.setPrice(divide * cst.getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else if (cst.getType() == 5) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double divide = memberConfig.getDouble("year_divide"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cst.setPrice(divide * cst.getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return pageInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Boolean pay(List<CloudTeacherStudent> orders) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order,BigDecimal cloudTeacherFee) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrderDao.queryByOrderId(order.getId()); 
			 |