add customer servant config

master
kira 6 years ago
parent 92a9e2a1ca
commit fde8a601ea

@ -60,4 +60,6 @@ public interface ManagerMapper {
List<JSONObject> findByIds(List<Integer> ids);
List<JSONObject> listOpenIdByRole(@Param("mask") int mask);
List<JSONObject> listServants(@Param("mask") int mask);
}

@ -0,0 +1,31 @@
package au.com.royalpay.payment.manage.mappers.system;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
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 yixian on 2016-06-29.
*/
@AutoMapper(tablename = "sys_customer_service", pkName = "manager_id")
public interface SysCustomerServiceMapper {
List<JSONObject> findOnline();
@AutoSql(type = SqlType.SELECT)
JSONObject findByManagerId(@Param("manager_id")String manager_id);
@AutoSql(type = SqlType.INSERT)
void save(JSONObject record);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject record);
void onoff(@Param("managerId") String managerId, @Param("status") int status);
}

@ -2,12 +2,15 @@ package au.com.royalpay.payment.manage.openim;
import au.com.royalpay.payment.manage.openim.beans.OpenimUserVO;
import au.com.royalpay.payment.manage.openim.core.CustomerServiceService;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.permission.manager.RequireManager;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -30,8 +33,8 @@ public class OpenimController {
@RequestMapping(value = "/check", method = RequestMethod.PUT)
@RequireManager
public void sendMsg(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
customerServiceService.checkAndSave(manager);
public JSONObject sendMsg(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return customerServiceService.checkAndSave(manager);
}
@RequestMapping(value = "/findOne", method = RequestMethod.GET)
@ -47,4 +50,9 @@ public class OpenimController {
return customerServiceService.query(clientMoniker,userNames);
}
@ManagerMapping(value = "/servant/onoff", method = RequestMethod.PUT,role = {ManagerRole.ADMIN})
public void listServants(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager, @RequestBody boolean onoff) {
customerServiceService.onoff(loginManager,onoff);
}
}

@ -12,9 +12,12 @@ import java.util.List;
*/
public interface CustomerServiceService {
void checkAndSave(JSONObject account);
JSONObject checkAndSave(JSONObject account);
OpenimUserVO findOne(int clientId,String userName);
List<JSONObject> query(String clientMoniker,String userNames);
void onoff(JSONObject manager,boolean status);
}

@ -122,7 +122,8 @@ public class OpenimClient {
Userinfos obj3 = new Userinfos();
list2.add(obj3);
obj3.setNick("king");
obj3.setUserid("kirawang");
obj3.setIconUrl("https://ss0.baidu.com/73t1bjeh1BF3odCf/it/u=1948403834,955109320&fm=85&s=0D06E5134AD145F30C8D6D680300303A");
obj3.setUserid("huangjin");
obj3.setPassword("xxxxxx");
req.setUserinfos(list2);
OpenimUsersAddResponse rsp = null;

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.openim.core.impl;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.SysCustomerServiceMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.openim.beans.OpenimUserVO;
import au.com.royalpay.payment.manage.openim.core.CustomerServiceService;
@ -11,6 +12,7 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -36,11 +38,11 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
private ClientAccountMapper clientAccountMapper;
@Resource
private ManagerMapper managerMapper;
private final String password = "XXXXXX";
@Resource
private SysCustomerServiceMapper sysCustomerServiceMapper;
@Override
public void checkAndSave(JSONObject account) {
public JSONObject checkAndSave(JSONObject account) {
JSONObject client = null;
boolean isPartner = true;
if (StringUtils.isNotEmpty(account.getString("account_id"))) {
@ -48,27 +50,25 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
if (client == null) {
throw new BadRequestException("Merchant Not Found");
}
account =clientAccountMapper.findById(account.getString("account_id"));
account = clientAccountMapper.findById(account.getString("account_id"));
isPartner = true;
}
if (StringUtils.isNotEmpty(account.getString("manager_id"))) {
account =managerMapper.findDetail(account.getString("manager_id"));
account = managerMapper.findDetail(account.getString("manager_id"));
isPartner = false;
}
String uid = account.getString("username") + (isPartner ? "(" + client.getString("client_moniker") + ")" : "");
JSONObject saveRecord = new JSONObject();
saveRecord.put("nick", account.getString("display_name"));
saveRecord.put("password", DigestUtils.md5Hex("uid"));
if (isPartner) {
saveRecord.put("user_id", uid);
saveRecord.put("account_type", "partner");
saveRecord.put("account_id", account.getString("account_id"));
saveRecord.put("servants", sysCustomerServiceMapper.findOnline());
} else {
saveRecord.put("user_id", uid);
saveRecord.put("account_type", "manager");
saveRecord.put("account_id", account.getString("manager_id"));
}
saveRecord.put("password", password);
openimApi.addUser(saveRecord);
return saveRecord;
}
@Override
@ -117,4 +117,25 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
});
return result;
}
@Override
public void onoff(JSONObject manager, boolean onoff) {
JSONObject record = new JSONObject();
record.put("manager_id",manager.getString("manager_id"));
record.put("onoff",onoff);
udpateOrSave(record);
}
private void udpateOrSave(JSONObject servant){
JSONObject record = sysCustomerServiceMapper.findByManagerId(servant.getString("manager_id"));
if(record==null){
JSONObject manager = managerMapper.findById(servant.getString("manager_id"));
servant.put("manager_id",manager.getString("manager_id"));
servant.put("user_id",manager.getString("username"));
sysCustomerServiceMapper.save(servant);
}else {
sysCustomerServiceMapper.update(servant);
}
}
}

