mirror of
https://github.com/chatopera/cosin.git
synced 2025-06-16 18:30:03 +08:00
https://gitee.com/cskefu/cskefu/issues/I836RO enable billing for agentuser resources
Signed-off-by: Hai Liang Wang <hai@chatopera.com>
This commit is contained in:
parent
a14671b70d
commit
8c0448f7fc
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
/*
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
* License, Version 1.0 (the "License"), https://docs.cskefu.com/licenses/v1.html
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright (C) 2019-2022 Chatopera Inc, <https://www.chatopera.com>,
|
||||
* Licensed under the Apache License, Version 2.0,
|
||||
* Copyright (C) 2019-2022 Chatopera Inc, <https://www.chatopera.com>,
|
||||
* Licensed under the Apache License, Version 2.0,
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
@ -22,12 +22,14 @@ import com.cskefu.cc.cache.Cache;
|
||||
import com.cskefu.cc.model.AgentUser;
|
||||
import com.cskefu.cc.model.AgentUserContacts;
|
||||
import com.cskefu.cc.model.Contacts;
|
||||
import com.cskefu.cc.model.ExecuteResult;
|
||||
import com.cskefu.cc.persistence.repository.ContactsRepository;
|
||||
import com.cskefu.cc.persistence.repository.AgentUserContactsRepository;
|
||||
import com.cskefu.cc.proxy.AgentStatusProxy;
|
||||
import com.cskefu.cc.proxy.AgentUserProxy;
|
||||
import com.chatopera.compose4j.Functional;
|
||||
import com.chatopera.compose4j.Middleware;
|
||||
import com.cskefu.cc.proxy.LicenseProxy;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -62,6 +64,9 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
|
||||
@Autowired
|
||||
private ACDMessageHelper acdMessageHelper;
|
||||
|
||||
@Autowired
|
||||
private LicenseProxy licenseProxy;
|
||||
|
||||
/**
|
||||
* 设置AgentUser基本信息
|
||||
*
|
||||
@ -87,6 +92,16 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
|
||||
ctx.getOnlineUserId(),
|
||||
ctx.getOnlineUserNickname(),
|
||||
ctx.getAppid());
|
||||
|
||||
// 执行计费逻辑
|
||||
ExecuteResult writeDownResult = licenseProxy.writeDownAgentUserUsageInStore(p);
|
||||
|
||||
if (writeDownResult.getRc() != ExecuteResult.RC_SUCC) {
|
||||
// 配额操作失败,提示座席
|
||||
p.setLicenseVerifiedPass(false);
|
||||
p.setLicenseBillingMsg(writeDownResult.getMsg());
|
||||
}
|
||||
|
||||
logger.info("[apply] create new agent user id {}", p.getId());
|
||||
return p;
|
||||
});
|
||||
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
/*
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
* License, Version 1.0 (the "License"), https://docs.cskefu.com/licenses/v1.html
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright (C) 2019-2022 Chatopera Inc, <https://www.chatopera.com>,
|
||||
* Licensed under the Apache License, Version 2.0,
|
||||
* Copyright (C) 2019-2022 Chatopera Inc, <https://www.chatopera.com>,
|
||||
* Licensed under the Apache License, Version 2.0,
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
@ -18,14 +18,17 @@ import com.cskefu.cc.basic.MainContext;
|
||||
import com.cskefu.cc.cache.Cache;
|
||||
import com.cskefu.cc.cache.RedisCommand;
|
||||
import com.cskefu.cc.cache.RedisKey;
|
||||
import com.cskefu.cc.exception.BillingResourceException;
|
||||
import com.cskefu.cc.model.AgentUser;
|
||||
import com.cskefu.cc.proxy.AgentAuditProxy;
|
||||
import com.cskefu.cc.proxy.LicenseProxy;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.After;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -51,6 +54,31 @@ public class AgentUserAspect {
|
||||
@Autowired
|
||||
private AgentAuditProxy agentAuditProxy;
|
||||
|
||||
@Autowired
|
||||
private LicenseProxy licenseProxy;
|
||||
|
||||
@Before("execution(* com.cskefu.cc.persistence.repository.AgentUserRepository.save(..))")
|
||||
public void beforeSave(final JoinPoint joinPoint) {
|
||||
final AgentUser agentUser = (AgentUser) joinPoint.getArgs()[0];
|
||||
|
||||
if (StringUtils.isBlank(agentUser.getId())) {
|
||||
logger.info("[beforeSave] agentUser id is blank");
|
||||
|
||||
if (StringUtils.isNotBlank(agentUser.getOpttype()) && StringUtils.equals(MainContext.OptType.CHATBOT.toString(), agentUser.getOpttype())) {
|
||||
// 机器人座席支持的对话,跳过计数
|
||||
agentUser.setLicenseVerifiedPass(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 计数加一
|
||||
try {
|
||||
licenseProxy.increResourceUsageInMetaKv(MainContext.BillingResource.AGENGUSER, 1);
|
||||
} catch (BillingResourceException e) {
|
||||
logger.error("[beforeSave] error", e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@After("execution(* com.cskefu.cc.persistence.repository.AgentUserRepository.save(..))")
|
||||
public void save(final JoinPoint joinPoint) {
|
||||
final AgentUser agentUser = (AgentUser) joinPoint.getArgs()[0];
|
||||
|
@ -71,9 +71,6 @@ public class AgentAuditController extends Handler {
|
||||
@Autowired
|
||||
private UserRepository userRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRepository;
|
||||
|
||||
@Autowired
|
||||
private ChatMessageRepository chatMessageRepository;
|
||||
|
||||
@ -245,7 +242,7 @@ public class AgentAuditController extends Handler {
|
||||
view.addObject(
|
||||
"agentUserList", agentUserRes.findByStatusAndAgentnoIsNot(
|
||||
MainContext.AgentUserStatusEnum.INSERVICE.toString(), logined.getId(), defaultSort));
|
||||
List<AgentUser> agentUserList = agentUserRepository.findByUserid(userid);
|
||||
List<AgentUser> agentUserList = agentUserRes.findByUserid(userid);
|
||||
view.addObject(
|
||||
"curagentuser", agentUserList != null && agentUserList.size() > 0 ? agentUserList.get(0) : null);
|
||||
|
||||
@ -266,7 +263,7 @@ public class AgentAuditController extends Handler {
|
||||
}
|
||||
ModelAndView view = request(super.createView(mainagentuser));
|
||||
final User logined = super.getUser(request);
|
||||
AgentUser agentUser = agentUserRepository.findById(id).orElse(null);
|
||||
AgentUser agentUser = agentUserRes.findById(id).orElse(null);
|
||||
|
||||
if (agentUser != null) {
|
||||
view.addObject("curagentuser", agentUser);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -117,7 +117,7 @@ public class IMController extends Handler {
|
||||
private LeaveMsgRepository leaveMsgRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRepository;
|
||||
private AgentUserRepository agentUserRes;
|
||||
|
||||
@Autowired
|
||||
private AttachmentRepository attachementRes;
|
||||
@ -822,7 +822,7 @@ public class IMController extends Handler {
|
||||
Contacts contacts1 = contactsRes.findOneByWluidAndWlsidAndWlcidAndDatastatus(
|
||||
uid, sid, cid, false);
|
||||
if (contacts1 != null) {
|
||||
agentUserRepository.findOneByUserid(userid).ifPresent(p -> {
|
||||
agentUserRes.findOneByUserid(userid).ifPresent(p -> {
|
||||
// 关联AgentService的联系人
|
||||
if (StringUtils.isNotBlank(p.getAgentserviceid())) {
|
||||
AgentService agentService = agentServiceRepository.findById(p.getAgentserviceid()).orElse(null);
|
||||
|
@ -77,9 +77,6 @@ public class ChatServiceController extends Handler {
|
||||
@Autowired
|
||||
private AgentStatusRepository agentStatusRepository;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRepository;
|
||||
|
||||
@Autowired
|
||||
private LeaveMsgRepository leaveMsgRes;
|
||||
|
||||
@ -233,7 +230,7 @@ public class ChatServiceController extends Handler {
|
||||
if (agentUser != null) {
|
||||
agentUser.setAgentno(agentno);
|
||||
agentUser.setAgentname(targetAgent.getUname());
|
||||
agentUserRepository.save(agentUser);
|
||||
agentUserRes.save(agentUser);
|
||||
if (MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(
|
||||
agentUser.getStatus())) {
|
||||
// 转接 , 发送消息给 目标坐席
|
||||
@ -288,11 +285,11 @@ public class ChatServiceController extends Handler {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
agentUser = agentUserRepository.findById(agentService.getAgentuserid()).orElse(null);
|
||||
agentUser = agentUserRes.findById(agentService.getAgentuserid()).orElse(null);
|
||||
if (agentUser != null) {
|
||||
agentUser.setAgentno(agentno);
|
||||
agentUser.setAgentname(targetAgent.getUname());
|
||||
agentUserRepository.save(agentUser);
|
||||
agentUserRes.save(agentUser);
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,7 +314,7 @@ public class ChatServiceController extends Handler {
|
||||
AgentService agentService = agentServiceRes.findById(id).orElse(null);
|
||||
if (agentService != null) {
|
||||
User user = super.getUser(request);
|
||||
AgentUser agentUser = agentUserRepository.findById(agentService.getAgentuserid()).orElse(null);
|
||||
AgentUser agentUser = agentUserRes.findById(agentService.getAgentuserid()).orElse(null);
|
||||
if (agentUser != null) {
|
||||
acdAgentService.finishAgentUser(agentUser);
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
* License, Version 1.0 (the "License"), https://docs.cskefu.com/licenses/v1.html
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright (C) 2018- Jun. 2023 Chatopera Inc, <https://www.chatopera.com>, Licensed under the Apache License, Version 2.0,
|
||||
* Copyright (C) 2018- Jun. 2023 Chatopera Inc, <https://www.chatopera.com>, Licensed under the Apache License, Version 2.0,
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统, Licensed under the Apache License, Version 2.0,
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统, Licensed under the Apache License, Version 2.0,
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package com.cskefu.cc.model;
|
||||
@ -19,6 +19,7 @@ import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@ -105,6 +106,7 @@ public class AgentUser implements Serializable, Comparable<AgentUser> {
|
||||
|
||||
@Transient
|
||||
private boolean tip = false;
|
||||
|
||||
@Transient
|
||||
private boolean agentTip = false;
|
||||
|
||||
@ -119,11 +121,25 @@ public class AgentUser implements Serializable, Comparable<AgentUser> {
|
||||
|
||||
@Transient
|
||||
private boolean fromhis = false;
|
||||
|
||||
@Transient
|
||||
private boolean online = false;
|
||||
|
||||
@Transient
|
||||
private boolean disconnect = false;
|
||||
|
||||
/**
|
||||
* 证书验证通过
|
||||
*/
|
||||
@Transient
|
||||
private boolean licenseVerifiedPass = true;
|
||||
|
||||
/**
|
||||
* 证书验证提示信息
|
||||
*/
|
||||
@Transient
|
||||
private String licenseBillingMsg;
|
||||
|
||||
|
||||
public AgentUser() {
|
||||
}
|
||||
@ -617,4 +633,22 @@ public class AgentUser implements Serializable, Comparable<AgentUser> {
|
||||
public void setAgentname(String agentname) {
|
||||
this.agentname = agentname;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public boolean isLicenseVerifiedPass() {
|
||||
return licenseVerifiedPass;
|
||||
}
|
||||
|
||||
public void setLicenseVerifiedPass(boolean licenseVerifiedPass) {
|
||||
this.licenseVerifiedPass = licenseVerifiedPass;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public String getLicenseBillingMsg() {
|
||||
return licenseBillingMsg;
|
||||
}
|
||||
|
||||
public void setLicenseBillingMsg(String licenseBillingMsg) {
|
||||
this.licenseBillingMsg = licenseBillingMsg;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
/*
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
* License, Version 1.0 (the "License"), https://docs.cskefu.com/licenses/v1.html
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright (C) 2019-2022 Chatopera Inc, <https://www.chatopera.com>,
|
||||
* Licensed under the Apache License, Version 2.0,
|
||||
* Copyright (C) 2019-2022 Chatopera Inc, <https://www.chatopera.com>,
|
||||
* Licensed under the Apache License, Version 2.0,
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package com.cskefu.cc.proxy;
|
||||
@ -34,6 +34,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@ -96,6 +97,8 @@ public class AgentUserProxy {
|
||||
@Lazy
|
||||
private PeerSyncIM peerSyncIM;
|
||||
|
||||
@Autowired
|
||||
private LicenseProxy licenseProxy;
|
||||
|
||||
/**
|
||||
* 与联系人主动聊天前查找获取AgentUser
|
||||
|
@ -19,6 +19,7 @@ import com.cskefu.cc.basic.Constants;
|
||||
import com.cskefu.cc.basic.MainContext;
|
||||
import com.cskefu.cc.basic.MainUtils;
|
||||
import com.cskefu.cc.exception.*;
|
||||
import com.cskefu.cc.model.AgentUser;
|
||||
import com.cskefu.cc.model.ExecuteResult;
|
||||
import com.cskefu.cc.model.MetaKv;
|
||||
import com.cskefu.cc.persistence.repository.MetaKvRepository;
|
||||
@ -511,5 +512,33 @@ public class LicenseProxy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 访客会话执行计费
|
||||
*
|
||||
* @param agentUser
|
||||
* @return
|
||||
*/
|
||||
public ExecuteResult writeDownAgentUserUsageInStore(final AgentUser agentUser) {
|
||||
// 检查是否还在体验阶段
|
||||
ExecuteResult er = new ExecuteResult();
|
||||
int alreadyUsed = getResourceUsageInMetaKv(MainContext.BillingResource.AGENGUSER);
|
||||
if (alreadyUsed <= 100) {
|
||||
// 可以免费创建 100 个访客会话
|
||||
er.setRc(ExecuteResult.RC_SUCC);
|
||||
return er;
|
||||
}
|
||||
|
||||
try {
|
||||
writeDownResourceUsageInStore(MainContext.BillingResource.AGENGUSER, 1);
|
||||
er.setRc(ExecuteResult.RC_SUCC);
|
||||
} catch (BillingQuotaException e) {
|
||||
er.setRc(ExecuteResult.RC_ERR1);
|
||||
er.setMsg(e.getMessage());
|
||||
} catch (BillingResourceException e) {
|
||||
er.setRc(ExecuteResult.RC_ERR2);
|
||||
er.setMsg(e.getMessage());
|
||||
}
|
||||
|
||||
return er;
|
||||
}
|
||||
}
|
||||
|
@ -11,196 +11,203 @@
|
||||
* Licensed under the Apache License, Version 2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
var title = "春松客服-开源客服系统" ;
|
||||
var socket , newuser = [] , newmessage = [] , ring = [];
|
||||
newuser['mp3'] = '/images/new.mp3';
|
||||
var title = "春松客服-开源客服系统";
|
||||
var socket, newuser = [], newmessage = [], ring = [];
|
||||
newuser['mp3'] = '/images/new.mp3';
|
||||
newmessage['mp3'] = '/images/message.mp3';
|
||||
ring['mp3'] = '/images/ring.mp3';
|
||||
$(document).ready(function(){
|
||||
var protocol = window.location.protocol.replace(/:/g,'');
|
||||
socket = io(protocol+'://'+hostname+':'+port+"/im/agent?userid="+userid+"&session="+session+"&admin="+adminuser , {transports: ['websocket'], upgrade: false});
|
||||
socket.on('connect',function() {
|
||||
console.log("[IM] 连接初始化成功");
|
||||
//请求服务端记录 当前用户在线事件
|
||||
}).on('disconnect',function() {
|
||||
console.log("[IM] 连接已断开");
|
||||
//请求服务端记录,当前用户离线
|
||||
$(document).ready(function () {
|
||||
var protocol = window.location.protocol.replace(/:/g, '');
|
||||
socket = io(protocol + '://' + hostname + ':' + port + "/im/agent?userid=" + userid + "&session=" + session + "&admin=" + adminuser, {
|
||||
transports: ['websocket'],
|
||||
upgrade: false
|
||||
});
|
||||
socket.on('connect', function () {
|
||||
console.log("[IM] 连接初始化成功");
|
||||
//请求服务端记录 当前用户在线事件
|
||||
}).on('disconnect', function () {
|
||||
console.log("[IM] 连接已断开");
|
||||
//请求服务端记录,当前用户离线
|
||||
});
|
||||
|
||||
socket.on('chatevent', function(data) {
|
||||
// console.log(data.messageType + " ..... message:"+data.message);
|
||||
}).on('task', function(data) {
|
||||
|
||||
}).on('new', function(data) {
|
||||
if($('#customerChatAudit').length > 0){
|
||||
if(customerChatAudit.$('#agentuser_' + data.userid).length > 0 && customerChatAudit.$("#chat_users li").length>1){
|
||||
customerChatAudit.$('#agentuser_' + data.userid).remove();
|
||||
customerChatAudit.$("#chat_users li:first-child a").click();
|
||||
}else{
|
||||
customerChatAudit.$('#ccaIndex').html("<div class=\"layui-layout layui-layout-content\" style=\"height: 100%;\">\n" +
|
||||
" <div class=\"box default-box\" style=\"height: 100%;\">\n" +
|
||||
" <div class=\"box-body ukefu-im-theme\">\n" +
|
||||
" <div class=\"ukefu-empty\" style=\"background: none\">\n" +
|
||||
" <i class=\"layui-icon\"></i>\n" +
|
||||
" <div style=\"\">还没有任何对话</div>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
"</div>");
|
||||
}
|
||||
}
|
||||
if($('#multiMediaDialogWin').length > 0 && multiMediaDialogWin != null && multiMediaDialogWin.$ &&multiMediaDialogWin.$('#agentusers').length > 0){
|
||||
multiMediaDialogWin.Proxy.newAgentUserService(data,"agent");
|
||||
}else{
|
||||
//来电弹屏
|
||||
$('#agentdesktop').attr('data-href' , '/agent/index.html?userid='+data.userid).click();
|
||||
WebIM.audioplayer('audioplane', newuser, false); // 播放
|
||||
}
|
||||
}).on('status', function(data) {
|
||||
$.post('/lazyAgentStatus').success(function(html){
|
||||
$('#agents_status').html(html);
|
||||
});
|
||||
// $('#agents_status').html("服务中的人数:"+data.users+"人,当前排队人数:"+data.inquene+"人,在线坐席数:"+data.agents+"人,坐席忙:"+data.busy+"人");
|
||||
}).on('message', function(data) {
|
||||
if($('#multiMediaDialogWin').length > 0 && multiMediaDialogWin != null && multiMediaDialogWin.$ && multiMediaDialogWin.$('#agentusers').length > 0){
|
||||
multiMediaDialogWin.Proxy.newAgentUserMessage(data,"agent");
|
||||
if(data.type == 'message'){
|
||||
WebIM.audioplayer('audioplane', newmessage, false); // 播放
|
||||
if(multiMediaDialogWin.isAisuggest && multiMediaDialogWin.isAisuggest == "true"){
|
||||
multiMediaDialogWin.Proxy.quickReply(data,"agent");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//来电弹屏
|
||||
$('#agentdesktop').attr('data-href' , '/agent/index.html?userid='+data.userid).click();
|
||||
}
|
||||
}).on('workorder', function(data) {
|
||||
|
||||
}).on('transout', function(data){
|
||||
// TODO 坐席会话被转接出去
|
||||
if($('#multiMediaDialogWin').length > 0){
|
||||
if(multiMediaDialogWin.document.getElementById('agentusers') != null){
|
||||
multiMediaDialogWin.Proxy.transoutAgentUserService(data);
|
||||
}
|
||||
}
|
||||
layer.msg("您与"+data.username+"的会话已被转接给"+data.agentname,{time:1500})
|
||||
socket.on('chatevent', function (data) {
|
||||
// console.log(data.messageType + " ..... message:"+data.message);
|
||||
}).on('task', function (data) {
|
||||
}).on('new', function (data) {
|
||||
console.log("new data ...", data);
|
||||
if ($('#customerChatAudit').length > 0) {
|
||||
if (customerChatAudit.$('#agentuser_' + data.userid).length > 0 && customerChatAudit.$("#chat_users li").length > 1) {
|
||||
customerChatAudit.$('#agentuser_' + data.userid).remove();
|
||||
customerChatAudit.$("#chat_users li:first-child a").click();
|
||||
} else {
|
||||
customerChatAudit.$('#ccaIndex').html("<div class=\"layui-layout layui-layout-content\" style=\"height: 100%;\">\n" +
|
||||
" <div class=\"box default-box\" style=\"height: 100%;\">\n" +
|
||||
" <div class=\"box-body ukefu-im-theme\">\n" +
|
||||
" <div class=\"ukefu-empty\" style=\"background: none\">\n" +
|
||||
" <i class=\"layui-icon\"></i>\n" +
|
||||
" <div style=\"\">还没有任何对话</div>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
"</div>");
|
||||
}
|
||||
}
|
||||
|
||||
}).on('audit_message', function(data){
|
||||
// 会话监控:消息
|
||||
if($('#customerChatAudit').length > 0 && customerChatAudit != null && customerChatAudit.$ && customerChatAudit.$('#agentuserscca').length > 0){
|
||||
customerChatAudit.Proxy.newAgentUserMessage(data,"cca");
|
||||
if(data.type == 'message'){
|
||||
WebIM.audioplayer('audioplane', newmessage, false); // 播放
|
||||
if(customerChatAudit.isCcaAisuggest && customerChatAudit.isCcaAisuggest == "true"){
|
||||
customerChatAudit.Proxy.quickReply(data,"cca");
|
||||
}
|
||||
}
|
||||
}
|
||||
}).on('audit_new', function(data){
|
||||
// 会话监控:新建
|
||||
if(skills.indexOf(data.skill)>-1 && $('#customerChatAudit').length > 0 && customerChatAudit != null && customerChatAudit.$){
|
||||
customerChatAudit.Proxy.newAgentUserService(data,"cca");
|
||||
if(data.type == 'message'){
|
||||
WebIM.audioplayer('audioplane', newmessage, false); // 播放
|
||||
}
|
||||
}
|
||||
}).on('audit_end', function(data){
|
||||
// 会话监控:结束
|
||||
if($('#customerChatAudit').length > 0){
|
||||
if(customerChatAudit.document.getElementById('agentuserscca') != null){
|
||||
customerChatAudit.Proxy.endAgentUserService(data);
|
||||
}
|
||||
}
|
||||
}).on('end', function(data) {
|
||||
console.warn(111111, data)
|
||||
if($('#multiMediaDialogWin').length > 0){
|
||||
if(multiMediaDialogWin.document.getElementById('agentusers') != null){
|
||||
multiMediaDialogWin.Proxy.endAgentUserService(data);
|
||||
}
|
||||
}else{
|
||||
//来电弹屏
|
||||
$('#agentdesktop').attr('data-href', '/agent/index.html?userid='+data.userid).click();
|
||||
}
|
||||
}).on('leave', function(data){
|
||||
top.layer.msg('当前会话已经过期,稍后将自动登出!',{icon: 1, time: 2000});
|
||||
setTimeout(function(){
|
||||
// 执行登出
|
||||
window.location.href = "/logout.html?code=2";
|
||||
}, 2000);
|
||||
});
|
||||
/****每分钟执行一次,与服务器交互,保持会话****/
|
||||
setInterval(function(){
|
||||
WebIM.ping();
|
||||
} , 60000);
|
||||
if ($('#multiMediaDialogWin').length > 0 &&
|
||||
multiMediaDialogWin != null &&
|
||||
multiMediaDialogWin.$ &&
|
||||
multiMediaDialogWin.$('#agentusers').length > 0) {
|
||||
multiMediaDialogWin.Proxy.newAgentUserService(data, "agent");
|
||||
} else {
|
||||
//来电弹屏
|
||||
$('#agentdesktop').attr('data-href', '/agent/index.html?userid=' + data.userid + '&licenseVerifiedPass=' + data.licenseVerifiedPass + '&licenseBillingMsg=' + data.licenseBillingMsg).click();
|
||||
WebIM.audioplayer('audioplane', newuser, false); // 播放
|
||||
}
|
||||
}).on('status', function (data) {
|
||||
$.post('/lazyAgentStatus').success(function (html) {
|
||||
$('#agents_status').html(html);
|
||||
});
|
||||
// $('#agents_status').html("服务中的人数:"+data.users+"人,当前排队人数:"+data.inquene+"人,在线坐席数:"+data.agents+"人,坐席忙:"+data.busy+"人");
|
||||
}).on('message', function (data) {
|
||||
if ($('#multiMediaDialogWin').length > 0 && multiMediaDialogWin != null && multiMediaDialogWin.$ && multiMediaDialogWin.$('#agentusers').length > 0) {
|
||||
multiMediaDialogWin.Proxy.newAgentUserMessage(data, "agent");
|
||||
if (data.type == 'message') {
|
||||
WebIM.audioplayer('audioplane', newmessage, false); // 播放
|
||||
if (multiMediaDialogWin.isAisuggest && multiMediaDialogWin.isAisuggest == "true") {
|
||||
multiMediaDialogWin.Proxy.quickReply(data, "agent");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//来电弹屏
|
||||
$('#agentdesktop').attr('data-href', '/agent/index.html?userid=' + data.userid).click();
|
||||
}
|
||||
}).on('workorder', function (data) {
|
||||
|
||||
}).on('transout', function (data) {
|
||||
// TODO 坐席会话被转接出去
|
||||
if ($('#multiMediaDialogWin').length > 0) {
|
||||
if (multiMediaDialogWin.document.getElementById('agentusers') != null) {
|
||||
multiMediaDialogWin.Proxy.transoutAgentUserService(data);
|
||||
}
|
||||
}
|
||||
layer.msg("您与" + data.username + "的会话已被转接给" + data.agentname, {time: 1500})
|
||||
|
||||
}).on('audit_message', function (data) {
|
||||
// 会话监控:消息
|
||||
if ($('#customerChatAudit').length > 0 && customerChatAudit != null && customerChatAudit.$ && customerChatAudit.$('#agentuserscca').length > 0) {
|
||||
customerChatAudit.Proxy.newAgentUserMessage(data, "cca");
|
||||
if (data.type == 'message') {
|
||||
WebIM.audioplayer('audioplane', newmessage, false); // 播放
|
||||
if (customerChatAudit.isCcaAisuggest && customerChatAudit.isCcaAisuggest == "true") {
|
||||
customerChatAudit.Proxy.quickReply(data, "cca");
|
||||
}
|
||||
}
|
||||
}
|
||||
}).on('audit_new', function (data) {
|
||||
// 会话监控:新建
|
||||
if (skills.indexOf(data.skill) > -1 && $('#customerChatAudit').length > 0 && customerChatAudit != null && customerChatAudit.$) {
|
||||
customerChatAudit.Proxy.newAgentUserService(data, "cca");
|
||||
if (data.type == 'message') {
|
||||
WebIM.audioplayer('audioplane', newmessage, false); // 播放
|
||||
}
|
||||
}
|
||||
}).on('audit_end', function (data) {
|
||||
// 会话监控:结束
|
||||
if ($('#customerChatAudit').length > 0) {
|
||||
if (customerChatAudit.document.getElementById('agentuserscca') != null) {
|
||||
customerChatAudit.Proxy.endAgentUserService(data);
|
||||
}
|
||||
}
|
||||
}).on('end', function (data) {
|
||||
console.warn(111111, data)
|
||||
if ($('#multiMediaDialogWin').length > 0) {
|
||||
if (multiMediaDialogWin.document.getElementById('agentusers') != null) {
|
||||
multiMediaDialogWin.Proxy.endAgentUserService(data);
|
||||
}
|
||||
} else {
|
||||
//来电弹屏
|
||||
$('#agentdesktop').attr('data-href', '/agent/index.html?userid=' + data.userid).click();
|
||||
}
|
||||
}).on('leave', function (data) {
|
||||
top.layer.msg('当前会话已经过期,稍后将自动登出!', {icon: 1, time: 2000});
|
||||
setTimeout(function () {
|
||||
// 执行登出
|
||||
window.location.href = "/logout.html?code=2";
|
||||
}, 2000);
|
||||
});
|
||||
/****每分钟执行一次,与服务器交互,保持会话****/
|
||||
setInterval(function () {
|
||||
WebIM.ping();
|
||||
}, 60000);
|
||||
});
|
||||
|
||||
var WebIM = {
|
||||
sendMessage:function(message , userid , appid , session , touser , agentstatus, agentuserid){
|
||||
WebIM.sendTypeMessage(message, userid, appid, session, touser, agentstatus, null , null,agentuserid) ;
|
||||
},
|
||||
sendTypeMessage:function(message , userid , appid , session , touser , agentstatus , msgtype , attachmentid,agentuserid){
|
||||
socket.emit('message', {
|
||||
appid : appid ,
|
||||
userid:userid,
|
||||
sign:session,
|
||||
touser:touser,
|
||||
session: session,
|
||||
username:agentstatus,
|
||||
nickname:agentstatus,
|
||||
message : message,
|
||||
msgtype:msgtype,
|
||||
attachmentid:attachmentid,
|
||||
agentuser:agentuserid
|
||||
sendMessage: function (message, userid, appid, session, touser, agentstatus, agentuserid) {
|
||||
WebIM.sendTypeMessage(message, userid, appid, session, touser, agentstatus, null, null, agentuserid);
|
||||
},
|
||||
sendTypeMessage: function (message, userid, appid, session, touser, agentstatus, msgtype, attachmentid, agentuserid) {
|
||||
socket.emit('message', {
|
||||
appid: appid,
|
||||
userid: userid,
|
||||
sign: session,
|
||||
touser: touser,
|
||||
session: session,
|
||||
username: agentstatus,
|
||||
nickname: agentstatus,
|
||||
message: message,
|
||||
msgtype: msgtype,
|
||||
attachmentid: attachmentid,
|
||||
agentuser: agentuserid
|
||||
});
|
||||
},
|
||||
// 发送会话监控干预消息
|
||||
sendIntervention: function(supervisorid, agentuserid, session, msgtype, content, extra){
|
||||
socket.emit('intervention', {
|
||||
supervisorid: supervisorid, // 坐席监控人员ID,必须
|
||||
agentuserid: agentuserid, // 坐席访客会话ID,必须
|
||||
msgtype: msgtype, // 干预消息类型, 必须
|
||||
content: content, // 干预消息内容, 必须
|
||||
session: session, // 登录会话ID
|
||||
extra: extra // 其它可选属性, 可选
|
||||
});
|
||||
},
|
||||
ping : function(){
|
||||
loadURL("/message/ping.html");
|
||||
console.log("[IM] heartbeat:" + new Date().getTime());
|
||||
},
|
||||
audioplayer:function(id, file, loop) {
|
||||
var audioplayer = document.getElementById(id);
|
||||
if (audioplayer != null) {
|
||||
document.body.removeChild(audioplayer);
|
||||
}
|
||||
},
|
||||
// 发送会话监控干预消息
|
||||
sendIntervention: function (supervisorid, agentuserid, session, msgtype, content, extra) {
|
||||
socket.emit('intervention', {
|
||||
supervisorid: supervisorid, // 坐席监控人员ID,必须
|
||||
agentuserid: agentuserid, // 坐席访客会话ID,必须
|
||||
msgtype: msgtype, // 干预消息类型, 必须
|
||||
content: content, // 干预消息内容, 必须
|
||||
session: session, // 登录会话ID
|
||||
extra: extra // 其它可选属性, 可选
|
||||
});
|
||||
},
|
||||
ping: function () {
|
||||
loadURL("/message/ping.html");
|
||||
console.log("[IM] heartbeat:" + new Date().getTime());
|
||||
},
|
||||
audioplayer: function (id, file, loop) {
|
||||
var audioplayer = document.getElementById(id);
|
||||
if (audioplayer != null) {
|
||||
document.body.removeChild(audioplayer);
|
||||
}
|
||||
|
||||
if (typeof(file) != 'undefined') {
|
||||
if (navigator.userAgent.indexOf("MSIE") > 0) { // IE
|
||||
var player = document.createElement('bgsound');
|
||||
player.id = id;
|
||||
player.src = file['mp3'];
|
||||
player.setAttribute('autostart', 'true');
|
||||
if (loop) {
|
||||
player.setAttribute('loop', 'infinite');
|
||||
}
|
||||
document.body.appendChild(player);
|
||||
if (typeof (file) != 'undefined') {
|
||||
if (navigator.userAgent.indexOf("MSIE") > 0) { // IE
|
||||
var player = document.createElement('bgsound');
|
||||
player.id = id;
|
||||
player.src = file['mp3'];
|
||||
player.setAttribute('autostart', 'true');
|
||||
if (loop) {
|
||||
player.setAttribute('loop', 'infinite');
|
||||
}
|
||||
document.body.appendChild(player);
|
||||
|
||||
} else { // Other FF Chome Safari Opera
|
||||
var player = document.createElement('audio');
|
||||
player.id = id;
|
||||
player.setAttribute('autoplay', 'autoplay');
|
||||
if (loop) {
|
||||
player.setAttribute('loop', 'loop');
|
||||
}
|
||||
document.body.appendChild(player);
|
||||
} else { // Other FF Chome Safari Opera
|
||||
var player = document.createElement('audio');
|
||||
player.id = id;
|
||||
player.setAttribute('autoplay', 'autoplay');
|
||||
if (loop) {
|
||||
player.setAttribute('loop', 'loop');
|
||||
}
|
||||
document.body.appendChild(player);
|
||||
|
||||
var mp3 = document.createElement('source');
|
||||
mp3.src = file['mp3'];
|
||||
mp3.type = 'audio/mpeg';
|
||||
player.appendChild(mp3);
|
||||
}
|
||||
}
|
||||
}
|
||||
var mp3 = document.createElement('source');
|
||||
mp3.src = file['mp3'];
|
||||
mp3.type = 'audio/mpeg';
|
||||
player.appendChild(mp3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -343,22 +343,23 @@ function newMessageScorllBottom(type, msgType) {
|
||||
|
||||
var Proxy = {
|
||||
newAgentUserService: function (data, type) {
|
||||
console.log("newAgentUserService data type", data, type)
|
||||
if ($('#tip_message_' + data.userid).length > 0) {
|
||||
var channel = data.channeltype
|
||||
if (channel) {
|
||||
if (channel === 'phone') {
|
||||
$('#tip_icon_phone_' + data.userid).attr("src", "/images/phone-ico.png");
|
||||
} else {
|
||||
$('#tip_icon_' +channel+ '_' + data.userid).removeClass('ukefu-channel-icon-end').addClass("ukefu-channel-icon");
|
||||
$('#tip_icon_' + channel + '_' + data.userid).removeClass('ukefu-channel-icon-end').addClass("ukefu-channel-icon");
|
||||
}
|
||||
}
|
||||
$('#tip_message_' + data.userid).removeClass('bg-gray').addClass("bg-green").text('在线');
|
||||
} else {
|
||||
if ($('.chat-list-item.active').length > 0) {
|
||||
var id = $('.chat-list-item.active').data('id');
|
||||
type == "agent" ? loadURL('/agent/agentusers.html?newuser=true&userid=' + id, '#agentusers') : loadURL('/apps/cca/agentusers.html?newuser=true&userid=' + id, '#agentuserscca');
|
||||
type == "agent" ? loadURL('/agent/agentusers.html?newuser=true&userid=' + id + '&licenseVerifiedPass=' + data.licenseVerifiedPass + '&licenseBillingMsg=' + data.licenseBillingMsg, '#agentusers') : loadURL('/apps/cca/agentusers.html?newuser=true&userid=' + id + "&licenseVerifiedPass=" + data.licenseVerifiedPass + "&licenseBillingMsg=" + data.licenseBillingMsg, '#agentuserscca');
|
||||
} else {
|
||||
type == "agent" ? location.href = "/agent/index.html?newuser=true" : location.href = "/apps/cca/index.html?newuser=true";
|
||||
type == "agent" ? location.href = "/agent/index.html?newuser=true&licenseVerifiedPass=" + data.licenseVerifiedPass + "&licenseBillingMsg=" + data.licenseBillingMsg : location.href = "/apps/cca/index.html?newuser=true&licenseVerifiedPass=" + data.licenseVerifiedPass + "&licenseBillingMsg=" + data.licenseBillingMsg;
|
||||
}
|
||||
}
|
||||
if (data.userid == cursession) {
|
||||
@ -485,7 +486,7 @@ var Proxy = {
|
||||
if (channel === 'phone') {
|
||||
$('#tip_icon_phone_' + data.userid).attr("src", "/images/cde-ico-gray.png");
|
||||
} else {
|
||||
$('#tip_icon_'+ channel +'_' + data.userid).removeClass("ukefu-channel-icon").addClass('ukefu-channel-icon-end');
|
||||
$('#tip_icon_' + channel + '_' + data.userid).removeClass("ukefu-channel-icon").addClass('ukefu-channel-icon-end');
|
||||
}
|
||||
}
|
||||
$('#tip_message_' + data.userid).removeClass("bg-green").addClass('bg-gray').text('离开');
|
||||
@ -504,7 +505,11 @@ var Proxy = {
|
||||
}
|
||||
},
|
||||
tipMsgForm: function (href) {
|
||||
top.layer.prompt({formType: 2, title: '请输入拉黑原因', area: ['300px', '50px']}, function (value, index, elem) {
|
||||
top.layer.prompt({
|
||||
formType: 2,
|
||||
title: '请输入拉黑原因',
|
||||
area: ['300px', '50px']
|
||||
}, function (value, index, elem) {
|
||||
location.href = href + "&description=" + encodeURIComponent(value);
|
||||
top.layer.close(index);
|
||||
});
|
||||
|
@ -80,3 +80,11 @@
|
||||
.last-msg
|
||||
small.ukefu-badge.bg-red(id="last_msg_" + agentuser.userid,style="#{(agentuser.tokenum == 0 || (curagentuser && curagentuser.id == agentuser.id)) ? 'display:none' : ''}")
|
||||
| #{agentuser.tokenum ? agentuser.tokenum : 0}
|
||||
script(language="javascript").
|
||||
$(document).ready(function () {
|
||||
var licenseVerifiedPass = #{licenseVerifiedPass};
|
||||
var licenseBillingMsg = '#{licenseBillingMsg}';
|
||||
if (licenseBillingMsg) {
|
||||
handleGeneralCodeInQueryPathOrApiResp(licenseBillingMsg);
|
||||
}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user