From 48a204f4c90a80c0bb4e5ba1f9f0f42939cadba8 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 01 一月 2020 10:19:34 +0800
Subject: [PATCH] 用户资金记录bug修改,京东,拼多多小程序商品转链

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java |  139 ++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 120 insertions(+), 19 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java
index 7e967e9..a17e140 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java
@@ -1,13 +1,12 @@
 package com.yeshi.fanli.controller.admin;
 
 import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
 import javax.annotation.Resource;
-
-import net.sf.json.JSONObject;
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,6 +21,8 @@
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
+
+import net.sf.json.JSONObject;
 
 @Controller
 @RequestMapping("admin/new/api/v1/notification")
@@ -39,9 +40,7 @@
 	 */
 //	@RequestMapping(value = "saveAdd")
 	public void saveAdd(String callback, AppPageNotification appPageNotification, PrintWriter out) {
-
 		try {
-			
 			String content = appPageNotification.getContent();
 			if (StringUtil.isNullOrEmpty(content) ) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏄剧ず鍐呭涓嶈兘涓虹┖"));
@@ -62,6 +61,40 @@
 				appPageNotification.setMd5(StringUtil.Md5(null + "#" + content + "#" + appPageNotification.getContentUrl()));
 			}
 			
+			Boolean show = appPageNotification.getShow();
+			if (show == null) {
+				show = false;
+				appPageNotification.setShow(show);
+			}
+			
+			Boolean canClose = appPageNotification.getCanClose();
+			if (canClose == null) {
+				canClose = false;
+				appPageNotification.setCanClose(canClose);
+			}
+			
+			String contentUrl = appPageNotification.getContentUrl();
+			if (canClose != null && canClose && !StringUtil.isNullOrEmpty(contentUrl)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璺宠浆閾炬帴鍜屽厑璁稿叧闂笉鍙悓鏃跺瓨鍦�"));
+				return;
+			}
+			
+			if (!canClose && StringUtil.isNullOrEmpty(contentUrl)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璺宠浆閾炬帴涓嶈兘涓虹┖"));
+				return;
+			}
+			
+			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+			
+			String beginTimeVO = appPageNotification.getBeginTimeVO();
+			if (!StringUtil.isNullOrEmpty(beginTimeVO)) {
+				appPageNotification.setBeginTime(format.parse(beginTimeVO.replaceAll("T", " ")));
+			}
+				
+			String endTimeVO = appPageNotification.getEndTimeVO();
+			if (!StringUtil.isNullOrEmpty(endTimeVO)) {
+				appPageNotification.setEndTime(format.parse(endTimeVO.replaceAll("T", " ")));
+			}
 			
 			appPageNotification.setCreateTime(new Date());
 			appPageNotification.setUpdateTime(new Date());
@@ -84,7 +117,6 @@
 	@RequestMapping(value = "saveModify")
 	public void saveModify(String callback, AppPageNotification appPageNotification, PrintWriter out) {
 		try {
-			
 			AppPageNotificationTypeEnum type = appPageNotification.getType();
 			if (type == null) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID涓嶈兘涓虹┖"));
@@ -103,10 +135,47 @@
 				return;
 			}
 			
+			Boolean show = appPageNotification.getShow();
+			if (show == null) {
+				show = false;
+				appPageNotification.setShow(show);
+			}
+			
+			Boolean canClose = appPageNotification.getCanClose();
+			if (canClose == null) {
+				canClose = false;
+				appPageNotification.setCanClose(canClose);
+			}
+			
+			if (canClose && !StringUtil.isNullOrEmpty(appPageNotification.getContentUrl())) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璺宠浆閾炬帴鍜屽厑璁稿叧闂笉鍙悓鏃跺瓨鍦�"));
+				return;
+			}
+			
+			if (!canClose && StringUtil.isNullOrEmpty(appPageNotification.getContentUrl())) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璺宠浆閾炬帴涓嶈兘涓虹┖"));
+				return;
+			}
+			
+			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+			
+			String beginTimeVO = appPageNotification.getBeginTimeVO();
+			if (!StringUtil.isNullOrEmpty(beginTimeVO)) {
+				appPageNotification.setBeginTime(format.parse(beginTimeVO.replaceAll("T", " ")));
+			}
+				
+			String endTimeVO = appPageNotification.getEndTimeVO();
+			if (!StringUtil.isNullOrEmpty(endTimeVO)) {
+				appPageNotification.setEndTime(format.parse(endTimeVO.replaceAll("T", " ")));
+			}
+			
 			appPageNotification.setMd5(StringUtil.Md5(type.name() + "#" + content + "#" + appPageNotification.getContentUrl()));
