Kaynağa Gözat

商户新模式结算

wuwen 5 yıl önce
ebeveyn
işleme
81bcaec921
24 değiştirilmiş dosya ile 850 ekleme ve 208 silme
  1. 41 26
      src/main/java/com/ssj/api/controller/ApiMerchantController.java
  2. 31 0
      src/main/java/com/ssj/bean/sys/fx/domain/Merchant.java
  3. 20 0
      src/main/java/com/ssj/bean/weixin/libmy/domain/TbLibJoinConsume.java
  4. 2 0
      src/main/java/com/ssj/dao/sys/fx/dao/FinanceQueryDao.java
  5. 8 4
      src/main/java/com/ssj/dao/sys/fx/dao/MerchantDao.java
  6. 41 2
      src/main/java/com/ssj/dao/sys/fx/dao/impl/FinanceQueryDaoImpl.java
  7. 7 3
      src/main/java/com/ssj/dao/weixin/library/dao/ILibJoinConsumeDao.java
  8. 2 0
      src/main/java/com/ssj/service/sys/finance/service/IFinanceService.java
  9. 5 0
      src/main/java/com/ssj/service/sys/finance/service/impl/FinanceServiceImpl.java
  10. 9 6
      src/main/java/com/ssj/service/sys/fx/service/MerchantService.java
  11. 87 29
      src/main/java/com/ssj/service/sys/fx/service/impl/MerchantServiceImpl.java
  12. 192 41
      src/main/java/com/ssj/service/sys/fx/service/impl/MerchantSignServiceImpl.java
  13. 1 0
      src/main/java/com/ssj/service/sys/role/service/impl/AdminServiceImpl.java
  14. 3 0
      src/main/java/com/ssj/service/weixin/library/service/ILibJoinConsumeService.java
  15. 25 13
      src/main/java/com/ssj/service/weixin/library/service/impl/LibJoinServiceConsumeImpl.java
  16. 1 1
      src/main/java/com/ssj/service/weixin/sales/service/impl/LibVipServiceServiceImpl.java
  17. 137 2
      src/main/java/com/ssj/sys/controller/FinanceReportController.java
  18. 36 11
      src/main/java/com/ssj/sys/controller/FxController.java
  19. 1 1
      src/main/resources/templates/sys/finance/allList4.html
  20. 0 0
      src/main/resources/templates/sys/finance/allList5.html
  21. 113 0
      src/main/resources/templates/sys/finance/allList6.html
  22. 24 12
      src/main/resources/templates/sys/fx/consumeList.html
  23. 31 19
      src/main/resources/templates/sys/fx/merchantAdd.html
  24. 33 38
      src/main/resources/templates/sys/fx/merchantAllList.html

+ 41 - 26
src/main/java/com/ssj/api/controller/ApiMerchantController.java

