Commit af0eb58c authored by 罗超's avatar 罗超

新增呼叫中心

parent e7bcc1fc
......@@ -157,5 +157,15 @@ namespace Edu.Model.CacheModel
/// 班级信息
/// </summary>
public object ClassInfo { get; set; }
/// <summary>
/// 是否是电话客服
/// </summary>
public int IsTenCccUser { get; set; }
/// <summary>
/// 客服Token
/// </summary>
public object TenCccToken { get; set; }
}
}
\ No newline at end of file
......@@ -126,5 +126,10 @@ namespace Edu.Model.Entity.User
/// 用户角色(1-市场人员,2-课程顾问)
/// </summary>
public UserRoleEnum UserRole { get; set; }
/// <summary>
/// 是否是电话客服
/// </summary>
public int IsTenCccUser { get; set; }
}
}
......@@ -207,5 +207,10 @@ namespace Edu.Model.Entity.User
/// 用户角色(1-市场人员,2-课程顾问)
/// </summary>
public UserRoleEnum UserRole { get; set; }
/// <summary>
/// 是否是电话客服
/// </summary>
public int IsTenCccUser { get; set; }
}
}
\ No newline at end of file
......@@ -212,5 +212,10 @@ namespace Edu.Model.ViewModel.User
/// </summary>
public UserRoleEnum UserRole { get; set; }
/// <summary>
/// 是否是电话客服(0 不是,1 是)
/// </summary>
public int IsTenCccUser { get; set; }
}
}
......@@ -87,5 +87,10 @@ namespace Edu.Model.ViewModel.User
/// 邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 是否是电话客服
/// </summary>
public int IsTenCccUser { get; set; }
}
}
\ No newline at end of file
......@@ -116,6 +116,7 @@ namespace Edu.Module.User
{ nameof(RB_Manager_ViewModel.Education),model.Education },
{ nameof(RB_Manager_ViewModel.Email),model.Email },
{ nameof(RB_Manager_ViewModel.UserRole),model.UserRole },
{ nameof(RB_Manager_ViewModel.IsTenCccUser),model.IsTenCccUser },
};
#region 日志
......
......@@ -181,6 +181,7 @@ namespace Edu.Module.User
fileds.Add(nameof(RB_Teacher_ViewModel.Education), model.Education);
fileds.Add(nameof(RB_Teacher_ViewModel.Email), model.Email);
fileds.Add(nameof(RB_Teacher_ViewModel.UserRole), model.UserRole);
fileds.Add(nameof(RB_Teacher_ViewModel.IsTenCccUser), model.IsTenCccUser);
}
#region 修改日志
string logContent = "";
......
......@@ -149,17 +149,17 @@ SELECT A.*,IFNULL(G.GroupName,'') AS GroupName,IFNULL(s.SName,'') AS SchoolName,
FROM
(
SELECT A.Id,A.Account,A.WorkUserId,A.`Password`,A.AccountType,A.AccountId,A.CreateBy,A.CreateTime,A.UpdateBy,A.UpdateTime,A.Group_Id,B.School_Id,A.`Status`,B.LeaveStatus
,A.AnnualLeaveDay, A.DirectSupervisor,A.OpenId,A.ActivationStatus,IFNULL(B.MName,'') AS AccountName,B.MHead AS UserIcon,B.Dept_Id,B.Post_Id,IFNULL(B.Email,'') AS Email
,A.AnnualLeaveDay, A.DirectSupervisor,A.OpenId,A.ActivationStatus,IFNULL(B.MName,'') AS AccountName,B.MHead AS UserIcon,B.Dept_Id,B.Post_Id,IFNULL(B.Email,'') AS Email,B.IsTenCccUser
FROM rb_account AS A INNER JOIN rb_manager AS B ON A.AccountId=B.MId AND A.AccountType=1
WHERE 1=1 {0}
UNION ALL
SELECT A.Id,A.Account,A.WorkUserId,A.`Password`,A.AccountType,A.AccountId,A.CreateBy,A.CreateTime,A.UpdateBy,A.UpdateTime,A.Group_Id,B.School_Id,A.`Status`,B.LeaveStatus
,A.AnnualLeaveDay, A.DirectSupervisor,A.OpenId,A.ActivationStatus,IFNULL(B.TeacherName,'') AS AccountName,B.TeacherIcon AS UserIcon,B.Dept_Id,B.Post_Id,IFNULL(B.Email,'') AS Email
,A.AnnualLeaveDay, A.DirectSupervisor,A.OpenId,A.ActivationStatus,IFNULL(B.TeacherName,'') AS AccountName,B.TeacherIcon AS UserIcon,B.Dept_Id,B.Post_Id,IFNULL(B.Email,'') AS Email,B.IsTenCccUser
FROM rb_account AS A INNER JOIN rb_teacher AS B ON A.AccountId=B.TId AND A.AccountType=2
WHERE 1=1 {0}
UNION ALL
SELECT A.Id,A.Account,A.WorkUserId,A.`Password`,A.AccountType,A.AccountId,A.CreateBy,A.CreateTime,A.UpdateBy,A.UpdateTime,A.Group_Id,B.School_Id,A.`Status`,B.LeaveStatus
,A.AnnualLeaveDay, A.DirectSupervisor,A.OpenId,A.ActivationStatus,IFNULL(B.AssistName,'') AS AccountName,B.AssistIcon AS UserIcon,B.Dept_Id,B.Post_Id,IFNULL(B.Email,'') AS Email
,A.AnnualLeaveDay, A.DirectSupervisor,A.OpenId,A.ActivationStatus,IFNULL(B.AssistName,'') AS AccountName,B.AssistIcon AS UserIcon,B.Dept_Id,B.Post_Id,IFNULL(B.Email,'') AS Email,0 AS IsTenCccUser
FROM rb_account AS A INNER JOIN rb_assist AS B ON A.AccountId=B.AId AND A.AccountType=3
WHERE 1=1 {0}
) AS A LEFT JOIN rb_group AS g ON A.Group_Id=g.GId
......@@ -476,7 +476,7 @@ SELECT ar.AccountRemark,A.Id,A.Account,A.Password,A.AccountId,A.WorkUserId,A.Gro
,(CASE WHEN CONCAT(DATE_FORMAT(now(),'%Y'),'-',DATE_FORMAT(BirthDate,'%m-%d')) >= DATE_FORMAT(now(),'%Y-%m-%d')
AND CONCAT(DATE_FORMAT(now(),'%Y'),'-',DATE_FORMAT(BirthDate,'%m-%d')) <= DATE_FORMAT(date_add(now(),INTERVAL 6 DAY),'%Y-%m-%d')
THEN 1
ELSE 0 END) IsBirth,A.UserRole
ELSE 0 END) IsBirth,A.UserRole,A.IsTenCccUser
FROM
(
SELECT A.Id,A.Account,A.`Password`, 1 as AccountType,B.MId as AccountId,A.WorkUserId
......@@ -484,7 +484,7 @@ FROM
,b.School_Id,IFNULL(B.MName,'') AS EmployeeName,B.MHead AS UserIcon,B.Dept_Id,B.Post_Id,B.IDCard
,B.Sex,B.Education,B.EntryTime,B.Address,B.BirthDate
,B.LeaveStatus,B.LeaveTime,B.MTel AS EmployeeTel,IFNULL(B.Email,'') AS Email
,0 as BaseHourFee,0 as BaseHoursEnabled,'' as EnableTime,B.UserRole
,0 as BaseHourFee,0 as BaseHoursEnabled,'' as EnableTime,B.UserRole,B.IsTenCccUser
FROM rb_manager AS B LEFT JOIN rb_account AS A ON A.AccountId=B.MId AND A.AccountType=1
WHERE 1=1 {0} {1}
UNION ALL
......@@ -493,7 +493,7 @@ FROM
,b.School_Id,IFNULL(B.TeacherName,'') AS EmployeeName,B.TeacherIcon AS UserIcon,B.Dept_Id,B.Post_Id,B.IDCard
,B.Sex,B.Education,B.EntryTime,B.Address,B.BirthDate
,B.LeaveStatus,B.LeaveTime,B.TeacherTel AS EmployeeTel,IFNULL(B.Email,'') AS Email
,B.BaseHourFee,B.BaseHoursEnabled,B.EnableTime,B.UserRole
,B.BaseHourFee,B.BaseHoursEnabled,B.EnableTime,B.UserRole,B.IsTenCccUser
FROM rb_teacher AS B LEFT JOIN rb_account AS A ON A.AccountId=B.TId AND A.AccountType=2
WHERE 1=1 {0} {2}
UNION ALL
......@@ -502,7 +502,7 @@ FROM
,b.School_Id,IFNULL(B.AssistName,'') AS EmployeeName,B.AssistIcon AS UserIcon,B.Dept_Id,B.Post_Id,B.IDCard
,B.Sex,B.Education,B.EntryTime,B.Address,B.BirthDate
,B.LeaveStatus,B.LeaveTime,B.AssistTel AS EmployeeTel,IFNULL(B.Email,'') AS Email
,0 as BaseHourFee,0 as BaseHoursEnabled,'' as EnableTime,0 AS UserRole
,0 as BaseHourFee,0 as BaseHoursEnabled,'' as EnableTime,0 AS UserRole,0 AS IsTenCccUser
FROM rb_assist AS B LEFT JOIN rb_account AS A ON A.AccountId=B.AId AND A.AccountType=3
WHERE 1=1 {0} {3}
) AS A LEFT JOIN rb_group AS g ON A.Group_Id=g.GId
......
......@@ -17,10 +17,12 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Senparc.Weixin.MP" Version="16.12.501.1" />
<PackageReference Include="Senparc.Weixin.Work" Version="3.9.600" />
<PackageReference Include="TencentCloudSDK.Ccc" Version="3.0.437" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Edu.Common\Edu.Common.csproj" />
<ProjectReference Include="..\Edu.Model\Edu.Model.csproj" />
</ItemGroup>
<ItemGroup>
......
using Edu.Model.ViewModel.User;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TencentCloud.Ccc.V20200210.Models;
using TencentCloud.Common;
namespace Edu.ThirdCore.TenCloud
{
/// <summary>
/// 腾讯呼叫中心帮助类
/// </summary>
public class TenCloudCCCHelper
{
private static readonly long SDKAPPID = 1400617921;
/// <summary>
/// 创建客服账号
/// </summary>
/// <param name="employee"></param>
/// <returns></returns>
public async Task<(bool result, string message)> SetUserToCCCUser(Employee_ViewModel employee)
{
CreateStaffRequest req = new CreateStaffRequest();
req.SdkAppId = SDKAPPID;
SeatUserInfo seatUserInfo1 = new SeatUserInfo();
seatUserInfo1.Name = employee.EmployeeName;
seatUserInfo1.Mail = employee.Email;
seatUserInfo1.Phone = employee.EmployeeTel;
seatUserInfo1.Nick = employee.EmployeeName.ToCharArray()[0] + "老师";
seatUserInfo1.UserId = employee.Id.ToString();
seatUserInfo1.StaffNumber = employee.Id.ToString();
req.Staffs = new SeatUserInfo[] { seatUserInfo1 };
var credential = TenCloudCredential._instance;
CreateStaffResponse resp = credential.CreateStaffSync(req);
//JObject result = JObject.Parse(AbstractModel.ToJsonString(resp));
if (resp.ErrorStaffList!=null && resp.ErrorStaffList.Length>0)
{
return (false, resp.ErrorStaffList[0].Message);
}
else
{
var groupId = QueryDescribeSkillGroup();
if (groupId == null)
{
return (false, "电话客服添加成功,但是关联技能组失败");
}
else
{
SetTenUserStaffSkillGroupList(employee.Email, groupId);
}
return (true, "添加成功");
}
}
public void SetTenUserStaffSkillGroupList(string mail, long?[] list)
{
var credential = TenCloudCredential._instance;
BindStaffSkillGroupListRequest req = new BindStaffSkillGroupListRequest();
req.SdkAppId = SDKAPPID;
req.StaffEmail = mail;
req.SkillGroupList = list;
BindStaffSkillGroupListResponse resp = credential.BindStaffSkillGroupListSync(req);
}
/// <summary>
/// 获取技能组数组
/// </summary>
/// <returns></returns>
public long?[] QueryDescribeSkillGroup()
{
var credential = TenCloudCredential._instance;
DescribeSkillGroupInfoListRequest req = new DescribeSkillGroupInfoListRequest();
req.SdkAppId = SDKAPPID;
req.PageSize = 1;
req.PageNumber = 100;
DescribeSkillGroupInfoListResponse resp = credential.DescribeSkillGroupInfoListSync(req);
if (resp.SkillGroupList != null && resp.SkillGroupList.Length > 0)
{
return resp.SkillGroupList.Select(x => x.SkillGroupId).ToArray();
}
else
{
return null;
}
}
/// <summary>
/// 删除坐席
/// </summary>
/// <param name="employee"></param>
/// <returns></returns>
public async Task<(bool result, string message)> DelUserToCCCUser(Employee_ViewModel employee)
{
var credential = TenCloudCredential._instance;
DeleteStaffRequest req = new DeleteStaffRequest();
req.SdkAppId = SDKAPPID;
req.StaffList = new string[] { employee.Email };
DeleteStaffResponse resp = credential.DeleteStaffSync(req);
return (resp.OnlineStaffList == null, "");
}
/// <summary>
/// 获取电话客服的Token
/// </summary>
/// <returns></returns>
public async Task<object> GetTenCccUserToken(string mail)
{
var credential = TenCloudCredential._instance;
CreateSDKLoginTokenRequest req = new CreateSDKLoginTokenRequest();
req.SdkAppId = SDKAPPID;
req.SeatUserId = mail;
CreateSDKLoginTokenResponse resp = credential.CreateSDKLoginTokenSync(req);
return new
{
SdkURL = resp.SdkURL,
Token = resp.Token
};
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using TencentCloud.Ccc.V20200210;
using TencentCloud.Common;
using TencentCloud.Common.Profile;
namespace Edu.ThirdCore.TenCloud
{
public class TenCloudCredential
{
private static CccClient instance = null;
private static object SingletonLock = new object();
private static object SingletonLock2 = new object();
public static CccClient _instance
{
get
{
if (instance == null)
{
lock (SingletonLock)
{
if (instance == null)
{
lock (SingletonLock2)
{
Credential cred = new Credential
{
SecretId = "AKIDufDWZw4wYy98rKXUAajcEbiZAYfW7Sgh",
SecretKey = "xe6IEtIRKxKRItDG3btvsb5JI1eBZkgL"
};
ClientProfile clientProfile = new ClientProfile();
HttpProfile httpProfile = new HttpProfile();
httpProfile.Endpoint = ("ccc.tencentcloudapi.com");
clientProfile.HttpProfile = httpProfile;
instance = new CccClient(cred, "", clientProfile);
}
}
}
}
return instance;
}
}
private TenCloudCredential() { }
}
}
......@@ -15,6 +15,7 @@ using Edu.Module.Duty;
using Edu.Module.Public;
using Edu.Module.System;
using Edu.Module.User;
using Edu.ThirdCore.TenCloud;
using Edu.WebApi.Filter;
using Edu.WebApi.Helper;
using Microsoft.AspNetCore.Authorization;
......@@ -222,6 +223,7 @@ namespace Edu.WebApi.Controllers.User
PostId = model.Post_Id,
PostName = model.PostName,
Email = model.Email,
IsTenCccUser = model.IsTenCccUser,
ActionMenuList = actionList?.Select(qitem => new { qitem.FunctionCode, qitem.FunctionName, qitem.MenuName, qitem.MenuUrl }),
UploadConfig = new
{
......@@ -235,6 +237,10 @@ namespace Edu.WebApi.Controllers.User
},
StudyAbroadObj = publicModule.GetStudyAbroadListModule()
};
if (model.IsTenCccUser == 1)
{
obj.TenCccToken = new TenCloudCCCHelper().GetTenCccUserToken(model.Email).Result;
}
UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.Id, obj, Common.Config.JwtExpirTime);
return ApiResult.Success(data: obj);
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Edu.AOP;
using Edu.Cache.User;
using Edu.Cache.WeChat;
......@@ -18,6 +19,7 @@ using Edu.Module.Customer;
using Edu.Module.Duty;
using Edu.Module.Log;
using Edu.Module.User;
using Edu.ThirdCore.TenCloud;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
......@@ -1393,7 +1395,7 @@ namespace Edu.WebApi.Controllers.User
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetEmployee()
public async Task<ApiResult> SetEmployeeAsync()
{
var extModel = new Employee_ViewModel()
{
......@@ -1418,6 +1420,7 @@ namespace Edu.WebApi.Controllers.User
Account = base.ParmJObj.GetStringValue("Account"),
Password = base.ParmJObj.GetStringValue("Password"),
UserRole = (UserRoleEnum)base.ParmJObj.GetInt("UserRole"),
IsTenCccUser = base.ParmJObj.GetInt("IsTenCccUser",0)
};
if (!string.IsNullOrEmpty(extModel.Password.Trim()))
{
......@@ -1511,6 +1514,24 @@ namespace Edu.WebApi.Controllers.User
}
#endregion
var oldModel = employeeModule.GetEmployeeModule(0, extModel.AccountId, extModel.AccountType.ToInt());
if (oldModel.IsTenCccUser == 0 && extModel.IsTenCccUser == 1)
{
var cccResult = await new TenCloudCCCHelper().SetUserToCCCUser(extModel);
if (!cccResult.result)
{
return ApiResult.Failed($"同步电话坐席失败,{cccResult.message}");
}
}
else if (oldModel.IsTenCccUser == 1 && extModel.IsTenCccUser == 0)
{
var cccResult = await new TenCloudCCCHelper().DelUserToCCCUser(extModel);
if (!cccResult.result)
{
return ApiResult.Failed($"电话客服功能关闭失败,请联系管理员");
}
}
bool flag = employeeModule.SetEmployeeModule(extModel, TXLToken);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......@@ -1708,6 +1729,7 @@ namespace Edu.WebApi.Controllers.User
DirectSupervisorName = base.GetUserInfo(extModel?.DirectSupervisor ?? 0)?.AccountName ?? "",
UserRole= extModel?.UserRole??0,
UserRoleName= extModel?.UserRole.ToName()??"",
IsTenCccUser = extModel?.IsTenCccUser ?? 0,
};
return ApiResult.Success(data: obj);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment