customer tmp

master
kira 6 years ago
parent 8579b406d3
commit d0df62162f

@ -75,4 +75,5 @@ public interface ClientAccountMapper {
@AdvanceSelect(addonWhereClause = "is_valid=1 and role=1 and wechat_openid is not null and wx_unionid is null", excludeColumns = {"salt", "password_hash"})
List<JSONObject> listNullUnionIdAccounts();
List<JSONObject> query(JSONObject params);
}

@ -40,7 +40,11 @@ public class OpenimController {
}
@RequestMapping(value = "/list",method = RequestMethod.GET)
public List<JSONObject> query(@RequestParam String clientMoniker){
return customerServiceService.query(clientMoniker);
public List<JSONObject> query(@RequestParam(required = false) String clientMoniker,@RequestParam(required = false) String userNames){
JSONObject params = new JSONObject();
params.put("clientMoniker",clientMoniker);
params.put("userNames",userNames);
return customerServiceService.query(clientMoniker,userNames);
}
}

@ -16,5 +16,5 @@ public interface CustomerServiceService {
OpenimUserVO findOne(int clientId,String userName);
List<JSONObject> query(String clientMoniker);
List<JSONObject> query(String clientMoniker,String userNames);
}

@ -14,6 +14,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
@ -83,17 +85,31 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
}
@Override
public List<JSONObject> query(String clientMoniker) {
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new BadRequestException("Merchant Not Found");
public List<JSONObject> query(String clientMoniker,String userNames) {
if(StringUtils.isEmpty(clientMoniker) && StringUtils.isEmpty(userNames)){
}
JSONObject queryParams = new JSONObject();
if(StringUtils.isNotEmpty(clientMoniker)) {
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new BadRequestException("Merchant Not Found");
}
queryParams.put("clientId",client.getIntValue("client_id"));
}
if(StringUtils.isNotEmpty(userNames)) {
queryParams.put("userNames", Arrays.asList(userNames.split(",")));
}
if(queryParams.size()<1){
return Collections.emptyList();
}
List<JSONObject> accounts = clientAccountMapper.listPartnerAccounts(client.getIntValue("client_id"));
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") + "(" + client.getString("client_moniker") + ")");
openimUser.put("userid", p.getString("username") + "(" + p.getString("client_moniker") + ")");
openimUser.put("headimg",p.getString("wechat_headimg"));
result.add(openimUser);
});
return result;

@ -0,0 +1,20 @@
<?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.ClientAccountMapper">
<select id="query" resultType="com.alibaba.fastjson.JSONObject">
SELECT a.*,c.client_moniker client_moniker FROM sys_accounts a left join sys_clients c on c.client_id = a.client_id
<where>
<if test="clientId!=null">
and a.client_id = #{clientId}
</if>
<if test="userNames!=null">
and a.username in (
<foreach collection="userNames" item="item" separator=",">
#{item}
</foreach>
)
</if>
</where>
</select>
</mapper>

@ -4,6 +4,7 @@
<script src="https://g.alicdn.com/aliww/ww/json/json.js" charset="utf-8"></script>
<![endif]-->
<!-- 自动适配移动端与pc端 -->
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.4.0/scripts/kit.js"
charset="utf-8"></script>
<script src="https://g.alicdn.com/aliww/h5.openim.sdk/1.0.6/scripts/wsdk.js"></script>
@ -19,82 +20,93 @@
appkey: 24960261,
credential: 'xxxxxx',
touid: window.touid,
pluginUrl: 'http://192.168.0.43:9001/service_contact_list.html?uid='
pluginUrl: 'http://192.168.0.67:9001/service_contact_list.html?uid='
+ window.uid,
onLoginSuccess: function (data) {
initLayout();
WKIT.Conn.sdk.Event.on('MSG_RECEIVED', function (data) {
updateContractList(data.data);
});
initUnreadMsgAndContact();
WKIT.Conn.sdk.Base.startListenAllMsg();
window.sdk =document.getElementById("J_wkitPluginFrame").contentWindow;
window.sdk = document.getElementById("J_wkitPluginFrame").contentWindow;
}
});
}
function switchTouid(touid) {
window.uid = touid;
WKIT.switchTouid({
touid: touid,
logo:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg',
Avatar:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg',
toAvatar:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg'
logo: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg',
Avatar: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg',
toAvatar: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg'
});
WKIT.Conn.sdk.Chat.setReadState({
touid: touid,
timestamp: Math.floor((+new Date()) / 1000),
success: function (data) {
console.log('set read state success', data);
},
error: function (error) {
console.log('set read state fail', error);
}
});
window.sdk.unreadMap[touid] = 0;
window.sdk.loadContactList();
window.sdk.unreadMap[touid].msgCount = 0;
}
function initUnreadMsgAndContact() {
WKIT.Conn.sdk.Base.getRecentContact({
count: 40,
success: function (data) {
var cnts = data.data.cnts;
for (var i = cnts.length - 1; i >= 0; i--) {
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(cnts[i].to)] = 0;
}
getUnreadMsgCount();
},
error: function (error) {
console.log('get contact msg count fail', error);
}
})
}
function getUnreadMsgCount() {
WKIT.Conn.sdk.Base.getUnreadMsgCount({
count: 40,
success: function (data) {
var unreads = data.data;
for (var i = unreads.length - 1; i >= 0; i--) {
window.sdk.unreadMap[ WKIT.Conn.sdk.Base.getNick(unreads[i].contact)] =
unreads[i].msgCount;
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;
}
window.sdk.loadContactList();
getUnreadMsgCount();
},
error: function (error) {
console.log('get recent contact fail', error);
console.log('get contact msg count fail',
error);
}
});
})
}
function getUnreadMsgCount() {
WKIT.Conn.sdk.Base.getUnreadMsgCount({
count: 40,
success: function (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) + ",";
}
window.sdk.loadContactList(uids);
},
error: function (error) {
console.log('get recent contact fail', error);
}
});
}
function updateContractList(data) {
var msg = data.msgs[0];
var msg_uid = WKIT.Conn.sdk.Base.getNick(msg.from);
if (window.sdk.unreadMap[msg_uid]) {
window.sdk.unreadMap[msg_uid] = window.sdk.unreadMap[msg_uid] + 1;
window.sdk.unreadMap[msg_uid].msgCount = window.sdk.unreadMap[msg_uid].msgCount + 1;
} else {
window.sdk.unreadMap[msg_uid] = 1;
var unreadMapEle = {msgCount:1}
window.sdk.unreadMap[msg_uid] = unreadMapEle;
}
window.sdk.loadContactList();
window.sdk.loadContactList(msg_uid);
}
function initLayout() {
$("#J_wkitUserInfo").hide();
$("#J_wkitPluginFrameWrap").css("height", "100%;");
$("#J_wkitPluginFrameWrap").css("margin", "0 0 0 0");
}
</script>
</html>