@@ -4,6 +4,7 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +38,17 @@ public class ApiMerchantController extends BaseController {
 	@Autowired
 	private ILibJoinConsumeService  libJoinConsumeService;
 	
+	
+	
+	//1:激活日期之前,生成一条数据为0的记录,重新设置激活日期,设置下一个结算日。
+	//注:type=1处理
+	
+	//2:开始计费日之前的,由定时任务处理数据,这里不做处理。
+	//注:type=1处理
+	
+	//3:开始计费日之后的,第1次激活的,生成一条真实的数据,设置下一个结算日。
+	//注:type=1处理
+	
 	@IgnoreSecurity
 	@RequestMapping(value = "/service")
     @ApiOperation(value = "获取商户套餐信息接口",  notes = "获取商户套餐信息接口")
@@ -46,35 +58,38 @@ public class ApiMerchantController extends BaseController {
         Map<String,Object> data=new HashMap<String, Object>();
         try {
         	Merchant merchant=merchantService.getMerchantByLibId(requestVO.getLibId());
-        	if(merchant!=null) {
-        		
-        		//大于2020-10-09才会结算。
-        		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        		String dateString="2020-10-09";
-        		
-	        	if(requestVO.getType()==1 
-	        			&& sdf.parse(dateString).getTime()<=new Date().getTime()) {
-	        		
-					merchant.setCurIsSummary(1);
-					merchant.setCurSummaryTime(new Date());
-					merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
-					merchantService.save(merchant);
-					
-					TbLibJoinConsume consume = new TbLibJoinConsume();
-					consume.setFromLibId(merchant.getLibId());
-					consume.setFromMerchantId(merchant.getId());
-					consume.setLibService(merchant.getLibService());
-					consume.setPlatformService(0);
-					consume.setType(2);
-					consume.setRemarks("消费【新模式用户激活消费】 -来源开放接口");
-					consume.setCreateTime(new Date());
-					libJoinConsumeService.save(consume);
-	        	}
+        	if(merchant!=null && merchant.getStartActiveTime()!=null) {
+        		if(merchant.getStartActiveTime().getTime()<=new Date().getTime()) {
+        			//1:激活日期之后才可以生成数据,生成一条数据为0的记录,重新设置激活日期,设置下一个结算日。
+        			List<TbLibJoinConsume> consumes=libJoinConsumeService.findTbLibJoinConsumeByStartActiveTime(merchant.getId(), merchant.getStartActiveTime());
+        			if(consumes==null || consumes.size()<=0) {
+        				logger.info("第三方调用接口【service】,商户产生激活期:"+merchant.getId());
+        				
+	        			merchant.setCurIsSummary(0);
+	        			merchant.setActiveTime(new Date());
+						merchant.setCurSummaryTime(new Date());
+						merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
+						merchantService.save(merchant);
+						
+						//记录
+						TbLibJoinConsume consume=new TbLibJoinConsume();
+						consume.setFromLibId(merchant.getLibId());
+						consume.setFromMerchantId(merchant.getId());
+						consume.setLibService(0);
+						consume.setPlatformService(0);
+						consume.setType(7);
+						consume.setSignType(merchant.getSignType());
+						consume.setRemarks("激活期扣费【服务包扣费】-来源开放接口");
+						consume.setCreateTime(new Date());
+						libJoinConsumeService.save(consume);
+        			}
+        		}
+	        	
 	        	DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         		data.put("id", merchant.getId());
         		data.put("libId", merchant.getLibId());
-        		data.put("summaryTime", merchant.getCurSummaryTime()!=null ?  format.format(merchant.getCurSummaryTime()) : "");
-        		data.put("endSummaryTime", merchant.getCurSummaryTime()!=null ? format.format(DateHelper.getMonthDate(merchant.getCurSummaryTime(),merchant.getLibServiceMonth())) : "");
+        		data.put("summaryTime", merchant.getComputeTime()!=null ?  format.format(merchant.getComputeTime()) : "");
+        		data.put("endSummaryTime", merchant.getComputeTime()!=null ? format.format(DateHelper.getMonthDate(merchant.getComputeTime(),merchant.getLibServiceMonth())) : "");
         		data.put("signType", merchant.getSignType());
         		data.put("libService", merchant.getLibService());
 	            responseEntity.success(data, "获取商户套餐信息成功");

+ 31 - 0
src/main/java/com/ssj/bean/sys/fx/domain/Merchant.java

@@ -95,6 +95,13 @@ public class Merchant extends BaseEntity {
 	private Integer signType;
 	
 	private Integer mealType;
+	
+	private Date startActiveTime;
+	
+	private Date activeTime;
+	
+	private Date computeTime;
+	
 
 	@Transient
 	private List<Merchant> subMerchants=new ArrayList<Merchant>();
@@ -397,4 +404,28 @@ public class Merchant extends BaseEntity {
 		this.mealType = mealType;
 	}
 
+	public Date getActiveTime() {
+		return activeTime;
+	}
+
+	public void setActiveTime(Date activeTime) {
+		this.activeTime = activeTime;
+	}
+
+	public Date getComputeTime() {
+		return computeTime;
+	}
+
+	public void setComputeTime(Date computeTime) {
+		this.computeTime = computeTime;
+	}
+
+	public Date getStartActiveTime() {
+		return startActiveTime;
+	}
+
+	public void setStartActiveTime(Date startActiveTime) {
+		this.startActiveTime = startActiveTime;
+	}
+
 }

+ 20 - 0
src/main/java/com/ssj/bean/weixin/libmy/domain/TbLibJoinConsume.java

@@ -20,6 +20,10 @@ public class TbLibJoinConsume extends BaseEntity{
 	
 	private String toMerchantId;
 	
+	private Integer signType;
+	
+	private Integer computeNum;
+	
 	private String vipId;
 	
 	private String derver;
@@ -121,6 +125,22 @@ public class TbLibJoinConsume extends BaseEntity{
 	public void setDerver(String derver) {
 		this.derver = derver;
 	}
+
+	public Integer getSignType() {
+		return signType;
+	}
+
+	public void setSignType(Integer signType) {
+		this.signType = signType;
+	}
+
+	public Integer getComputeNum() {
+		return computeNum;
+	}
+
+	public void setComputeNum(Integer computeNum) {
+		this.computeNum = computeNum;
+	}
     
 	
 	

+ 2 - 0
src/main/java/com/ssj/dao/sys/fx/dao/FinanceQueryDao.java

@@ -19,4 +19,6 @@ public interface FinanceQueryDao {
     
     Page<Map<String, Object>> balanceConsumeDetailList(Map<String, Object> params, Pageable pageable);
     
+    Page<Map<String, Object>> balanceConsumeDetailList_New(Map<String, Object> params, Pageable pageable);
+    
 }

+ 8 - 4
src/main/java/com/ssj/dao/sys/fx/dao/MerchantDao.java

@@ -46,12 +46,16 @@ public interface MerchantDao extends JpaRepository<Merchant, String> {
 	@Query(nativeQuery = true, value = " SELECT * from fx_merchant t where t.sign_type in (1,2,3)  ORDER BY t.create_time ASC ")
 	public List<Merchant> findMerchantSignByAll();
 	
-	@Query(nativeQuery = true, value = " SELECT * from fx_merchant t where t.sign_type in (1,2,3) AND TO_DAYS(t.end_sign_time)<=TO_DAYS(NOW()) ORDER BY t.create_time ASC ")
-	public List<Merchant> findMerchantSignByEndTime();
-	
-	@Query(nativeQuery = true, value = " SELECT * from fx_merchant t where t.sign_type in (1,2,3) AND TO_DAYS(t.next_summary_time)<=TO_DAYS(NOW()) ORDER BY t.create_time ASC ")
+	@Query(nativeQuery = true, value = " SELECT * from fx_merchant t where t.sign_type in (1,2,3) AND TO_DAYS(t.next_summary_time)=TO_DAYS(NOW()) ORDER BY t.create_time ASC ")
 	public List<Merchant> findMerchantSignBySummaryTime();
 	
+	@Query(nativeQuery = true, value = " SELECT * from fx_merchant t where t.sign_type in (1,2,3) AND TO_DAYS(t.active_time)=TO_DAYS(NOW()) ORDER BY t.create_time ASC ")
+	public List<Merchant> findMerchantSignByActiveTime();
+	
+	@Query(nativeQuery = true, value = " SELECT * from fx_merchant t where t.sign_type in (1,2,3) AND TO_DAYS(t.compute_time)=TO_DAYS(NOW()) ORDER BY t.create_time ASC ")
+	public List<Merchant> findMerchantSignByComputeTime();
+	
+	
 	
 	
 }

+ 41 - 2
src/main/java/com/ssj/dao/sys/fx/dao/impl/FinanceQueryDaoImpl.java

@@ -445,15 +445,54 @@ public class FinanceQueryDaoImpl implements FinanceQueryDao {
          selSql.append(" ) AS derver_count");
          selSql.append(" from fx_merchant t ");
          selSql.append(" LEFT JOIN tb_lib_join j on t.lib_id=j.id ");
-         selSql.append(" where t.`status`!=4 and t.type in (1,2) ");
+         selSql.append(" where t.`status`!=4 and t.sign_type=0 and t.type in (1,2) ");
          if(!StringUtil.isEmpty(params.get("unitName"))){
              selSql.append(" AND (t.unit_name LIKE concat('%',?,'%')  OR j.league_name LIKE concat('%',?,'%')  ) ");
              queryParams.add(params.get("unitName"));
              queryParams.add(params.get("unitName"));
          }
-         selSql.append(" ORDER BY t.sign_time asc ");
+         selSql.append(" ORDER BY FIELD(t.`type`,1,2),t.create_time asc ");
          selSql.append(" ) as tmp ");
          return dao.findPage(selSql.toString(),queryParams.toArray(),pageable);
 	}
 
+	
+	
+
+	@Override
+	public Page<Map<String, Object>> balanceConsumeDetailList_New(Map<String, Object> params, Pageable pageable) {
+		 StringBuilder selSql = new StringBuilder();
+         List<Object> queryParams = new ArrayList<Object>();
+         
+         selSql.append(" SELECT t.*, ");
+         selSql.append(" IFNULL((SELECT SUM(c.lib_service) from tb_lib_join_consume c WHERE c.from_merchant_id=t.id AND c.type=7 AND DATE_FORMAT(c.create_time,'%Y-%m')=? ),0) as sum_1, ");
+         selSql.append(" IFNULL((SELECT SUM(c.lib_service) from tb_lib_join_consume c WHERE c.from_merchant_id=t.id AND c.type in (8,10) AND DATE_FORMAT(c.create_time,'%Y-%m')=? ),0) as sum_2, ");
+         selSql.append(" IFNULL((SELECT SUM(c.lib_service) from tb_lib_join_consume c WHERE c.to_merchant_id=t.id AND c.type=9 AND DATE_FORMAT(c.create_time,'%Y-%m')=? ),0) as sum_3, ");
+         selSql.append(" IFNULL((SELECT SUM(c.lib_service) from tb_lib_join_consume c WHERE c.from_merchant_id=t.id AND c.type=10 AND DATE_FORMAT(c.create_time,'%Y-%m')=? ),0) as sum_4, ");
+         selSql.append(" (SELECT COUNT(*) from tb_lib_join_consume c WHERE c.from_merchant_id=t.id AND c.type=7 AND DATE_FORMAT(c.create_time,'%Y-%m')=? ) as count_1, ");
+         selSql.append(" (SELECT COUNT(*) from tb_lib_join_consume c WHERE c.to_merchant_id=t.id AND c.type=9 AND DATE_FORMAT(c.create_time,'%Y-%m')=? ) as count_2,  ");
+         selSql.append(" ? as balance_month ");
+         queryParams.add(params.get("startMonth"));
+         queryParams.add(params.get("startMonth"));
+         queryParams.add(params.get("startMonth"));
+         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(" LEFT JOIN tb_lib_join j on t.lib_id=j.id ");
+         selSql.append(" where t.`status`!=4 and t.sign_type in (1,2,3) and t.type in (1,2) ");
+         if(!StringUtil.isEmpty(params.get("unitName"))){
+             selSql.append(" AND (t.unit_name LIKE concat('%',?,'%')  OR j.league_name LIKE concat('%',?,'%')  ) ");
+             queryParams.add(params.get("unitName"));
+             queryParams.add(params.get("unitName"));
+         }
+         selSql.append(" ORDER BY FIELD(t.`type`,1,2),t.create_time asc  ");
+         return dao.findPage(selSql.toString(),queryParams.toArray(),pageable);
+	}
+
+	
+	
 }

+ 7 - 3
src/main/java/com/ssj/dao/weixin/library/dao/ILibJoinConsumeDao.java

@@ -1,12 +1,13 @@
 package com.ssj.dao.weixin.library.dao;
 
-import com.ssj.bean.weixin.libmy.domain.TbLibJoinConsume;
+import java.util.Date;
+import java.util.List;
+
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
 
-import java.util.Date;
-import java.util.List;
+import com.ssj.bean.weixin.libmy.domain.TbLibJoinConsume;
 
 @Repository
 public interface ILibJoinConsumeDao extends JpaRepository<TbLibJoinConsume, String> {
@@ -26,6 +27,9 @@ public interface ILibJoinConsumeDao extends JpaRepository<TbLibJoinConsume, Stri
 	
 	@Query(nativeQuery = true, value = " SELECT IFNULL(COUNT(1),0) from tb_lib_join_consume t WHERE t.from_merchant_id=?1 AND t.type=2 AND t.vip_id is NOT NULL AND TO_DAYS(DATE_SUB(NOW(),INTERVAL 1 DAY))>TO_DAYS(t.create_time) ")
 	Integer findTbLibJoinConsumeByBeforeDays(String merchantId);
+	
+	@Query(nativeQuery = true, value = " SELECT * from tb_lib_join_consume t WHERE t.type=7 AND t.from_merchant_id=?1 AND TO_DAYS(t.create_time)>=TO_DAYS(?2) ORDER BY t.create_time ASC	")
+	public List<TbLibJoinConsume> findTbLibJoinConsumeByStartActiveTime(String merchantId, Date startActiveTime);
 
 	
 }

+ 2 - 0
src/main/java/com/ssj/service/sys/finance/service/IFinanceService.java

@@ -19,6 +19,8 @@ public interface IFinanceService {
     
     Page<Map<String, Object>> balanceConsumeDetailList(Map<String, Object> params, Pageable pageable);
     
+    Page<Map<String, Object>> balanceConsumeDetailList_New(Map<String, Object> params, Pageable pageable);
+    
     
     
 }

+ 5 - 0
src/main/java/com/ssj/service/sys/finance/service/impl/FinanceServiceImpl.java

@@ -47,4 +47,9 @@ public class FinanceServiceImpl implements IFinanceService {
 	public Page<Map<String, Object>> balanceConsumeDetailList(Map<String, Object> params, Pageable pageable) {
 		return dao.balanceConsumeDetailList(params, pageable);
 	}
+
+	@Override
+	public Page<Map<String, Object>> balanceConsumeDetailList_New(Map<String, Object> params, Pageable pageable) {
+		return dao.balanceConsumeDetailList_New(params, pageable);
+	}
 }

+ 9 - 6
src/main/java/com/ssj/service/sys/fx/service/MerchantService.java

@@ -18,7 +18,7 @@ public interface MerchantService extends BaseService<Merchant, String> {
     		,String password,String province,String city,String area,String schoollist,String location,Admin curadmin);
 	
 	//保存新模式的商户
-	Response saveMerchantByNew(Merchant merchant,String startTime,String endTime,String summaryTime
+	Response saveMerchantByNew(Merchant merchant,String startTime,String endTime,String startActiveTimeStr,String activeTimeStr,String computeTimeStr
     		,String password,String province,String city,String area,String schoollist,String location,Admin curadmin);
 	
 	//导入商户数据,生成帐号
@@ -133,16 +133,19 @@ public interface MerchantService extends BaseService<Merchant, String> {
 	//通过vipId查出这个绑定机构对应的商户,两个月内绑定的商户
 	Merchant getDefaultMerchantByVipId(String vipId);
 	
-	
 	public List<Merchant> findMerchantByType(int[] type);
 	
-	//套餐过期的商户
-	List<Merchant> findMerchantSignByEndTime();
 	
+	List<Merchant> findMerchantSignByAll();
+	
+	//下一个结算日的商户列表
 	List<Merchant> findMerchantSignBySummaryTime();
 	
-	List<Merchant> findMerchantSignByAll();
+	//当日激活期的商户列表
+	List<Merchant> findMerchantSignByActiveTime();
+	
+	//当日开始计费日的商户列表
+	List<Merchant> findMerchantSignByComputeTime();
 	
-
 
 }

+ 87 - 29
src/main/java/com/ssj/service/sys/fx/service/impl/MerchantServiceImpl.java

@@ -331,6 +331,7 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 					tbLibJoinConsume.setPlatformService(0);
 					tbLibJoinConsume.setRemarks("会员服务过期,自动续费扣币");
 					tbLibJoinConsume.setType(2);
+					tbLibJoinConsume.setSignType(0);
 					tbLibJoinConsume.setCreateTime(new Date());
 					joinConsumeService.save(tbLibJoinConsume);
 					
@@ -539,6 +540,7 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 								tbLibJoinConsume.setPlatformService(0);
 								tbLibJoinConsume.setRemarks("会员服务过期,自动续费扣币,"+merchant.getUnitName()+" 商户币不足,扣上一级");
 								tbLibJoinConsume.setType(2);
+								tbLibJoinConsume.setSignType(0);
 								tbLibJoinConsume.setCreateTime(new Date());
 								joinConsumeService.save(tbLibJoinConsume);
 							}else {
@@ -559,6 +561,7 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 										tbLibJoinConsume.setPlatformService(0);
 										tbLibJoinConsume.setRemarks("会员服务过期,自动续费扣币,"+merchant.getUnitName()+" 商户币不足,扣上二级");
 										tbLibJoinConsume.setType(2);
+										tbLibJoinConsume.setSignType(0);
 										tbLibJoinConsume.setCreateTime(new Date());
 										joinConsumeService.save(tbLibJoinConsume);
 									}else {
@@ -933,6 +936,7 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 			tbLibJoinConsume.setPlatformService(0);
 			tbLibJoinConsume.setRemarks(remarks);
 			tbLibJoinConsume.setType(3);
+			tbLibJoinConsume.setSignType(0);
 			tbLibJoinConsume.setCreateTime(new Date());
 			joinConsumeService.save(tbLibJoinConsume);
 		} catch (Exception e) {
@@ -1210,10 +1214,6 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 		return dao.findMerchantByType(type);
 	}
 
-	@Override
-	public List<Merchant> findMerchantSignByEndTime() {
-		return dao.findMerchantSignByEndTime();
-	}
 
 	@Override
 	public List<Merchant> findMerchantSignBySummaryTime() {
@@ -1410,7 +1410,7 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 	@Override
 	public Response saveMerchantByNew(
 				Merchant merchant,
-				String startTime,String endTime,String summaryTime,String password,String province,String city,String area,String schoollist,String location,
+				String startTime,String endTime,String startActiveTimeStr,String activeTimeStr,String computeTimeStr,String password,String province,String city,String area,String schoollist,String location,
 				Admin curadmin) {
 		Response response=new Response();
 		
@@ -1427,7 +1427,15 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 				        return response;
 					}
 				}
+				if(merchant.getLibServiceMonth()<oldmerchant.getLibServiceMonth()) {
+					response.failure("您充值月份数不可小于当前月份数");
+			        return response;
+				}
 				
+				//旧的月份
+				Integer oldMonth=oldmerchant.getLibServiceMonth();
+				//新的月份
+				Integer month=merchant.getLibServiceMonth();
 				
 				if(!oldmerchant.getSignType().equals(merchant.getSignType())) {
 					isSignType=true;
@@ -1435,6 +1443,7 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 				if(!oldmerchant.getLibServiceMonth().equals(merchant.getLibServiceMonth())) {
 					isServiceMonth=true;
 				}
+				
 				oldmerchant.setDeputyName(merchant.getDeputyName());
 				oldmerchant.setDeputyPhone(merchant.getDeputyPhone());
 				oldmerchant.setLegalPerson(merchant.getLegalPerson());
@@ -1452,13 +1461,29 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 				oldmerchant.setAddress(merchant.getAddress());
 				oldmerchant.setMealType(merchant.getMealType());
 				oldmerchant.setLibServiceMonth(merchant.getLibServiceMonth());
-				if(StringUtils.isNotEmpty(summaryTime)) {
-					oldmerchant.setCurSummaryTime(summaryTime!=null ? DateHelper.parseDate(summaryTime, "yyyy-MM-dd"): null);
-					oldmerchant.setNextSummaryTime(summaryTime!=null ? DateHelper.parseDate(summaryTime, "yyyy-MM-dd"): null);
-				}
 				oldmerchant.setLocation(location);
-				oldmerchant.setSignTime(startTime!=null ? DateHelper.parseDate(startTime, "yyyy-MM-dd"): null);
-				oldmerchant.setEndSignTime(endTime!=null ? DateHelper.parseDate(endTime, "yyyy-MM-dd"): null);
+				
+				
+				if(StringUtils.isNotEmpty(startActiveTimeStr)) {
+					oldmerchant.setStartActiveTime(DateHelper.parseDate(startActiveTimeStr, "yyyy-MM-dd"));
+				}
+				if(StringUtils.isNotEmpty(activeTimeStr)) {
+					oldmerchant.setActiveTime(DateHelper.parseDate(activeTimeStr, "yyyy-MM-dd"));
+				}
+				if(StringUtils.isNotEmpty(activeTimeStr)) {
+					oldmerchant.setCurSummaryTime(DateHelper.parseDate(activeTimeStr, "yyyy-MM-dd"));
+					oldmerchant.setNextSummaryTime(DateHelper.getMonthDate(oldmerchant.getCurSummaryTime(),1));
+				}
+				
+				if(StringUtils.isNotEmpty(computeTimeStr)) {
+					oldmerchant.setComputeTime(DateHelper.parseDate(computeTimeStr, "yyyy-MM-dd"));
+				}
+				if(StringUtils.isNotEmpty(startTime)) {
+					oldmerchant.setSignTime(DateHelper.parseDate(startTime, "yyyy-MM-dd"));
+				}
+				if(StringUtils.isNotEmpty(endTime)) {
+					oldmerchant.setEndSignTime(DateHelper.parseDate(endTime, "yyyy-MM-dd"));
+				}
 				
 				//删除所有关联的学校
 				List<MerchantArea> merchantAreas=merchantAreaService.findSchoolByMerchantList(merchant.getId());
@@ -1506,18 +1531,6 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 							break;
 					}
 					
-					//记录套餐更改记录
-					for (int i = 1; i <= merchant.getLibServiceMonth(); i++) {
-						TbLibJoinConsume consume=new TbLibJoinConsume();
-						consume.setToLibId(merchant.getLibId());
-						consume.setToMerchantId(merchant.getId());
-						consume.setLibService(oldmerchant.getLibService());
-						consume.setPlatformService(0);
-						consume.setType(1);
-						consume.setRemarks("充值【套餐模式更改】,开通月份:"+i);
-						consume.setCreateTime(new Date());
-						libJoinConsumeService.save(consume);
-					}
 					//更新套餐
 					oldmerchant.setSignType(merchant.getSignType());
 				}
@@ -1540,8 +1553,22 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 				}
 				
 				
-				//旧套餐大于新套餐的话,就服务降级
 				if(isSignType || isServiceMonth) {
+					//记录套餐更改记录
+					for (int i = oldMonth+1; i <= month; i++) {
+						TbLibJoinConsume consume=new TbLibJoinConsume();
+						consume.setToLibId(merchant.getLibId());
+						consume.setToMerchantId(merchant.getId());
+						consume.setLibService(oldmerchant.getLibService());
+						consume.setPlatformService(0);
+						consume.setType(6);
+						consume.setSignType(merchant.getSignType());
+						consume.setComputeNum(merchant.getCurIsSummary());
+						consume.setRemarks("服务包开通【服务包更改:第"+i+"月】");
+						consume.setCreateTime(new Date());
+						libJoinConsumeService.save(consume);
+					}
+					
 					//调用openApi接口
 					DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
 					libVipServiceService.openApiServiceCRM(
@@ -1549,7 +1576,7 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 							oldmerchant.getLibId(), 
 							oldmerchant.getSignType(),
 							oldmerchant.getLibService(),
-							format.format(DateHelper.getMonthDate(oldmerchant.getCurSummaryTime(),oldmerchant.getLibServiceMonth())));
+							format.format(DateHelper.getMonthDate(oldmerchant.getComputeTime(),oldmerchant.getLibServiceMonth())));
 				}
 				
 				
@@ -1588,10 +1615,29 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 				merchant.setCreateTime(new Date());
 				merchant.setSaleLoginName(curadmin.getLoginName());
 				merchant.setCurIsSummary(0);
-				merchant.setCurSummaryTime(StringUtils.isNotEmpty(summaryTime) ? DateHelper.parseDate(summaryTime, "yyyy-MM-dd"): null);
-				merchant.setNextSummaryTime(StringUtils.isNotEmpty(summaryTime) ? DateHelper.parseDate(summaryTime, "yyyy-MM-dd"): null);
 				merchant.setSignTime(startTime!=null ? DateHelper.parseDate(startTime, "yyyy-MM-dd"):null);
 				merchant.setEndSignTime(endTime!=null ? DateHelper.parseDate(endTime, "yyyy-MM-dd"): null);
+				
+				if(StringUtils.isNotEmpty(startActiveTimeStr)) {
+					merchant.setStartActiveTime(DateHelper.parseDate(startActiveTimeStr, "yyyy-MM-dd"));
+				}
+				if(StringUtils.isNotEmpty(activeTimeStr)) {
+					merchant.setActiveTime(DateHelper.parseDate(activeTimeStr, "yyyy-MM-dd"));
+				}
+				if(StringUtils.isNotEmpty(computeTimeStr)) {
+					merchant.setComputeTime(DateHelper.parseDate(computeTimeStr, "yyyy-MM-dd"));
+				}
+				if(StringUtils.isNotEmpty(activeTimeStr)) {
+					merchant.setCurSummaryTime(DateHelper.parseDate(activeTimeStr, "yyyy-MM-dd"));
+					merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
+				}
+				if(StringUtils.isNotEmpty(startTime)) {
+					merchant.setSignTime(DateHelper.parseDate(startTime, "yyyy-MM-dd"));
+				}
+				if(StringUtils.isNotEmpty(endTime)) {
+					merchant.setEndSignTime(DateHelper.parseDate(endTime, "yyyy-MM-dd"));
+				}
+				
 				String code="SSJ-FX";
 				if(StringUtils.isNotEmpty(merchant.getParentPosCode())){
 					Merchant pMerchant =this.getMerchantByPosCode(merchant.getParentPosCode());
@@ -1670,8 +1716,10 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 					consume.setToMerchantId(merchant.getId());
 					consume.setLibService(merchant.getLibService());
 					consume.setPlatformService(0);
-					consume.setType(1);
-					consume.setRemarks("充值【套餐模式开通】,开通月份:"+i);
+					consume.setSignType(merchant.getSignType());
+					consume.setType(6);
+					consume.setComputeNum(merchant.getCurIsSummary());
+					consume.setRemarks("服务包开通【服务包开通:第"+i+"月】");
 					consume.setCreateTime(new Date());
 					libJoinConsumeService.save(consume);
 				}
@@ -1687,6 +1735,16 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 	public List<Merchant> findMerchantSignByAll() {
 		return dao.findMerchantSignByAll();
 	}
+
+	@Override
+	public List<Merchant> findMerchantSignByActiveTime() {
+		return dao.findMerchantSignByActiveTime();
+	}
+
+	@Override
+	public List<Merchant> findMerchantSignByComputeTime() {
+		return dao.findMerchantSignByComputeTime();
+	}
 	
 
 }

+ 192 - 41
src/main/java/com/ssj/service/sys/fx/service/impl/MerchantSignServiceImpl.java

@@ -1,7 +1,5 @@
 package com.ssj.service.sys.fx.service.impl;
 
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
@@ -66,7 +64,19 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
 
     //12点定时任务,处理套餐的数据
     //1:处理加油包过期的数据
-    //2:处理商户主套餐过期的数据,加油包全过期。
+    
+    //2:处理激活日期的数据,生成一条0的激活数据,设置下一个结算日,CurIsSummary=0,免费结算
+    //注:如果在激活日期之前的时间,也会生成一条0的激活数据,设置下一个结算日,CurIsSummary=0,免费结算
+    
+    //3:处理激活日期的下一结算日数据,再生成一条0的结算数据,CurIsSummary=0的,设置下一个结算时间。
+    //注:设置当前的时间
+    
+    //4:处理开始计费日期,生成一条真实的数据30,设置当前的时间, 设置下一个结算日,CurIsSummary=+1,真实开始结算。
+    
+    
+    //5:处理开始计费日期的下一个结算日,生成一条30的数据,如果当前的CurIsSummary>=LibServiceMonth证明,结算完成,把结算日期都设置为空。
+    //注:处理商户主套餐过期的数据,加油包全过期。
+    
     @Override
 	public void runMerchantSignByEndTime() {
     	try {
@@ -74,11 +84,10 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
 			List<MerchantSign> merchantSigns=dao.findMerchantSignByEndTime();
 			for (MerchantSign merchantSign : merchantSigns) {
 				try {
-					merchantSign.setRemarks("加油包过期");
+					merchantSign.setRemarks("加油包失效【加油包过期");
 					merchantSign.setStatus(1);
 					merchantSign.setUpdateTime(new Date());
 					this.save(merchantSign);
-					
 					Merchant merchant = merchantService.getById(merchantSign.getMerchantId());
 					merchant.setLibService(merchant.getLibService()-merchantSign.getLibService());
 					merchantService.save(merchant);
@@ -91,18 +100,18 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
 						List<LibVip> libVips=libVipService.findByLibId(merchant.getLibId());
 						if(libVips.size()>merchant.getLibService()) {
 							//这里需要调用灿哥的代码。
-							
 						}
 					}
-					
 					//记录加油包记录
 					TbLibJoinConsume consume=new TbLibJoinConsume();
 					consume.setFromLibId(merchant.getLibId());
 					consume.setFromMerchantId(merchant.getId());
 					consume.setLibService(merchantSign.getLibService());
 					consume.setPlatformService(0);
-					consume.setType(2);
-					consume.setRemarks("消费【加油包过期】");
+					consume.setType(10);
+					consume.setComputeNum(merchant.getCurIsSummary());
+					consume.setSignType(merchant.getSignType());
+					consume.setRemarks("加油包失效【加油包过期】");
 					consume.setCreateTime(new Date());
 					libJoinConsumeService.save(consume);
 					
@@ -113,23 +122,150 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
 							merchant.getSignType(),
 							merchant.getLibService(),
 							null);
+				} catch (Exception e) {
+					e.printStackTrace();
+					logger.error("1:处理加油包过期数据,异常:"+e.getMessage());
+				}
+			}
+			
+			
+			//2:处理激活日期的数据,生成一条0的激活数据,设置下一个结算日,CurIsSummary=0,免费结算
+		    //注:如果在激活日期之前的时间,也会生成一条0的激活数据,设置下一个结算日,CurIsSummary=0,免费结算
+			List<Merchant> activeMerchants=merchantService.findMerchantSignByActiveTime();
+			for (Merchant merchant : activeMerchants) {
+				try {
+					merchant.setCurIsSummary(0);
+					merchant.setCurSummaryTime(new Date());
+					merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
+					merchantService.save(merchant);
+					
+					//记录
+					TbLibJoinConsume consume=new TbLibJoinConsume();
+					consume.setFromLibId(merchant.getLibId());
+					consume.setFromMerchantId(merchant.getId());
+					consume.setLibService(0);
+					consume.setPlatformService(0);
+					consume.setType(7);
+					consume.setComputeNum(merchant.getCurIsSummary());
+					consume.setSignType(merchant.getSignType());
+					consume.setRemarks("激活期扣费【服务包扣费】");
+					consume.setCreateTime(new Date());
+					libJoinConsumeService.save(consume);
 					
 				} catch (Exception e) {
 					e.printStackTrace();
-					logger.error("1:处理加油包过期的数据,异常:"+e.getMessage());
+					logger.error("2:处理商户系统激活日期数据,异常:"+e.getMessage());
 				}
 			}
 			
 			
-			//2:处理商户结算的数据
+			//3:处理激活日期的下一结算日数据,再生成一条0的结算数据,CurIsSummary=0的,设置下一个结算时间。
+		    //注:设置当前的时间
+			List<Merchant> activeEndMerchants=merchantService.findMerchantSignBySummaryTime();
+			for (Merchant merchant : activeEndMerchants) {
+				
+				//只有在激活期的商户才处理数据。
+				if(merchant.getCurIsSummary()==null || merchant.getCurIsSummary()==0) {
+					try {
+						merchant.setCurIsSummary(0);
+						merchant.setCurSummaryTime(new Date());
+						merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
+						merchantService.save(merchant);
+						
+						//记录
+						TbLibJoinConsume consume=new TbLibJoinConsume();
+						consume.setFromLibId(merchant.getLibId());
+						consume.setFromMerchantId(merchant.getId());
+						consume.setLibService(0);
+						consume.setPlatformService(0);
+						consume.setType(8);
+						consume.setComputeNum(merchant.getCurIsSummary());
+						consume.setSignType(merchant.getSignType());
+						consume.setRemarks("激活期失效【服务包失效】");
+						consume.setCreateTime(new Date());
+						libJoinConsumeService.save(consume);
+						
+					} catch (Exception e) {
+						e.printStackTrace();
+						logger.error("3:处理商户激活结算日期数据,异常:"+e.getMessage());
+					}
+				}
+			}
+			
+			
+			
+			//4:处理开始计费日期,生成一条真实的数据30,设置当前的时间, 设置下一个结算日,CurIsSummary=+1,真实开始结算。
+			List<Merchant> computeMerchants=merchantService.findMerchantSignByComputeTime();
+			for (Merchant merchant : computeMerchants) {
+				try {
+					
+					//记录激活期的结算
+					TbLibJoinConsume consume=new TbLibJoinConsume();
+					consume.setFromLibId(merchant.getLibId());
+					consume.setFromMerchantId(merchant.getId());
+					consume.setLibService(0);
+					consume.setPlatformService(0);
+					consume.setType(8);
+					consume.setComputeNum(merchant.getCurIsSummary());
+					consume.setSignType(merchant.getSignType());
+					consume.setRemarks("激活期失效【服务包失效】");
+					consume.setCreateTime(new Date());
+					libJoinConsumeService.save(consume);
+					
+					
+					merchant.setCurIsSummary(1);
+					merchant.setCurSummaryTime(new Date());
+					merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
+					merchantService.save(merchant);
+					
+					//记录
+					consume=new TbLibJoinConsume();
+					consume.setFromLibId(merchant.getLibId());
+					consume.setFromMerchantId(merchant.getId());
+					consume.setLibService(merchant.getLibService());
+					consume.setPlatformService(0);
+					consume.setType(7);
+					consume.setComputeNum(merchant.getCurIsSummary());
+					consume.setSignType(merchant.getSignType());
+					consume.setRemarks("计费期扣费【服务包扣费:第"+merchant.getCurIsSummary()+"月】");
+					consume.setCreateTime(new Date());
+					libJoinConsumeService.save(consume);
+
+				} catch (Exception e) {
+					e.printStackTrace();
+					logger.error("2:处理商户系统激活日期数据,异常:"+e.getMessage());
+				}
+			}
+			
+			
+			
+			//5:处理商户结算的数据
 			List<Merchant> summaryMerchants=merchantService.findMerchantSignBySummaryTime();
 			for (Merchant merchant : summaryMerchants) {
 				try {
-					//没有月份了,直接跳出
-					if(merchant.getLibServiceMonth()<=0) {
+					//还在免费期的,直接跳出,由第3步处理了
+					if(merchant.getCurIsSummary()==null || merchant.getCurIsSummary()<=0) {
 						continue;
 					}
 					
+					//没有月份数据的,直接跳出,不做处理
+					if(merchant.getLibServiceMonth()==null || merchant.getLibServiceMonth()<=0) {
+						continue;
+					}
+					
+					//记录
+					TbLibJoinConsume consume=new TbLibJoinConsume();
+					consume.setFromLibId(merchant.getLibId());
+					consume.setFromMerchantId(merchant.getId());
+					consume.setLibService(0);
+					consume.setSignType(merchant.getSignType());
+					consume.setPlatformService(0);
+					consume.setType(8);
+					consume.setComputeNum(merchant.getCurIsSummary());
+					consume.setRemarks("计费期失效【服务包失效:第"+(merchant.getCurIsSummary())+"月】");
+					consume.setCreateTime(new Date());
+					libJoinConsumeService.save(consume);
+					
 					//处理商户结算的数据
 					//已经够月份了,就终止商户
 					if(merchant.getCurIsSummary()>=merchant.getLibServiceMonth()) {
@@ -156,24 +292,28 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
 							logger.error("3:处理商户结算的数据,异常:"+e.getMessage());
 						}
 						continue;
+					}else {
+						merchant.setCurIsSummary(merchant.getCurIsSummary()==null ? 1 : merchant.getCurIsSummary()+1);
+						merchant.setCurSummaryTime(new Date());
+						merchant.setNextSummaryTime(DateHelper.getMonthDate(new Date(),1));
+						merchantService.save(merchant);
+						
+						
+						//记录
+						consume=new TbLibJoinConsume();
+						consume.setFromLibId(merchant.getLibId());
+						consume.setFromMerchantId(merchant.getId());
+						consume.setLibService(0);
+						consume.setPlatformService(0);
+						consume.setType(7);
+						consume.setComputeNum(merchant.getCurIsSummary());
+						consume.setSignType(merchant.getSignType());
+						consume.setRemarks("计费期扣费【服务包扣费:第"+merchant.getCurIsSummary()+"月】");
+						consume.setCreateTime(new Date());
+						libJoinConsumeService.save(consume);
+						
 					}
 					
-					merchant.setCurIsSummary(merchant.getCurIsSummary()==null ? 1 : merchant.getCurIsSummary()+1);
-					//merchant.setCurSummaryTime(new Date());
-					merchant.setNextSummaryTime(DateHelper.getMonthDate(new Date(),1));
-					merchantService.save(merchant);
-					
-					//记录
-					TbLibJoinConsume consume=new TbLibJoinConsume();
-					consume.setFromLibId(merchant.getLibId());
-					consume.setFromMerchantId(merchant.getId());
-					consume.setLibService(merchant.getLibService());
-					consume.setPlatformService(0);
-					consume.setType(2);
-					consume.setRemarks("消费【套餐第"+(merchant.getCurIsSummary())+"个月结算】");
-					consume.setCreateTime(new Date());
-					libJoinConsumeService.save(consume);
-					
 				} catch (Exception e) {
 					e.printStackTrace();
 					logger.error("2:处理商户结算的数据,异常:"+e.getMessage());
@@ -200,21 +340,28 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
 		merchantSign.setStatus(0);
 		merchantSign.setCreateTime(new Date());
 		
+		Date computeTime=merchant.getComputeTime();
+		if(computeTime.getTime()<new Date().getTime()) {
+			computeTime=new Date();
+		}
+		String remarks="加油包开通【新模式】";
 		Calendar cal = Calendar.getInstance();
-		cal.setTime(merchant.getSignTime());
+		cal.setTime(computeTime);
 		switch (signType) {
 		case 4:
+			remarks="加油包开通【新模式月包】";
 			cal.add(Calendar.MONTH, num);
 			
 			merchantSign.setLibService(10);
-			merchantSign.setSignTime(merchant.getSignTime());
+			merchantSign.setSignTime(merchant.getComputeTime());
 			merchantSign.setEndSignTime(cal.getTime());
 			break;
 		case 5:
+			remarks="加油包开通【新模式量包】";
 			cal.add(Calendar.MONTH, 1);
 			
 			merchantSign.setLibService(10*num);
-			merchantSign.setSignTime(merchant.getSignTime());
+			merchantSign.setSignTime(merchant.getComputeTime());
 			merchantSign.setEndSignTime(cal.getTime());
 			break;
 		default:
@@ -231,15 +378,19 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
 		this.syncMerchantByLibJoin(merchant);
 		
 		//记录加油包记录
-		TbLibJoinConsume consume=new TbLibJoinConsume();
-		consume.setToLibId(merchant.getLibId());
-		consume.setToMerchantId(merchant.getId());
-		consume.setLibService(merchantSign.getLibService());
-		consume.setPlatformService(0);
-		consume.setType(1);
-		consume.setRemarks("加油包充值");
-		consume.setCreateTime(new Date());
-		libJoinConsumeService.save(consume);
+		for (int i = 1; i <=num; i++) {
+			TbLibJoinConsume consume=new TbLibJoinConsume();
+			consume.setToLibId(merchant.getLibId());
+			consume.setToMerchantId(merchant.getId());
+			consume.setLibService(10);
+			consume.setPlatformService(0);
+			consume.setType(9);
+			consume.setComputeNum(0);
+			consume.setSignType(merchant.getSignType());
+			consume.setRemarks(remarks);
+			consume.setCreateTime(new Date());
+			libJoinConsumeService.save(consume);
+		}
 		
 		//调用openApi接口
 		libVipServiceService.openApiServiceCRM(

+ 1 - 0
src/main/java/com/ssj/service/sys/role/service/impl/AdminServiceImpl.java

@@ -197,6 +197,7 @@ public class AdminServiceImpl extends BaseServiceImpl<Admin, String> implements
 				consume.setLibService(merchant.getLibService());
 				consume.setPlatformService(0);
 				consume.setType(1);
+				consume.setSignType(merchant.getSignType());
 				consume.setRemarks("充值【套餐模式开通】");
 				consume.setCreateTime(new Date());
 				libJoinConsumeService.save(consume);

+ 3 - 0
src/main/java/com/ssj/service/weixin/library/service/ILibJoinConsumeService.java

@@ -50,5 +50,8 @@ public interface ILibJoinConsumeService extends BaseService<TbLibJoinConsume, St
 	Integer findTbLibJoinConsumeByFrontDay(String merchantId);
 	
 	Integer findTbLibJoinConsumeByBeforeDays(String merchantId);
+	
+	List<TbLibJoinConsume> findTbLibJoinConsumeByStartActiveTime(String merchantId,Date startActiveTime);
+	
 
 }

+ 25 - 13
src/main/java/com/ssj/service/weixin/library/service/impl/LibJoinServiceConsumeImpl.java

@@ -1,27 +1,27 @@
 package com.ssj.service.weixin.library.service.impl;
 
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.repository.PagingAndSortingRepository;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
 import com.ssj.bean.sys.fx.domain.Merchant;
 import com.ssj.bean.weixin.libmy.domain.LibVip;
 import com.ssj.bean.weixin.libmy.domain.TbLibJoinConsume;
 import com.ssj.dao.weixin.library.dao.ILibJoinConsumeDao;
 import com.ssj.dao.weixin.library.dao.ILibJoinConsumeQueryDao;
-import com.ssj.framework.basic.utils.DateHelper;
 import com.ssj.framework.core.common.service.BaseServiceImpl;
 import com.ssj.service.sys.fx.service.MerchantService;
 import com.ssj.service.weixin.library.service.ILibJoinConsumeService;
 import com.ssj.service.weixin.library.service.ILibVipService;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.repository.PagingAndSortingRepository;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
 
 @Service
 @Transactional
@@ -57,6 +57,7 @@ public class LibJoinServiceConsumeImpl extends BaseServiceImpl<TbLibJoinConsume,
 			consume.setLibService(libServiceNum);
 			consume.setPlatformService(platformServiceNum);
 			consume.setType(1);
+			consume.setSignType(0);
 			consume.setRemarks("充值");
 			consume.setCreateTime(new Date());
 			dao.save(consume);
@@ -82,6 +83,7 @@ public class LibJoinServiceConsumeImpl extends BaseServiceImpl<TbLibJoinConsume,
 			consume.setLibService(libServiceNum);
 			consume.setPlatformService(platformServiceNum);
 			consume.setType(1);
+			consume.setSignType(0);
 			consume.setRemarks("充值");
 			consume.setCreateTime(new Date());
 			dao.save(consume);
@@ -117,6 +119,7 @@ public class LibJoinServiceConsumeImpl extends BaseServiceImpl<TbLibJoinConsume,
 							consume.setLibService(libServiceNum);
 							consume.setPlatformService(platformServiceNum);
 							consume.setType(2);
+							consume.setSignType(0);
 							consume.setRemarks("消费");
 							consume.setCreateTime(new Date());
 							if (StringUtils.isNotEmpty(vipId)) {
@@ -182,6 +185,7 @@ public class LibJoinServiceConsumeImpl extends BaseServiceImpl<TbLibJoinConsume,
 			fromConsume.setLibService(libServiceNum);
 			fromConsume.setPlatformService(platformServiceNum);
 			fromConsume.setType(5);
+			fromConsume.setSignType(0);
 			fromConsume.setRemarks("向下分配币,"+fromLibId+"-->"+toLibId);
 			fromConsume.setCreateTime(new Date());
 			this.save(fromConsume);
@@ -194,6 +198,7 @@ public class LibJoinServiceConsumeImpl extends BaseServiceImpl<TbLibJoinConsume,
 			toConsume.setLibService(libServiceNum);
 			toConsume.setPlatformService(platformServiceNum);
 			toConsume.setType(4);
+			toConsume.setSignType(0);
 			toConsume.setRemarks("上级分配币,"+fromLibId+"-->"+toLibId);
 			toConsume.setCreateTime(new Date());
 			this.save(toConsume);
@@ -232,6 +237,7 @@ public class LibJoinServiceConsumeImpl extends BaseServiceImpl<TbLibJoinConsume,
 	       tbLibJoinConsume.setPlatformService(platformServiceNum);
 		   tbLibJoinConsume.setRemarks("上级分配币,"+fromMerchant+"-->"+toMerchant);
 		   tbLibJoinConsume.setType(4);
+		   tbLibJoinConsume.setSignType(0);
 		   tbLibJoinConsume.setCreateTime(new Date());
 		   this.save(tbLibJoinConsume);
 
@@ -244,6 +250,7 @@ public class LibJoinServiceConsumeImpl extends BaseServiceImpl<TbLibJoinConsume,
 	       tbLibJoinConsume.setPlatformService(platformServiceNum);
 		   tbLibJoinConsume.setRemarks("向下级分配币 ,"+fromMerchant+"-->"+toMerchant);
 		   tbLibJoinConsume.setType(5);
+		   tbLibJoinConsume.setSignType(0);
 		   tbLibJoinConsume.setCreateTime(new Date());
 		   this.save(tbLibJoinConsume);
 		   
@@ -284,6 +291,11 @@ public class LibJoinServiceConsumeImpl extends BaseServiceImpl<TbLibJoinConsume,
 		return dao.findTbLibJoinConsumeByBeforeDays(merchantId);
 	}
 
+	@Override
+	public List<TbLibJoinConsume> findTbLibJoinConsumeByStartActiveTime(String merchantId, Date startActiveTime) {
+		return dao.findTbLibJoinConsumeByStartActiveTime(merchantId, startActiveTime);
+	}
+
 	
 	 
 }

+ 1 - 1
src/main/java/com/ssj/service/weixin/sales/service/impl/LibVipServiceServiceImpl.java

@@ -1728,7 +1728,7 @@ public class LibVipServiceServiceImpl extends BaseServiceImpl<LibVipService, Str
      */
     Date getEndDate(String vipId, String libId) {
         Merchant merchant=merchantService.getMerchantByLibId(libId);
-        return DateHelper.getMonthDate(merchant.getCurSummaryTime(),merchant.getLibServiceMonth());
+        return DateHelper.getMonthDate(merchant.getComputeTime(),merchant.getLibServiceMonth());
     }
 
 

+ 137 - 2
src/main/java/com/ssj/sys/controller/FinanceReportController.java

@@ -296,7 +296,7 @@ public class FinanceReportController extends BaseController {
         model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
         model.addAttribute("page", sp);
         model.addAttribute("search", params);
-        return "sys/finance/balanceLossDetailList";
+        return "sys/finance/allList5";
     }
     
     
@@ -411,13 +411,52 @@ public class FinanceReportController extends BaseController {
     }
     
     
+
+    //小塾币情况表-结算,按月进行筛选
+    @RequestMapping("/balanceConsumeDetailList_New")
+    public String balanceConsumeDetailList_New(Model model,
+                                        @RequestParam(required = false, defaultValue = "30") int pageSize,
+                                        @RequestParam(required = false, defaultValue = "1") int pageNo) {
+
+        Map<String, Object> params = new HashMap<String, Object>();
+            
+        params.put("startMonth", request.getParameter("startMonth")==null? new SimpleDateFormat("yyyy-MM").format(new Date()):request.getParameter("startMonth"));
+        params.put("unitName", request.getParameter("unitName")==null?"":request.getParameter("unitName"));
+        addPostcodes(params);
+        
+        SplitPage sp = new SplitPage();
+        sp.setAction(request.getRequestURI());
+        sp.setPageNo(pageNo);
+        sp.setPageSize(pageSize);
+        sp.setParams(params);
+        Page<Map<String,Object>> page = financeService.balanceConsumeDetailList_New(params, initPage(pageNo, pageSize));
+        List<Map<String,Object>> list=page.getContent();
+        for (Map<String, Object> map : list) {
+        	if(map.containsKey("type")) {
+        		if(map.get("type")==null || Integer.parseInt(map.get("type").toString())!=1){
+        			map.put("external_unit_name", map.get("unit_name"));
+        			map.put("unit_name", "");
+        		}
+        	}
+		}
+        
+        sp.setRowCnt((int) page.getTotalElements());
+        model.addAttribute("list",list);
+        model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
+        model.addAttribute("page", sp);
+        model.addAttribute("search", params);
+        return "sys/finance/allList6";
+    }
+    
+    
+    
     
     @RequestMapping(value = "/export5", method = RequestMethod.POST)
     @ResponseBody
     public void export5( HttpServletRequest request, HttpServletResponse response) {
         ServletOutputStream os = null;
         try {
-            String libName="小塾币使用情况-结算";
+            String libName="小塾币使用情况-结算(旧模式)";
             os = response.getOutputStream(); //获得输出流
             response.reset();   //清空输出流
             String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
@@ -486,6 +525,102 @@ public class FinanceReportController extends BaseController {
     
     
     
+    @RequestMapping(value = "/export6", method = RequestMethod.POST)
+    @ResponseBody
+    public void export6( HttpServletRequest request, HttpServletResponse response) {
+        ServletOutputStream os = null;
+        try {
+            String libName="小塾币使用情况-结算(新模式)";
+            os = response.getOutputStream(); //获得输出流
+            response.reset();   //清空输出流
+            String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
+            response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头
+            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+            response.setCharacterEncoding("utf-8");
+            Map<String, Object> params = new HashMap<String, Object>();
+            params.put("startMonth", request.getParameter("startMonth")==null? new SimpleDateFormat("yyyy-MM").format(new Date()):request.getParameter("startMonth"));
+            params.put("unitName", request.getParameter("unitName")==null?"":request.getParameter("unitName"));
+            addPostcodes(params);
+            Page<Map<String,Object>> page = financeService.balanceConsumeDetailList_New(params, initPage(1, 100000));
+            
+            List<Map<String,Object>> list=page.getContent();
+            for (Map<String, Object> map : list) {
+            	map.put("price_1", "700");
+            	
+            	if(map.containsKey("type")) {
+            		if(map.get("type")==null || Integer.parseInt(map.get("type").toString())!=1){
+            			map.put("external_unit_name", map.get("unit_name"));
+            			map.put("unit_name", "");
+            		}
+            	}
+            	if(map.containsKey("sign_type")) {
+            		if(map.get("sign_type")==null){
+            			if(Integer.parseInt(map.get("sign_type").toString())==1){
+            				map.put("sign_type", "服务包1");
+            			}else if(Integer.parseInt(map.get("sign_type").toString())==2){
+            				map.put("sign_type", "服务包2");
+            			}else if(Integer.parseInt(map.get("sign_type").toString())==3){
+            				map.put("sign_type", "服务包3");
+            			}else {
+            				map.put("sign_type", "");
+            			}
+            		
+            		}
+            	}
+            	map.put("count_1_m", "");
+            	map.put("count_2_m", "");
+            	
+            	if(map.containsKey("count_1")) {
+            		if(Integer.parseInt(map.get("count_1").toString())>0) {
+            			map.put("count_1_m", map.get("balance_month") );
+            		}
+            	}
+            	if(map.containsKey("count_2")) {
+            		if(Integer.parseInt(map.get("count_2").toString())>0) {
+            			map.put("count_2_m", map.get("balance_month") );
+            		}
+            	}
+            	
+    		}
+            
+            List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
+            myColumns3.add(new ExcelColumn("月份", "balance_month", 20));
+            myColumns3.add(new ExcelColumn("商户账号", "pos_code", 20));
+            myColumns3.add(new ExcelColumn("商户编码", "org_code", 20));
+            myColumns3.add(new ExcelColumn("商户级别", "level_name", 20));
+            myColumns3.add(new ExcelColumn("签约商户", "unit_name", 20));
+            myColumns3.add(new ExcelColumn("非签约商户", "external_unit_name", 20));
+           
+            myColumns3.add(new ExcelColumn("服务包名称", "sign_type", 20));
+            myColumns3.add(new ExcelColumn("服务包/月金额", "price", 20));
+            myColumns3.add(new ExcelColumn("有效服务数", "sum_1", 20));
+            myColumns3.add(new ExcelColumn("结束服务数", "sum_2", 20));
+            myColumns3.add(new ExcelColumn("服务包/结算月份", "count_1_m", 20));
+            
+            myColumns3.add(new ExcelColumn("加油包/月金额", "price_1", 20));
+            myColumns3.add(new ExcelColumn("加油包/有效服务数", "sum_3", 20));
+            myColumns3.add(new ExcelColumn("加油包/结束服务数", "sum_4", 20));
+            myColumns3.add(new ExcelColumn("加油包/结算月份", "count_2_m", 20));
+            myColumns3.add(new ExcelColumn("加油包/结算数量", "count_2", 20));
+            
+            CustomizeToExcel.downFile(myColumns3, list, os);
+        }catch (IOException e) {
+            logger.error("异常", e);
+        }catch (Exception e1){
+            logger.error("异常", e1);
+        }finally{
+            if(os != null){
+                try {
+                    os.flush();
+                    os.close();
+                } catch (IOException e) {
+                    logger.error("异常", e);
+                }
+            }
+
+        }
+    }
+    
     
     
     

+ 36 - 11
src/main/java/com/ssj/sys/controller/FxController.java

@@ -1331,8 +1331,9 @@ public class FxController  extends BaseController {
 	
 	@RequestMapping("/saveMerchant")
 	@ResponseBody
-    public Response saveMerchant(Model model,Merchant merchant,String startTime,String endTime,String summaryTime
+    public Response saveMerchant(Model model,Merchant merchant,String startTime,String endTime,String startActiveTimeStr,String activeTimeStr,String computeTimeStr
     		,String password,String province,String city,String area,String schoollist,String location)throws Exception {
+		Response response = new  Response();
 		HttpSession session = request.getSession();
 		Admin curadmin =(Admin) session.getAttribute("admin");
 		
@@ -1341,8 +1342,23 @@ public class FxController  extends BaseController {
 			
 	        return merchantService.saveMerchantByUsed(merchant, startTime, endTime, password, province, city, area, schoollist, location, curadmin);
 		}else {
-			
-	        return merchantService.saveMerchantByNew(merchant, startTime, endTime, summaryTime, password, province, city, area, schoollist, location, curadmin);
+			if(StringUtils.isEmpty(startActiveTimeStr)) {
+				response.failure("新模式的开始激活日期不可为空");
+		        return response;
+			}
+			if(StringUtils.isEmpty(activeTimeStr)) {
+				response.failure("新模式的结束激活日期不可为空");
+		        return response;
+			}
+			if(StringUtils.isEmpty(computeTimeStr)) {
+				response.failure("新模式的计费开始日不可为空");
+		        return response;
+			}
+			if(merchant.getLibServiceMonth()==null || merchant.getLibServiceMonth()<=0) {
+				response.failure("新模式的充值月份数不可小于0");
+		        return response;
+			}
+	        return merchantService.saveMerchantByNew(merchant, startTime, endTime,startActiveTimeStr,activeTimeStr, computeTimeStr, password, province, city, area, schoollist, location, curadmin);
 		}
     }
 	
@@ -1721,7 +1737,8 @@ public class FxController  extends BaseController {
     		myColumns3.add(new ExcelColumn("充值/已结算(月份)", "monthStr", 20));
     		myColumns3.add(new ExcelColumn("合同开始日期", "signTime", 20));
     		myColumns3.add(new ExcelColumn("合同结束日期", "endSignTime", 20));
-    		myColumns3.add(new ExcelColumn("激活日期", "summaryTimeStr", 20));
+    		myColumns3.add(new ExcelColumn("激活日期", "activeTimeStr", 20));
+    		myColumns3.add(new ExcelColumn("计费开始日", "computeTimeStr", 20));
     		myColumns3.add(new ExcelColumn("下个结算日", "nextSummaryTime", 20));
     		
     		myColumns3.add(new ExcelColumn("关联机构", "joinName", 20));
@@ -1837,45 +1854,52 @@ public class FxController  extends BaseController {
 				}else if("signType".equals(key)){
 					String str="";
 					String monthStr="";
-					String summaryTimeStr="";
+					String activeTimeStr="";
+					String computeTimeStr="";
 					String libService_0="";
 					String libService_1="";
 					switch (value!=null ?value.toString():"") {
 					case "0":
 						str="旧兼容模式";
 						monthStr="";
-						summaryTimeStr="";
+						activeTimeStr="";
+						computeTimeStr="";
 						libService_0=obj.getLibService()+"";
 						break;
 					case "1":
 						str="服务包1";
 						monthStr=obj.getLibServiceMonth()+"/"+obj.getCurIsSummary();
-						summaryTimeStr=DateHelper.format(obj.getCurSummaryTime(), "yyyy-MM-dd") ;
+						activeTimeStr=DateHelper.format(obj.getActiveTime(), "yyyy-MM-dd") ;
+						computeTimeStr=DateHelper.format(obj.getComputeTime(), "yyyy-MM-dd") ;
 						libService_1=obj.getLibService()+"";
 						break;
 					case "2":
 						str="服务包2";
 						monthStr=obj.getLibServiceMonth()+"/"+obj.getCurIsSummary();
-						summaryTimeStr=DateHelper.format(obj.getCurSummaryTime(), "yyyy-MM-dd") ;
+						activeTimeStr=DateHelper.format(obj.getActiveTime(), "yyyy-MM-dd") ;
+						computeTimeStr=DateHelper.format(obj.getComputeTime(), "yyyy-MM-dd") ;
 						libService_1=obj.getLibService()+"";
 						break;
 					case "3":
 						str="服务包3";
 						monthStr=obj.getLibServiceMonth()+"/"+obj.getCurIsSummary();
-						summaryTimeStr=DateHelper.format(obj.getCurSummaryTime(), "yyyy-MM-dd") ;
+						activeTimeStr=DateHelper.format(obj.getActiveTime(), "yyyy-MM-dd") ;
+						computeTimeStr=DateHelper.format(obj.getComputeTime(), "yyyy-MM-dd") ;
 						libService_1=obj.getLibService()+"";
 						break;
 					default:
 						str="";
 						monthStr="";
-						summaryTimeStr="";
+						activeTimeStr="" ;
+						computeTimeStr="";
 						libService_0="";
 						libService_1="";
 						break;
 					}
 					map.put(key,  str);
 					map.put("monthStr",monthStr);
-					map.put("summaryTimeStr", summaryTimeStr);
+					map.put("activeTimeStr", activeTimeStr);
+					map.put("computeTimeStr", computeTimeStr);
 					map.put("libService_0", libService_0);
 					map.put("libService_1", libService_1);
 				}else if("mealType".equals(key)){
@@ -2946,6 +2970,7 @@ public class FxController  extends BaseController {
 							consume.setLibService(merchant.getLibService());
 							consume.setPlatformService(0);
 							consume.setType(2);
+							consume.setSignType(merchant.getSignType());
 							consume.setRemarks("消费【新模式激活消费】");
 							consume.setCreateTime(new Date());
 							libJoinConsumeService.save(consume);

+ 1 - 1
src/main/resources/templates/sys/finance/allList4.html

@@ -22,7 +22,7 @@
 	<span>位置:</span>
 	<ul class="placeul">
 		<li><a href="#">小塾管理</a></li>
-		<li><a href="#">小塾币使用情况-结算</a></li>
+		<li><a href="#">小塾币使用情况-结算(旧模式)</a></li>
 	</ul>
 </div>
 <div class="rightinfo">

src/main/resources/templates/sys/finance/balanceLossDetailList.html → src/main/resources/templates/sys/finance/allList5.html


+ 113 - 0
src/main/resources/templates/sys/finance/allList6.html

@@ -0,0 +1,113 @@
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+<title>私塾家</title>
+<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
+</head>
+<style>
+	.tablelink{margin-right:10px;}
+	.stylecss{
+	      color: red;
+	}
+	.select_width{
+	     width: 220px;
+	}
+	.date_width{
+	     width: 150px;
+	}
+</style>
+<body>
+<div class="place">
+	<span>位置:</span>
+	<ul class="placeul">
+		<li><a href="#">小塾管理</a></li>
+		<li><a href="#">小塾币使用情况-结算(新模式)</a></li>
+	</ul>
+</div>
+<div class="rightinfo">
+	<form id="seachform" th:action="@{/sys/finance/balanceConsumeDetailList_New.html}" method="post">
+	<ul class="seachform">
+		<li>
+			<label>日期</label>
+			<input type="text" id="startMonth" name="startMonth" autocomplete="off"   onclick="WdatePicker({dateFmt:'yyyy-MM'})" th:value="${search.startMonth }" class="scinput date_width " placeholder="选择日期">
+		</li>
+		
+		<li>
+			<label>机构名称</label>
+			<input type="text" id="unitName" name="unitName"   th:value="${search.unitName }" class="scinput " placeholder="输入商户/机构关键字">
+		</li>
+		
+			<li>
+				<input type="button" class="scbtn" value="查询" />
+				<input type="button" id="button" class="scbtn" value="导出" />
+			</li>
+		
+	</ul>
+	</form>
+	<table class="tablelist">
+		<thead>
+		    <tr>
+				<th style="width: 50px;">序号</th>
+				<th>签约帐号</th>
+				<th>签约商户</th>
+				<th>非签约商户</th>
+				
+		    	<th>服务包名称</th>
+		    	
+		    	<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>
+		    </tr>
+		</thead>
+		<tbody>
+			<tr th:each="item:${list}" >
+					<td th:text="${itemStat.count}"></td>
+					<td th:text="${item.get('pos_code')}"></td>
+					<td th:text="${item.get('unit_name')}"></td>
+					<td th:text="${item.get('external_unit_name')}"></td>
+					<td  th:switch="${item.sign_type}">
+					   <span th:case="1" >服务包1</span>
+					   <span th:case="2" >服务包2</span>
+					   <span th:case="3" >服务包3</span>
+					</td>
+					<td th:text="${item.get('price')}"></td>
+					<td th:text="${item.get('sum_1')}"></td>
+					<td th:text="${item.get('sum_2')}"></td>
+					<td th:text="${item.get('count_1')>0 ? item.get('balance_month') : ''   }"></td>
+					<td th:text="700"></td>
+					<td th:text="${item.get('sum_3')}"></td>
+					<td th:text="${item.get('sum_4')}"></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>
+			</tr>
+		</tbody>
+	</table>
+	<!-- 分页 -->
+	<div class="pagin">
+		<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录,当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
+		<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
+	</div>
+	
+		
+</div>
+</body>
+<script type="text/javascript">
+	$("#button").on('click',function(){
+		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/finance/export6";
+		$("#seachform").submit();
+		window.setTimeout(function(){
+			document.getElementById("seachform").action = "[[${sysUrl}]]/sys/finance/balanceConsumeDetailList_New.html";
+		},3000);
+	});
+</script>
+
+
+</html>

+ 24 - 12
src/main/resources/templates/sys/fx/consumeList.html

@@ -50,11 +50,17 @@
 				<label>操作类型</label>
 				<select class="scinput select_width"  name="type"   style="width: 150px;" >
 					<option value="" th:selected="${search.get('type')+'' eq '' ? true : false} ">全部</option>
-					<option value="1" th:selected="${search.get('type')+'' eq '1' ? true : false} ">充值</option>
-					<option value="2" th:selected="${search.get('type')+'' eq '2' ? true : false} ">消费</option>
-					<option value="3" th:selected="${search.get('type')+'' eq '3' ? true : false} ">服务扣除的</option>
-					<option value="4" th:selected="${search.get('type')+'' eq '4' ? true : false} ">上级分配币 </option>
-					<option value="5" th:selected="${search.get('type')+'' eq '5' ? true : false} ">向下分配币 </option>
+					<option value="1" th:selected="${search.get('type')+'' eq '1' ? true : false} ">塾币充值【旧模式】</option>
+					<option value="2" th:selected="${search.get('type')+'' eq '2' ? true : false} ">塾币消费【旧模式】</option>
+					<option value="3" th:selected="${search.get('type')+'' eq '3' ? true : false} ">服务扣除【旧模式】</option>
+					<option value="4" th:selected="${search.get('type')+'' eq '4' ? true : false} ">上级分配币【旧模式】 </option>
+					<option value="5" th:selected="${search.get('type')+'' eq '5' ? true : false} ">向下分配币【旧模式】</option>
+					
+					<option value="6" th:selected="${search.get('type')+'' eq '6' ? true : false} ">服务包开通【新模式】</option>
+					<option value="7" th:selected="${search.get('type')+'' eq '7' ? true : false} ">服务包激活【新模式】</option>
+					<option value="8" th:selected="${search.get('type')+'' eq '8' ? true : false} ">服务包结算【新模式】</option>
+					<option value="9" th:selected="${search.get('type')+'' eq '9' ? true : false} ">加油包开通【新模式】</option>
+					<option value="10" th:selected="${search.get('type')+'' eq '10' ? true : false}">加油包结算【新模式】</option>
 				</select>
 			</li>
 			<li>
@@ -103,7 +109,6 @@
 		        <th style="width: 6%">操作</th>
  		    	<th style="width: 6%">机构塾币</th>
  		    	<th style="width: 6%">平台塾币</th>
-<!-- 		        <th>备注</th>  -->
 		        <th style="width: 10%">操作时间</th> 
 		        <th style="width: 100px">备注</th>
 		    </tr>
@@ -129,14 +134,21 @@
 					   <span th:case="5">直接签约(新模式)</span>
 					</td>
 					<td style="color: red" th:switch="${item.type}">
-					   <span th:case="1">充值</span>
-					   <span th:case="2">消费 </span>
-					   <span th:case="3">服务扣除的</span>
-					   <span th:case="4">上级分配币 </span>
+					   <span th:case="1">塾币充值【旧模式】</span>
+					   <span th:case="2">塾币消费【旧模式】 </span>
+					   <span th:case="3">服务扣除【旧模式】</span>
+					   <span th:case="4">上级分配币【旧模式】 </span>
+					   <span th:case="5">向下分配币【旧模式】 </span>
+					   
+					   <span th:case="6">服务包开通【新模式】 </span>
+					   <span th:case="7">服务包激活【新模式】 </span>
+					   <span th:case="8">服务包结算【新模式】 </span>
+					   <span th:case="9">加油包开通【新模式】 </span>
+					   <span th:case="10">加油包结算【新模式】 </span>
+
 					</td>
 					<td th:text="${item.lib_service}"></td>
 					<td th:text="${item.platform_service}"></td>
-<!-- 					<td th:text="${item.remarks}"></td>  -->
 					<td th:text="${#calendars.format(item.create_time,'yyyy-MM-dd HH:mm:ss')}" ></td>  
 					<td th:text="${item.remarks}"></td>
 			</tr>
@@ -151,7 +163,7 @@
 </div>
 
 
-<ul style="margin-bottom: 100px;margin-left: 20px">
+<ul style="margin-bottom: 100px;margin-left: 20px;display: none">
 		<li style="line-height: 25px;">
 			<span style="font-size: 14px;">操作名词解释</span>
 		</li>

+ 31 - 19
src/main/resources/templates/sys/fx/merchantAdd.html

@@ -60,7 +60,7 @@ dtext{
 	cursor: pointer;
 }
 .forminfo li label{
-	width: 180px;
+	width: 250px;
 	text-align: right;
 	padding-right: 10px
 }
@@ -144,26 +144,36 @@ dtext{
 						<option value="3" th:selected="${merchant.signType==3 ? true : false}">服务包3</option>
 					</select>
 				</div>
-				<label th:if="${merchant.id!=null}"  style="width: 230px;color:red">[修改套餐模式,不会影响加油包有效性 ]</label>
+				<text th:if="${merchant.id!=null}"  style="width: 230px;color:red">[修改套餐模式,不会影响加油包有效性 ]</text>
 			</li>
 			
 
 			<li>
-				<label>合同时间:<b >*</b></label>
+				<label>合同日期:<b >*</b></label>
 				<input type="hidden"  id="minDate" value="2020-01-01" >
-				<input type="text" id="signTime" name="signTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'minDate\')}'})" autocomplete="off" th:value="${#dates.format(merchant.signTime, 'yyyy-MM-dd')}" class="scinput date_width " placeholder="合同开始时间">
+				<input type="text" id="signTime" name="signTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'minDate\')}'})" autocomplete="off" th:value="${#dates.format(merchant.signTime, 'yyyy-MM-dd')}" class="scinput date_width " placeholder="合同开始日期">
 				&nbsp;&nbsp;&nbsp;~~&nbsp;&nbsp;
-				<input type="text" id="endSignTime" name="endSignTime"   onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'signTime\')}'})"  autocomplete="off" th:value="${#dates.format(merchant.endSignTime, 'yyyy-MM-dd')}" class="scinput date_width" placeholder="合同结束时间">
+				<input type="text" id="endSignTime" name="endSignTime"   onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'signTime\')}'})"  autocomplete="off" th:value="${#dates.format(merchant.endSignTime, 'yyyy-MM-dd')}" class="scinput date_width" placeholder="合同结束日期">
 			</li>
 			
 			<li>
 				<label><b >【服务包模式】</b>充值月份数:<b>*</b></label>
 				<input type="number" id="libServiceMonth" min="0" class="dfinput fl" name="libServiceMonth" th:value="${merchant.libServiceMonth!=null ? merchant.libServiceMonth : 0}"/>
+				<text th:if="${merchant.id!=null}"  style="width: 230px;color:red">[增量添加数值为续费开通 ]</text>
 			</li>
 			
 			<li>
-				<label><b >【服务包模式】</b>激活时间:<b >*</b></label>
-				<input type="text"  class="dfinput fl"  id="curSummaryTime" name="curSummaryTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true,minDate:'%y-%M-%d'})" autocomplete="off" th:value="${#dates.format(merchant.curSummaryTime, 'yyyy-MM-dd')}" placeholder="激活时间">
+				<label><b >【服务包模式】</b>激活开始日期:<b >*</b></label>
+				<input type="text"  class="dfinput fl"  id="startActiveTime" name="startActiveTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true})" autocomplete="off" th:value="${#dates.format(merchant.startActiveTime, 'yyyy-MM-dd')}" placeholder="合同开始激活日期">
+			</li>
+			<li>
+				<label><b >【服务包模式】</b>激活结束日期:<b >*</b></label>
+				<input type="text"  class="dfinput fl"  id="activeTime" name="activeTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true})" autocomplete="off" th:value="${#dates.format(merchant.activeTime, 'yyyy-MM-dd')}" placeholder="合同结束激活日期">
+			</li>
+			
+			<li>
+				<label><b >【服务包模式】</b>计费开始日期:<b >*</b></label>
+				<input type="text"  class="dfinput fl"  id="computeTime" name="computeTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true})" autocomplete="off" th:value="${#dates.format(merchant.computeTime, 'yyyy-MM-dd')}" placeholder="计费开始日期">
 			</li>
 			
 			<li>
@@ -257,15 +267,13 @@ dtext{
 			</li>
 				
 		    <li>
-				<label>服务:签约单价<b></b></label>
-				<div class="vocation" style="margin-right: 5px; width: 345px">
-					<select name="price" id="price" class="select1"> 
-						<option value="0" th:selected="${merchant.price!=50.0 && merchant.price!=55.0 && merchant.price!=68.0 ? true : false}">请选择</option>
-						<option value="50" th:selected="${merchant.price==50.0 ? true : false}">50.0</option>
-						<option value="55" th:selected="${merchant.price==55.0 ? true : false}">55.0</option>
-						<option value="68" th:selected="${merchant.price==68.0 ? true : false}">68.0</option>
-					</select>
-				</div>
+				<label>服务包充值金额 / 服务:签约单价<b></b></label>
+				<input type="text" id="price" class="dfinput fl" name="price" th:value="${merchant.price==null ? 0 : merchant.price}"/>
+			</li>
+			
+			<li>
+				<label><b >【服务包模式】</b>平台管理费金额<b></b></label>
+				<input type="text" id="outPrice" class="dfinput fl" name="outPrice" th:value="${merchant.outPrice==null ? 0 : merchant.outPrice}"/>
 			</li>
 			
 			<li>
@@ -762,6 +770,7 @@ function save(){
             'status':$("#status").val(),
             'parentPosCode':$("#parentposcode").val(),
             'price':$("#price").val(),
+            'outPrice':$("#outPrice").val(),
             'remarks':$("#remarks").val(),
             'password':$("#password").val(),
             'signService':$("#signService").val(),
@@ -769,11 +778,14 @@ function save(){
             
             'signType':$("#signType").val(),
             'mealType':$("#mealType").val(),
-            'startTime':$("#signTime").val(),
-            'endTime':$("#endSignTime").val(),
             
             'libServiceMonth':$("#libServiceMonth").val(),
-            'summaryTime':$("#curSummaryTime").val(),
+            
+            'startTime':$("#signTime").val(),
+            'endTime':$("#endSignTime").val(),
+            'startActiveTimeStr':$("#startActiveTime").val(),
+            'activeTimeStr':$("#activeTime").val(),
+            'computeTimeStr':$("#computeTime").val(),
             
             'province':$("#province").val(),
             'city':$("#city").val(),

+ 33 - 38
src/main/resources/templates/sys/fx/merchantAllList.html

@@ -151,15 +151,18 @@
 		</li>
 		<li>
 		
-			<ul class="toolbar" th:if="${ #httpSession.getAttribute('admin') !=null   &&  (#lists.contains(#httpSession.getAttribute('admin').authorities,'财务管理员') ||  #lists.contains(#httpSession.getAttribute('admin').authorities,'分销管理员'))  }">
+			<ul class="toolbar" th:if="
+			${ #httpSession.getAttribute('admin') !=null && 
+			(
+				#lists.contains(#httpSession.getAttribute('admin').authorities,'财务管理员')  ||
+				#lists.contains(#httpSession.getAttribute('admin').authorities,'分销管理员')   ||
+				#lists.contains(#httpSession.getAttribute('admin').authorities,'超级管理员角色')  
+			)  }">
 				<a href="javascript:;" onclick="savemerchant('')">
 					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}"></span>添加</li>
 				</a>
 			</ul>
 			
-			<a href="javascript:;" onclick="savemerchant('')">
-				<li class="click"><span><img th:src="@{/static/sys/images/t01.png}"></span>添加</li>
-			</a>
 		</li>
 	</ul>
 	</form>
@@ -177,17 +180,18 @@
 
 		    	<th >商户账号</th>
 		    	<th >单位名称 </th>
-		    	<th style="width: 60px;">商户级别</th>
+<!-- 		    	<th style="width: 60px;">商户级别</th> -->
 		    	<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="width: 60px;">合同硬件采购数量</th> -->
-		    	<th style="max-width: 160px;" >合同时间</th>
+		    	<th style="max-width: 160px;" >合同日期</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="width: 60px;" >下个结算日</th>
 		        <th  >操作</th> 
 		    </tr> 
@@ -198,13 +202,13 @@
 					<td th:title="${item.posCode}" th:text="${item.posCode}"></td>
 					<td th:title="${item.unitName}" th:text="${item.unitName}"></td>
 					
-					<td  th:switch="${item.level}">
-					   <span th:case="1" style="color:red">市代</span>
-					   <span th:case="2" style="color:red">区代</span>
-					   <span th:case="3" style="color:red">学校独家</span>
-					   <span th:case="4" style="color:red">普通</span>
-					   <span th:case="*" >--</span>
-					</td>
+<!-- 					<td  th:switch="${item.level}"> -->
+<!-- 					   <span th:case="1" style="color:red">市代</span> -->
+<!-- 					   <span th:case="2" style="color:red">区代</span> -->
+<!-- 					   <span th:case="3" style="color:red">学校独家</span> -->
+<!-- 					   <span th:case="4" style="color:red">普通</span> -->
+<!-- 					   <span th:case="*" >--</span> -->
+<!-- 					</td> -->
 					
 					<td  th:title="${item.libJoin!=null ? item.libJoin.leagueName : '' }" >
 						<a href="javascript:;" th:onclick="'openNew(\''+${item.libId}+'\')'" th:if="${item.libId!='' && item.libId!=null}"	class="tablelink">[[${item.libJoin.leagueName}]]</a>
@@ -229,7 +233,6 @@
 					<td  th:text="${item.portNum}"></td>
 					<td  th:text="${item.libService}"></td>
 					<td  th:text="${item.platformService}"></td>
-<!-- 					<td  th:text="${item.hardwareService}"></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>
@@ -237,35 +240,27 @@
 					   <span th:if="${item.libServiceMonth>0  && ( item.signType==1 || item.signType==2 || item.signType==3 )}"  style="color: red">[[${item.libServiceMonth +' / '+ item.curIsSummary}]]</span>
 					   <span th:if="${item.nextSummaryTime==null && ( item.signType==1 || item.signType==2 || item.signType==3 )}" >已结清</span>
 					</td>
-					
-					<td  th:text="${#calendars.format(item.curSummaryTime,'yyyy-MM-dd')}" ></td> 
-					
+					<td  th:text="${#calendars.format(item.startActiveTime,'yyyy-MM-dd')}" ></td> 
+					<td  th:text="${#calendars.format(item.activeTime,'yyyy-MM-dd')}" ></td> 
+					<td  th:text="${#calendars.format(item.computeTime,'yyyy-MM-dd')}" ></td> 
 					<td  th:text="${#calendars.format(item.nextSummaryTime,'yyyy-MM-dd')}" ></td> 
-					
-<!-- 					<td  th:switch="${item.status}"> -->
-<!-- 					   <span th:case="1">待签</span> -->
-<!-- 					   <span th:case="2">已签待交付</span> -->
-<!-- 					   <span th:case="3">已签已交付</span> -->
-<!-- 					   <span th:case="4">无效</span> -->
-<!-- 					</td> -->
-
-<!-- 					<td  th:text="${#calendars.format(item.createTime,'yyyy-MM-dd')}" ></td>   -->
+				
 					<td  >   
-						<di th:if="${ #httpSession.getAttribute('admin') !=null   &&  (#lists.contains(#httpSession.getAttribute('admin').authorities,'财务管理员') ||  #lists.contains(#httpSession.getAttribute('admin').authorities,'分销管理员'))  }">
-							
+						<di th:if="
+						${ #httpSession.getAttribute('admin') !=null && 
+						(
+							#lists.contains(#httpSession.getAttribute('admin').authorities,'财务管理员')  ||
+							#lists.contains(#httpSession.getAttribute('admin').authorities,'分销管理员')   ||
+							#lists.contains(#httpSession.getAttribute('admin').authorities,'超级管理员角色')  
+						)  }
+						">
 							<a href="javascript:;" th:if="${item.signType==0 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'joinServiceEdit(\''+${item.id}+'\')'" class="tablelink">塾币</a>
 							<a href="javascript:;" th:if="${item.signType!=0 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'mealServiceAdd(\''+${item.id}+'\')'" class="tablelink">加油包</a>
 						
 							<a href="javascript:;" th:if="${item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'updatemerchant(\''+${item.id}+'\',\'4\')'"   class="tablelink">删除</a>
 							<a href="javascript:;" th:if="${item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'savemerchant(\''+${item.id}+'\')'"  	class="tablelink">修改</a>
 						</di>
-						
-							<a href="javascript:;" th:if="${item.signType==0 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'joinServiceEdit(\''+${item.id}+'\')'" class="tablelink">塾币</a>
-							<a href="javascript:;" th:if="${item.signType!=0 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'mealServiceAdd(\''+${item.id}+'\')'" class="tablelink">加油包</a>
-							<a href="javascript:;" th:if="${item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'updatemerchant(\''+${item.id}+'\',\'4\')'"   class="tablelink">删除</a>
-							<a href="javascript:;" th:if="${item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'savemerchant(\''+${item.id}+'\')'"  	class="tablelink">修改</a>
-						
-												
+										
 						<a href="javascript:;" th:if="${item.status!=4 && item.libId!='' && item.libId!=null && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'untyingmerchant(\''+${item.id}+'\')'"  	class="tablelink">解绑</a>
 						<a href="javascript:;" th:onclick="'infomerchant(\''+${item.id}+'\')'"  	class="tablelink">查看</a>