Merge branch 'notice' into develop

# Conflicts:
#	src/db/modify.sql
#	src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
master
eason.qian 7 years ago
commit 9bafbc56c2

@ -281,6 +281,12 @@ CREATE TABLE `act_app_list` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='app活动' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='app活动'
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弹框';
ALTER TABLE sys_notice MODIFY end_time DATE NOT NULL COMMENT '截止日期';
ALTER TABLE sys_notice ADD `desc` VARCHAR(1000) NULL COMMENT '简介';

@ -55,6 +55,8 @@ public interface RetailAppService {
JSONObject getNoticeDetailById(JSONObject device, String noticeId); JSONObject getNoticeDetailById(JSONObject device, String noticeId);
List<JSONObject> getLatestNotice(int client_id);
void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id); void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id);
JSONObject bankAccountInfo(JSONObject device); JSONObject bankAccountInfo(JSONObject device);

@ -12,6 +12,7 @@ import au.com.royalpay.payment.manage.fund.core.impls.XPlanFundConfigServiceImpl
import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper; import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper;
import au.com.royalpay.payment.manage.mappers.notice.NoticePartnerMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
@ -140,6 +141,8 @@ public class RetailAppServiceImp implements RetailAppService {
private ClientContractService clientContractService; private ClientContractService clientContractService;
@Resource @Resource
private SysConfigManager sysConfigManager; private SysConfigManager sysConfigManager;
@Resource
private NoticePartnerMapper noticePartnerMapper;
private Map<String, AppMsgSender> senderMap = new HashMap<>(); private Map<String, AppMsgSender> senderMap = new HashMap<>();
@ -869,6 +872,28 @@ public class RetailAppServiceImp implements RetailAppService {
return res; return res;
} }
@Override
public List<JSONObject> getLatestNotice(int client_id) {
JSONObject notice = new JSONObject();
JSONObject lastNotice = noticeManage.getLatestWindowNotice(client_id);
if(lastNotice!=null){
lastNotice.put("id",lastNotice.getString("notice_id"));
lastNotice.remove("notice_id");
}
notice.put("data",lastNotice);
JSONObject unReadParams = new JSONObject();
unReadParams.put("client_id",client_id);
unReadParams.put("status",0);
int counts = noticePartnerMapper.countNoticePartner(unReadParams);
notice.put("unReadCounts",counts);
notice.put("type","notice");
List<JSONObject> result = new ArrayList<>();
result.add(notice);
return result;
}
@Override @Override
public void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id) { public void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id) {
String clientType = device.getString("client_type"); String clientType = device.getString("client_type");
@ -1345,6 +1370,7 @@ public class RetailAppServiceImp implements RetailAppService {
public JSONObject getCheckClientInfo(JSONObject device) { public JSONObject getCheckClientInfo(JSONObject device) {
return clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id")); return clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id"));
} }
private static boolean mathchLetterorNum(String str) { private static boolean mathchLetterorNum(String str) {
String regex = "[A-Za-z0-9]{8}"; String regex = "[A-Za-z0-9]{8}";
return str.matches(regex); return str.matches(regex);

@ -115,9 +115,9 @@ public class RetailAppController {
return retailAppService.getClientSettlementLog(device, appQueryBean); return retailAppService.getClientSettlementLog(device, appQueryBean);
} }
@RequestMapping("/transaction_log/{clearing_detail_id}") @RequestMapping("/transaction_log/{clearing_detail_id}")
public JSONObject getTransactionLogByClearingDetailId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable int clearing_detail_id, @RequestParam(required = false) String timezone) { public JSONObject getTransactionLogByClearingDetailId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable int clearing_detail_id,
@RequestParam(required = false) String timezone) {
return retailAppService.getTransactionLogsByClearingDetailId(device, clearing_detail_id, timezone); return retailAppService.getTransactionLogsByClearingDetailId(device, clearing_detail_id, timezone);
} }
@ -128,7 +128,8 @@ public class RetailAppController {
} }
@RequestMapping(value = "/notice/{noticeId}", method = RequestMethod.PUT) @RequestMapping(value = "/notice/{noticeId}", method = RequestMethod.PUT)
public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId, @RequestBody JSONObject account_param) { public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId,
@RequestBody JSONObject account_param) {
if (!device.getString("account_id").equals(account_param.getString("account_id"))) { if (!device.getString("account_id").equals(account_param.getString("account_id"))) {
throw new ForbiddenException("You have no permission"); throw new ForbiddenException("You have no permission");
} }
@ -141,10 +142,10 @@ public class RetailAppController {
} }
/* 消息模块end */ /* 消息模块end */
/* 我的页面begin */ /* 我的页面begin */
@RequestMapping(value = "/partner_password/{account_id}", method = RequestMethod.PUT) @RequestMapping(value = "/partner_password/{account_id}", method = RequestMethod.PUT)
public void changePassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String account_id, @RequestBody @Valid ChangePwdBean change, Errors errors) { public void changePassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String account_id,
@RequestBody @Valid ChangePwdBean change, Errors errors) {
HttpUtils.handleValidErrors(errors); HttpUtils.handleValidErrors(errors);
retailAppService.changeAccountPassword(device, change, account_id); retailAppService.changeAccountPassword(device, change, account_id);
} }
@ -205,16 +206,19 @@ public class RetailAppController {
return retailAppService.getClientInfo(device); return retailAppService.getClientInfo(device);
} }
@RequestMapping(value = "/client/check", method = RequestMethod.GET)
public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.getCheckClientInfo(device);
}
@RequestMapping(value = "/client", method = RequestMethod.PUT) @RequestMapping(value = "/client", method = RequestMethod.PUT)
public void updateClient(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody AppClientBean appClientBean) { public void updateClient(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody AppClientBean appClientBean) {
retailAppService.updateClient(device, appClientBean); retailAppService.updateClient(device, appClientBean);
} }
@RequestMapping(value = "/daily_transactions/date/{dateStr}", method = RequestMethod.GET) @RequestMapping(value = "/daily_transactions/date/{dateStr}", method = RequestMethod.GET)
public JSONObject listDailyTransactions(@PathVariable String dateStr, @RequestParam(defaultValue = "Australia/Melbourne") String timezone, public JSONObject listDailyTransactions(@PathVariable String dateStr, @RequestParam(defaultValue = "Australia/Melbourne") String timezone,
@RequestParam(defaultValue = "false") boolean thisdevice, @RequestParam(defaultValue = "false") boolean thisdevice, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.listDailyTransactions(dateStr, timezone, thisdevice, device); return retailAppService.listDailyTransactions(dateStr, timezone, thisdevice, device);
} }
@ -264,7 +268,8 @@ public class RetailAppController {
} }
@RequestMapping(value = "/cash_back/clean_info", method = RequestMethod.GET) @RequestMapping(value = "/cash_back/clean_info", method = RequestMethod.GET)
public JSONObject getCashbackCleanInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "client_id", required = false) String client_id) { public JSONObject getCashbackCleanInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,
@RequestParam(value = "client_id", required = false) String client_id) {
if (client_id == null) { if (client_id == null) {
client_id = device.getString("client_id"); client_id = device.getString("client_id");
} }
@ -276,11 +281,11 @@ public class RetailAppController {
signInStatusManager.clientQRCodeAppSignIn(device, codeId); signInStatusManager.clientQRCodeAppSignIn(device, codeId);
} }
/* 优惠券Begin */ /* 优惠券Begin */
@RequestMapping(value = "/coupon/used", method = RequestMethod.GET) @RequestMapping(value = "/coupon/used", method = RequestMethod.GET)
public JSONObject getCoupons(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int limit) { public JSONObject getCoupons(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "limit", defaultValue = "10") int limit) {
return retailAppService.getCoupons(device, page, limit); return retailAppService.getCoupons(device, page, limit);
} }
@ -295,7 +300,6 @@ public class RetailAppController {
} }
/* 优惠券End */ /* 优惠券End */
/** /**
* 广 * 广
*/ */
@ -309,28 +313,31 @@ public class RetailAppController {
return retailAppService.getAdDetail(device, article_id); return retailAppService.getAdDetail(device, article_id);
} }
@RequestMapping(value = "/bills/{bill_id}", method = RequestMethod.GET) @RequestMapping(value = "/bills/{bill_id}", method = RequestMethod.GET)
public JSONObject getBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { public JSONObject getBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return billService.getBillDetail(bill_id, device.getIntValue("client_id")); return billService.getBillDetail(bill_id, device.getIntValue("client_id"));
} }
@RequestMapping(value = "/bills/list", method = RequestMethod.GET) @RequestMapping(value = "/bills/list", method = RequestMethod.GET)
public JSONObject getBills(QueryBillBean queryBillBean, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { public JSONObject getBills(QueryBillBean queryBillBean, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return billService.queryBills(device.getIntValue("client_id"), queryBillBean); return billService.queryBills(device.getIntValue("client_id"), queryBillBean);
} }
@RequestMapping(value = "/bills", method = RequestMethod.PUT) @RequestMapping(value = "/bills", method = RequestMethod.PUT)
public JSONObject addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody NewBillBean newBillBean) { public JSONObject addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody NewBillBean newBillBean) {
JSONObject result = billService.save(device.getIntValue("client_id"), newBillBean); JSONObject result = billService.save(device.getIntValue("client_id"), newBillBean);
result.remove("bill"); result.remove("bill");
return result; return result;
} }
@RequestMapping(value = "/bills/{bill_id}/close", method = RequestMethod.POST) @RequestMapping(value = "/bills/{bill_id}/close", method = RequestMethod.POST)
public void closeBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { public void closeBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
billService.updateBillStatus(bill_id, "2", device.getIntValue("client_id")); billService.updateBillStatus(bill_id, "2", device.getIntValue("client_id"));
} }
@RequestMapping(value = "/bills/orders/{bill_id}", method = RequestMethod.GET) @RequestMapping(value = "/bills/orders/{bill_id}", method = RequestMethod.GET)
public JSONObject getBillOrders(@PathVariable("bill_id")String bill_id, QueryBillOrderBean queryBillOrderBean,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ public JSONObject getBillOrders(@PathVariable("bill_id") String bill_id, QueryBillOrderBean queryBillOrderBean,
@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
JSONObject result = billOrderService.query(bill_id, device.getIntValue("client_id"), queryBillOrderBean); JSONObject result = billOrderService.query(bill_id, device.getIntValue("client_id"), queryBillOrderBean);
result.put("analysis", billOrderService.analysis(bill_id, device.getIntValue("client_id"), queryBillOrderBean)); result.put("analysis", billOrderService.analysis(bill_id, device.getIntValue("client_id"), queryBillOrderBean));
return result; return result;

@ -1,12 +1,17 @@
package au.com.royalpay.payment.manage.mappers.notice; package au.com.royalpay.payment.manage.mappers.notice;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import java.util.Date;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
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 cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/** /**
* Created by yishuqian on 10/10/2016. * Created by yishuqian on 10/10/2016.
*/ */
@ -20,4 +25,6 @@ public interface NoticeManageMapper {
void createNotice(JSONObject notice); void createNotice(JSONObject notice);
@AutoSql(type = SqlType.UPDATE) @AutoSql(type = SqlType.UPDATE)
void updateNotice(JSONObject notice); void updateNotice(JSONObject notice);
JSONObject getLatestWindowNotice(@Param("client_id") int client_id,@Param("end_time")Date end_time);
} }

@ -16,6 +16,7 @@ public class NoticeInfo {
private final DateFormat format = new SimpleDateFormat("yyyyMMdd"); private final DateFormat format = new SimpleDateFormat("yyyyMMdd");
@NotNull @NotNull
private String title; private String title;
private String desc;
private String end_time; private String end_time;
private String content; private String content;
private String status; private String status;
@ -23,6 +24,8 @@ public class NoticeInfo {
private boolean is_tomail; private boolean is_tomail;
private boolean is_tomail_cc_stockholder; private boolean is_tomail_cc_stockholder;
private boolean is_to_app; private boolean is_to_app;
private boolean is_app_window;
private int merchants_type=0;
private String notice_id; private String notice_id;
public JSONObject toJson() { public JSONObject toJson() {
@ -35,6 +38,10 @@ public class NoticeInfo {
} }
} }
res.put("title",title); res.put("title",title);
if (desc != null){
res.put("desc",desc);
}
res.put("merchants_type",merchants_type);
if (content != null){ if (content != null){
res.put("content",content); res.put("content",content);
} }
@ -47,6 +54,9 @@ public class NoticeInfo {
res.put("is_tomail",is_tomail); res.put("is_tomail",is_tomail);
res.put("is_tomail_cc_stockholder",is_tomail_cc_stockholder); res.put("is_tomail_cc_stockholder",is_tomail_cc_stockholder);
res.put("is_to_app",is_to_app); res.put("is_to_app",is_to_app);
if (is_app_window){
res.put("is_app_window",is_app_window);
}
if (notice_id != null){ if (notice_id != null){
res.put("notice_id",notice_id); res.put("notice_id",notice_id);
} }
@ -120,4 +130,28 @@ public class NoticeInfo {
public void setNotice_id(String notice_id) { public void setNotice_id(String notice_id) {
this.notice_id = notice_id; this.notice_id = notice_id;
} }
public boolean isIs_app_window() {
return is_app_window;
}
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;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
} }

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.notice.core;
import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
import au.com.royalpay.payment.manage.notice.beans.NoticeQuery; import au.com.royalpay.payment.manage.notice.beans.NoticeQuery;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.transaction.annotation.Transactional;
/** /**
* Created by yishuqian on 28/09/2016. * Created by yishuqian on 28/09/2016.
@ -12,6 +13,9 @@ public interface NoticeManage {
JSONObject addNotice(NoticeInfo noticeInfo, JSONObject manager); JSONObject addNotice(NoticeInfo noticeInfo, JSONObject manager);
@Transactional
JSONObject saveNotice(NoticeInfo noticeInfo, JSONObject manager);
JSONObject getNoticeById(String noticeId); JSONObject getNoticeById(String noticeId);
void updateNotice(JSONObject manager, String noticeId, NoticeInfo info) throws Exception; void updateNotice(JSONObject manager, String noticeId, NoticeInfo info) throws Exception;
@ -20,4 +24,8 @@ public interface NoticeManage {
JSONObject listNoticeReadClients(String noticeId, int page, int limit); JSONObject listNoticeReadClients(String noticeId, int page, int limit);
void toggleNoticeAppWindow(String noticeId, Boolean isAppWindow);
JSONObject getLatestWindowNotice(int client_id);
} }

@ -1,25 +1,5 @@
package au.com.royalpay.payment.manage.notice.core.impls; package au.com.royalpay.payment.manage.notice.core.impls;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import com.alibaba.fastjson.JSONObject;
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 au.com.royalpay.payment.manage.appclient.core.RetailAppService; import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
import au.com.royalpay.payment.manage.mappers.log.NotifyErrorLogMapper; import au.com.royalpay.payment.manage.mappers.log.NotifyErrorLogMapper;
import au.com.royalpay.payment.manage.mappers.notice.NoticeManageMapper; import au.com.royalpay.payment.manage.mappers.notice.NoticeManageMapper;
@ -30,8 +10,29 @@ import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
import au.com.royalpay.payment.manage.notice.beans.NoticeQuery; import au.com.royalpay.payment.manage.notice.beans.NoticeQuery;
import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.notice.core.NoticeManage; import au.com.royalpay.payment.manage.notice.core.NoticeManage;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
/** /**
* Created by yishuqian on 28/09/2016. * Created by yishuqian on 28/09/2016.
*/ */
@ -91,6 +92,31 @@ public class NoticeManageImpl implements NoticeManage {
return notice; return notice;
} }
@Transactional
@Override
public JSONObject saveNotice(NoticeInfo noticeInfo, JSONObject manager) {
Date date = new Date();
JSONObject notice = noticeInfo.toJson();
notice.put("create_time", date);
notice.put("create_id", manager.getString("manager_id"));
notice.put("create_name", manager.getString("display_name"));
if (!notice.getBoolean("merchants_type")){
String sendClients = "";
List<JSONObject> 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;
}
@Override @Override
public JSONObject getNoticeById(String noticeId) { public JSONObject getNoticeById(String noticeId) {
JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId); JSONObject notice = noticeManageMapper.getNoticeDetailById(noticeId);
@ -110,6 +136,21 @@ public class NoticeManageImpl implements NoticeManage {
notice.put("send_id", manager.getString("manager_id")); notice.put("send_id", manager.getString("manager_id"));
notice.put("send_name", manager.getString("display_name")); notice.put("send_name", manager.getString("display_name"));
} }
if (!notice.getBoolean("merchants_type")){
StringBuilder sendClients = new StringBuilder();
List<JSONObject> clients = clientMapper.listValidClient();
clients.forEach(c -> {
if (c.getInteger("parent_client_id")==null || c.getInteger("parent_client_id")!=9){
String p = c.getString("client_moniker")+",";
sendClients.append(p);
}
});
if (sendClients.length()>0){
notice.put("send_clients",sendClients.substring(0,sendClients.length()-1));
}
}
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()) {
@ -178,6 +219,19 @@ public class NoticeManageImpl implements NoticeManage {
return PageListUtils.buildPageListResult(clients); return PageListUtils.buildPageListResult(clients);
} }
@Override
public JSONObject getLatestWindowNotice(int client_id) {
return noticeManageMapper.getLatestWindowNotice(client_id,new Date());
}
@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);
}
} }