@ -1,20 +1,135 @@
<html>
<!--[if lt IE 9]>
<meta charset="utf-8" />
<meta charset="utf-8"/>
<script src="https://g.alicdn.com/aliww/ww/json/json.js" charset="utf-8"></script>
<![endif]-->
<!-- 自动适配移动端与pc端 -->
<script src="https://g.alicdn.com/aliww/h5.openim.sdk/1.0.6/scripts/wsdk.js" charset="UTF-8"></script>
<script src="https://g.alicdn.com/aliww/h5.openim.sdk/1.0.6/scripts/wsdk.js"
charset="UTF-8"></script>
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<style>
li {
float: left;
list-style-type: none;
transition: background-color .1s;
margin-bottom: 13px;
width: 100%;
}
ul {
padding: 0;
}
.search-div{
height: 3%;
}
.search-div input{
background: #D8D8D8;
border-radius: 5px;
}
.hover {
color: black;
background-color: rgba(255, 255, 255, 0.03);
}
.active {
color: red;
background-color: rgba(255, 255, 255, 0.1);
}
.avatar {
border-radius: 2px;
}
.headimg {
float: left;
border-radius: 50%;
width: 25px;
height: 25px;
border: 1px solid #000;
border-radius: 50%;
background-position: center;
background-attachment: inherit;
}
.headimg-img {
width: 10px;
}
.avatar {
margin-top: 8px;
padding-left: 27px;
}
.notice {
width: 15px;
height: 15px;
line-height: 15px;
font-size: 10px;
color: #fff;
text-align: center;
background-color: #f00;
border-radius: 50%;
position: relative;
right: -16px;
top: -7px;
}
</style>
<script>
var unreadMap = {};
function searchContact() {
var uid = $('#searchText').val()
var searchContactList={};
for(var key in unreadMap){
if(key.search(uid)>-1){
searchContactList[key] = unreadMap[key];
}
}
showContactList(searchContactList);
}
function loadContactList() {
function loadContactList(uids) {
var param = {userNames: uids};
$.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++) {
unreadMap[resp[i].nick].headimg = resp[i].headimg;
}
showContactList(unreadMap);
}
})
};
function showContactList(map) {
var contact_list = '';
for (var key in unreadMap) {
for (var key in map) {
var css = 'hover';
if (key == parent.window.uid) {
css = 'active';
}
var headImUrl = '';
if (unreadMap[key].headimg) {
headImUrl = unreadMap[key].headimg;
} else {
headImUrl = "/static/images/act/encourage_money/default_headimg.png";
}
contact_list +=
"<li onclick=switchToUser('" + key + "')>" + key + ":" + unreadMap[key] + "</li>";
"<li " + " class=\"" + css + "\" onclick=switchToUser('" + key
+ "')>"
+ "<div class=\"headimg\" style='background-image:url(" + headImUrl
+ "')>"
+ "<div class=\"notice\">" + unreadMap[key].msgCount + "</div>"
+ "</div>"
+ "<div class=\"avatar\">" + key + "</div>"
+ "</li>"
}
$("#contact_list").html(contact_list);
}
@ -22,10 +137,15 @@
function switchToUser(touid) {
parent.switchTouid(touid);
}
</script>
<body>
<ul id="contact_list">
</ul>
<div class="search-div">
<input id="searchText" type="text" onchange="searchContact()">
</div>
<div class="list">
<ul id="contact_list">
</ul>
</div>
</body>
</html>
Loading…
Cancel
Save