diff --git a/pom.xml b/pom.xml index 2776361cb..0a3d855d2 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 4.0.0 manage - 1.0.35 + 1.0.36 UTF-8 diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index f733aa1a8..69cedabf3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -187,4 +187,10 @@ public interface RetailAppService { * 退款密码 */ void resetRefundPassword(JSONObject device, JSONObject json); + + JSONObject toggleCBBankChannel(JSONObject device, String noticeId); + + JSONObject toggleCBBankCustomerSurcharge(JSONObject device, boolean customerSurcharge); + + void getCBBankAggregateFile(JSONObject device, HttpServletResponse httpResponse); } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 44761a752..af8b694ee 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -57,10 +57,7 @@ import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor; -import au.com.royalpay.payment.tools.utils.PageListUtils; -import au.com.royalpay.payment.tools.utils.PasswordUtils; -import au.com.royalpay.payment.tools.utils.QRCodeUtils; -import au.com.royalpay.payment.tools.utils.TimeZoneUtils; +import au.com.royalpay.payment.tools.utils.*; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -79,6 +76,7 @@ import org.apache.commons.lang3.time.DateUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.Cacheable; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; @@ -87,6 +85,8 @@ import org.springframework.util.Assert; import org.thymeleaf.context.Context; import org.thymeleaf.spring4.SpringTemplateEngine; +import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; @@ -107,6 +107,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; /** @@ -201,6 +202,8 @@ public class RetailAppServiceImp implements RetailAppService { private SpringTemplateEngine thymeleaf; @Resource private StringRedisTemplate stringRedisTemplate; + private final String CBBANK_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/05/1564972204689_uwZvpTBjtLUMcN8c540xcZvux1Rd3O.pdf"; + @Resource private SmsSender smsSender; private final String BIND_ACCOUNT_EMAIL_PREFIX = "BIND_ACCOUNT_EMAIL"; @@ -1285,12 +1288,18 @@ public class RetailAppServiceImp implements RetailAppService { String father = ""; String html = doc.body().children().wrap(father).html(); // logger.debug("wrapped html---->"+html); - res.put("content", doc.html()); + if (res.getIntValue("type")==2) { + List buttons = JSONObject.parseArray(res.getString("buttons"),JSONObject.class); + res.put("buttons", buttons); + }else { + res.put("content", doc.html()); + } return res; } @Override public List getLatestNotice(int client_id) { + JSONObject clientConfig = clientConfigService.find(client_id); JSONObject notice = new JSONObject(); JSONObject latestNotice = noticeManage.getLatestWindowNotice(client_id); if (latestNotice != null) { @@ -1302,12 +1311,70 @@ public class RetailAppServiceImp implements RetailAppService { unReadParams.put("client_id", client_id); unReadParams.put("status", 0); unReadParams.put("is_to_app", 1); + unReadParams.put("type", 1); int counts = noticePartnerMapper.countNoticePartner(unReadParams); notice.put("unReadCounts", counts); notice.put("type", "notice"); List result = new ArrayList<>(); result.add(notice); + JSONObject confirmNotice = new JSONObject(); + JSONObject latestConfirmNotice = noticeManage.getLatestWindowConfirmNotice(client_id); + if (latestConfirmNotice != null) { + latestConfirmNotice.put("id", latestConfirmNotice.getString("notice_id")); + latestConfirmNotice.remove("notice_id"); + List buttons = JSONObject.parseArray(latestConfirmNotice.getString("buttons"),JSONObject.class); + latestConfirmNotice.put("buttons", buttons); + String content = latestConfirmNotice.getString("content"); + if (content.indexOf("%excharge_rate%")>0) { + JSONObject rate = merchantInfoProvider.clientCurrentRate(client_id, new Date(), "CB_BankPay"); + if (rate != null) { + content = content.replace("%excharge_rate%", (rate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() + "%")); + }else { + content = content.replace("%excharge_rate%", "(暂未配置)"); + } + } + if (StringUtils.isNotBlank(latestConfirmNotice.getString("aggregate_file"))) { + JSONObject rate = merchantInfoProvider.clientCurrentRate(client_id, new Date(), "CB_BankPay"); + JSONArray rateInfo = new JSONArray(); + if (rate != null) { + String cleanDays = "T+" + rate.getIntValue("clean_days"); + String rateValue = rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%"; + String EndDate = DateFormatUtils.format(rate.getDate("expiry_date"), "yyyy-MM-dd"); + String[] rateName = {"清算时间", "签约费率", "结束时间"}; + String[] rateKey = {cleanDays, rateValue, EndDate}; + for(int i =0;i buttons = new ArrayList<>(); + if (button0 != null) { + JSONObject buttonJson = JSON.parseObject(button0); + if (StringUtils.isNotBlank(buttonJson.getString("name")) && StringUtils.isNotBlank(buttonJson.getString("type"))) { + buttons.add(buttonJson); + } + } + if (button1 != null) { + JSONObject buttonJson = JSON.parseObject(button1); + if (StringUtils.isNotBlank(buttonJson.getString("name")) && StringUtils.isNotBlank(buttonJson.getString("type"))) { + buttons.add(buttonJson); + } + } + if (button2 != null) { + JSONObject buttonJson = JSON.parseObject(button2); + if (StringUtils.isNotBlank(buttonJson.getString("name")) && StringUtils.isNotBlank(buttonJson.getString("type"))) { + buttons.add(buttonJson); + } + } + if (buttons.size() > 0 ) { + res.put("buttons",buttons); + } + if (aggregate_file != null) { + res.put("aggregate_file",aggregate_file); + } + if (url != null) { + res.put("url",url); + } + if (type != null) { + res.put("type", type); + }else { + res.put("type", 1); + } return res; } public String getTitle() { @@ -154,4 +198,50 @@ public class NoticeInfo { public void setDesc(String desc) { this.desc = desc; } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setButton1(String button1) { + this.button1 = button1; + } + + public String getButton1() { + return button1; + } + public void setButton2(String button2) { + this.button2 = button2; + } + + public String getButton2() { + return button2; + } + public void setButton0(String button0) { + this.button0 = button0; + } + + public String getButton0() { + return button0; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getAggregate_file() { + return aggregate_file; + } + + public void setAggregate_file(String aggregate_file) { + this.aggregate_file = aggregate_file; + } } 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 a30934aa6..00e461615 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 @@ -28,4 +28,6 @@ public interface NoticeManage { JSONObject getLatestWindowNotice(int client_id); + JSONObject getLatestWindowConfirmNotice(int client_id); + } 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 65e7f0769..8c932290a 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 @@ -19,6 +19,7 @@ import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -68,6 +69,18 @@ public class NoticeManageImpl implements NoticeManage { @Override public JSONObject listNotices(NoticeQuery query) { PageList notices = noticeManageMapper.listPageNotices(query.toParams(), new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); + for (JSONObject notice : notices) { + if (notice.getIntValue("type") == 2) { + if (notice.get("buttons") != null) { + List buttons = JSONObject.parseArray(notice.getString("buttons"), JSONObject.class); + if (buttons != null && buttons.size() > 0) { + for (int i = 0; i < buttons.size(); i++) { + notice.put("button" + i, buttons.get(i)); + } + } + } + } + } return PageListUtils.buildPageListResult(notices); } @@ -102,6 +115,7 @@ public class NoticeManageImpl implements NoticeManage { @Override public JSONObject saveNotice(NoticeInfo noticeInfo, JSONObject manager) { Date date = new Date(); + List buttons = new ArrayList<>(); JSONObject notice = noticeInfo.toJson(); notice.put("create_time", date); notice.put("create_id", manager.getString("manager_id")); @@ -119,20 +133,43 @@ public class NoticeManageImpl implements NoticeManage { notice.put("send_clients",sendClients.substring(0,sendClients.length()-1)); } } + buttons = JSONObject.parseArray(notice.getString("buttons"),JSONObject.class); + notice.remove("buttons"); noticeManageMapper.createNotice(notice); - + if (notice.getIntValue("type")==2) { + for (JSONObject button : buttons) { + if (StringUtils.isNotBlank(button.getString("link"))) { + if (button.getString("link").indexOf("%noticeId%") > 0) { + button.put("link", button.getString("link").replace("%noticeId%", notice.getString("notice_id"))); + } + } + } + notice.put("buttons", buttons.toString()); + noticeManageMapper.updateNotice(notice); + } return notice; } @Override public JSONObject getNoticeById(String noticeId) { JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId); + if (notice.getIntValue("type") == 2) { + if (notice.get("buttons") != null) { + List buttons = JSONObject.parseArray(notice.getString("buttons"), JSONObject.class); + if (buttons != null && buttons.size() > 0) { + for (int i = 0; i < buttons.size(); i++) { + notice.put("button" + i, buttons.get(i)); + } + } + } + } return notice; } @Override @Transactional public void updateNotice(JSONObject manager, String noticeId, NoticeInfo info) throws Exception { + List buttons = new ArrayList<>(); JSONObject noticeInfo = noticeManageMapper.getNoticeDetailById(noticeId); Assert.notNull(noticeInfo); Date date = new Date(); @@ -158,6 +195,19 @@ public class NoticeManageImpl implements NoticeManage { } } + if (notice.getIntValue("type")==2) { + buttons = JSONObject.parseArray(notice.getString("buttons"),JSONObject.class); + for (JSONObject button : buttons) { + if (StringUtils.isNotBlank(button.getString("link"))) { + if (button.getString("link").indexOf("%noticeId%") > 0) { + button.put("link", button.getString("link").replace("%noticeId%", notice.getString("notice_id"))); + } + } + } + notice.put("buttons", buttons.toString()); + }else { + notice.remove(buttons); + } noticeManageMapper.updateNotice(notice); if (info.getStatus() != null && info.getSend_clients() != null) { if (info.getStatus().equals("1") && noticeInfo.getString("status").equals("0") && !info.getSend_clients().isEmpty()) { @@ -310,6 +360,11 @@ public class NoticeManageImpl implements NoticeManage { return noticeManageMapper.getLatestWindowNotice(client_id,new Date()); } + @Override + public JSONObject getLatestWindowConfirmNotice(int client_id) { + return noticeManageMapper.getLatestWindowConfirmNotice(client_id,new Date()); + } + @Override public void toggleNoticeAppWindow(String noticeId, Boolean isAppWindow) { JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.xml index 67997bf16..dcdd5cf88 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.xml @@ -21,6 +21,19 @@ where c.client_id = #{client_id} and n.status = 1 and end_time > #{end_time} and n.is_app_window = 1 + and n.type = 1 + order by n.send_time desc + limit 1 + + + + select n.title,n.`desc`,n.buttons,n.notice_id,n.content,n.url,n.aggregate_file + from sys_notice_client c left join sys_notice n + on c.notice_id = n.notice_id and c.`status` = 0 + where c.client_id = #{client_id} and n.status = 1 + and end_time > #{end_time} + and n.is_app_window = 1 + and n.type = 2 order by n.send_time desc limit 1 diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticePartnerMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticePartnerMapper.xml index 6f0b045a0..f0fe72f7e 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticePartnerMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticePartnerMapper.xml @@ -35,5 +35,8 @@ and n.is_to_app=#{is_to_app} + + and n.type=#{type} + \ No newline at end of file diff --git a/src/main/ui/static/config/notice/notice.js b/src/main/ui/static/config/notice/notice.js index a200062d6..d8b991b5c 100644 --- a/src/main/ui/static/config/notice/notice.js +++ b/src/main/ui/static/config/notice/notice.js @@ -90,7 +90,18 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' app.controller('addNoticeCtrl', ['$scope', '$http', '$filter', '$state', 'commonDialog', function ($scope, $http, $filter, $state, commonDialog) { $scope.merchantTypes = angular.copy(merchantTypes); $scope.saveNoticeResult = false; - $scope.notice = {}; + $scope.notice = { + type : '1', + button1:{ + "method" : 'PUT' + }, + button2:{ + "method" : 'PUT' + }, + button0:{ + "method" : 'PUT' + } + }; $scope.today = new Date(); $scope.save = function (form) { if (form.$invalid) { diff --git a/src/main/ui/static/config/notice/templates/notice_add.html b/src/main/ui/static/config/notice/templates/notice_add.html index 469c281cb..7512564d8 100644 --- a/src/main/ui/static/config/notice/templates/notice_add.html +++ b/src/main/ui/static/config/notice/templates/notice_add.html @@ -71,13 +71,274 @@ + + Notice Type + + + 普通通知 + 确认通知 + + + + ng-class="{'has-error':noticeForm.content.$invalid && noticeForm.content.$dirty}" ng-if="notice.type=='1'"> + + Content + + + + Less Than 400 + Characters(including symbols and spaces) + + + + + + Button - 1 + + + + Button Name + + + + + Less Than 100 + Characters(including symbols and spaces) + + + + + Button Type + + + + Please Choose + 带确认的请求框 + 无需确认的请求框 + 关闭框 + + + + + Button Method + + + + GET + PUT + POST + + + + + Button Link + + + + + + + Confirm Title + + + + + + + Confirm Content + + + + + + + + + + + + Button - 2 + + + + Button Name + + + + + + + Button Type + + + + Please Choose + 带确认的请求框 + 无需确认的请求框 + 关闭框 + + + + + Button Method + + + + GET + PUT + POST + + + + + Button Link + + + + + Less Than 100 + Characters(including symbols and spaces) + + + + + Confirm Title + + + + + + + Confirm Content + + + + + + + + + + Button - 3 + + + + Button Name + + + + + + + Button Type + + + + Please Choose + 带确认的请求框 + 无需确认的请求框 + 关闭框 + + + + + Button Method + + + + GET + PUT + POST + + + + + Button Link + + + + + Less Than 100 + Characters(including symbols and spaces) + + + + + Confirm Title + + + + + + + Confirm Content + + + + + + + + + + + + 了解更多 URL + + + + + + 合同文件获取Link + + + + + * Expiry Date diff --git a/src/main/ui/static/config/notice/templates/notice_detail.html b/src/main/ui/static/config/notice/templates/notice_detail.html index 94204ac85..beb92db2b 100644 --- a/src/main/ui/static/config/notice/templates/notice_detail.html +++ b/src/main/ui/static/config/notice/templates/notice_detail.html @@ -47,6 +47,13 @@ + + Notice Type + + 普通通知 + 确认通知 + + Expiry Date
Less Than 400 + Characters(including symbols and spaces)
Less Than 100 + Characters(including symbols and spaces)
普通通知
确认通知