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 | 48 +++++++++++++++++++++++++++++++++++------------- 1 files changed, 35 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 791d4e8..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,6 @@ package com.yeshi.fanli.service.impl.push; +import java.math.BigDecimal; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -94,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) { @@ -112,6 +122,10 @@ PushCoupon current = selectByPrimaryKey(id); if (current == null) { throw new PushCouponException(1, "璇ヨ褰曞凡涓嶅瓨鍦�"); + } + + if(current.isPushed()) { + throw new PushCouponException(1, "宸叉帹閫佺殑淇℃伅涓嶈兘淇敼"); } current.setTitle(title); @@ -147,29 +161,36 @@ throw new PushCouponException(1, "鏍囬鎴栧唴瀹逛笉鑳戒负绌�"); } + + List<String> listuid = null; + String uids = pushCoupon.getUids(); + 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‘\""); + } } - String uids = pushCoupon.getUids(); - if (uids == null || uids.trim().length() == 0) { + + if (listuid == null) { // 鍏ㄦ帹 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, listVersion); - } + for (String str_uid: listuid) { + if (str_uid != null && str_uid.trim().length() > 0) { + pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listVersion); } } - } // 宸叉帹閫� @@ -192,6 +213,7 @@ for (Long id: list) { long receivedCount = pushCouponRecordService.countByPushId(id); + // 棰嗗彇鏁伴噺 if (receivedCount > 0) { continue; } -- Gitblit v1.8.0