-			appPageNotification.setId(old.getId());
 			appPageNotification.setUpdateTime(new Date());
-			appPageNotificationService.updateByPrimaryKeySelective(appPageNotification);
+			
+			appPageNotification.setId(old.getId());
+			appPageNotification.setType(old.getType());
+			appPageNotification.setCreateTime(old.getCreateTime());
+			appPageNotificationService.updateByPrimaryKey(appPageNotification);
 
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
 
@@ -148,9 +217,25 @@
 				return;
 			}
 			
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
 			for (AppPageNotification notification: list) {
 				AppPageNotificationTypeEnum type = notification.getType();
 				notification.setPageName(type.getDesc());
+				
+				
+				Date startTime = notification.getBeginTime();
+				if (startTime == null) {
+					notification.setBeginTimeVO("");
+				} else {
+					notification.setBeginTimeVO(sdf.format(startTime));
+				}
+				
+				Date endTime = notification.getEndTime();
+				if (endTime == null) {
+					notification.setEndTimeVO("");
+				} else {
+					notification.setEndTimeVO(sdf.format(endTime));
+				}
 			}
 			
 			
@@ -198,16 +283,29 @@
 			}
 			
 			Boolean canClose = resultObj.getCanClose();
-			if (canClose) {
-				resultObj.setCanClose(false);
+			if (canClose != null && canClose) {
+				canClose = false;
 			} else {
-				resultObj.setCanClose(true);
+				canClose = true;
 			}
-
-			appPageNotificationService.updateByPrimaryKeySelective(resultObj);
+			
+			if (canClose && !StringUtil.isNullOrEmpty(resultObj.getContentUrl())) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璺宠浆閾炬帴鍜屽厑璁稿叧闂笉鍙悓鏃跺瓨鍦�"));
+				return;
+			}
+			
+			if (!canClose && StringUtil.isNullOrEmpty(resultObj.getContentUrl())) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璺宠浆閾炬帴涓嶈兘涓虹┖"));
+				return;
+			}
+			
+			AppPageNotification newOBj = new AppPageNotification();
+			newOBj.setId(resultObj.getId());
+			newOBj.setCanClose(canClose);
+			appPageNotificationService.updateByPrimaryKeySelective(newOBj);
 			
 			JSONObject data = new JSONObject();
-			data.put("state", resultObj.getCanClose());
+			data.put("state", newOBj.getCanClose());
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 
 		} catch (Exception e) {
@@ -238,16 +336,19 @@
 			}
 			
 			Boolean show = resultObj.getShow();
-			if (show) {
-				resultObj.setShow(false);
+			if (show != null && show) {
+				show = false;
 			} else {
-				resultObj.setShow(true);
+				show = true;
 			}
-
-			appPageNotificationService.updateByPrimaryKeySelective(resultObj);
+			
+			AppPageNotification newOBj = new AppPageNotification();
+			newOBj.setId(resultObj.getId());
+			newOBj.setShow(show);
+			appPageNotificationService.updateByPrimaryKeySelective(newOBj);
 			
 			JSONObject data = new JSONObject();
-			data.put("state", resultObj.getShow());
+			data.put("state", newOBj.getShow());
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 
 		} catch (Exception e) {

--
Gitblit v1.8.0