@ -34,7 +34,7 @@ public class NoticeManageController {
public JSONObject addNotice(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody @Valid NoticeInfo noticeInfo, public JSONObject addNotice(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody @Valid NoticeInfo noticeInfo,
Errors errors) { Errors errors) {
HttpUtils.handleValidErrors(errors); HttpUtils.handleValidErrors(errors);
return noticeManage.addNotice(noticeInfo, manager); return noticeManage.saveNotice(noticeInfo, manager);
} }
@ManagerMapping(value = "/{noticeId}", method = RequestMethod.GET) @ManagerMapping(value = "/{noticeId}", method = RequestMethod.GET)
public JSONObject getNoticeById(@PathVariable String noticeId) { public JSONObject getNoticeById(@PathVariable String noticeId) {
@ -52,6 +52,12 @@ public class NoticeManageController {
return noticeManage.listNoticeReadClients(noticeId,page,limit); 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}) @ManagerMapping(value = "/{noticeId}/clients", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
public int listNoticeClients(@PathVariable String noticeId){ public int listNoticeClients(@PathVariable String noticeId){
return noticeManage.listNoticeClients(noticeId); return noticeManage.listNoticeClients(noticeId);

@ -14,5 +14,14 @@
</where> </where>
</select> </select>
<select id="getLatestWindowNotice" resultType="com.alibaba.fastjson.JSONObject">
select n.title,n.`desc`,n.notice_id
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
order by n.send_time desc
limit 1
</select>
</mapper> </mapper>

@ -7,7 +7,7 @@
WHERE client_id = #{client_id} WHERE client_id = #{client_id}
</update> </update>
<select id="listValidClient" resultType="com.alibaba.fastjson.JSONObject"> <select id="listValidClient" resultType="com.alibaba.fastjson.JSONObject">
SELECT c.client_id FROM sys_clients c SELECT c.client_id,c.client_moniker,c.parent_client_id FROM sys_clients c
WHERE is_valid=1 and (approve_result = 1 or approve_result = 2) WHERE is_valid=1 and (approve_result = 1 or approve_result = 2)
</select> </select>
<select id="listGreenChannel" resultType="com.alibaba.fastjson.JSONObject"> <select id="listGreenChannel" resultType="com.alibaba.fastjson.JSONObject">

@ -4,6 +4,16 @@
define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', 'uiBootstrap', 'uiRouter', 'ngBootSwitch', 'ngFileUpload'], function (angular) { define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', 'uiBootstrap', 'uiRouter', 'ngBootSwitch', 'ngFileUpload'], function (angular) {
'use strict'; 'use strict';
var merchantTypes = [
{
"label": "All",
"value": 0
},
{
"label": "Custom",
"value": 1
}];
var app = angular.module('noticeApp', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ngFileUpload', 'ng.uditor']); var app = angular.module('noticeApp', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ngFileUpload', 'ng.uditor']);
app.config(['$stateProvider', function ($stateProvider) { app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('notice', { $stateProvider.state('notice', {
@ -77,6 +87,7 @@ 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.saveNoticeResult = false; $scope.saveNoticeResult = false;
$scope.notice = {}; $scope.notice = {};
$scope.today = new Date(); $scope.today = new Date();
@ -92,11 +103,10 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
var notice = angular.copy($scope.notice); var notice = angular.copy($scope.notice);
if (notice.end_time) { if (notice.end_time) {
notice.end_time = $filter('date')(notice.end_time, 'yyyyMMdd') notice.end_time = $filter('date')(notice.end_time, 'yyyyMMdd')
} else { }
if (notice.status == '1') { if (notice.merchants_type == 1) {
commonDialog.alert({title: 'Error', content: 'Expiry Date can not be null', type: 'error'}); if (notice.send_clients.length == 0) {
$scope.notice.status = '0'; commonDialog.alert({title: 'Error', content: 'Send Clients is null', type: 'error'});
return;
} }
} }
$scope.saveNoticeResult = true; $scope.saveNoticeResult = true;
@ -112,6 +122,8 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
}; };
}]); }]);
app.controller('noticeDetailCtrl', ['$scope', '$http', '$state', '$uibModal', 'commonDialog', 'notice', function ($scope, $http, $state, $uibModal, commonDialog, notice) { app.controller('noticeDetailCtrl', ['$scope', '$http', '$state', '$uibModal', 'commonDialog', 'notice', function ($scope, $http, $state, $uibModal, commonDialog, notice) {
$scope.init = {};
$scope.notice = notice.data; $scope.notice = notice.data;
$scope.pagination = {}; $scope.pagination = {};
$scope.params = {}; $scope.params = {};
@ -128,17 +140,70 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
$scope.clients = resp.data.data; $scope.clients = resp.data.data;
$scope.pagination = resp.data.pagination; $scope.pagination = resp.data.pagination;
}); });
} };
if ($scope.notice.status == '1') { if ($scope.notice.status == '1') {
$scope.listClients(); $scope.listClients();
$scope.totalClients(); $scope.totalClients();
} }
$scope.toggleAppWindow = function () {
if (!$scope.init.is_app_window) {
$scope.init.is_app_window = true;
return;
}
$http.put('/sys/notice/' + $scope.notice.notice_id + '/app_window', {is_app_window: $scope.notice.is_app_window}).then(function () {
commonDialog.alert({
title: 'Success',
content: "修改成功",
type: 'success'
})
}, function (resp) {
commonDialog.alert({
title: 'failed to change App Window status',
content: resp.data.message,
type: 'error'
});
})
};
$scope.sendNotice = function () {
$uibModal.open({
templateUrl: '/static/config/notice/templates/send_notice_dialog.html',
controller: 'sendNoticeCtrl',
resolve: {
notice: function () {
return $scope.notice;
}
}
}).result.then(function () {
commonDialog.alert({title: '操作成功', content: '您成功修改了密码', type: 'success'})
})
};
}]); }]);
app.controller('sendNoticeCtrl', ['$scope', '$http', '$state', 'commonDialog', 'notice', function ($scope, $http, $state, commonDialog, notice) {
$scope.notice = angular.copy(notice);
$scope.submit = function (form) {
$scope.errmsg = null;
$scope.saveNoticeResult = true;
$scope.notice.status = 1;
$http.put('/sys/notice/' + $scope.notice.notice_id, $scope.notice).then(function (resp) {
$scope.saveNoticeResult = false;
commonDialog.alert({title: 'Success', content: 'Send a notice successfully', type: 'success'});
$scope.$close();
$state.go('notice.detail', {notice_id: $scope.notice.notice_id})
}, function (resp) {
$scope.saveNoticeResult = false;
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
});
}
}]);
app.controller('noticeEditCtrl', ['$scope', '$http', '$filter', '$timeout', '$state', '$uibModal', 'commonDialog', 'notice', app.controller('noticeEditCtrl', ['$scope', '$http', '$filter', '$timeout', '$state', '$uibModal', 'commonDialog', 'notice',
function ($scope, $http, $filter, $timeout, $state, $uibModal, commonDialog, notice) { function ($scope, $http, $filter, $timeout, $state, $uibModal, commonDialog, notice) {
$scope.merchantTypes = angular.copy(merchantTypes);
$scope.saveNoticeResult = false; $scope.saveNoticeResult = false;
$scope.notice = notice.data; $scope.notice = notice.data;
$scope.notice.merchants_type = $scope.notice.merchants_type ? 1 : 0;
if (notice.data.end_time != null) { if (notice.data.end_time != null) {
$scope.notice.end_time = new Date(notice.data.end_time); $scope.notice.end_time = new Date(notice.data.end_time);
} }

@ -58,48 +58,65 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"
ng-class="{'has-error':noticeForm.intro.$invalid && noticeForm.intro.$dirty}">
<label class="control-label col-sm-2" for="title-input">Intro</label>
<div class="col-sm-8">
<textarea class="form-control" ng-model="notice.desc" type="text"
id="intro-input" name="intro" maxlength="400"/>
<div ng-messages="noticeForm.intro.$error"
ng-if="noticeForm.intro.$dirty">
<p class="small text-danger" ng-message="maxlength">Less Than 400
Characters(including symbols and spaces)</p>
</div>
</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}">
<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>
<!--<textarea class="form-control" required ng-model="notice.content"-->
<!--name="content" id="desc-input"></textarea>-->
<!--<div ng-messages="noticeForm.content.$error"-->
<!--ng-if="noticeForm.content.$dirty">-->
<!--<p class="small text-danger" ng-message="required">Required Field</p>-->
<!--</div>-->
</div> </div>
</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">
<input class="form-control" id="endtime-input" <input class="form-control" id="endtime-input" required
ng-model="notice.end_time" ng-model="notice.end_time"
uib-datepicker-popup size="10" placeholder="Expiry Date" uib-datepicker-popup size="10" placeholder="Expiry Date"
is-open="dateEnd.open" ng-click="dateEnd.open=true" is-open="dateEnd.open" ng-click="dateEnd.open=true"
datepicker-options="{minDate:today}"> datepicker-options="{minDate:today}">
</div> </div>
<div ng-if="notice.notice_id" class="col-sm-2" style="display: inline-block"> <!--<div ng-if="notice.notice_id" class="col-sm-2" style="display: inline-block">-->
<input type="checkbox" <!--<input type="checkbox"-->
ng-model="notice.is_tomail"> Send Emails <!--ng-model="notice.is_tomail"> Send Emails-->
</div> <!--</div>-->
<div ng-if="notice.notice_id && notice.is_tomail" class="col-sm-2" style="display: inline-block"> <!--<div ng-if="notice.notice_id && notice.is_tomail" class="col-sm-2" style="display: inline-block">-->
<input type="checkbox" <!--<input type="checkbox"-->
ng-model="notice.is_tomail_cc_stockholder"> CC to stockholders <!--ng-model="notice.is_tomail_cc_stockholder"> CC to stockholders-->
</div> <!--</div>-->
<div ng-if="notice.notice_id" class="col-sm-2" style="display: inline-block"> <!--<div ng-if="notice.notice_id" class="col-sm-2" style="display: inline-block">-->
<input type="checkbox" <!--<input type="checkbox"-->
ng-model="notice.is_to_app"> Send App <!--ng-model="notice.is_to_app"> Send App-->
</div> <!--</div>-->
</div> </div>
<div class="form-group" ng-if="notice.notice_id && notice.is_tomail||notice.notice_id && notice.is_to_app"> <div class="form-group">
<label class="control-label col-sm-2" for="clients-input">Send Partners</label> <label class="control-label col-sm-2" for="merchants-type">Merchants</label>
<div class="col-sm-8" style="display: inline-block" ng-if="notice.status=='0'|| notice.status==null"> <div class="col-sm-2" style="display: inline-block" ng-if="notice.status=='0'|| notice.status==null">
<textarea class="form-control col-sm-10" ng-model="notice.send_clients" <!--<select class="form-control" ng-model="notice.merchants_type" id="merchants-type">-->
name="clients" id="clients-input"></textarea> <!--<option value="0">ALL</option>-->
<a class="btn btn-success" role="button" ng-click="selectClients(notice)"><i <!--<option value="1">Custom</option>-->
class="fa fa-search"></i></a> <!--</select>-->
<select class="form-control" name="merchants_type" required ng-model="notice.merchants_type"
id="merchants-type"
ng-options="state.value as state.label for state in merchantTypes">
<option value="">Please Choose</option>
</select>
</div>
<div class="col-sm-6" style="display: inline-block" ng-if="(notice.status=='0'|| notice.status==null) && notice.merchants_type==1">
<textarea class="form-control" ng-model="notice.send_clients" type="text"
id="send-clients-input" name="send_clients"/>
<p class="small text-danger" ng-if="notice.merchants_type==1">以PartnerCode1,PartnerCode2..的形式填写</p>
</div> </div>
<div class="col-sm-8" ng-if="notice.status=='1'"> <div class="col-sm-8" ng-if="notice.status=='1'">
<p class="form-control-static" ng-bind="notice.send_clients"></p> <p class="form-control-static" ng-bind="notice.send_clients"></p>
@ -110,9 +127,9 @@
</div> </div>
<div class="btn-group margin-bottom margin-top"> <div class="btn-group margin-bottom margin-top">
<button class="btn btn-success" type="button" ng-click="save(noticeForm)">Save</button> <button class="btn btn-success" type="button" ng-click="save(noticeForm)">Save</button>
<button ng-if="notice.status=='0'|| notice.status==null" class="btn btn-danger" type="button" <!--<button ng-if="notice.status=='0'|| notice.status==null" class="btn btn-danger" type="button"-->
ng-click="notice.status='1';save(noticeForm)">Send <!--ng-click="notice.status='1';save(noticeForm)">Send-->
</button> <!--</button>-->
</div> </div>
</div> </div>
</div> </div>

@ -16,36 +16,87 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
Notice Information Notice Information
<a role="button" class="pull-right" ng-if="notice.status==0" <a role="button" class="pull-right" ng-if="notice.status==0" ng-click="sendNotice(notice)">
<i class="fa fa-envelope-o"></i> Send
</a>
<a role="button" class="pull-right" style="margin-right:10px" ng-if="notice.status==0"
ui-sref="notice.edit({notice_id:notice.notice_id})"> ui-sref="notice.edit({notice_id:notice.notice_id})">
<i class="fa fa-edit"></i> Edit <i class="fa fa-edit"></i> Edit
</a> </a>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="form-horizontal"> <div class="form-horizontal">
<div class="col-sm-12"> <div class="form-group">
<label class="control-label col-sm-2">Intro</label>
<div class="col-sm-10">
<p class="form-control-static" ng-bind="notice.desc"></p>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Content</label>
<div class="col-sm-10">
<p class="form-control-static" ng-bind-html="notice.content"></p> <p class="form-control-static" ng-bind-html="notice.content"></p>
</div> </div>
<div class="col-sm-12" ng-if="notice.send_time"> </div>
<label class="control-label col-sm-1">Send Time</label> <div class="form-group" ng-if="notice.send_time">
<label class="control-label col-sm-2">Send Time</label>
<div class="col-sm-11"> <div class="col-sm-10">
<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="col-sm-12" ng-if="notice.end_time"> <div class="form-group" ng-if="notice.end_time">
<label class="control-label col-sm-1">Expiry Date</label> <label class="control-label col-sm-2">Expiry Date</label>
<div class="col-sm-11"> <div class="col-sm-10">
<p class="form-control-static" ng-bind="notice.end_time|limitTo:10"></p> <p class="form-control-static" ng-bind="notice.end_time|limitTo:10"></p>
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label col-sm-2">Merchants</label>
<div class="col-sm-10">
<p class="form-control-static" ng-if="!notice.merchants_type">全部商户</p>
<p class="form-control-static" ng-if="notice.merchants_type">自定义商户</p>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2"></label>
<div class="col-sm-10">
<textarea readonly style="width: 100%" class="form-control-static" ng-bind="notice.send_clients"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Send Channels</label>
<div class="col-sm-10">
<div class="col-sm-6">
<label class="control-label col-sm-4">Emails</label>
<div class="col-sm-6">
<input type="checkbox" switch-active="false" ng-model="notice.is_tomail" bs-switch>
</div>
</div>
<div class="col-sm-6">
<label class="control-label col-sm-4">App Notice</label>
<div class="col-sm-6">
<input type="checkbox" switch-active="false" ng-model="notice.is_to_app" bs-switch>
</div>
</div>
<div class="col-sm-6">
<label class="control-label col-sm-4">App Window</label>
<div class="col-sm-6">
<input type="checkbox" ng-model="notice.is_app_window" bs-switch switch-change="toggleAppWindow()">
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<!--end 商品基本资料--> <!--end 商品基本资料-->
<div class="panel panel-default" ng-if="notice.status==1 && clients.length>0"> <div class="panel panel-default" ng-if="notice.status==1 && clients.length>0">
<div class="panel-heading">Reading Partners <div class="panel-heading">Reading Partners
<span style="font-size: smaller;color: grey">(send to {{total_clients}} partners and {{pagination.totalCount}} partners of them have read)</span></div> <span style="font-size: smaller;color: grey">(send to {{total_clients}} partners and {{pagination.totalCount}} partners of them have read)</span>
</div>
<div class="panel-body"> <div class="panel-body">
<div class="box-body no-padding table-responsive"> <div class="box-body no-padding table-responsive">
<table class="table table-striped"> <table class="table table-striped">
@ -80,7 +131,9 @@
next-text="&rsaquo;" next-text="&rsaquo;"
first-text="&laquo;" first-text="&laquo;"
last-text="&raquo;"></uib-pagination> last-text="&raquo;"></uib-pagination>
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}}</div> <div class="col-xs-12">Total Records:{{pagination.totalCount}};Total
Pages:{{pagination.totalPages}}
</div>
</div> </div>
</div> </div>
</div> </div>

@ -0,0 +1,38 @@
<div class="modal-header">
<h4>Send Notice</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<form name="sendNoticeForm" novalidate>
<div class="form-group">
<label class="control-label col-sm-2">Send Channels</label>
<div class="col-sm-10">
<div class="col-sm-6">
<label class="control-label col-sm-4">Emails</label>
<div class="col-sm-6">
<input type="checkbox" ng-model="notice.is_tomail" bs-switch>
</div>
</div>
<div class="col-sm-6">
<label class="control-label col-sm-4">App Notice</label>
<div class="col-sm-6">
<input type="checkbox" ng-model="notice.is_to_app" bs-switch>
</div>
</div>
<div class="col-sm-6">
<label class="control-label col-sm-4">App Window</label>
<div class="col-sm-6">
<input type="checkbox" ng-model="notice.is_app_window" bs-switch>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" ng-click="submit()">OK</button>
<button type="button" class="btn btn-danger" ng-click="$dismiss()">Cancel</button>
</div>
Loading…
Cancel
Save