增加取消订阅邮件管理

master
yuan 7 years ago
parent bf6bd34e36
commit debc6ea13c

@ -27,6 +27,9 @@ public interface MailUnsubMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
JSONObject getOne(@Param("id") Long id,@Param("address") String address); JSONObject getOne(@Param("id") Long id,@Param("address") String address);
@AutoSql(type = SqlType.SELECT)
JSONObject findOneByClientMoniker(@Param("client_moniker") String client_moniker);
PageList<JSONObject> queryPageable(JSONObject params, PageBounds pagination); PageList<JSONObject> queryPageable(JSONObject params, PageBounds pagination);
List<JSONObject> query(JSONObject params); List<JSONObject> query(JSONObject params);

@ -310,4 +310,8 @@ public interface ClientManager {
JSONObject getByEmail(String email, int page, int limit,List<String> ExceptClientIds); JSONObject getByEmail(String email, int page, int limit,List<String> ExceptClientIds);
void addSub(String client_moniker, JSONObject manager);
void removeSub(String client_moniker, JSONObject manager);
} }

@ -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.log.LogSettleMailMapper;
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.redpack.ActClientInvitationCodeMapper; 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.*;
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.merchants.beans.ActivityPosterBuilder; 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.BankAccountInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
@ -187,6 +173,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Resource @Resource
private ClientRateMapper clientRateMapper; private ClientRateMapper clientRateMapper;
@Resource @Resource
private MailUnsubMapper mailUnsubMapper;
@Resource
private AttachmentClient attachmentClient; private AttachmentClient attachmentClient;
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@ -326,6 +314,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
checkClientOrg(manager, client); checkClientOrg(manager, client);
} }
client.putAll(clientConfigService.find(client.getIntValue("client_id"))); client.putAll(clientConfigService.find(client.getIntValue("client_id")));
client.put("unsubscribe",mailUnsubMapper.findOneByClientMoniker(clientMoniker) == null?false:true);
client.put("show_all_permission", true); client.put("show_all_permission", true);
int role = manager != null ? manager.getIntValue("role") : 0; int role = manager != null ? manager.getIntValue("role") : 0;
if (manager != null) { if (manager != null) {
@ -3623,4 +3612,28 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
param.put("except_client_ids",exceptClientIds); param.put("except_client_ids",exceptClientIds);
return PageListUtils.buildPageListResult(clientMapper.simpleQuery(param,new PageBounds(page, limit))); 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"));
}
} }

@ -517,6 +517,14 @@ public class PartnerManageController {
public List<JSONObject> getClientSubMerchantIdLogs(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { public List<JSONObject> getClientSubMerchantIdLogs(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.getClientSubMerchantIdLogs(clientMoniker,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);
}
} }

@ -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.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.beans.NoticeBean; import au.com.royalpay.payment.manage.notice.beans.NoticeBean;
import au.com.royalpay.payment.manage.notice.core.MailService; 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.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.utils.PageListUtils; 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.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; 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.PageBounds;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
@ -199,7 +201,7 @@ public class MailServiceImp implements MailService {
@Override @Override
public JSONObject queryUnsubPageable(JSONObject params, int limit, int page) { 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")); JSONObject existRecord = mailUnsubMapper.getOne(null,client.getString("contact_email"));
if(existRecord!=null){ if(existRecord!=null){
return; throw new BadRequestException("Client has already existed");
} }
JSONObject record= new JSONObject(); JSONObject record= new JSONObject();
record.put("id", IdUtil.getId()); record.put("id", IdUtil.getId());

@ -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.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 com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.PathVariable; import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -29,9 +28,9 @@ public class MailController {
mailService.removeUnsub(id); 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}) // @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); mailService.addUnsub(client_moniker);
} }
@ -39,8 +38,12 @@ public class MailController {
// @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT}) // @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) { 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(); JSONObject params = new JSONObject();
params.put("client_moniker",client_moniker); if(StringUtils.isNotEmpty(client_moniker)){
params.put("address",address); params.put("client_moniker",client_moniker);
}
if(StringUtils.isNotEmpty(address)){
params.put("address",address);
}
return mailService.queryUnsubPageable(params,limit,page); return mailService.queryUnsubPageable(params,limit,page);
} }
} }

