From 553e4585a5ec8e2c22b50e33a27d14ead6fd034d Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期五, 26 四月 2019 15:16:07 +0800
Subject: [PATCH] 店铺足迹删除+ 假删除

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushCouponServiceImpl.java |   57 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushCouponServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushCouponServiceImpl.java
index 007f2f0..e8a7e10 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushCouponServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushCouponServiceImpl.java
@@ -1,13 +1,15 @@
 package com.yeshi.fanli.service.impl.push;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
 import javax.annotation.Resource;
-import javax.transaction.Transactional;
 
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import com.yeshi.fanli.dao.mybatis.push.PushCouponMapper;
 import com.yeshi.fanli.entity.push.PushCoupon;
@@ -17,6 +19,8 @@
 import com.yeshi.fanli.service.inter.push.PushCouponRecordService;
 import com.yeshi.fanli.service.inter.push.PushCouponService;
 import com.yeshi.fanli.service.inter.push.PushService;
+
+import net.sf.json.JSONObject;
 
 @Service
 public class PushCouponServiceImpl implements PushCouponService {
@@ -94,9 +98,18 @@
 		}
 
 		Integer amount = record.getAmount();
-		if (amount == null || amount < 1) {
-			throw new PushCouponException(1, "鍒告暟閲忎笉鑳藉皬浜�1");
+		if (amount == null) {
+			throw new PushCouponException(1, "鍒告暟閲忎笉鑳戒负绌�");
+		} else if (amount < 1 || amount > 5) {
+			throw new PushCouponException(1, "鍒告暟閲忚寖鍥存槸 1~5");
 		}
+		
+		BigDecimal percent = record.getPercent();
+		if (percent != null && (percent.compareTo(new BigDecimal(60)) > 0
+				|| percent.compareTo(new BigDecimal(1)) < 0)) {
+			throw new PushCouponException(1, "鍒告瘮渚嬭寖鍥存槸1~60 鐨勬鏁存暟");
+		}
+		
 
 		Long id = record.getId();
 		if (id == null) {
@@ -112,6 +125,10 @@
 			PushCoupon current = selectByPrimaryKey(id);
 			if (current == null) {
 				throw new PushCouponException(1, "璇ヨ褰曞凡涓嶅瓨鍦�");
+			}
+			
+			if(current.isPushed()) {
+				throw new PushCouponException(1, "宸叉帹閫佺殑淇℃伅涓嶈兘淇敼");
 			}
 
 			current.setTitle(title);
@@ -139,6 +156,10 @@
 		if(pushCoupon.isPushed()) {
 			throw new PushCouponException(1, "璇ヤ俊鎭笉鑳介噸澶嶆帹閫�");
 		}
+		String versions = pushCoupon.getVersions();
+		if (versions == null || versions.trim().length() == 0 ) {
+			throw new PushCouponException(1, "鎺ㄩ�佺増鏈笉鑳戒负绌�");
+		}
 		
 
 		String title = pushCoupon.getTitle();
@@ -157,24 +178,37 @@
 			}
 		}
 		
-		List<String> listVersion = null;
-		String versions = pushCoupon.getVersions();
-		if (versions != null && versions.trim().length() > 0) {
-			listVersion  = Arrays.asList(versions.split(","));
-			if (listVersion == null || listVersion.size() == 0) {
-				throw new PushCouponException(1, "鐗堟湰鍙锋牸寮忎笉姝g‘\"");
+		List<String> listIOS = new ArrayList<String>();
+		JSONObject json = JSONObject.fromObject(versions);
+		String versionsIOS = json.getString("IOS");
+		if (versionsIOS != null && versionsIOS.trim().length() > 0) {
+			if (versionsIOS.contains("鍏ㄦ帹")) {
+				listIOS = null;
+			} else {
+				listIOS = Arrays.asList(versionsIOS.split(","));
 			}
 		}
 		
+		List<String> listAndroid = new ArrayList<String>();
+		String versionsAndroid  = json.getString("Android");
+		if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
+			if (versionsAndroid.contains("鍏ㄦ帹")) {
+				listAndroid = null;
+			} else {
+				listAndroid = Arrays.asList(versionsAndroid.split(","));
+			}
+		}
+		
+		
 		if (listuid == null) {
 			// 鍏ㄦ帹
-			pushService.pushWelfareCenter(null, title, content, listVersion);
+			pushService.pushWelfareCenter(null, title, content, listIOS, listAndroid);
 			
 		} else {
 			// 鎸囧畾鐢ㄦ埛鎺ㄩ��
 			for (String str_uid: listuid) {
 				if (str_uid != null && str_uid.trim().length() > 0) {
-					pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listVersion);
+					pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listIOS, listAndroid);
 				}
 			}
 		}
@@ -199,6 +233,7 @@
 		
 		for (Long id: list) {
 			long receivedCount = pushCouponRecordService.countByPushId(id);
+			// 棰嗗彇鏁伴噺
 			if (receivedCount > 0) {
 				continue;
 			}

--
Gitblit v1.8.0