From a8e45a802600ca1cde28fe8522a26635328bbd99 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 15 三月 2019 17:45:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushCouponServiceImpl.java |   58 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 13 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 a0e3225..bb45644 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,5 +1,7 @@
 package com.yeshi.fanli.service.impl.push;
 
+import java.math.BigDecimal;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
@@ -93,9 +95,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) {
@@ -111,6 +122,10 @@
 			PushCoupon current = selectByPrimaryKey(id);
 			if (current == null) {
 				throw new PushCouponException(1, "璇ヨ褰曞凡涓嶅瓨鍦�");
+			}
+			
+			if(current.isPushed()) {
+				throw new PushCouponException(1, "宸叉帹閫佺殑淇℃伅涓嶈兘淇敼");
 			}
 
 			current.setTitle(title);
@@ -134,6 +149,11 @@
 		if (pushCoupon == null) {
 			throw new PushCouponException(1, "鎺ㄩ�佷俊鎭凡涓嶅瓨鍦�");
 		}
+		
+		if(pushCoupon.isPushed()) {
+			throw new PushCouponException(1, "璇ヤ俊鎭笉鑳介噸澶嶆帹閫�");
+		}
+		
 
 		String title = pushCoupon.getTitle();
 		String content = pushCoupon.getContent();
@@ -142,24 +162,35 @@
 		}
 		
 		
+		List<String> listuid = null;
 		String uids = pushCoupon.getUids();
-		if (uids == null || uids.trim().length() == 0) {
+		if (uids != null && uids.trim().length() > 0) {
+			listuid = Arrays.asList(uids.split(","));
+			if (listuid == null || listuid.size() == 0) {
+				throw new PushCouponException(1, "鐢ㄦ埛id鏍煎紡涓嶆纭�");
+			}
+		}
+		
+		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‘\"");
+			}
+		}
+		
+		if (listuid == null) {
 			// 鍏ㄦ帹
-			pushService.pushWelfareCenter(null, title, content);
+			pushService.pushWelfareCenter(null, title, content, listVersion);
 			
 		} else {
 			// 鎸囧畾鐢ㄦ埛鎺ㄩ��
-			String[] uidArray = uids.split(",");
-			
-			if (uidArray != null) {
-				for (int i = 0; i < uidArray.length; i++) {
-					String str_uid = uidArray[i];
-					if (str_uid != null && str_uid.trim().length() > 0) {
-						pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content);
-					}
+			for (String str_uid: listuid) {
+				if (str_uid != null && str_uid.trim().length() > 0) {
+					pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listVersion);
 				}
 			}
-			
 		}
 		
 		// 宸叉帹閫�
@@ -182,6 +213,7 @@
 		
 		for (Long id: list) {
 			long receivedCount = pushCouponRecordService.countByPushId(id);
+			// 棰嗗彇鏁伴噺
 			if (receivedCount > 0) {
 				continue;
 			}

--
Gitblit v1.8.0