@ -30,6 +30,10 @@ define(['angular', 'uiRouter'], function (angular) {
return $http.get('/sys/permission/modules') 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',{ })/*.state('sysconfig.payment_config',{
url: '/payment_config', url: '/payment_config',
templateUrl: '/static/config/sysconfigs/templates/payemnt_config.html', 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) { /*app.controller('paymentConfigCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) {
$scope.loadSysConfigs = function () { $scope.loadSysConfigs = function () {
$http.get('/sysconfig/base').then(function (resp) { $http.get('/sysconfig/base').then(function (resp) {

@ -0,0 +1,13 @@
<div class="content" style="min-height: 100px">
<div class="form-inline">
<div class="form-group">
<input class="form-control" placeholder="Client Moniker" ng-model="params.client_moniker">
</div>
<div class="form-group">
<button class="btn btn-success pull-right" ng-click="save()">Add</button>
</div>
</div>
</div>

@ -0,0 +1,82 @@
<section class="content-header">
<h1>Mail Not Subscribe</h1>
<ol class="breadcrumb">
<li>
<a ui-sref="^"><i class="fa fa-cog"></i> System Config</a>
</li>
<li>Mail Not Subscribe</li>
</ol>
</section>
<div class="content">
<div class="row">
<div class="col-sm-12">
<div class="box-solid">
<div class="box box-warning">
<div class="box-header">
<div class="form-inline">
<div class="form-group">
<input class="form-control" placeholder="Client Moniker" ng-model="params.client_moniker">
</div>
<div class="form-group">
<input class="form-control" placeholder="Mail Address" ng-model="params.address">
</div>
<button class="btn btn-success" ng-click="loadUnSubs(1)"><i
class="fa fa-search"></i> Search</button>
<button class="btn btn-success pull-right" ng-click="addUnSub()" ng-click="addUnSubs()">Add</button>
</div>
</div>
</div>
<div class="box">
<div class="box-header">
<h3 class="box-title">Not Subscribed List</h3>
</div>
<div class="box-body no-padding table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Partner Code</th>
<th>Client Id</th>
<th>Mail Address</th>
<th>Create Time</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="subscribe in mailSubscribes">
<td ng-bind="subscribe.client_moniker"></td>
<td ng-bind="subscribe.client_id"></td>
<td ng-bind="subscribe.address"></td>
<td ng-bind="subscribe.create_time"></td>
<td>
<a class="text-primary" role="button" title="delete">
<i class="glyphicon glyphicon-trash" ng-click="deleteSub(subscribe.id)"></i>
</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="box-footer" ng-if="mailSubscribes.length">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="loadUnSubs()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total
Pages:{{pagination.totalPages}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

@ -20,6 +20,11 @@
Permission Config Permission Config
</a> </a>
<a class="btn btn-app" role="button" ui-sref=".mail_subscribe">
<i class="fa fa-edit"></i>
Mail Subscriptions
</a>
<!--<a class="btn btn-app" role="button" ui-sref=".payment_config"> <!--<a class="btn btn-app" role="button" ui-sref=".payment_config">
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
Payment Config Payment Config

@ -869,6 +869,17 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
}) })
}) })
}; };
$scope.removeSub = function () {
$http.delete('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) {
$state.reload();
});
};
$scope.addSub = function () {
$http.put('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) {
$state.reload();
});
};
}]); }]);
app.controller('partnerEditCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog', 'timezone', 'partner', app.controller('partnerEditCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog', 'timezone', 'partner',
function ($scope, $http, $state, Upload, commonDialog, timezone, partner) { function ($scope, $http, $state, Upload, commonDialog, timezone, partner) {

@ -32,6 +32,11 @@
height: 100px; height: 100px;
margin-left: 20px; margin-left: 20px;
} }
.star_position{
position: absolute;
right: 0px;
top: -1px;
}
</style> </style>
<section class="content-header"> <section class="content-header">
<h1> <h1>
@ -515,7 +520,12 @@
</div> </div>
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
<label class="control-label col-sm-4">E-mail</label> <label class="control-label col-sm-4">E-mail
<span ng-if="('10'|withRole)">
<i style="cursor: pointer" ng-click="addSub()" ng-if="!partner.unsubscribe" class="fa fa-star text-yellow star_position"></i>
<i style="cursor: pointer" ng-click="removeSub()" ng-if="partner.unsubscribe" class="fa fa-star-o text-yellow star_position"></i>
</span>
</label>
<div class="col-sm-8"> <div class="col-sm-8">
<p class="form-control-static"> <p class="form-control-static">

Loading…
Cancel
Save