Browse Source

crm叠加包

wuwen 3 years ago
parent
commit
a31d9670b2

+ 9 - 2
src/main/java/com/ssj/dao/sys/fx/dao/MerchantMealDao.java

@@ -20,6 +20,9 @@ public interface MerchantMealDao extends JpaRepository<MerchantMeal, String> {
 	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.merchant_id=?1 and t.status=1  ORDER BY t.end_sign_time DESC LIMIT 1 ")
 	public MerchantMeal getMerchantMealByMaxEndSignTime(String merchantId);
 	
+	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.merchant_id=?1 and t.status=1  ORDER BY t.sign_time ASC LIMIT 1 ")
+	public MerchantMeal getMerchantMealByMinSignTime(String merchantId);
+	
 	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.merchant_id=?1 and t.status=1 and TO_DAYS(t.sign_time)>=TO_DAYS(NOW()) ORDER BY t.sign_time ASC LIMIT 1 ")
 	public MerchantMeal getMerchantMealByCurSignTime(String merchantId);
 	
@@ -29,8 +32,8 @@ public interface MerchantMealDao extends JpaRepository<MerchantMeal, String> {
 	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.merchant_id=?1 ORDER BY t.create_time DESC,t.end_sign_time DESC")
 	public List<MerchantMeal> findMerchantMealAll(String merchantId);
 	
-	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.status=1 AND t.merchant_id=?1 AND TO_DAYS(t.sign_time)<=TO_DAYS(NOW()) AND TO_DAYS(t.end_sign_time)>TO_DAYS(NOW()) ORDER BY t.end_sign_time DESC LIMIT 1")
-	public MerchantMeal getMerchantMealByCurTime(String merchantId);
+	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.status=1 AND t.merchant_id=?1 AND TO_DAYS(t.sign_time)<=TO_DAYS(NOW()) AND TO_DAYS(t.end_sign_time)>TO_DAYS(NOW()) ORDER BY t.end_sign_time DESC ")
+	public List<MerchantMeal> getMerchantMealByCurTime(String merchantId);
 	
 	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.status=1 AND t.type=1 AND t.merchant_id=?1 AND TO_DAYS(t.sign_time)<=TO_DAYS(?2) AND TO_DAYS(t.end_sign_time)>TO_DAYS(?2) ORDER BY t.sign_time ASC LIMIT 1 ")
 	public MerchantMeal getMerchantMealByActiveCur(String merchantId,Date date);
@@ -41,6 +44,10 @@ public interface MerchantMealDao extends JpaRepository<MerchantMeal, String> {
 	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.status=1 AND t.type>1 AND t.merchant_id=?1 AND TO_DAYS(t.sign_time)>TO_DAYS(?2) ORDER BY t.sign_time ASC ")
 	public List<MerchantMeal> findMerchantMealByServiceMax(String merchantId,Date date);
 	
+	//大于当前时间最近的一条数据
+	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_meal t WHERE t.status=1 AND t.type>1 AND t.merchant_id=?1 AND TO_DAYS(t.end_sign_time)>TO_DAYS(?2) ORDER BY t.end_sign_time ASC LIMIT 1 ")
+	public MerchantMeal findMerchantMealByServiceMaxEnd(String merchantId,Date date);
+	
 	
 	
 	

+ 38 - 23
src/main/java/com/ssj/dao/sys/fx/dao/impl/FinanceQueryDaoImpl.java

@@ -511,34 +511,49 @@ public class FinanceQueryDaoImpl implements FinanceQueryDao {
 	public Page<Map<String, Object>> balanceConsumeDetailList_New2(Map<String, Object> params, Pageable pageable) {
 		 StringBuilder selSql = new StringBuilder();
          List<Object> queryParams = new ArrayList<Object>();
-         selSql.append(" SELECT tmp.id,tmp.pos_code,tmp.unit_name,tmp.meal_type,tmp.count_2,tmp.moid,IFNULL(tmo.unit_price,0) as price,tmp.pr_2 as price_1,tmo.sign_type,? as balance_month  from ( ");
-         selSql.append(" SELECT t.id,t.pos_code,t.unit_name,t.meal_type,  ");
-         selSql.append(" ( ");
-	         selSql.append(" SELECT mo.id from fx_merchant_meal me LEFT JOIN fx_merchant_meal_order mo ON me.order_id=mo.id  ");
-	         selSql.append(" WHERE me.merchant_id=t.id AND me.type>1 AND DATE_FORMAT(me.sign_time,'%Y-%m')=?  ");
-	         selSql.append(" ORDER BY mo.price DESC LIMIT 1 ");
-         selSql.append(" ) as moid,  ");
-         selSql.append(" ( ");
-         selSql.append(" SELECT count(1) from fx_merchant_sign ms WHERE ms.merchant_id=t.id AND DATE_FORMAT(ms.sign_time,'%Y-%m')=? ");
-         selSql.append(" ) as count_2, ");
-         selSql.append(" ( ");
-         selSql.append(" SELECT IFNULL(SUM(mso.unit_price),0) from fx_merchant_sign ms LEFT JOIN fx_merchant_sign_order mso ON ms.order_id=mso.id WHERE ms.merchant_id=t.id AND DATE_FORMAT(ms.sign_time,'%Y-%m')=? ");
-         selSql.append(" ) as pr_2");
+//         selSql.append(" SELECT tmp.id,tmp.pos_code,tmp.unit_name,tmp.meal_type,tmp.count_2,tmp.moid,IFNULL(tmo.unit_price,0) as price,tmp.pr_2 as price_1,tmo.sign_type,? as balance_month  from ( ");
+//         selSql.append(" SELECT t.id,t.pos_code,t.unit_name,t.meal_type,  ");
+//         selSql.append(" ( ");
+//	         selSql.append(" SELECT mo.id from fx_merchant_meal me LEFT JOIN fx_merchant_meal_order mo ON me.order_id=mo.id  ");
+//	         selSql.append(" WHERE me.merchant_id=t.id AND me.type>1 AND DATE_FORMAT(me.sign_time,'%Y-%m')=?  ");
+//	         selSql.append(" ORDER BY mo.price DESC LIMIT 1 ");
+//         selSql.append(" ) as moid,  ");
+//         selSql.append(" ( ");
+//         selSql.append(" SELECT count(1) from fx_merchant_sign ms WHERE ms.merchant_id=t.id AND DATE_FORMAT(ms.sign_time,'%Y-%m')=? ");
+//         selSql.append(" ) as count_2, ");
+//         selSql.append(" ( ");
+//         selSql.append(" SELECT IFNULL(SUM(mso.unit_price),0) from fx_merchant_sign ms LEFT JOIN fx_merchant_sign_order mso ON ms.order_id=mso.id WHERE ms.merchant_id=t.id AND DATE_FORMAT(ms.sign_time,'%Y-%m')=? ");
+//         selSql.append(" ) as pr_2");
+//         
+//         queryParams.add(params.get("startMonth"));
+//         queryParams.add(params.get("startMonth"));
+//         queryParams.add(params.get("startMonth"));
+//         queryParams.add(params.get("startMonth"));
+//    
+//         selSql.append(" from fx_merchant t ");
+//         selSql.append(" WHERE t.`status`!=4 and t.sign_type>=1 and t.type in (5)   ");
+//         if(!StringUtil.isEmpty(params.get("merchantId"))){
+//             selSql.append(" AND t.id=? ");
+//             queryParams.add(params.get("merchantId"));
+//         }
+//         selSql.append(" ORDER BY FIELD(t.`type`,1,2),t.create_time asc  ");
+//         selSql.append(" ) as tmp ");
+//         selSql.append(" LEFT JOIN fx_merchant_meal_order tmo ON tmp.moid=tmo.id ");
          
+         
+         selSql.append(" SELECT t.id,t.pos_code,t.unit_name,t.meal_type,me.sign_time,tmo.id as moid,IFNULL(tmo.unit_price,0) as price,tmo.sign_type, ? as balance_month from fx_merchant t  ");
+         selSql.append(" LEFT JOIN fx_merchant_meal me ON me.merchant_id=t.id AND me.type>1 AND DATE_FORMAT(me.sign_time,'%Y-%m')=? ");
+         selSql.append(" LEFT JOIN fx_merchant_meal_order tmo ON me.order_id=tmo.id ");
+         selSql.append(" WHERE t.`status`!=4 and t.sign_type>=1 and t.type in (5)  ");
          queryParams.add(params.get("startMonth"));
          queryParams.add(params.get("startMonth"));
-         queryParams.add(params.get("startMonth"));
-         queryParams.add(params.get("startMonth"));
-    
-         selSql.append(" from fx_merchant t ");
-         selSql.append(" WHERE t.`status`!=4 and t.sign_type>=1 and t.type in (5)   ");
+         
          if(!StringUtil.isEmpty(params.get("merchantId"))){
-             selSql.append(" AND t.id=? ");
-             queryParams.add(params.get("merchantId"));
+        	 selSql.append(" AND t.id=? ");
+        	 queryParams.add(params.get("merchantId"));
          }
-         selSql.append(" ORDER BY FIELD(t.`type`,1,2),t.create_time asc  ");
-         selSql.append(" ) as tmp ");
-         selSql.append(" LEFT JOIN fx_merchant_meal_order tmo ON tmp.moid=tmo.id ");
+         selSql.append(" ORDER BY t.create_time asc   ");
+      
          return dao.findPage(selSql.toString(),queryParams.toArray(),pageable);
 	}
 

+ 73 - 77
src/main/java/com/ssj/service/sys/fx/service/impl/MerchantMealServiceImpl.java

@@ -108,21 +108,7 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 		Merchant merchant=merchantService.getById(merchantId);
 		switch (merchant.getPosType()) {
 		case 2:
-			//如果传入了日期,就按传入的日期处理。
-			//如果激活日期和结束为空,就设置当前日期。
-			boolean isActiveLog=false;
-			if(merchant.getStartActiveTime()==null || merchant.getActiveTime()==null) {
-				if(StringUtils.isNotEmpty(startActiveTime) && StringUtils.isNotEmpty(activeTime)) {
-					merchant.setStartActiveTime(DateHelper.parseDate(startActiveTime, "yyyy-MM-dd"));
-					merchant.setActiveTime(DateHelper.parseDate(activeTime, "yyyy-MM-dd"));
-					isActiveLog=true;
-				}else {
-					merchant.setStartActiveTime(new Date());
-					merchant.setActiveTime(new Date());
-				}
-				merchantService.save(merchant);
-			}
-			
+		
 			MerchantMealOrder mealOrder=new MerchantMealOrder();
 			mealOrder.setStartActiveTime(StringUtils.isNotEmpty(startActiveTime) ? DateHelper.parseDate(startActiveTime, "yyyy-MM-dd") : null);
 			mealOrder.setActiveTime(StringUtils.isNotEmpty(activeTime) ? DateHelper.parseDate(activeTime, "yyyy-MM-dd") : null);
@@ -158,7 +144,7 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 			mrchantMealOrderService.save(mealOrder);
 			
 			//添加激活期的记录
-			if(isActiveLog) {
+			if(StringUtils.isNotEmpty(startActiveTime) && StringUtils.isNotEmpty(activeTime) && !activeTime.equals(startActiveTime)) {
 				Integer month=DateHelper.getDifferMonth(DateHelper.parseDate(startActiveTime, "yyyy-MM-dd"),DateHelper.parseDate(activeTime, "yyyy-MM-dd"));
 				Date startTime=DateHelper.parseDate(startActiveTime, "yyyy-MM-dd");
 				Date endTime=DateHelper.getMonthDate(startTime,1);
@@ -185,26 +171,20 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 			}
 			
 			//端口商户的处理,
-			Date signTime=new Date();
-			MerchantMeal merchantMeal=this.getMerchantMealByMaxEndSignTime(merchantId);	
-			if(merchantMeal!=null ) {
-				if(merchantMeal.getEndSignTime().getTime()>=new Date().getTime()) {
-					signTime=merchantMeal.getEndSignTime();
-				}
-			}else {
-				if(merchant.getComputeTime()!=null) {
-					signTime=merchant.getComputeTime();
-				}else {
-					signTime=merchant.getActiveTime();
-				}
-			}
+			Date signTime=mealOrder.getActiveTime();
 			Date endSignTime=DateHelper.getMonthDate(signTime,1);
+			MerchantMeal nextMerchantMeal=dao.findMerchantMealByServiceMaxEnd(merchantId, signTime);
+			if(nextMerchantMeal!=null) {
+				endSignTime=nextMerchantMeal.getEndSignTime();
+			}
+		
+			
 			//添加赠送的记录
 			for (int i =1; i <=giveMonth; i++) {
 				MerchantMeal meal=new MerchantMeal();
 				meal.setMerchantId(merchantId);
 				meal.setSignTime(signTime);
-				meal.setEndSignTime(DateHelper.getMonthDate(signTime,1));
+				meal.setEndSignTime(endSignTime);
 				meal.setSignType(signType);
 				meal.setType(2);
 				meal.setStatus(1);
@@ -290,12 +270,17 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 			}
 			mrchantMealOrderService.save(mealOrder);
 
-
 			Date signTime=DateHelper.parseDate(startActiveTime, "yyyy-MM-dd");
 			Date endSignTime=DateHelper.getMonthDate(signTime,1);
+			MerchantMeal nextMerchantMeal=dao.findMerchantMealByServiceMaxEnd(merchantId, signTime);
+			if(nextMerchantMeal!=null) {
+				endSignTime=nextMerchantMeal.getEndSignTime();
+			}
+		
 			//添加购买的记录
 			int yearIndex = hisMonth/12;
 			int monthLeft = hisMonth%12;
+			
 			for (int i =1; i <=month; i++) {
 				MerchantMeal meal=new MerchantMeal();
 				meal.setMerchantId(merchantId);
@@ -312,11 +297,13 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 				meal.setCreateTime(new Date());
 				meal.setOrderId(mealOrder.getId());
 				merchantMeals.add(meal);
+				
 				if((monthLeft+i)%12==0){
 					meal.setYearIndex(yearIndex+(monthLeft+i)/12);
 				}else{
 					meal.setYearIndex(yearIndex+(monthLeft+i)/12+1);
 				}
+				
 				signTime=endSignTime;
 				endSignTime=DateHelper.getMonthDate(signTime,1);
 			}
@@ -342,58 +329,38 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 		Merchant merchant=merchantService.getById(merchantId);
 		switch (merchant.getPosType()) {
 		case 2://端口商户
+		case 3://学校商户
 			
 			//查询结束时间最大的数据。
 			MerchantMeal maxMerchantMeal=dao.getMerchantMealByMaxEndSignTime(merchantId);
+			//查询开始时间最小的数据。
+			MerchantMeal minMerchantMeal=dao.getMerchantMealByMinSignTime(merchantId);
+			
 			//查询当前日期在服务期段的数据
-			MerchantMeal merchantMeal=dao.getMerchantMealByCurTime(merchantId);
-			if(merchantMeal==null) {
-				//查出大于今天的服务数据
-				merchantMeal=dao.getMerchantMealByCurSignTime(merchantId);
-			}
-			if(merchantMeal==null) {
-				//查出没有大于今天的服务数据,就取最大的数据。
-				merchantMeal=maxMerchantMeal;
-			}
+			List<MerchantMeal> merchantMeals=dao.getMerchantMealByCurTime(merchantId);
 			
-			if(maxMerchantMeal!=null && merchantMeal!=null) {
-				MerchantMealOrder merchantMealOrder=mrchantMealOrderService.getById(maxMerchantMeal.getOrderId());
-				merchant.setEndActiveTime(maxMerchantMeal.getEndSignTime());
-				merchant.setSignType(merchantMeal.getSignType());
-				merchant.setPortNum(merchantMealOrder!=null ? merchantMealOrder.getPortNum() : 0);
-				merchant.setLibService(merchantMeal.getLibService()+merchantSignService.getMerchantSignByCurLibService(merchantId));
-				merchantService.save(merchant);
-				
-				//调用openApi接口
-				if(StringUtils.isNotEmpty(merchant.getLibId())) {
-					DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
-					libVipServiceService.openApiServiceCRM(
-							3,
-							merchant.getLibId(), 
-							merchant.getSignType(),
-							merchant.getMealType(),
-							merchant.getLibService(),
-							merchant.getStartActiveTime()!=null ? format.format(merchant.getStartActiveTime()) : "",
-							merchant.getStartActiveTime()!=null ? format.format(merchant.getStartActiveTime()) : "",
-							merchant.getEndActiveTime()!=null ? format.format(merchant.getEndActiveTime()) : ""
-							);
+			if(merchantMeals!=null && merchantMeals.size()>0) {
+				Integer maxSignType=null;
+				Integer maxPortNum=0;
+				Integer sumLibService=0;
+				for (MerchantMeal merchantMeal : merchantMeals) {
+					if(maxSignType==null || maxSignType<merchantMeal.getSignType()) {
+						maxSignType=merchantMeal.getSignType();
+					}
+
+					sumLibService=sumLibService+merchantMeal.getLibService();
 				}
-			}
-			break;
-		case 3:
-			//学校商户
-			MerchantMealOrder merchantMealOrder=mrchantMealOrderService.getMerchantMealOrderByCurTime(merchantId);
-			if(merchantMealOrder==null) {
-				merchantMealOrder=mrchantMealOrderService.getMerchantMealOrderByMaxCreateTime(merchantId);
-			}
-			
-			if(merchantMealOrder!=null) {
-				merchant.setStartActiveTime(merchantMealOrder.getSignTime());
-				merchant.setActiveTime(merchantMealOrder.getSignTime());
-				merchant.setEndActiveTime(merchantMealOrder.getEndSignTime());
-				merchant.setSignType(merchantMealOrder.getSignType());
-				merchant.setPortNum(merchantMealOrder.getPortNum());
-				merchant.setLibService(merchantMealOrder.getLibService()+merchantSignService.getMerchantSignByCurLibService(merchantId));
+				//现在处理,不存在降级的操作,如果之前的type比现在的大,那就还是用之前的。
+				if(merchant.getSignType()!=null && merchant.getSignType()>maxSignType) {
+					maxSignType=merchant.getSignType();
+				}
+				
+				merchant.setStartActiveTime(minMerchantMeal.getSignTime());
+				merchant.setActiveTime(minMerchantMeal.getSignTime());
+				merchant.setEndActiveTime(maxMerchantMeal.getEndSignTime());
+				merchant.setSignType(maxSignType);
+				merchant.setPortNum(maxPortNum);
+				merchant.setLibService(sumLibService+merchantSignService.getMerchantSignByCurLibService(merchantId));
 				merchantService.save(merchant);
 				
 				//调用openApi接口
@@ -412,6 +379,35 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 				}
 			}
 			break;
+//		case 3://2021-03-16号改为和端口商户一样处理。
+//			
+//			MerchantMealOrder merchantMealOrder=mrchantMealOrderService.getMerchantMealOrderByCurTime(merchantId);
+//
+//			if(merchantMealOrder!=null) {
+//				merchant.setStartActiveTime(merchantMealOrder.getSignTime());
+//				merchant.setActiveTime(merchantMealOrder.getSignTime());
+//				merchant.setEndActiveTime(merchantMealOrder.getEndSignTime());
+//				merchant.setSignType(merchantMealOrder.getSignType());
+//				merchant.setPortNum(merchantMealOrder.getPortNum());
+//				merchant.setLibService(merchantMealOrder.getLibService()+merchantSignService.getMerchantSignByCurLibService(merchantId));
+//				merchantService.save(merchant);
+//				
+//				//调用openApi接口
+//				if(StringUtils.isNotEmpty(merchant.getLibId())) {
+//					DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+//					libVipServiceService.openApiServiceCRM(
+//							3,
+//							merchant.getLibId(), 
+//							merchant.getSignType(),
+//							merchant.getMealType(),
+//							merchant.getLibService(),
+//							merchant.getStartActiveTime()!=null ? format.format(merchant.getStartActiveTime()) : "",
+//							merchant.getStartActiveTime()!=null ? format.format(merchant.getStartActiveTime()) : "",
+//							merchant.getEndActiveTime()!=null ? format.format(merchant.getEndActiveTime()) : ""
+//							);
+//				}
+//			}
+//			break;
 		default:
 			break;
 		}

+ 50 - 49
src/main/java/com/ssj/sys/controller/FinanceReportController.java

@@ -513,36 +513,36 @@ public class FinanceReportController extends BaseController {
 //        	}else {
 //        		map.put("price_1", "350");
 //        	}
-          	map.put("sum_price_1", "0");
-        	map.put("sum_price_2", "0");
-        	map.put("sum_price_3", "0");
+//          map.put("sum_price_1", "0");
+//        	map.put("sum_price_2", "0");
+//        	map.put("sum_price_3", "0");
         	
-        	map.put("count_1_m", "");
-        	map.put("count_2_m", "");
-        	
-        	if(map.containsKey("moid")) {
-        		if(map.get("moid")!=null) {
-        			map.put("count_1_m", map.get("balance_month") );
-        			map.put("sum_price_1", map.get("price")!=null && StringUtils.isNotEmpty(map.get("price").toString()) ? 
-        					new BigDecimal(map.get("price").toString()).doubleValue()*
-        					0.4  
-        					: 0);
-        		}
-        	}
+//        	map.put("count_1_m", "");
+//        	map.put("count_2_m", "");
         	
-        	if(map.containsKey("count_2")) {
-        		if(Integer.parseInt(map.get("count_2").toString())>0) {
-        			map.put("count_2_m", map.get("balance_month") );
-        			map.put("sum_price_2", map.get("price_1")!=null && StringUtils.isNotEmpty(map.get("price_1").toString()) ? 
-        					new BigDecimal(map.get("price_1").toString()).doubleValue()
-        					*0.4 
-        					: 0);
-        		}else {
-        			map.put("price_1", "0");
-        		}
-        	}
+//        	if(map.containsKey("moid")) {
+//        		if(map.get("moid")!=null) {
+//        			map.put("count_1_m", map.get("balance_month") );
+//        			map.put("sum_price_1", map.get("price")!=null && StringUtils.isNotEmpty(map.get("price").toString()) ? 
+//        					new BigDecimal(map.get("price").toString()).doubleValue()*
+//        					0.4  
+//        					: 0);
+//        		}
+//        	}
+//        	if(map.containsKey("count_2")) {
+//        		if(Integer.parseInt(map.get("count_2").toString())>0) {
+//        			map.put("count_2_m", map.get("balance_month") );
+//        			map.put("sum_price_2", map.get("price_1")!=null && StringUtils.isNotEmpty(map.get("price_1").toString()) ? 
+//        					new BigDecimal(map.get("price_1").toString()).doubleValue()
+//        					*0.4 
+//        					: 0);
+//        		}else {
+//        			map.put("price_1", "0");
+//        		}
+//        	}
         	
-        	map.put("sum_price_3", new BigDecimal(map.get("price").toString()).doubleValue()+new BigDecimal(map.get("price_1").toString()).doubleValue());
+//        	map.put("price_1", "0");
+//        	map.put("sum_price_3", new BigDecimal(map.get("price").toString()).doubleValue()+new BigDecimal(map.get("price_1").toString()).doubleValue());
 
 		}
         
@@ -708,31 +708,31 @@ public class FinanceReportController extends BaseController {
             		}
             	}
             	
-            	map.put("count_1_m", "");
-            	map.put("count_2_m", "");
+//            	map.put("count_1_m", "");
+//            	map.put("count_2_m", "");
             	
             	if(map.containsKey("moid")) {
             		if(map.get("moid")!=null) {
             			map.put("count_1_m", map.get("balance_month") );
-            			map.put("sum_price_1", map.get("price")!=null && StringUtils.isNotEmpty(map.get("price").toString()) ? 
-            					new BigDecimal(map.get("price").toString()).doubleValue()*
-            					0.4  
-            					: 0);
+//            			map.put("sum_price_1", map.get("price")!=null && StringUtils.isNotEmpty(map.get("price").toString()) ? 
+//            					new BigDecimal(map.get("price").toString()).doubleValue()*
+//            					0.4  
+//            					: 0);
             		}
             	}
             	
-            	if(map.containsKey("count_2")) {
-            		if(Integer.parseInt(map.get("count_2").toString())>0) {
-            			map.put("count_2_m", map.get("balance_month") );
-            			map.put("sum_price_2", map.get("price_1")!=null && StringUtils.isNotEmpty(map.get("price_1").toString()) ? 
-            					new BigDecimal(map.get("price_1").toString()).doubleValue()
-            					*0.4 
-            					: 0);
-            		}else {
-            			map.put("price_1", "0");
-            		}
-            	}
-            	map.put("sum_price_3", new BigDecimal(map.get("price").toString()).doubleValue()+new BigDecimal(map.get("price_1").toString()).doubleValue());
+//            	if(map.containsKey("count_2")) {
+//            		if(Integer.parseInt(map.get("count_2").toString())>0) {
+//            			map.put("count_2_m", map.get("balance_month") );
+//            			map.put("sum_price_2", map.get("price_1")!=null && StringUtils.isNotEmpty(map.get("price_1").toString()) ? 
+//            					new BigDecimal(map.get("price_1").toString()).doubleValue()
+//            					*0.4 
+//            					: 0);
+//            		}else {
+//            			map.put("price_1", "0");
+//            		}
+//            	}
+//            	map.put("sum_price_3", new BigDecimal(map.get("price").toString()).doubleValue()+new BigDecimal(map.get("price_1").toString()).doubleValue());
     		}
             
             List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
@@ -745,13 +745,14 @@ public class FinanceReportController extends BaseController {
             myColumns3.add(new ExcelColumn("服务包名称", "sign_type", 20));
             
             myColumns3.add(new ExcelColumn("服务包/结算月份", "count_1_m", 20));
+            myColumns3.add(new ExcelColumn("服务包/结算日期", "sign_time", 20));
             myColumns3.add(new ExcelColumn("服务包结算金额", "price", 20));
             
-            myColumns3.add(new ExcelColumn("加油包/结算月份", "count_2_m", 20));
-            myColumns3.add(new ExcelColumn("加油包/结算数量", "count_2", 20));
-            myColumns3.add(new ExcelColumn("加油包结算金额", "price_1", 20));
+//            myColumns3.add(new ExcelColumn("加油包/结算月份", "count_2_m", 20));
+//            myColumns3.add(new ExcelColumn("加油包/结算数量", "count_2", 20));
+//            myColumns3.add(new ExcelColumn("加油包结算金额", "price_1", 20));
             
-            myColumns3.add(new ExcelColumn("总结算金额", "sum_price_3", 20));
+//            myColumns3.add(new ExcelColumn("总结算金额", "sum_price_3", 20));
             
             CustomizeToExcel.downFile(myColumns3, list, os);
         }catch (IOException e) {

+ 14 - 4
src/main/java/com/ssj/sys/controller/FxController.java

@@ -54,6 +54,7 @@ import com.ssj.bean.sys.fx.domain.DeviceParts;
 import com.ssj.bean.sys.fx.domain.DevicePartsAct;
 import com.ssj.bean.sys.fx.domain.Merchant;
 import com.ssj.bean.sys.fx.domain.MerchantBackup;
+import com.ssj.bean.sys.fx.domain.MerchantMeal;
 import com.ssj.bean.sys.fx.domain.MerchantMealOrder;
 import com.ssj.bean.sys.fx.domain.MerchantPlatOrder;
 import com.ssj.bean.sys.fx.domain.MerchantSignOrder;
@@ -2878,9 +2879,9 @@ public class FxController  extends BaseController {
 	    		myColumns3.add(new ExcelColumn("合同开始日期", "signTimeStr", 20));
 	    		myColumns3.add(new ExcelColumn("合同结束日期", "endSignTimeStr", 20));
 	    		
-	    		myColumns3.add(new ExcelColumn("激活开始日期", "startActiveTimeStr", 20));
-	    		myColumns3.add(new ExcelColumn("激活结束日期", "activeTimeStr", 20));
-	    		myColumns3.add(new ExcelColumn("计费开始日期", "computeTimeStr", 20));
+//	    		myColumns3.add(new ExcelColumn("激活开始日期", "startActiveTimeStr", 20));
+//	    		myColumns3.add(new ExcelColumn("激活结束日期", "activeTimeStr", 20));
+//	    		myColumns3.add(new ExcelColumn("计费开始日期", "computeTimeStr", 20));
 	    		myColumns3.add(new ExcelColumn("服务结束日期", "endActiveTimeStr", 20));
 	    		
 	    		myColumns3.add(new ExcelColumn("签约数(练习册用)", "signService", 20));
@@ -5080,11 +5081,20 @@ public class FxController  extends BaseController {
 		Merchant merchant=merchantService.getById(id);
 		List<MerchantMealOrder> list=merchantMealOrderService.findMerchantMealOrderAll(id);
 		Date startActiveTime=null;
-		if(merchant.getStartActiveTime()==null || merchant.getActiveTime()==null) {
+		Date activeTime=null;
+		if(list==null || list.size()<=0) {
 			startActiveTime=new Date();
+		}else {
+			MerchantMeal merchantMeal=merchantMealService.getMerchantMealByMaxEndSignTime(id);
+			if(merchantMeal!=null) {
+				activeTime=merchantMeal.getEndSignTime();
+			}else {
+				activeTime=new Date();
+			}
 		}
 		model.addAttribute("merchant", merchant);
 		model.addAttribute("startActiveTime", startActiveTime);
+		model.addAttribute("activeTime", activeTime);
 		model.addAttribute("list", list);
         return "sys/fx/merchantMealAdd";
     }

+ 10 - 8
src/main/resources/templates/sys/finance/allList6.html

@@ -73,14 +73,15 @@
 		    	<th>服务包名称</th>
 		    	
 		    	<th>结算月份</th>
+		    	<th>结算日期</th>
 		    	<th>服务包结算金额</th>
 		    	
 		    	
-		    	<th style="color: red">加油包/结算月份</th>
-		    	<th style="color: red">加油包/结算数</th>
-		    	<th style="color: red">加油包结算金额</th>
+<!-- 		    	<th style="color: red">加油包/结算月份</th> -->
+<!-- 		    	<th style="color: red">加油包/结算数</th> -->
+<!-- 		    	<th style="color: red">加油包结算金额</th> -->
 		    	
-		    	<th >总结算金额</th>
+<!-- 		    	<th >总结算金额</th> -->
 		    </tr>
 		</thead>
 		<tbody>
@@ -103,13 +104,14 @@
 					</td>
 					
 					<td th:text="${item.get('moid')!=null ? item.get('balance_month') : ''   }"></td>
+					<td th:text="${item.get('moid')!=null ? item.get('sign_time') : '' }"></td>
 					<td th:text="${item.get('moid')!=null ? item.get('price') : '0' }"></td>
 	
-					<td th:text="${item.get('count_2')>0 ? item.get('balance_month') : ''   }"></td>
-					<td th:text="${item.get('count_2')>0 ? item.get('count_2') : ''   }"></td>
-					<td th:text="${item.get('price_1')}"></td>
+<!-- 					<td th:text="${item.get('count_2')>0 ? item.get('balance_month') : ''   }"></td> -->
+<!-- 					<td th:text="${item.get('count_2')>0 ? item.get('count_2') : ''   }"></td> -->
+<!-- 					<td th:text="${item.get('price_1')}"></td> -->
 					
-					<td th:text="${item.get('sum_price_3')}"></td>
+<!-- 					<td th:text="${item.get('sum_price_3')}"></td> -->
 			</tr>
 		</tbody>
 	</table>

+ 9 - 8
src/main/resources/templates/sys/fx/merchantAllList.html

@@ -292,13 +292,13 @@
 		    	<th >商户套餐 </th>
 		    	<th >商户模式 </th>
 		    	<th >平台管理费 </th>
-		    	<th style="width: 60px;">签约端口数量</th>
 		    	<th style="width: 60px;">服务人数</th>
+		    	<th style="width: 60px;">签约端口数量</th>
 		    	<th style="width: 60px;">剩余机构塾币</th>
 		    	<th style="max-width: 160px;" >合同日期</th>
-		    	<th style="width: 60px;" >激活开始日期</th>
-		    	<th style="width: 60px;" >激活结束日期</th>
-		    	<th style="width: 60px;" >计费开始日期</th>
+<!-- 		    	<th style="width: 60px;" >激活开始日期</th> -->
+<!-- 		    	<th style="width: 60px;" >激活结束日期</th> -->
+<!-- 		    	<th style="width: 60px;" >计费开始日期</th> -->
 		    	<th style="width: 60px;" >服务结束日期</th>
 		    	<th  >状态</th> 
 		        <th  >操作</th> 
@@ -340,15 +340,16 @@
 					</td>
 					
 					<td  th:text="${item.posType>1 ? item.outPrice: '--' }"></td>
-					<td  th:text="${item.portNum}"></td>
 					<td  th:text="${item.posType>1 ? item.libService : '--'}"></td>
+					
+					<td  th:text="${item.posType<=1 ? item.portNum : '--' }"></td>
 					<td  th:text="${item.posType<=1 ? item.libService  : '--' }"></td>
 					
 					
 					<td th:title="${item.signTime!=null ?  #dates.format(item.signTime, 'yyyy-MM-dd')+'~'+#dates.format(item.endSignTime, 'yyyy-MM-dd') : '--' }"  th:text="${item.signTime!=null ?  #dates.format(item.signTime, 'yyyy-MM-dd')+'~'+#dates.format(item.endSignTime, 'yyyy-MM-dd') : '--' }"></td>
-					<td  th:text="${item.posType>1 ? #calendars.format(item.startActiveTime,'yyyy-MM-dd'): '--'}" ></td> 
-					<td  th:text="${item.posType>1 ? #calendars.format(item.activeTime,'yyyy-MM-dd'): '--'}" ></td> 
-					<td  th:text="${item.posType>1 ? #calendars.format(item.computeTime,'yyyy-MM-dd'): '--'}" ></td> 
+<!-- 					<td  th:text="${item.posType>1 ? #calendars.format(item.startActiveTime,'yyyy-MM-dd'): '--'}" ></td>  -->
+<!-- 					<td  th:text="${item.posType>1 ? #calendars.format(item.activeTime,'yyyy-MM-dd'): '--'}" ></td>  -->
+<!-- 					<td  th:text="${item.posType>1 ? #calendars.format(item.computeTime,'yyyy-MM-dd'): '--'}" ></td>  -->
 					<td  th:text="${item.posType>1 ? #calendars.format(item.endActiveTime,'yyyy-MM-dd'): '--'}" ></td> 
 					<td  th:switch="${item.status}">
 					   <span th:case="1" >冻结&nbsp;</span>

+ 17 - 0
src/main/resources/templates/sys/fx/merchantMealAdd.html

@@ -317,6 +317,23 @@
 		        <td></td>
 		      </tr>
 		      
+		      
+		       <tr valign="top" th:if="${activeTime!=null}">
+	  			<td align="right" width="70" style="line-height: 30px;font-weight: 700">合同激活日期:</td>
+	  	        <td>
+		        	<ul class="nmb_jj">
+			            <li style="position: absolute;">
+			            	<input type="text" style="width: 120px;" class="srkk"  id="activeTime" name="activeTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true})" autocomplete="off" th:value="${#dates.format(activeTime, 'yyyy-MM-dd')}" placeholder="合同开始激活日期">
+			            </li>
+		          </ul>
+		        </td>
+		      </tr>
+		      <tr th:if="${activeTime!=null}">
+		        <td height="20"></td>
+		        <td></td>
+		      </tr>
+		      
+		      
 		      <tr valign="top">
 	  			<td align="right" width="70" style="line-height: 30px;font-weight: 700">购买月数量:</td>
 	  	        <td>