add App大额渠道开通弹窗

master
luoyang 5 years ago
parent 0e18f4a342
commit ce207acfba

@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>1.0.35</version> <version>1.0.36</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

@ -187,4 +187,10 @@ public interface RetailAppService {
* 退 * 退
*/ */
void resetRefundPassword(JSONObject device, JSONObject json); void resetRefundPassword(JSONObject device, JSONObject json);
JSONObject toggleCBBankChannel(JSONObject device, String noticeId);
JSONObject toggleCBBankCustomerSurcharge(JSONObject device, boolean customerSurcharge);
void getCBBankAggregateFile(JSONObject device, HttpServletResponse httpResponse);
} }

@ -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.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor; import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.*;
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 com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@ -79,6 +76,7 @@ import org.apache.commons.lang3.time.DateUtils;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -87,6 +85,8 @@ import org.springframework.util.Assert;
import org.thymeleaf.context.Context; import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.SpringTemplateEngine;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
@ -107,6 +107,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
@ -201,6 +202,8 @@ public class RetailAppServiceImp implements RetailAppService {
private SpringTemplateEngine thymeleaf; private SpringTemplateEngine thymeleaf;
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
private final String CBBANK_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/05/1564972204689_uwZvpTBjtLUMcN8c540xcZvux1Rd3O.pdf";
@Resource @Resource
private SmsSender smsSender; private SmsSender smsSender;
private final String BIND_ACCOUNT_EMAIL_PREFIX = "BIND_ACCOUNT_EMAIL"; private final String BIND_ACCOUNT_EMAIL_PREFIX = "BIND_ACCOUNT_EMAIL";
@ -1285,12 +1288,18 @@ public class RetailAppServiceImp implements RetailAppService {
String father = "<div style=\"padding:0 10px\"></div>"; String father = "<div style=\"padding:0 10px\"></div>";
String html = doc.body().children().wrap(father).html(); String html = doc.body().children().wrap(father).html();
// logger.debug("wrapped html---->"+html); // logger.debug("wrapped html---->"+html);
if (res.getIntValue("type")==2) {
List<JSONObject> buttons = JSONObject.parseArray(res.getString("buttons"),JSONObject.class);
res.put("buttons", buttons);
}else {
res.put("content", doc.html()); res.put("content", doc.html());
}
return res; return res;
} }
@Override @Override
public List<JSONObject> getLatestNotice(int client_id) { public List<JSONObject> getLatestNotice(int client_id) {
JSONObject clientConfig = clientConfigService.find(client_id);
JSONObject notice = new JSONObject(); JSONObject notice = new JSONObject();
JSONObject latestNotice = noticeManage.getLatestWindowNotice(client_id); JSONObject latestNotice = noticeManage.getLatestWindowNotice(client_id);
if (latestNotice != null) { if (latestNotice != null) {
@ -1302,12 +1311,70 @@ public class RetailAppServiceImp implements RetailAppService {
unReadParams.put("client_id", client_id); unReadParams.put("client_id", client_id);
unReadParams.put("status", 0); unReadParams.put("status", 0);
unReadParams.put("is_to_app", 1); unReadParams.put("is_to_app", 1);
unReadParams.put("type", 1);
int counts = noticePartnerMapper.countNoticePartner(unReadParams); int counts = noticePartnerMapper.countNoticePartner(unReadParams);
notice.put("unReadCounts", counts); notice.put("unReadCounts", counts);
notice.put("type", "notice"); notice.put("type", "notice");
List<JSONObject> result = new ArrayList<>(); List<JSONObject> result = new ArrayList<>();
result.add(notice); 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<JSONObject> 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<rateName.length;i++){
JSONObject b = new JSONObject();
b.put("name",rateName[i]);
b.put("value",rateKey[i]);
b.put("type", "string");
rateInfo.add(b);
}
if (clientConfig != null) {
JSONObject customerSurcharge = new JSONObject();
customerSurcharge.put("name", "客户支付手续费");
customerSurcharge.put("value", String.valueOf(clientConfig.getBooleanValue("cbbank_surcharge")));
customerSurcharge.put("type", "button");
customerSurcharge.put("method", "PUT");
customerSurcharge.put("key", "customerSurcharge");
customerSurcharge.put("link", PlatformEnvironment.getEnv().concatUrl("api/v1.0/retail/app/cbbank_pay/toggleCustomerSurcharge"));
rateInfo.add(customerSurcharge);
}
latestConfirmNotice.put("rate_info", rateInfo);
}
}
latestConfirmNotice.put("content", content);
confirmNotice.put("data", latestConfirmNotice);
}
unReadParams.put("type", 2);
counts = noticePartnerMapper.countNoticePartner(unReadParams);
confirmNotice.put("unReadCounts", counts);
confirmNotice.put("type", "confirm_notice");
result.add(confirmNotice);
JSONObject latestAct = appActService.getLatestWindowNotice(); JSONObject latestAct = appActService.getLatestWindowNotice();
if (latestAct != null) { if (latestAct != null) {
latestAct.put("id", latestAct.getString("act_id")); latestAct.put("id", latestAct.getString("act_id"));
@ -2044,6 +2111,114 @@ public class RetailAppServiceImp implements RetailAppService {
clientConfigService.update(update); clientConfigService.update(update);
} }
@Override
public JSONObject toggleCBBankChannel(JSONObject device,String noticeId) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) {
throw new BadRequestException("You have no permission");
}
JSONObject result = new JSONObject();
JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id"));
try {
clientManager.switchChannelPermission(account, client.getString("client_moniker"), "cb_bankpay", true);
} catch (Exception e) {
result.put("status", "Fail");
result.put("message", "开通大额支付渠道失败,失败原因:" + e.getMessage());
return result;
}
updateReadStatus(device, noticeId);
result.put("status", "Success");
result.put("message", "开通大额支付渠道成功!");
return result;
}
@Override
public JSONObject toggleCBBankCustomerSurcharge(JSONObject device,boolean customerSurcharge) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) {
throw new BadRequestException("You have no permission");
}
JSONObject result = new JSONObject();
try {
clientManager.changeCBBankPaySurcharge(account, customerSurcharge);
} catch (Exception e) {
JSONObject clientConfig = clientConfigService.find(device.getIntValue("client_id"));
result.put("status", "Fail");
if (customerSurcharge) {
result.put("message", "开启客户支付手续费失败,失败原因:" + e.getMessage());
}else {
result.put("message", "关闭客户支付手续费失败,失败原因:" + e.getMessage());
}
result.put("customerSurcharge", String.valueOf(clientConfig.getBooleanValue("cbbank_surcharge")));
return result;
}
result.put("status", "Success");
if (customerSurcharge) {
result.put("message", "开启客户支付手续费成功!");
}else {
result.put("message", "关闭客户支付手续费成功!");
}
result.put("customerSurcharge", String.valueOf(customerSurcharge));
return result;
}
@Override
public void getCBBankAggregateFile(JSONObject device, HttpServletResponse httpResponse) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id"));
client.put("now", DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
String clientName = "";
clientName = client.getString("business_name");
if (StringUtils.isNotBlank(client.getString("acn"))) {
clientName += "(" + client.getString("acn") + ")";
client.put("client_acn", client.getString("acn"));
}
client.put("client_name", clientName);
client.put("bd_name", client.getString("bd_user_name"));
client.put("client_phone", client.getString("contact_phone"));
client.put("client_email", client.getString("contact_email"));
client.put("client_address", (client.getString("address") + "\n" + client.getString("suburb") + ' ' + client.getString("state") + ' ' + client.getString("postcode")));
JSONObject rate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay");
if (rate != null) {
client.put("client_rate", (rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%"));
int cleanDays = rate.getIntValue("clean_days");
client.put("clean_days", ("T+" + cleanDays));
client.put("days", cleanDays);
}
JSONObject bankAccount = clientManager.getBankAccountByClientId(client.getIntValue("client_id"));
if (bankAccount != null) {
client.put("bank_name", bankAccount.getString("bank"));
client.put("bank_country", bankAccount.getString("city"));
client.put("bank_account_number", bankAccount.getString("account_no"));
client.put("bank_account_name", bankAccount.getString("account_name"));
}
exportAggregateFile(client, httpResponse);
}
private void exportAggregateFile(JSONObject client, HttpServletResponse httpResponse) {
httpResponse.setContentType("application/pdf");
httpResponse.setHeader("content-disposition", "attachment;filename=" + client.getString("client_moniker") + "_AGREEMENT_" + new Date() + ".pdf");
ServletOutputStream sos = null;
try {
sos = httpResponse.getOutputStream();
PdfUtils pdu = new PdfUtils();
pdu.setTemplatePdfPath(CBBANK_AGGREGATE_FILE);
pdu.setPdfTemplate(client);
File file = new File(client.getString("client_moniker") + "_agreement.pdf");
ByteArrayOutputStream bos = pdu.templetPdfBos(file);
sos.write(bos.toByteArray());
sos.close();
} catch (Exception e) {
}
}
private void deleteAccountEmailKey(String codeKey){ private void deleteAccountEmailKey(String codeKey){
stringRedisTemplate.delete(getUpdateAccountEmailKey(codeKey)); stringRedisTemplate.delete(getUpdateAccountEmailKey(codeKey));
} }

@ -179,6 +179,11 @@ public class RetailAppController {
retailAppService.updateReadStatus(device, noticeId); retailAppService.updateReadStatus(device, noticeId);
} }
@RequestMapping(value = "/notice/{noticeId}/stopNotice", method = RequestMethod.PUT)
public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId) {
retailAppService.updateReadStatus(device, noticeId);
}
@RequestMapping(value = "/notice/{noticeId}", method = RequestMethod.GET) @RequestMapping(value = "/notice/{noticeId}", method = RequestMethod.GET)
public JSONObject getNoticeId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId) { public JSONObject getNoticeId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId) {
return retailAppService.getNoticeDetailById(device, noticeId); return retailAppService.getNoticeDetailById(device, noticeId);
@ -703,4 +708,20 @@ public class RetailAppController {
retailAppService.resetRefundPassword(device, json); retailAppService.resetRefundPassword(device, json);
} }
@RequestMapping(value = "/{notice_id}/toggleCBBankChannel", method = RequestMethod.PUT)
public JSONObject toggleCBBankChannel(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@PathVariable("notice_id") String noticeId) {
return retailAppService.toggleCBBankChannel(device,noticeId);
}
@RequestMapping(value = "/cbbank_pay/toggleCustomerSurcharge", method = RequestMethod.PUT)
public JSONObject toggleCBBankCustomerSurcharge(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestBody JSONObject customerSurcharge) {
return retailAppService.toggleCBBankCustomerSurcharge(device, customerSurcharge.getBooleanValue("customerSurcharge"));
}
@RequestMapping(value = "/cbbank_pay/aggregate_file", method = RequestMethod.GET)
public void getCBBankAggragateFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,HttpServletResponse httpResponse) {
retailAppService.getCBBankAggregateFile(device, httpResponse);
}
} }

