From 24a8d17e007545f7426c48352109aa1a9c6587ee Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 06 五月 2020 12:02:09 +0800
Subject: [PATCH] IOS上线隐藏我的界面的banner与超级会员升级信息

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialCardServiceImpl.java |   88 ++++++++++++++++++++++++++++----------------
 1 files changed, 56 insertions(+), 32 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialCardServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialCardServiceImpl.java
index 0e9e4da..698ff9a 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialCardServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialCardServiceImpl.java
@@ -21,6 +21,8 @@
 import com.yeshi.fanli.service.inter.homemodule.SpecialCardService;
 import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
 import com.yeshi.fanli.service.inter.homemodule.SpecialService;
+import com.yeshi.fanli.util.FilePathEnum;
+import com.yeshi.fanli.util.StringUtil;
 
 
 @Service
@@ -53,7 +55,7 @@
 		}
 		
 		// 鏃堕棿浠诲姟鎺у埗
-		conversionTime(record);
+		handleTime(record);
 		
 		
 		// 鍥剧墖涓婁紶
@@ -105,35 +107,31 @@
 	
 	/**
 	 * web娈垫椂闂磋浆鎹�
+	 * 
 	 * @param record
 	 */
-	public void conversionTime(SpecialCard record) throws SpecialCardException, 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 SpecialCardException(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(SpecialCard record) throws SpecialCardException, 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 SpecialCardException(1, "璧峰鏃堕棿涓嶈兘灏忎簬缁撴潫鏃堕棿");
 		}
 	}
 	
+	 
 	
 	/**
 	 * 涓婁紶鍥剧墖
@@ -149,7 +147,7 @@
 		String type = contentType.substring(contentType.indexOf("/") + 1);
 	
 		// 鏂囦欢璺緞
-		String filePath="/img/SpecialCard/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
+		String filePath=FilePathEnum.specialCard.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
 		// 鎵ц涓婁紶
 		String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
 		
@@ -169,7 +167,7 @@
 
 	
 	@Override
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	public int deleteBatchByPrimaryKey(List<Long> list) throws Exception{
 		specialService.deleteBatchByCardID(list);
 		return specialCardMapper.deleteBatchByPrimaryKey(list);
@@ -187,15 +185,20 @@
 			long totalSpecial= specialService.countlistQueryByCard(specialCard.getId(), null, null);
 			specialCard.setTotalSpecial(totalSpecial);
 			
+			// 灏嗙姸鎬佸彉鍖�
+			if (specialCard.getState() != null && specialCard.getState() == 0) {
+				specialCard.setState(1);
+			} else {
+				specialCard.setState(0);
+			}
+			
+			
 			Date startTime = specialCard.getStartTime();
 			Date endTime = specialCard.getEndTime();
 			if (startTime == null && endTime == null) {
-				specialCard.setTimeTask(false);
 				specialCard.setStartTime_str("");
 				specialCard.setEndTime_str("");
 			} else {
-				specialCard.setTimeTask(true);
-				
 				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
 				if (startTime == null) {
 					specialCard.setStartTime_str("");
@@ -217,9 +220,7 @@
 					specialCard.setPlaceName(specialPlace.getName());
 				}
 			}
-			
 		}
-		
 		return listObj;
 	}
 	
@@ -234,6 +235,29 @@
 	}
 	
 	
+	@Override
+	public void switchState(Long id) throws SpecialCardException {
+		if (id == null) {
+			throw new SpecialCardException(1, "璇蜂紶閫掓纭弬鏁�");
+		}
+		
+		SpecialCard resultObj = specialCardMapper.selectByPrimaryKey(id);
+		if (resultObj == null) {
+			throw new SpecialCardException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�");
+		}
+		
+		Integer state = resultObj.getState();
+		if (state == null || state == 0) {
+			state = 1;
+		} else {
+			state = 0;
+		}
+		
+		SpecialCard updateObj = new SpecialCard();
+		updateObj.setId(id);
+		updateObj.setState(state);
+		specialCardMapper.updateByPrimaryKeySelective(updateObj);
+	}
 	
 
 }

--
Gitblit v1.8.0