From a18f721522817b1b1a8139ba96fc890bfbab291b Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期三, 22 四月 2020 09:46:18 +0800
Subject: [PATCH] 补贴调整

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java |   53 +++++++++++++++++++----------------------------------
 1 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
index 700b80d..4fb8b69 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
@@ -29,7 +29,6 @@
 import com.yeshi.fanli.entity.common.JumpDetailV2;
 import com.yeshi.fanli.entity.system.ConfigKeyEnum;
 import com.yeshi.fanli.exception.banner.SwiperPictureException;
-import com.yeshi.fanli.exception.homemodule.HomeNavbarException;
 import com.yeshi.fanli.exception.homemodule.SpecialException;
 import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
 import com.yeshi.fanli.service.inter.config.AppVersionService;
@@ -102,11 +101,6 @@
 			record.setParams(params.trim());
 		}
 
-		String startTime_str = record.getStartTime_str();
-		if (record.isTimeTask() && (startTime_str == null || startTime_str.length() == 0)) {
-			throw new SpecialException(1, "鎺у埗鏃堕棿涓嶈兘涓虹┖");
-		}
-
 		if (!StringUtil.isNullOrEmpty(jumpType)) {
 			List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType);
 			if (listByType != null && listByType.size() > 0) {
@@ -115,7 +109,7 @@
 		}
 
 		// 鏃堕棿杞崲
-		conversionTime(record);
+		handleTime(record);
 
 		Long state = record.getState();
 		if (state == null) {
@@ -227,30 +221,24 @@
 	 * 
 	 * @param record
 	 */
-	public void conversionTime(Special record) throws SpecialException, Exception {
-		// 鏄惁鏃堕棿鎺у埗
-		if (!record.isTimeTask()) {
-			record.setStartTime(null);
-			record.setEndTime(null);
-		} else {
-			String startTime_str = record.getStartTime_str();
-			String endTime_str = record.getEndTime_str();
-
-			if ((startTime_str == null || startTime_str.trim().length() == 0)
-					&& (endTime_str == null || endTime_str.trim().length() == 0)) {
-				throw new HomeNavbarException(1, "璇疯緭鍏ユ帶鍒舵椂闂�");
-			} else {
-				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-				if (startTime_str != null && startTime_str.trim().length() > 0) {
-					startTime_str = startTime_str.replaceAll("T", " ");
-					record.setStartTime(format.parse(startTime_str));
-				}
-
-				if (endTime_str != null && endTime_str.trim().length() > 0) {
-					endTime_str = endTime_str.replaceAll("T", " ");
-					record.setEndTime(format.parse(endTime_str));
-				}
-			}
+	private void handleTime(Special record) throws SpecialException, Exception {
+		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+		
+		String startTime_str = record.getStartTime_str();
+		if (!StringUtil.isNullOrEmpty(startTime_str)) {
+			startTime_str = startTime_str.replaceAll("T", " ");
+			record.setStartTime(format.parse(startTime_str));
+		}
+		
+		String endTime_str = record.getEndTime_str();
+		if (!StringUtil.isNullOrEmpty(endTime_str)) {
+			endTime_str = endTime_str.replaceAll("T", " ");
+			record.setEndTime(format.parse(endTime_str));
+		}
+		
+		if (record.getEndTime() != null && record.getStartTime() != null
+				&& record.getStartTime().getTime() > record.getEndTime().getTime()) {
+			throw new SpecialException(1, "璧峰鏃堕棿涓嶈兘灏忎簬缁撴潫鏃堕棿");
 		}
 	}
 
@@ -400,12 +388,9 @@
 			Date endTime = special.getEndTime();
 
 			if (startTime == null && endTime == null) {
-				special.setTimeTask(false);
 				special.setStartTime_str("");
 				special.setEndTime_str("");
 			} else {
-				special.setTimeTask(true);
-
 				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
 				if (startTime == null) {
 					special.setStartTime_str("");

--
Gitblit v1.8.0