diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/MailUnsubMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/MailUnsubMapper.java index 7a512f7c5..07f08af4c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/MailUnsubMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/MailUnsubMapper.java @@ -27,6 +27,9 @@ public interface MailUnsubMapper { @AutoSql(type = SqlType.SELECT) JSONObject getOne(@Param("id") Long id,@Param("address") String address); + @AutoSql(type = SqlType.SELECT) + JSONObject findOneByClientMoniker(@Param("client_moniker") String client_moniker); + PageList queryPageable(JSONObject params, PageBounds pagination); List query(JSONObject params); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 939d22ef6..ef0ac79e8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -310,4 +310,8 @@ public interface ClientManager { JSONObject getByEmail(String email, int page, int limit,List ExceptClientIds); + void addSub(String client_moniker, JSONObject manager); + + void removeSub(String client_moniker, JSONObject manager); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index a75189f26..a7bf6ff4d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -19,21 +19,7 @@ import au.com.royalpay.payment.manage.mappers.log.LogClientSubMerchantIdMapper; import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; -import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper; -import au.com.royalpay.payment.manage.mappers.system.MailSendMapper; -import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; -import au.com.royalpay.payment.manage.mappers.system.OrgMapper; -import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper; +import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder; import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; @@ -187,6 +173,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private ClientRateMapper clientRateMapper; @Resource + private MailUnsubMapper mailUnsubMapper; + @Resource private AttachmentClient attachmentClient; @Resource private StringRedisTemplate stringRedisTemplate; @@ -326,6 +314,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkClientOrg(manager, client); } client.putAll(clientConfigService.find(client.getIntValue("client_id"))); + client.put("unsubscribe",mailUnsubMapper.findOneByClientMoniker(clientMoniker) == null?false:true); client.put("show_all_permission", true); int role = manager != null ? manager.getIntValue("role") : 0; if (manager != null) { @@ -3623,4 +3612,28 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid param.put("except_client_ids",exceptClientIds); return PageListUtils.buildPageListResult(clientMapper.simpleQuery(param,new PageBounds(page, limit))); } + + @Override + public void addSub(String client_moniker, JSONObject manager) { + JSONObject client = getClientInfoByMoniker(client_moniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + mailService.addUnsub(client_moniker); + } + + @Override + public void removeSub(String client_moniker, JSONObject manager) { + JSONObject client = getClientInfoByMoniker(client_moniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + JSONObject sub = mailUnsubMapper.findOneByClientMoniker(client_moniker); + if(sub == null){ + throw new BadRequestException(); + } + mailService.removeUnsub(sub.getLong("id")); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 61baace0f..df6203b1a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -517,6 +517,14 @@ public class PartnerManageController { public List getClientSubMerchantIdLogs(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { return clientManager.getClientSubMerchantIdLogs(clientMoniker,manager); } + @ManagerMapping(value = "/unsub/{clientMoniker}",method = RequestMethod.PUT,role = {ManagerRole.OPERATOR}) + public void addSub(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.addSub(clientMoniker,manager); + } + @ManagerMapping(value = "/unsub/{clientMoniker}",method = RequestMethod.DELETE,role = {ManagerRole.OPERATOR}) + public void removeSub(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.removeSub(clientMoniker,manager); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/MailServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/MailServiceImp.java index cd436b203..6e9e7e7d9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/MailServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/MailServiceImp.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.notice.beans.NoticeBean; import au.com.royalpay.payment.manage.notice.core.MailService; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.utils.PageListUtils; @@ -12,6 +13,7 @@ import au.com.royalpay.payment.tools.utils.id.IdUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import org.apache.commons.codec.digest.DigestUtils; @@ -199,7 +201,7 @@ public class MailServiceImp implements MailService { @Override public JSONObject queryUnsubPageable(JSONObject params, int limit, int page) { - return PageListUtils.buildPageListResult(mailUnsubMapper.queryPageable(params,new PageBounds(page, limit))); + return PageListUtils.buildPageListResult(mailUnsubMapper.queryPageable(params,new PageBounds(page, limit, Order.formString("create_time.desc")))); } @@ -211,7 +213,7 @@ public class MailServiceImp implements MailService { } JSONObject existRecord = mailUnsubMapper.getOne(null,client.getString("contact_email")); if(existRecord!=null){ - return; + throw new BadRequestException("Client has already existed"); } JSONObject record= new JSONObject(); record.put("id", IdUtil.getId()); diff --git a/src/main/java/au/com/royalpay/payment/manage/system/web/MailController.java b/src/main/java/au/com/royalpay/payment/manage/system/web/MailController.java index e2137591c..aff69f059 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/web/MailController.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/web/MailController.java @@ -2,13 +2,12 @@ package au.com.royalpay.payment.manage.system.web; import au.com.royalpay.payment.manage.notice.core.MailService; +import au.com.royalpay.payment.manage.permission.manager.RequireManager; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import com.alibaba.fastjson.JSONObject; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -29,9 +28,9 @@ public class MailController { mailService.removeUnsub(id); } - @RequestMapping(value = "/unsub",method = RequestMethod.PUT) + @RequestMapping(value = "/unsub/{client_moniker}",method = RequestMethod.PUT) // @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT}) - public void removeSub(@RequestParam String client_moniker) { + public void removeSub(@PathVariable String client_moniker) { mailService.addUnsub(client_moniker); } @@ -39,8 +38,12 @@ public class MailController { // @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT}) public JSONObject list(@RequestParam(required = false) String client_moniker,@RequestParam(required = false) String address,@RequestParam(required = false,defaultValue = "10") int limit ,@RequestParam(required = false,defaultValue = "1") int page) { JSONObject params = new JSONObject(); - params.put("client_moniker",client_moniker); - params.put("address",address); + if(StringUtils.isNotEmpty(client_moniker)){ + params.put("client_moniker",client_moniker); + } + if(StringUtils.isNotEmpty(address)){ + params.put("address",address); + } return mailService.queryUnsubPageable(params,limit,page); } } diff --git a/src/main/ui/static/config/sysconfigs/sysconfigs.js b/src/main/ui/static/config/sysconfigs/sysconfigs.js index 881bba243..763f50f5c 100644 --- a/src/main/ui/static/config/sysconfigs/sysconfigs.js +++ b/src/main/ui/static/config/sysconfigs/sysconfigs.js @@ -30,6 +30,10 @@ define(['angular', 'uiRouter'], function (angular) { return $http.get('/sys/permission/modules') }] } + }).state('sysconfig.mail_subscribe', { + url: '/mail', + templateUrl: '/static/config/sysconfigs/templates/mail_subscribe.html', + controller: 'mailSubscribeCtrl' })/*.state('sysconfig.payment_config',{ url: '/payment_config', templateUrl: '/static/config/sysconfigs/templates/payemnt_config.html', @@ -227,6 +231,55 @@ define(['angular', 'uiRouter'], function (angular) { }; }]); + app.controller('mailSubscribeCtrl', ['$scope', '$http','commonDialog','$uibModal',function ($scope, $http,commonDialog,$uibModal) { + $scope.params = {}; + $scope.pagination = {}; + $scope.loadUnSubs = function (page) { + var params = angular.copy($scope.params); + params.page = page || $scope.pagination.page || 1; + $http.get('/sys/mail/unsub/query',{params:params}).then(function (resp) { + $scope.mailSubscribes = resp.data.data; + $scope.pagination = resp.data.pagination; + }) + }; + $scope.deleteSub = function (id) { + commonDialog.confirm({ + title: 'Confirm', + content: 'Are you sure?' + }).then(function () { + $http.delete('/sys/mail/unsub/'+id).then(function () { + $scope.loadUnSubs(); + }, function (resp) { + commonDialog.alert({title: 'Error!', content: resp.data.message, type: 'error'}) + }) + }) + }; + $scope.addUnSub = function () { + $uibModal.open({ + templateUrl: '/static/config/sysconfigs/templates/add_mail_unsub.html', + controller: 'addUnSubDialogCtrl', + size: 'sm' + }).result.then(function () { + $scope.loadUnSubs(); + }); + }; + $scope.loadUnSubs(); + }]); + app.controller('addUnSubDialogCtrl', ['$scope', '$http', 'commonDialog','$state', function ($scope, $http, commonDialog,$state) { + $scope.unSub = {}; + $scope.save = function () { + var unSub = angular.copy($scope.params); + if(!unSub.client_moniker){ + alert("client_moniker 不可为空!") + } + $http.put('/sys/mail/unsub/'+unSub.client_moniker).then(function (resp) { + commonDialog.alert({title: 'Success', content: '新增成功', type: 'success'}); + $scope.$close(); + }, function (resp) { + commonDialog.alert({title: 'Error!', content: resp.data.message, type: 'error'}) + }) + } + }]); /*app.controller('paymentConfigCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { $scope.loadSysConfigs = function () { $http.get('/sysconfig/base').then(function (resp) { diff --git a/src/main/ui/static/config/sysconfigs/templates/add_mail_unsub.html b/src/main/ui/static/config/sysconfigs/templates/add_mail_unsub.html new file mode 100644 index 000000000..6d24869d2 --- /dev/null +++ b/src/main/ui/static/config/sysconfigs/templates/add_mail_unsub.html @@ -0,0 +1,13 @@ + + +
+
+
+ +
+
+ +
+ +
+
diff --git a/src/main/ui/static/config/sysconfigs/templates/mail_subscribe.html b/src/main/ui/static/config/sysconfigs/templates/mail_subscribe.html new file mode 100644 index 000000000..db91203ff --- /dev/null +++ b/src/main/ui/static/config/sysconfigs/templates/mail_subscribe.html @@ -0,0 +1,82 @@ +
+

Mail Not Subscribe

+ +
+
+
+
+
+
+
+
+
+ +
+
+ +
+ + +
+
+
+
+
+

Not Subscribed List

+
+ +
+ + + + + + + + + + + + + + + + + + + +
Partner CodeClient IdMail AddressCreate TimeOperation
+ + + +
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/src/main/ui/static/config/sysconfigs/templates/sysconfig.html b/src/main/ui/static/config/sysconfigs/templates/sysconfig.html index 0109d8749..ecfe43b97 100644 --- a/src/main/ui/static/config/sysconfigs/templates/sysconfig.html +++ b/src/main/ui/static/config/sysconfigs/templates/sysconfig.html @@ -20,6 +20,11 @@ Permission Config + + + Mail Subscriptions + +