From 8e886dec435d203d61ddf723a8599ca34f4d1e96 Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Thu, 15 Mar 2018 12:21:32 +0800 Subject: [PATCH] fix --- src/db/modify.sql | 5 +- .../manage/notice/beans/NoticeInfo.java | 10 ++++ .../manage/notice/core/NoticeManage.java | 1 + .../notice/core/impls/NoticeManageImpl.java | 32 ++++++++---- .../notice/web/NoticeManageController.java | 6 +++ .../manage/mappers/system/ClientMapper.xml | 2 +- src/main/ui/static/config/notice/notice.js | 52 ++++++++++++++++--- .../config/notice/templates/notice_add.html | 18 +++---- .../notice/templates/notice_detail.html | 3 ++ .../notice/templates/send_notice_dialog.html | 38 ++++++++++++++ 10 files changed, 140 insertions(+), 27 deletions(-) create mode 100644 src/main/ui/static/config/notice/templates/send_notice_dialog.html diff --git a/src/db/modify.sql b/src/db/modify.sql index 3c50e380d..393d6b93a 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -240,4 +240,7 @@ ALTER TABLE `financial_bd_prize_log` ALTER TABLE sys_notice ADD merchants_type TINYINT(1) DEFAULT 0 NOT NULL COMMENT '商户范围0:全部商户 1:自定义商户'; -ALTER TABLE sys_notice ADD is_app_window TINYINT(1) DEFAULT 0 COMMENT '是否需要APP弹框'; \ No newline at end of file +ALTER TABLE sys_notice ADD is_app_window TINYINT(1) DEFAULT 0 COMMENT '是否需要APP弹框'; + + +ALTER TABLE sys_notice MODIFY end_time DATE NOT NULL COMMENT '截止日期'; \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/notice/beans/NoticeInfo.java b/src/main/java/au/com/royalpay/payment/manage/notice/beans/NoticeInfo.java index 162f7ef40..c9b10bca5 100644 --- a/src/main/java/au/com/royalpay/payment/manage/notice/beans/NoticeInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/notice/beans/NoticeInfo.java @@ -24,6 +24,7 @@ public class NoticeInfo { private boolean is_tomail_cc_stockholder; private boolean is_to_app; private boolean is_app_window; + private int merchants_type=0; private String notice_id; public JSONObject toJson() { @@ -36,6 +37,7 @@ public class NoticeInfo { } } res.put("title",title); + res.put("merchants_type",merchants_type); if (content != null){ res.put("content",content); } @@ -132,4 +134,12 @@ public class NoticeInfo { public void setIs_app_window(boolean is_app_window) { this.is_app_window = is_app_window; } + + public int getMerchants_type() { + return merchants_type; + } + + public void setMerchants_type(int merchants_type) { + this.merchants_type = merchants_type; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/notice/core/NoticeManage.java b/src/main/java/au/com/royalpay/payment/manage/notice/core/NoticeManage.java index 6bb834d75..8d1e249ad 100644 --- a/src/main/java/au/com/royalpay/payment/manage/notice/core/NoticeManage.java +++ b/src/main/java/au/com/royalpay/payment/manage/notice/core/NoticeManage.java @@ -24,4 +24,5 @@ public interface NoticeManage { JSONObject listNoticeReadClients(String noticeId, int page, int limit); + void toggleNoticeAppWindow(String noticeId, Boolean isAppWindow); } diff --git a/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/NoticeManageImpl.java b/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/NoticeManageImpl.java index 13a6d9d10..f0048c497 100644 --- a/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/NoticeManageImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/NoticeManageImpl.java @@ -8,6 +8,7 @@ import java.util.List; import javax.annotation.Resource; +import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -99,18 +100,20 @@ public class NoticeManageImpl implements NoticeManage { notice.put("create_time", date); notice.put("create_id", manager.getString("manager_id")); notice.put("create_name", manager.getString("display_name")); - - noticeManageMapper.createNotice(notice); - if (noticeInfo.getStatus() != null && noticeInfo.getStatus().equals("1")) { - List clients = clientMapper.listClients(); - if (!clients.isEmpty()) { - for (JSONObject client : clients) { - client.put("create_time", date); - client.put("notice_id", notice.getString("notice_id")); - noticePartnerMapper.save(client); - } + if (!notice.getBoolean("merchants_type")){ + String sendClients = ""; + List clients = clientMapper.listValidClient(); + clients.forEach(c -> { + String p = c+","; + sendClients.concat(p); + }); + if (sendClients.length()>0){ + sendClients.substring(0,sendClients.length()-1); } + notice.put("send_clients",sendClients); } + noticeManageMapper.createNotice(notice); + return notice; } @@ -201,6 +204,15 @@ public class NoticeManageImpl implements NoticeManage { return PageListUtils.buildPageListResult(clients); } + @Override + public void toggleNoticeAppWindow(String noticeId, Boolean isAppWindow) { + JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId); + if (notice.getDate("end_time")!=null && notice.getDate("end_time").compareTo(new Date())<0){ + throw new ForbiddenException("The Notice has expired"); + } + notice.put("is_app_window",isAppWindow); + noticeManageMapper.updateNotice(notice); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/notice/web/NoticeManageController.java b/src/main/java/au/com/royalpay/payment/manage/notice/web/NoticeManageController.java index 371a11851..5a5d6982e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/notice/web/NoticeManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/notice/web/NoticeManageController.java @@ -52,6 +52,12 @@ public class NoticeManageController { return noticeManage.listNoticeReadClients(noticeId,page,limit); } + @ManagerMapping(value = "/{noticeId}/app_window", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public void toggleNoticeAppWindow(@PathVariable String noticeId, @RequestBody JSONObject jsonObject){ + Boolean isAppWindow = jsonObject.getBoolean("is_app_window"); + noticeManage.toggleNoticeAppWindow(noticeId,isAppWindow); + } + @ManagerMapping(value = "/{noticeId}/clients", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) public int listNoticeClients(@PathVariable String noticeId){ return noticeManage.listNoticeClients(noticeId); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index 980a4ffa0..641b1d317 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -7,7 +7,7 @@ WHERE client_id = #{client_id} +