add customer service

master
kira 6 years ago
parent 405fdda8d2
commit cc766351ad

@ -28,7 +28,7 @@ public class OpenimController {
@Resource
private CustomerServiceService customerServiceService;
@RequestMapping(value = "/check", method = RequestMethod.POST)
@RequestMapping(value = "/check", method = RequestMethod.PUT)
@RequireManager
public void sendMsg(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
customerServiceService.checkAndSave(manager);

@ -20,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -29,10 +30,10 @@ import java.util.List;
@Service
public class OpenimClient {
Logger logger = LoggerFactory.getLogger(getClass());
// private final String appkey = "24960261";
// private final String secret = "7639427973bd671be15c9d0c1e9c90b4";
private final String appkey = "24962653";
private final String secret = "1c1a1320c4e6f24df24e3fe41c3fc00a";
private final String appkey = "24960261";
private final String secret = "7639427973bd671be15c9d0c1e9c90b4";
// private final String appkey = "24962653";
// private final String secret = "1c1a1320c4e6f24df24e3fe41c3fc00a";
private final String url = "https://eco.taobao.com/router/rest";
public JSONObject getUser(String userId) {
@ -109,4 +110,27 @@ public class OpenimClient {
throw new ServerErrorException("System error");
}
}
public static void main(String[] args) {
String appkey = "24960261";
String secret = "7639427973bd671be15c9d0c1e9c90b4";
String url = "https://eco.taobao.com/router/rest";
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimUsersAddRequest req = new OpenimUsersAddRequest();
List<Userinfos> list2 = new ArrayList<Userinfos>();
Userinfos obj3 = new Userinfos();
list2.add(obj3);
obj3.setNick("king");
obj3.setUserid("kirawang");
obj3.setPassword("xxxxxx");
req.setUserinfos(list2);
OpenimUsersAddResponse rsp = null;
try {
rsp = client.execute(req);
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println(rsp.getBody());
}
}

@ -1,6 +1,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.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.openim.beans.OpenimUserVO;
import au.com.royalpay.payment.manage.openim.core.CustomerServiceService;
@ -33,20 +34,25 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
private ClientManager clientManager;
@Resource
private ClientAccountMapper clientAccountMapper;
@Resource
private ManagerMapper managerMapper;
private final String password = "XXXXXX";
@Override
public void checkAndSave(JSONObject account) {
JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id"));
if (client == null) {
throw new BadRequestException("Merchant Not Found");
}
JSONObject client = null;
boolean isPartner = true;
if (StringUtils.isNotEmpty(account.getString("account_id"))) {
client = clientManager.getClientInfo(account.getIntValue("client_id"));
if (client == null) {
throw new BadRequestException("Merchant Not Found");
}
account =clientAccountMapper.findById(account.getString("account_id"));
isPartner = true;
}
if (StringUtils.isNotEmpty(account.getString("manager_id"))) {
account =managerMapper.findDetail(account.getString("manager_id"));
isPartner = false;
}
String uid = account.getString("username") + (isPartner ? "(" + client.getString("client_moniker") + ")" : "");
@ -85,31 +91,28 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
}
@Override
public List<JSONObject> query(String clientMoniker,String userNames) {
if(StringUtils.isEmpty(clientMoniker) && StringUtils.isEmpty(userNames)){
}
public List<JSONObject> query(String clientMoniker, String userNames) {
JSONObject queryParams = new JSONObject();
if(StringUtils.isNotEmpty(clientMoniker)) {
if (StringUtils.isNotEmpty(clientMoniker)) {
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new BadRequestException("Merchant Not Found");
return Collections.EMPTY_LIST;
}
queryParams.put("clientId",client.getIntValue("client_id"));
queryParams.put("clientId", client.getIntValue("client_id"));
}
if(StringUtils.isNotEmpty(userNames)) {
if (StringUtils.isNotEmpty(userNames)) {
queryParams.put("userNames", Arrays.asList(userNames.split(",")));
}
if(queryParams.size()<1){
if (queryParams.size() < 1) {
return Collections.emptyList();
}
List<JSONObject> accounts = clientAccountMapper.query(queryParams);
List<JSONObject> result = new ArrayList<>(accounts.size());
accounts.forEach(p -> {
JSONObject openimUser = new JSONObject();
openimUser.put("nick", p.getString("display_name"));
openimUser.put("userid", p.getString("username") + "(" + p.getString("client_moniker") + ")");
openimUser.put("headimg",p.getString("wechat_headimg"));
openimUser.put("nick", p.getString("username") + "(" + p.getString("client_moniker") + ")");
openimUser.put("headimg", p.getString("wechat_headimg"));
result.add(openimUser);
});
return result;

@ -25,4 +25,6 @@ public interface ManagerAccountsService {
List<JSONObject> listGroupBds(JSONObject loginManager);
JSONObject getBDConfig(String bd_id);
JSONObject getUser(String managerId);
}

@ -4,21 +4,24 @@ import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.signin.beans.ManagerInfo;
import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
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.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
/**
* Created by yixian on 2016-07-06.
*/
@ -134,6 +137,14 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
return financialBDConfigMapper.getBdConfig(bd_id);
}
@Override
public JSONObject getUser(String managerId) {
JSONObject manager = managerMapper.findDetail(managerId);
JSONObject result = new JSONObject();
result.put("username",manager.getString("username"));
return result;
}
private void checkOrg(JSONObject loginManager,JSONObject manager){
if (loginManager.getInteger("org_id")!=null){
List<JSONObject> orgs = orgMapper.listOrgAndChild(loginManager.getIntValue("org_id"));

@ -2,25 +2,33 @@ package au.com.royalpay.payment.manage.signin.web;
import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.signin.beans.QueryManagerBean;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.permission.manager.RequireManager;
import au.com.royalpay.payment.manage.signin.beans.ManagerInfo;
import au.com.royalpay.payment.manage.signin.beans.QueryManagerBean;
import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
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;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* Created by yixian on 2016-07-05.
*/
@ -74,6 +82,11 @@ 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);

@ -120,6 +120,12 @@ margin-bottom: 10%;"/>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li class="user-menu">
<a role="button" ng-click="customerService()">
<i class="fa fa-wechat"></i> contact service
</a>
</li>
<li class="user-menu">
<a role="button" ng-click="managerBindWechat(true)">
<i class="fa fa-wechat"></i> Bind WeChat

@ -1,6 +1,7 @@
<html>
<!--[if lt IE 9]>
<meta charset="utf-8"/>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<script src="https://g.alicdn.com/aliww/ww/json/json.js" charset="utf-8"></script>
<![endif]-->
<!-- 自动适配移动端与pc端 -->
@ -11,16 +12,21 @@
<script>
window.uid = 'imuser123';
window.touid = 'imuser1234';
window.onload = function () {
if(getQueryString('uid')){
window.uid = getQueryString('uid');
window.touid = getQueryString('uid');
}
WKIT.init({
container: document.getElementById('J_demo'),
width: 700,
height: 500,
uid: window.uid,
appkey: 24960261,
credential: 'xxxxxx',
credential: 'XXXXXX',
touid: window.touid,
pluginUrl: 'http://192.168.0.67:9001/service_contact_list.html?uid='
pluginUrl: '/service_contact_list.html?uid='
+ window.uid,
onLoginSuccess: function (data) {
initLayout();
@ -52,6 +58,7 @@
}
});
window.sdk.unreadMap[touid].msgCount = 0;
window.sdk.showContactList(window.sdk.unreadMap);
}
function initUnreadMsgAndContact() {
@ -60,8 +67,9 @@
success: function (data) {
var cnts = data.data.cnts;
for (var i = cnts.length - 1; i >= 0; i--) {
var unreadmapEle = {msgCount:0};
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(cnts[i].to)]=unreadmapEle;
var unreadmapEle = {msgCount: 0};
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(
cnts[i].from)] = unreadmapEle;
}
getUnreadMsgCount();
},
@ -76,11 +84,17 @@
WKIT.Conn.sdk.Base.getUnreadMsgCount({
count: 40,
success: function (data) {
console.log(data);
var unreads = data.data;
var uids = "";
for (var i = unreads.length - 1; i >= 0; i--) {
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(unreads[i].contact)].msgCount =unreads[i].msgCount;
uids += WKIT.Conn.sdk.Base.getNick(unreads[i].contact) + ",";
if(window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(unreads[i].contact)]){
}
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(unreads[i].contact)].msgCount =
unreads[i].msgCount;
var nick = WKIT.Conn.sdk.Base.getNick(unreads[i].contact)
uids += nick.substr(0,nick.length-6) + ",";
}
window.sdk.loadContactList(uids);
},
@ -96,17 +110,23 @@
if (window.sdk.unreadMap[msg_uid]) {
window.sdk.unreadMap[msg_uid].msgCount = window.sdk.unreadMap[msg_uid].msgCount + 1;
} else {
var unreadMapEle = {msgCount:1}
var unreadMapEle = {msgCount: 1}
window.sdk.unreadMap[msg_uid] = unreadMapEle;
}
window.sdk.loadContactList(msg_uid);
window.sdk.loadContactList(msg_uid.substr(0,msg_uid-6));
}
function initLayout() {
$("#J_wkitUserInfo").hide();
$("#J_wkitPluginFrameWrap").css("height", "100%;");
$("#J_wkitPluginFrameWrap").height("100%");
$("#J_wkitPluginFrameWrap").css("margin", "0 0 0 0");
}
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
</script>
</html>

@ -21,13 +21,15 @@
padding: 0;
}
.search-div{
.search-div {
height: 3%;
}
.search-div input{
.search-div input {
background: #D8D8D8;
border-radius: 5px;
}
.hover {
color: black;
background-color: rgba(255, 255, 255, 0.03);
@ -75,22 +77,70 @@
right: -16px;
top: -7px;
}
.frm_search {
width: 133px;
height: 32px;
line-height: 32px;
border: 0;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
background-color: #D8D8D8;
color: #fff;
padding-left: 30px;
font-size: 12px;
}
.search_bar {
position: relative;
width: 137px;
margin: 0 auto 6px;
}
.web_wechat_search {
background: url(/static/images/search.png) no-repeat;
display: inline-block;
vertical-align: middle;
width: 25px;
height: 30px;
position: absolute;
line-height: 1.6;
background-size: 16px;
background-position: 5px;
}
</style>
<script>
var unreadMap = {};
function searchContact() {
var uid = $('#searchText').val()
var searchContactList={};
for(var key in unreadMap){
if(key.search(uid)>-1){
var uid = $('#searchText').val();
var searchContactList = {};
for (var key in unreadMap) {
if (key.search(uid) > -1) {
searchContactList[key] = unreadMap[key];
}
}
showContactList(searchContactList);
var param = {clientMoniker: uid};
$.ajax({
url: '/sys/openim/list',
method: 'GET',
data: param,
contentType: 'application/json',
dataType: 'json',
success: function (resp) {
for (var i = 0; i <= resp.length - 1; i++) {
resp[i].msgCount = 0;
searchContactList[resp[i].nick] = resp[i];
unreadMap[resp[i].nick] = resp[i];
}
showContactList(searchContactList);
},
error: function () {
showContactList(searchContactList);
}
});
}
function loadContactList(uids) {
var param = {userNames: uids};
$.ajax({
@ -107,7 +157,7 @@
}
})
};
function showContactList(map) {
var contact_list = '';
for (var key in map) {
@ -116,8 +166,8 @@
css = 'active';
}
var headImUrl = '';
if (unreadMap[key].headimg) {
headImUrl = unreadMap[key].headimg;
if (map[key].headimg) {
headImUrl = map[key].headimg;
} else {
headImUrl = "/static/images/act/encourage_money/default_headimg.png";
}
@ -126,7 +176,7 @@
+ "')>"
+ "<div class=\"headimg\" style='background-image:url(" + headImUrl
+ "')>"
+ "<div class=\"notice\">" + unreadMap[key].msgCount + "</div>"
+ "<div class=\"notice\">" + map[key].msgCount + "</div>"
+ "</div>"
+ "<div class=\"avatar\">" + key + "</div>"
+ "</li>"
@ -140,8 +190,9 @@
</script>
<body>
<div class="search-div">
<input id="searchText" type="text" onchange="searchContact()">
<div class="search_bar">
<i class="web_wechat_search"></i>
<input id="searchText" class="frm_search" type="text" onchange="searchContact()">
</div>
<div class="list">
<ul id="contact_list">

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

@ -176,6 +176,15 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
// $scope.showQrCode(resp.data.url);
})
}
$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');
})
});
}
}]);
app.controller('changePwdCtrl', ['$scope', '$http', function ($scope, $http) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Loading…
Cancel
Save