@ -26,5 +26,5 @@ public interface ManagerAccountsService {
JSONObject getBDConfig(String bd_id);
JSONObject getUser(String managerId);
List<JSONObject> listServants(JSONObject loginManager);
}

@ -138,11 +138,8 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
}
@Override
public JSONObject getUser(String managerId) {
JSONObject manager = managerMapper.findDetail(managerId);
JSONObject result = new JSONObject();
result.put("username",manager.getString("username"));
return result;
public List<JSONObject> listServants(JSONObject loginManager) {
return managerMapper.listServants(ManagerRole.SERVANT.getMask());
}
private void checkOrg(JSONObject loginManager,JSONObject manager){

@ -82,20 +82,20 @@ public class ManagerAccountsController {
managerAccountsService.disable(userId, loginManager);
}
@ManagerMapping(value = "/current", method = RequestMethod.GET, role = {ManagerRole.ADMIN})
public JSONObject getUser(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) {
return managerAccountsService.getUser(loginManager.getString("manager_id"));
}
@ManagerMapping(value = "/roles/bd_leader", method = RequestMethod.GET)
public List<JSONObject> listBDLeaders(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) {
return managerAccountsService.listBDLeaders(loginManager);
}
@ManagerMapping(value = "/group/group_bds", method = RequestMethod.GET)
public List<JSONObject> listGroupBds(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) {
return managerAccountsService.listGroupBds(loginManager);
}
@ManagerMapping(value = "/roles/servant", method = RequestMethod.GET,role = {ManagerRole.ADMIN})
public List<JSONObject> listServants(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) {
return managerAccountsService.listServants(loginManager);
}
}

@ -94,4 +94,14 @@
WHERE role & #{mask} >0 AND wx_openid IS NOT NULL AND is_valid = 1
]]>
</select>
<select id="listServants" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT display_name
FROM sys_managers
WHERE role & #{mask} >0 AND org_id IS NULL AND is_valid = 1
]]>
</select>
</mapper>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.SysCustomerServiceMapper">
<select id="findOnline" resultType="com.alibaba.fastjson.JSONObject">
select user_id from sys_customer_service
where `status` = 1
</select>
<update id="onoff">
udpate sys_customer_servie
set status = #{status}
where manager_id = #{managerId}
</update>
</mapper>

@ -17,6 +17,7 @@
if(getQueryString('uid')){
window.uid = getQueryString('uid');
window.touid = getQueryString('uid');
window.password = getQueryString('p');
}
WKIT.init({
container: document.getElementById('J_demo'),
@ -24,7 +25,7 @@
height: 500,
uid: window.uid,
appkey: 24960261,
credential: 'XXXXXX',
credential: window.password,
touid: window.touid,
pluginUrl: '/service_contact_list.html?uid='
+ window.uid,

@ -12,7 +12,7 @@
container: document.getElementById('J_demo'),
width: 700,
height: 500,
uid: 'kirawang',
uid: 'huangjin',
appkey: 24960261,
credential: 'xxxxxx',
touid: 'imuser123',

@ -178,12 +178,8 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
}
$scope.customerService = function () {
$http.put('/sys/openim/check').then(function (resp) {
$http.get('/sys/manager_accounts/current').then(function (resp) {
console.log(resp.data);
window.open('/service_client.html?uid='+resp.data.username,'_blank');
})
window.open('/service_client.html?p='+resp.data.password+'&uid='+resp.data.user_id,'_blank');
});
}
}]);

@ -34,6 +34,10 @@ define(['angular', 'uiRouter'], function (angular) {
url: '/mail',
templateUrl: '/static/config/sysconfigs/templates/mail_subscribe.html',
controller: 'mailSubscribeCtrl'
}).state('sysconfig.servantsConfig', {
url: '/servantsConfig',
templateUrl: '/static/config/sysconfigs/templates/servants_config.html',
controller: 'servantsConfigCtrl'
})/*.state('sysconfig.payment_config',{
url: '/payment_config',
templateUrl: '/static/config/sysconfigs/templates/payemnt_config.html',
@ -61,6 +65,25 @@ define(['angular', 'uiRouter'], function (angular) {
app.controller('sysConfigCtrl', ['$scope', function ($scope) {
}]);
app.controller('servantsConfigCtrl', ['$scope','$http','commonDialog', function ($scope,$http,commonDialog) {
$scope.loadServants = function () {
$http.get('/sys/manager_accounts/roles/servant').then(function (resp) {
$scope.servants = resp.data;
})
};
$scope.loadServants();
$scope.onoff = function (servant) {
var param = {onoff:servant.onoff};
$http.put('/sys/openim/roles/servant',param).then(function (resp) {
},function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
});
};
}]);
app.controller('basicConfigCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) {
$scope.loadSysConfigs = function () {
$http.get('/sysconfig/base').then(function (resp) {

@ -0,0 +1,52 @@
<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-body no-padding table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Display Name</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="servant in servants">
<td ng-bind="servant.display_name"></td>
<td>
<input type="checkbox" ng-click="onoff(servant)" ng-model="servant.onoff">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>

@ -30,6 +30,11 @@
Partner Permission Config
</a>
<a class="btn btn-app" role="button" ui-sref=".servantsConfig">
<i class="fa fa-key"></i>
Servants Config
</a>
<!--<a class="btn btn-app" role="button" ui-sref=".payment_config">
<i class="fa fa-edit"></i>
Payment Config

Loading…
Cancel
Save