@ -27,4 +27,6 @@ public interface NoticeManageMapper {
void updateNotice(JSONObject notice); void updateNotice(JSONObject notice);
JSONObject getLatestWindowNotice(@Param("client_id") int client_id,@Param("end_time")Date end_time); JSONObject getLatestWindowNotice(@Param("client_id") int client_id,@Param("end_time")Date end_time);
JSONObject getLatestWindowConfirmNotice(@Param("client_id") int client_id,@Param("end_time")Date end_time);
} }

@ -2,11 +2,16 @@ package au.com.royalpay.payment.manage.notice.beans;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by yishuqian on 28/09/2016. * Created by yishuqian on 28/09/2016.
@ -27,6 +32,12 @@ public class NoticeInfo {
private boolean is_app_window; private boolean is_app_window;
private int merchants_type=0; private int merchants_type=0;
private String notice_id; private String notice_id;
private String button0;
private String button1;
private String button2;
private String url;
private String aggregate_file;
private String type;
public JSONObject toJson() { public JSONObject toJson() {
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
@ -60,6 +71,39 @@ public class NoticeInfo {
if (notice_id != null){ if (notice_id != null){
res.put("notice_id",notice_id); res.put("notice_id",notice_id);
} }
List<JSONObject> 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; return res;
} }
public String getTitle() { public String getTitle() {
@ -154,4 +198,50 @@ public class NoticeInfo {
public void setDesc(String desc) { public void setDesc(String desc) {
this.desc = 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;
}
} }

@ -28,4 +28,6 @@ public interface NoticeManage {
JSONObject getLatestWindowNotice(int client_id); JSONObject getLatestWindowNotice(int client_id);
JSONObject getLatestWindowConfirmNotice(int client_id);
} }

@ -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.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -68,6 +69,18 @@ public class NoticeManageImpl implements NoticeManage {
@Override @Override
public JSONObject listNotices(NoticeQuery query) { public JSONObject listNotices(NoticeQuery query) {
PageList<JSONObject> notices = noticeManageMapper.listPageNotices(query.toParams(), new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); PageList<JSONObject> 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<JSONObject> 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); return PageListUtils.buildPageListResult(notices);
} }
@ -102,6 +115,7 @@ public class NoticeManageImpl implements NoticeManage {
@Override @Override
public JSONObject saveNotice(NoticeInfo noticeInfo, JSONObject manager) { public JSONObject saveNotice(NoticeInfo noticeInfo, JSONObject manager) {
Date date = new Date(); Date date = new Date();
List<JSONObject> buttons = new ArrayList<>();
JSONObject notice = noticeInfo.toJson(); JSONObject notice = noticeInfo.toJson();
notice.put("create_time", date); notice.put("create_time", date);
notice.put("create_id", manager.getString("manager_id")); 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)); notice.put("send_clients",sendClients.substring(0,sendClients.length()-1));
} }
} }
buttons = JSONObject.parseArray(notice.getString("buttons"),JSONObject.class);
notice.remove("buttons");
noticeManageMapper.createNotice(notice); 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; return notice;
} }
@Override @Override
public JSONObject getNoticeById(String noticeId) { public JSONObject getNoticeById(String noticeId) {
JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId); JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId);
if (notice.getIntValue("type") == 2) {
if (notice.get("buttons") != null) {
List<JSONObject> 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; return notice;
} }
@Override @Override
@Transactional @Transactional
public void updateNotice(JSONObject manager, String noticeId, NoticeInfo info) throws Exception { public void updateNotice(JSONObject manager, String noticeId, NoticeInfo info) throws Exception {
List<JSONObject> buttons = new ArrayList<>();
JSONObject noticeInfo = noticeManageMapper.getNoticeDetailById(noticeId); JSONObject noticeInfo = noticeManageMapper.getNoticeDetailById(noticeId);
Assert.notNull(noticeInfo); Assert.notNull(noticeInfo);
Date date = new Date(); 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); noticeManageMapper.updateNotice(notice);
if (info.getStatus() != null && info.getSend_clients() != null) { if (info.getStatus() != null && info.getSend_clients() != null) {
if (info.getStatus().equals("1") && noticeInfo.getString("status").equals("0") && !info.getSend_clients().isEmpty()) { 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()); return noticeManageMapper.getLatestWindowNotice(client_id,new Date());
} }
@Override
public JSONObject getLatestWindowConfirmNotice(int client_id) {
return noticeManageMapper.getLatestWindowConfirmNotice(client_id,new Date());
}
@Override @Override
public void toggleNoticeAppWindow(String noticeId, Boolean isAppWindow) { public void toggleNoticeAppWindow(String noticeId, Boolean isAppWindow) {
JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId); JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId);

@ -21,6 +21,19 @@
where c.client_id = #{client_id} and n.status = 1 where c.client_id = #{client_id} and n.status = 1
and end_time &gt; #{end_time} and end_time &gt; #{end_time}
and n.is_app_window = 1 and n.is_app_window = 1
and n.type = 1
order by n.send_time desc
limit 1
</select>
<select id="getLatestWindowConfirmNotice" resultType="com.alibaba.fastjson.JSONObject">
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 &gt; #{end_time}
and n.is_app_window = 1
and n.type = 2
order by n.send_time desc order by n.send_time desc
limit 1 limit 1
</select> </select>

@ -35,5 +35,8 @@
<if test="is_to_app!=null"> <if test="is_to_app!=null">
and n.is_to_app=#{is_to_app} and n.is_to_app=#{is_to_app}
</if> </if>
<if test="type!=null">
and n.type=#{type}
</if>
</select> </select>
</mapper> </mapper>

@ -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) { app.controller('addNoticeCtrl', ['$scope', '$http', '$filter', '$state', 'commonDialog', function ($scope, $http, $filter, $state, commonDialog) {
$scope.merchantTypes = angular.copy(merchantTypes); $scope.merchantTypes = angular.copy(merchantTypes);
$scope.saveNoticeResult = false; $scope.saveNoticeResult = false;
$scope.notice = {}; $scope.notice = {
type : '1',
button1:{
"method" : 'PUT'
},
button2:{
"method" : 'PUT'
},
button0:{
"method" : 'PUT'
}
};
$scope.today = new Date(); $scope.today = new Date();
$scope.save = function (form) { $scope.save = function (form) {
if (form.$invalid) { if (form.$invalid) {

@ -71,13 +71,274 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label col-sm-2" for="title-input">Notice Type</label>
<div class="col-sm-8">
<select ng-model="notice.type" class="form-control">
<option value="1">普通通知</option>
<option value="2">确认通知</option>
</select>
</div>
</div>
<div class="form-group" <div class="form-group"
ng-class="{'has-error':noticeForm.content.$invalid && noticeForm.content.$dirty}"> ng-class="{'has-error':noticeForm.content.$invalid && noticeForm.content.$dirty}" ng-if="notice.type=='1'">
<label class="control-label col-sm-2"></label> <label class="control-label col-sm-2"></label>
<div class="col-sm-8"> <div class="col-sm-8">
<ueditor ng-model="notice.content" ue-height="400"></ueditor> <ueditor ng-model="notice.content" ue-height="400"></ueditor>
</div> </div>
</div> </div>
<div class="form-group"
ng-class="{'has-error':noticeForm.content.$invalid && noticeForm.content.$dirty}" ng-if="notice.type=='2'">
<label class="control-label col-sm-2" for="title-input">Content</label>
<div class="col-sm-8">
<textarea class="form-control" ng-model="notice.content" type="text"
id="content-input" name="content" maxlength="400"/>
<div ng-messages="noticeForm.content.$error"
ng-if="noticeForm.content.$dirty">
<p class="small text-danger" ng-message="maxlength">Less Than 400
Characters(including symbols and spaces)</p>
</div>
</div>
</div>
<div ng-if="notice.type=='2'">
<div class="panel panel-warning" style="width: 25%;margin-left: 10%;display: inline-block" >
<div class="panel-heading">Button - 1</div>
<div class="panel-body">
<div class="form-horizontal">
<div class="form-group">
<div class="col-sm-3" style="display: inline-block">Button Name
</div>
<div class="col-sm-6">
<input class="form-control" ng-model="notice.button0.name" type="text"
id="button0-name-input" required name="button0-name" maxlength="10">
<div ng-messages="noticeForm.button0-name.$error"
ng-if="noticeForm.button0-name.$dirty">
<p class="small text-danger" ng-message="maxlength">Less Than 100
Characters(including symbols and spaces)</p>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-3" style="display: inline-block">Button Type
</div>
<div class="col-sm-6">
<select ng-model="notice.button0.type" class="form-control">
<option value=''>Please Choose</option>
<option value='1'>带确认的请求框</option>
<option value='2'>无需确认的请求框</option>
<option value='3'>关闭框</option>
</select>
</div>
</div>
<div class="form-group" ng-if="notice.button0.type ==1 || notice.button0.type ==2">
<div class="col-sm-3" style="display: inline-block">Button Method
</div>
<div class="col-sm-6">
<select ng-model="notice.button0.method" class="form-control">
<option value='GET'>GET</option>
<option value='PUT'>PUT</option>
<option value='POST'>POST</option>
</select>
</div>
</div>
<div class="form-group" ng-if="notice.button0.type ==1 || notice.button0.type ==2">
<div class="col-sm-3" style="display: inline-block">Button Link
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button0.link" type="text"
id="button0-link-input" name="button0-link"
style="font-size: 10px"
maxlength="200">
</div>
</div>
<div class="form-group" ng-if="notice.button0.type ==1">
<div class="col-sm-3" style="display: inline-block">Confirm Title
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button0.confirm_info.title" type="text"
id="button0-confirm_info-title-input" required name="button0-confirm_info-title"
style="font-size: 10px"
maxlength="50">
</div>
</div>
<div class="form-group" ng-if="notice.button0.type == 1">
<div class="col-sm-3" style="display: inline-block">Confirm Content
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button0.confirm_info.content" type="text"
id="button0-confirm_info-content-input" required name="button0-confirm_info-content"
style="font-size: 10px"
maxlength="50">
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-warning" style="width: 25%;margin-left: 2%;display: inline-block" >
<div class="panel-heading">Button - 2</div>
<div class="panel-body">
<div class="form-horizontal">
<div class="form-group">
<div class="col-sm-3" style="display: inline-block">Button Name
</div>
<div class="col-sm-6">
<input class="form-control" ng-model="notice.button1.name" type="text"
id="button1-name-input" name="button1-name" maxlength="10">
</div>
</div>
<div class="form-group">
<div class="col-sm-3" style="display: inline-block">Button Type
</div>
<div class="col-sm-6">
<select ng-model="notice.button1.type" class="form-control">
<option value=''>Please Choose</option>
<option value='1'>带确认的请求框</option>
<option value='2'>无需确认的请求框</option>
<option value='3'>关闭框</option>
</select>
</div>
</div>
<div class="form-group" ng-if="notice.button1.type ==1 || notice.button1.type ==2">
<div class="col-sm-3" style="display: inline-block">Button Method
</div>
<div class="col-sm-6">
<select ng-model="notice.button1.method" class="form-control">
<option value='GET'>GET</option>
<option value='PUT'>PUT</option>
<option value='POST'>POST</option>
</select>
</div>
</div>
<div class="form-group" ng-if="notice.button1.type ==1 || notice.button1.type ==2">
<div class="col-sm-3" style="display: inline-block">Button Link
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button1.link" type="text"
id="button1-link-input" required name="button1-link"
style="font-size: 10px"
maxlength="200">
<div ng-messages="noticeForm.button1-link.$error"
ng-if="noticeForm.button1-name.$dirty">
<p class="small text-danger" ng-message="maxlength">Less Than 100
Characters(including symbols and spaces)</p>
</div>
</div>
</div>
<div class="form-group" ng-if="notice.button1.type ==1">
<div class="col-sm-3" style="display: inline-block">Confirm Title
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button1.confirm_info.title" type="text"
id="button1-confirm_info-title-input" required name="button1-confirm_info-title"
style="font-size: 10px"
maxlength="50">
</div>
</div>
<div class="form-group" ng-if="notice.button1.type ==1">
<div class="col-sm-3" style="display: inline-block">Confirm Content
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button1.confirm_info.content" type="text"
id="button1-confirm_info-content-input" required name="button1-confirm_info-content"
style="font-size: 10px"
maxlength="50">
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-warning" style="width: 25%;margin-left: 2%;display: inline-block" >
<div class="panel-heading">Button - 3</div>
<div class="panel-body">
<div class="form-horizontal">
<div class="form-group">
<div class="col-sm-3" style="display: inline-block">Button Name
</div>
<div class="col-sm-6">
<input class="form-control" ng-model="notice.button2.name" type="text"
id="button2-name-input" name="button2-name" maxlength="10">
</div>
</div>
<div class="form-group">
<div class="col-sm-3" style="display: inline-block">Button Type
</div>
<div class="col-sm-6">
<select ng-model="notice.button2.type" class="form-control">
<option value=''>Please Choose</option>
<option value='1'>带确认的请求框</option>
<option value='2'>无需确认的请求框</option>
<option value='3'>关闭框</option>
</select>
</div>
</div>
<div class="form-group" ng-if="notice.button2.type ==1 || notice.button2.type ==2">
<div class="col-sm-3" style="display: inline-block">Button Method
</div>
<div class="col-sm-6">
<select ng-model="notice.button2.method" class="form-control">
<option value='GET'>GET</option>
<option value='PUT'>PUT</option>
<option value='POST'>POST</option>
</select>
</div>
</div>
<div class="form-group" ng-if="notice.button2.type ==1 || notice.button2.type ==2">
<div class="col-sm-3" style="display: inline-block">Button Link
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button2.link" type="text"
id="button2-link-input" required name="button2-link"
style="font-size: 10px"
maxlength="200">
<div ng-messages="noticeForm.button2-link.$error"
ng-if="noticeForm.button2-name.$dirty">
<p class="small text-danger" ng-message="maxlength">Less Than 100
Characters(including symbols and spaces)</p>
</div>
</div>
</div>
<div class="form-group" ng-if="notice.button2.type ==1">
<div class="col-sm-3" style="display: inline-block">Confirm Title
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button2.confirm_info.title" type="text"
id="button2-confirm_info-title-input" required name="button2-confirm_info-title"
style="font-size: 10px"
maxlength="50">
</div>
</div>
<div class="form-group" ng-if="notice.button2.type ==1">
<div class="col-sm-3" style="display: inline-block">Confirm Content
</div>
<div class="col-sm-9">
<input class="form-control" ng-model="notice.button2.confirm_info.content" type="text"
id="button2-confirm_info-content-input" required name="button2-confirm_info-content"
style="font-size: 10px"
maxlength="50">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group" ng-if="notice.type=='2'">
<label class="control-label col-sm-2" for="title-input">了解更多 URL</label>
<div class="col-sm-8">
<input class="form-control" ng-model="notice.url" type="text"
id="url-input" name="url" maxlength="100">
</div>
</div>
<div class="form-group" ng-if="notice.type=='2'">
<label class="control-label col-sm-2" for="title-input">合同文件获取Link</label>
<div class="col-sm-8">
<input class="form-control" ng-model="notice.aggregate_file" type="text"
id="aggregate_file-input" name="aggregate_file" maxlength="100">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="endtime-input">* Expiry Date</label> <label class="control-label col-sm-2" for="endtime-input">* Expiry Date</label>
<div class="col-sm-2" style="display: inline-block"> <div class="col-sm-2" style="display: inline-block">

@ -47,6 +47,13 @@
<p class="form-control-static" ng-bind="notice.send_time|limitTo:10"></p> <p class="form-control-static" ng-bind="notice.send_time|limitTo:10"></p>
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label col-sm-2">Notice Type</label>
<div class="col-sm-10">
<p class="form-control-static" ng-if="notice.type=='1'">普通通知</p>
<p class="form-control-static" ng-if="notice.type=='2'">确认通知</p>
</div>
</div>
<div class="form-group" ng-if="notice.end_time"> <div class="form-group" ng-if="notice.end_time">
<label class="control-label col-sm-2">Expiry Date</label> <label class="control-label col-sm-2">Expiry Date</label>
<div class="col-sm-10"> <div class="col-sm-10">

Loading…
Cancel
Save