| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018 |
-
- using CallCenter.Utility;
- using CallCenterApi.Common;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.tel
- {
- public class CallInScreenController : BaseController
- {
- /// <summary>
- /// 添加黑名单
- /// </summary>
- /// <returns></returns>
- public ActionResult AddBlack()
- {
-
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (ua != null)
- {
- string tel = HttpUtility.UrlDecode(RequestString.GetFormString("tel"));
- string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
- int n = RequestString.GetInt("num", 0);
- int type = RequestString.GetInt("type", 0);
- Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
- var date = DateTime.Now;
- var enddate = date;
- switch (type)
- {
- case 1: enddate = enddate.AddDays(n); break;
- case 2: enddate = enddate.AddHours(n); break;
- case 3: enddate = enddate.AddMinutes(n); break;
- case 4: enddate = DateTime.MaxValue; break;
- }
- if (dModel == null)
- {
- dModel = new Model.T_Call_Blacklist();
- dModel.F_CallId = callid;
- dModel.F_TelPhone = tel.Trim();
- dModel.F_SetTime = date;
- dModel.F_RemoveTime = enddate;
- dModel.F_InterceptNum = 1;
- dModel.F_UserId = ua.F_UserId;
- int b = new BLL.T_Call_Blacklist().Add(dModel);
- if (b > 0)
- {
- return Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
- }
- else
- {
- return Error("添加失败");
- }
- }
- else
- {
- dModel.F_RemoveTime = enddate;
- if (new BLL.T_Call_Blacklist().Update(dModel))
- {
- return Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
- }
- else
- {
- return Error("修改失败");
- }
- }
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 取消黑名单
- /// </summary>
- /// <returns></returns>
- public ActionResult DelBlack()
- {
-
- //if (Request.IsAuthenticated)
- //{
- string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
- Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
- if (dModel != null)
- {
- bool bl = new BLL.T_Call_Blacklist().Delete(dModel.F_BlackId);
- if (bl)
- {
- return Success("取消成功");
- }
- }
- return Success("找不到此记录");
- // }
- // return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 根据来电号码获取客户信息
- /// </summary>
- /// <returns></returns>
- public ActionResult GetCustomerByTel()
- {
-
- if (Request.IsAuthenticated)
- {
- //DataTable dt = new DataTable();
- string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
- BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
- //dt = bll.GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Tables[0];
- //20180509 来电弹屏一个号码弹两个客户信息 machenyang
- var cusmodel = bll.GetModelList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Count() == 0 ? null : bll.GetModelList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").OrderByDescending(p => p.F_CustomerId).First();
- return Success("客户信息加载成功", cusmodel);
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 根据来电号码获取最近的callid
- /// </summary>
- /// <returns></returns>
- public ActionResult GetCallIdByPhone()
- {
-
- if (Request.IsAuthenticated)
- {
- DataTable dt = new DataTable();
- string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
- Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByTelphone(tel);
- return Success("加载成功", model);
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 根据callid获取最近的通话记录
- /// </summary>
- /// <returns></returns>
- public ActionResult GetTelRecordByCallid()
- {
-
- if (Request.IsAuthenticated)
- {
- DataTable dt = new DataTable();
- string callid = HttpUtility.UrlDecode(RequestString.GetQueryString("callid"));
- Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
- return Success("通话记录加载成功", model);
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 来电归属地查询
- /// </summary>
- /// <returns></returns>
- public ActionResult GetPhoneLocation()
- {
- if (Request.IsAuthenticated)
- {
- string location = "未知";
- string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
- if (tel.Trim().Length == 12)
- {
- BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
- Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(1, 7) + "' ").FirstOrDefault();
- if (mobileModel != null)
- {
- location = mobileModel.F_CityDes + mobileModel.F_CardDes;
- }
- else
- {
- var PhoneNumber = MobiledataController.GetDetails(tel.Substring(1, 11));
- if (PhoneNumber != null&& PhoneNumber.Count >0)
- {
- Model.T_Sys_MobileData dModel = new Model.T_Sys_MobileData();
- dModel.F_MobileNum = tel.Substring(1, 7);
- var model = new BLL.T_Sys_MobileData().GetList(1, "F_CityDes='" + PhoneNumber["省份"] + "-" + PhoneNumber["市区"] + "' and F_IsDelete=0", "F_Id desc ");
- if (model != null)
- dModel.F_ZipCode = model.FirstOrDefault().F_ZipCode;
- dModel.F_CityDes = PhoneNumber["省份"] + "-" + PhoneNumber["市区"];
- dModel.F_CardDes = PhoneNumber["电信运营商"];
- dModel.F_IsDelete = 0;
- dModel.F_CreateUser = "8000";
- dModel.F_CreateTime = DateTime.Now;
- int t = new BLL.T_Sys_MobileData().Add(dModel);
- if (t > 0)
- {
- location = dModel.F_CityDes + dModel.F_CardDes;
- }
- }
- else
- {
- BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
- List<Model.T_Sys_TelTitleData> mobileModel1 = numbBll.GetModelList(" F_KeyPhoneNum='" + tel.Substring(0, 4) + "'");
- if (mobileModel1 == null || mobileModel1.Count <= 0)
- {
- mobileModel1 = numbBll.GetModelList(" F_KeyPhoneNum='" + tel.Substring(0, 3) + "'");
- }
- if (mobileModel1.Count > 0)
- {
- location = mobileModel1[0].F_TitleName;
- }
- }
- }
- }
- else
- {
- if (tel.Trim().Length == 11 && tel.Substring(0, 1) != "0")
- {
- BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
- Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(0, 7) + "' ").FirstOrDefault();
- if (mobileModel != null)
- {
- location = mobileModel.F_CityDes + mobileModel.F_CardDes;
- }
- else
- {
- var PhoneNumber = MobiledataController .GetDetails (tel.Substring(0, 10));
- if (PhoneNumber != null && PhoneNumber.Count > 0)
- {
- Model.T_Sys_MobileData dModel = new Model.T_Sys_MobileData();
- dModel.F_MobileNum = tel.Substring(0, 7);
- var model = new BLL.T_Sys_MobileData().GetList(1, "F_CityDes='" + PhoneNumber["省份"] + "-" + PhoneNumber["市区"] + "' and F_IsDelete=0", "F_Id desc ");
- if (model != null)
- dModel.F_ZipCode = model.FirstOrDefault().F_ZipCode;
- dModel.F_CityDes = PhoneNumber["省份"] + "-" + PhoneNumber["市区"];
- dModel.F_CardDes = PhoneNumber["电信运营商"];
- dModel.F_IsDelete = 0;
- dModel.F_CreateUser = "8000";
- dModel.F_CreateTime = DateTime.Now;
- int t = new BLL.T_Sys_MobileData().Add(dModel);
- if (t > 0)
- {
- location = dModel.F_CityDes + dModel.F_CardDes;
- }
- }
- }
- }
- else
- {
- if (tel.Trim().Length > 3)
- {
- BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
- List<Model.T_Sys_TelTitleData> mobileModel = numbBll.GetModelList(" F_KeyPhoneNum='" + tel.Substring(0, 4) + "'");
- if (mobileModel == null || mobileModel.Count <= 0)
- {
- mobileModel = numbBll.GetModelList(" F_KeyPhoneNum='" + tel.Substring(0, 3) + "'");
- }
- if (mobileModel.Count > 0)
- {
- location = mobileModel[0].F_TitleName;
- }
- }
- }
- }
- return Success("归属地加载成功", location);
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 历史记录列表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetOldList()
- {
-
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (ua != null)
- {
- string sql = "";
- string sqlcount = "";
- DataTable dt = new DataTable();
- //来电号码
- string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
- string strcalltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- //除管理员外,各坐席只能看到自己的
- //20180507 每个人都能看到该来电的所有历史记录 machenyang
- //if (ua.F_RoleId != 17)
- // sql += " and UserId = '" + userId + "'";
- ////20180514 坐席能看到同组的
- //var usergroup = ua.F_SeartGroup;
- //var usercodes = new BLL.T_Sys_UserAccount().GetModelList("F_SeartGroup='" + usergroup + "'") == null ? null : new BLL.T_Sys_UserAccount().GetModelList("F_SeartGroup='" + usergroup + "'").Select(p => p.F_UserCode);
- //var str = "";
- //if (usercodes != null)
- //{
- // foreach (var item in usercodes)
- // {
- // str += item.ToString() + ',';
- // }
- // str = str.TrimEnd(',');
- // sql += " and UserCode in ("+str+") ";
- //}
- //else
- // sql += " and UserCode='"+ua.F_UserCode+"' ";
- #region 2018-05-30 lihai 坐席能看到同组的通话记录
- int seartGroupId = ua.F_SeartGroupID ?? 0;
- if (seartGroupId != 0)
- {
- //groupcode判断是市场部或客服部的通话记录
- var modelSeartGroup = new BLL.T_Sys_SeatGroup().GetModel(seartGroupId);
- if (modelSeartGroup != null)
- {
- sql += " and groupcode = '" + modelSeartGroup.F_ZXZCode + "' ";
- //if (modelSeartGroup.F_ZXZCode == "SCZ")
- //{
- // sql += " and groupcode = 'SCZ' ";
- //}
- //else
- //{
- // sql += " and groupcode = 'KFZ' ";
- //}
- }
- //else
- // sql += " and UserCode='" + ua.F_UserCode + "' ";
- }
- else
- {
- //找不到对应坐席组
- sql += " and UserCode='" + ua.F_UserCode + "' ";
- }
- #endregion
- if (strcalltype.Trim() != "" && strcalltype != "undefined")
- {
- sql += " and CallType=" + strcalltype + " ";
- }
- if (strtel.Trim() != "" && strtel != "undefined")
- {
- sql += " and CallNumber= '" + strtel.Trim() + "' ";
- sqlcount += " and CallNumber= '" + strtel.Trim() + "' ";
- }
- //else
- //{
- // sql += " and 1=0 ";
- //}
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- sql += " and datediff(day,BeginTime,'" + strstarttime + "')<=0 ";
- sqlcount += " and datediff(day,BeginTime,'" + strstarttime + "')<=0 ";
- }
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and datediff(day,BeginTime,'" + strendtime + "')>=0 ";
- sqlcount += " and datediff(day,BeginTime,'" + strendtime + "')>=0 ";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Call_CallRecords WITH(NOLOCK)",
- "CallRecordsId",
- "*",
- sql,
- "ORDER BY CallRecordsId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- dt.Columns.Add("CusName");
- dt.Columns.Add("CusDepName");
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- var listCustomer = new BLL.T_Cus_CustomerBase().GetModelList(" F_DeleteFlag=0 ");
- foreach (DataRow dr in dt.Rows)
- {
- string path = dr["FilePath"] != null ? dr["FilePath"].ToString() : "";
- if (path != "" && config != null && !string.IsNullOrEmpty(config.F_ParamValue))
- {
- var ym = config.F_ParamValue;
- if (ym.Substring(ym.Length - 1) == "/")
- {
- ym = ym.Substring(0, ym.Length - 1);
- }
- dr["FilePath"] = ym + path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
- }
- var modelCustomer = listCustomer.FirstOrDefault(x => x.F_Telephone == dr["CallNumber"].ToString());
- if (modelCustomer != null)
- {
- dr["CusName"] = modelCustomer.F_CustomerName; //客户姓名
- dr["CusDepName"] = modelCustomer.F_CustomerIndustry; //来电单位
- }
- }
- int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 " + sqlcount);
- int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 " + sqlcount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount,
- hrcount = hrcount,
- hccount = hccount,
- };
- return Content(obj.ToJson());
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 获取最新知识库
- /// </summary>
- /// <returns></returns>
- public ActionResult GetZSKList()
- {
-
- if (Request.IsAuthenticated)
- {
- DataTable dt = new DataTable();
- string pid = HttpUtility.UrlDecode(RequestString.GetQueryString("pid"));
- string keywords = HttpUtility.UrlDecode(RequestString.GetQueryString("keywords"));
- string sql = " F_DeleteFlag=0";
- if (pid.Trim() != "")
- {
- sql += " and F_CategoryId=" + pid.Trim();
- }
- if (keywords.Trim() != "")
- {
- sql += " and (F_Content like '%" + keywords.Trim() + "%' or F_Title like '%"
- + keywords.Trim() + "%' or F_KeyWords like '%" + keywords.Trim() + "%')";
- }
- dt = new BLL.T_RepositoryInformation().GetList(8, sql, " F_RepositoryId desc").Tables[0];
- return Success("加载成功", dt);
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 振铃事件
- /// </summary>
- /// <returns></returns>
- public ActionResult UpdateZL()
- {
-
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (ua != null)
- {
- Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
- model.CallId = RequestString.GetFormString("callid");
- //model.UserId = ua.F_UserId;
- //model.UserCode = ua.F_UserCode;
- //model.UserName = ua.F_UserName;
- ////model.ExtNumber = ua.F_WorkNumber;
- //model.ExtNumber = CurrentUser.UserData.F_ExtensionNumber;
- model.DealType = 5;
- bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
- if (bl)
- {
- return Success("更新振铃状态成功");
- }
- else
- {
- // return Error("更新振铃状态失败");
- return Success("更新振铃状态失败");
- }
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 摘机事件
- /// </summary>
- /// <returns></returns>
- public ActionResult UpdateZJ()
- {
-
- if (Request.IsAuthenticated)
- {
- Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
- model.CallId = RequestString.GetFormString("callid");
- model.CallState = 1;
- model.DealType = 6;
- bool bl = new BLL.T_Call_CallRecords().UpdateCallInAnswerTelRecord(model);
- if (bl)
- {
- Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(model.CallId);
- string type = vmodel.OperateType.ToString();
- if (type == "7")
- {
- new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
- }
- return Success("更新摘机状态成功");
- }
- else
- {
- //return Error("更新摘机状态失败");
- return Success("更新摘机状态失败");
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 挂机事件
- /// </summary>
- /// <returns></returns>
- public ActionResult UpdateGJ()
- {
-
- if (Request.IsAuthenticated)
- {
- return Success("更新挂机状态成功");
- //string strid = RequestString.GetFormString("callid");
- //bool bl = new BLL.T_Call_CallRecords().UpdateCallInHookTelRecord(strid);
- //if (bl)
- //{
- // return Success("更新挂机状态成功");
- //}
- //else
- //{
- // return Success("更新挂机状态失败");
- //}
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 录音事件
- /// </summary>
- /// <returns></returns>
- public ActionResult UpdateLY(string callid)
- {
-
- if (Request.IsAuthenticated)
- {
- Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
- if (vmodel!=null)
- {
- string type = vmodel.OperateType.ToString();
- if (type == "7")
- {
- new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
- }
- }
- return Success("更新挂机状态成功");
- //Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
- //model.CallId = RequestString.GetFormString("callid");
- //model.CallState = 1;
- //model.DealType = 6;
- ////model.FilePath = RequestString.GetFormString("path");
- //bool bl = new BLL.T_Call_CallRecords().UpdateCallInPathTelRecord(model);
- //if (bl)
- //{
- // Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(model.CallId);
- // string type = vmodel.OperateType.ToString();
- // if (type == "7")
- // {
- // new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
- // }
- // return Success("更新挂机状态成功");
- //}
- //else
- //{
- // return Success("更新挂机状态失败");
- //}
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 创建工单
- /// </summary>
- /// <returns></returns>
- public ActionResult AddWorkOrder()
- {
-
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (ua != null)
- {
- //姓名
- string callCustomer = RequestString.GetFormString("callCustomer");
- //电话
- string tel = RequestString.GetFormString("tel");
- //来电所在省份
- string prov = RequestString.GetFormString("province");
- //来电单位
- string lddep = RequestString.GetFormString("lddep");
- //反馈单位
- string fkdep = RequestString.GetFormString("fkdep");
- //工单来源
- int gdly = RequestString.GetFormInt("gdly", 0);
- //工单类型
- int gdlx = RequestString.GetFormInt("gdlx", 0);
- //工单状态 471 默认未处理
- int gdzt = RequestString.GetFormInt("gdzt", 471);
- //反馈内容
- string fkcont = RequestString.GetFormString("fkcont");
- //快递信息
- string sendmsg = RequestString.GetFormString("sendmsg");
- //备注1
- string note1 = RequestString.GetFormString("note1");
- //备注2
- string note2 = RequestString.GetFormString("note2");
- //备注3
- string note3 = RequestString.GetFormString("note3");
- //callID
- string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
- if(string.IsNullOrEmpty(callCustomer))
- return Error("姓名不能为空!");
- if (string.IsNullOrEmpty(tel))
- return Error("电话不能为空!");
- if (string.IsNullOrEmpty(lddep))
- return Error("来电单位不能为空!");
- Model.T_Wo_WorkOrder model = new Model.T_Wo_WorkOrder();
- model.WorkOrderID = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
- model.Customer = callCustomer;
- model.CustomerTel = tel;
- //将省份放入工单
- model.CreateUserID = prov;
- //工单来源
- model.Type = gdly;
- //工单类型
- model.TypeClass = gdlx;
- //反馈内容
- //var detailutf8 = System.Web.HttpUtility.UrlDecode(fkcont, System.Text.Encoding.UTF8);
- var detailutf8 = System.Web.HttpUtility.HtmlDecode(fkcont);
- model.Detail = detailutf8;
- //快递信息
- model.Files = sendmsg;
- //备注一
- model.County = note1;
- //备注二
- model.Province = note2;
- //备注三
- model.City = note3;
- //默认为未处理
- int gdstate = 0;
- string dep = DbHelperSQL.GetSingle("select F_ZXZName from [dbo].[T_Sys_SeatGroup],T_Sys_UserAccount where T_Sys_UserAccount.F_SeartGroupID =[dbo].[T_Sys_SeatGroup].F_ZXZID and F_UserCode ='" + ua.F_UserCode + "' ").ToString();
- if (dep.Contains("市场"))
- {
- if (string.IsNullOrEmpty(fkcont.Trim()))
- gdstate = 1;
- }
- else
- {
- if (gdzt != 471)
- gdstate = 1;
- }
- model.State = gdstate;
- if (gdstate == 1)//如果直接为已处理 需要将lastdealuser改为当前坐席
- model.LastDealUser = ua.F_UserCode;
- model.IsDel = 0;
- model.IsReturn = 0;
- model.IsReturnBak = 0;
- model.ResponDept = 0;
- model.Answer = "";
- model.IsTimeOut = 0;
- model.IsUserSend = 0;
- model.IsAdminSend = 0;
- ////原——将新增的工单插入待指派表中
- //Model.T_Wo_WorkOrderTimeOut to = new BLL.T_Wo_WorkOrderTimeOut().GetModel(gdlx);
- //if (to != null)
- //{
- // model.LimitTime = to.MainTime;
- //}
- //存入callid
- model.CallID = callid;
- //来电单位 反馈单位
- model.Address = lddep;
- model.Source = fkdep;
- model.CreateUser = ua.F_UserCode;
- model.CreateTime = DateTime.Now;
- //if (clbm != 0 || clid != 0)
- //{
- // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
- // item.WorkOrderID = model.WorkOrderID;
- // item.ToDept = clbm;
- // item.Type = 1;
- // if (clid != 0)
- // {
- // Model.T_Sys_UserAccount clus = new BLL.T_Sys_UserAccount().GetModel(clid);
- // if (clus != null)
- // {
- // item.ToUser = clus.F_UserCode;
- // }
- // }
- // else
- // {
- // string users = string.Empty;
- // var list = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId='" + clbm + "'");
- // foreach (var l in list)
- // {
- // if (string.IsNullOrEmpty(users))
- // {
- // users = l.F_UserCode;
- // }
- // else
- // {
- // users = users + "," + l.F_UserCode;
- // }
- // }
- // item.ToUser = users;
- // }
- // if (to != null)
- // {
- // item.LimitTime = to.ItemTime;
- // }
- // item.Detail = answer;
- // item.IsLast = 0;
- // item.State = 0;
- // item.IsStart = 0;
- // item.IsTimeOut = 0;
- // item.IsDel = 0;
- // item.CreateUser = ua.F_UserCode;
- // item.CreateTime = DateTime.Now;
- // long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
- // if (itemid > 0)
- // {
- // model.State = 1;//已指派
- // model.AppointTime = DateTime.Now;
- // #region 消息表
- // foreach (string ur in item.ToUser.Split(','))
- // {
- // Model.T_Msg_List msg = new Model.T_Msg_List();
- // msg.Type = 1;
- // msg.ToUser = ur;
- // msg.ToID = Int32.Parse(itemid.ToString());
- // msg.Detail = ua.F_UserName + "给你指派了工单,单号:" + model.WorkOrderID;
- // msg.State = 0;
- // msg.IsDel = 0;
- // msg.CreateUser = ua.F_UserCode;
- // msg.CreateDate = DateTime.Now;
- // new BLL.T_Msg_List().Add(msg);
- // }
- // #endregion
- // }
- //}
- if (new BLL.T_Wo_WorkOrder().Add(model) > 0)
- {
- if (!string.IsNullOrEmpty(callid))
- {
- var rec = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
- if (rec != null)
- {
- rec.IsExitWorkOrder = true;
- new BLL.T_Call_CallRecords().Update(rec);
- }
- }
- #region 将不存在的客户保存到客户基础信息中。
- //如果客户不存在,需要同时添加到客户基础信息表中,存在则修改
- Model.T_Cus_CustomerBase userModel = new BLL.T_Cus_CustomerBase().GetModel(tel);
- if (userModel == null)
- {
- int cusid = new BLL.T_Cus_CustomerBase().Add(new Model.T_Cus_CustomerBase()
- {
- F_CustomerName = callCustomer,
- F_Mobile = tel,
- F_Telephone = tel,
- F_CreateBy = userId,
- F_CreatedOn = DateTime.Now,
- F_DeleteFlag = 0,
- F_Province = prov,
- F_CustomerIndustry = lddep,
- F_RelationShipClass = fkdep
- });
- //if (cusid > 0)
- // return Success("新增成功!");
- }
- else
- {
- userModel.F_Province = prov;
- userModel.F_CustomerIndustry = lddep;
- userModel.F_RelationShipClass = fkdep;
- userModel.F_CustomerName = callCustomer;
- userModel.F_Mobile = tel;
- userModel.F_Telephone = tel;
- new BLL.T_Cus_CustomerBase().Update(userModel);
- }
- #endregion
- #region 新增工单后新的单位要保存到反馈单位和来电单位中
- List<string> lddep_cache = null;
- lddep_cache = CacheHelper.Get("LDDep") as List<string>;
- if (lddep_cache != null && lddep_cache.Count > 0)
- {
- if (!lddep_cache.Contains(lddep))
- lddep_cache.Add(lddep);
- if (!lddep_cache.Contains(fkdep))
- lddep_cache.Add(fkdep);
- CacheHelper.Insert("LDDep", lddep_cache);
- }
- else
- {
- lddep_cache = new BLL.T_Cus_CustomerBase().GetLDdep();
- var gdlddep = new BLL.T_Wo_WorkOrder().GetModelList("1=1").Select(p => p.Address).Distinct().ToList();//从工单来电单位中加载
- var gdfkdep = new BLL.T_Wo_WorkOrder().GetModelList("1=1").Select(p => p.Source).Distinct().ToList();//从工单反馈单位中加载
- foreach (var item in gdlddep)
- {
- if (!lddep.Contains(item))
- lddep_cache.Add(item);
- }
- foreach (var item in gdfkdep)
- {
- if (!lddep.Contains(item))
- lddep_cache.Add(item);
- }
- if (lddep_cache != null && lddep_cache.Count > 0)
- {
- if (!lddep_cache.Contains(lddep))
- lddep_cache.Add(lddep);
- if (!lddep_cache.Contains(fkdep))
- lddep_cache.Add(fkdep);
- CacheHelper.Insert("LDDep", lddep_cache);
- }
- else
- return Error("获取失败,没有对应数据");
- }
- #endregion
- return Success("新增成功!");
- }
- else
- {
- return Error("新增失败!");
- }
- #region no use
- //Model.T_Wo_WorkOrderBase model = new Model.T_Wo_WorkOrderBase();
- //model.F_CODE = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
- //model.F_WORKORDERTYPEID = type;
- //model.F_WORKORDERSTATEID = 0;
- //model.F_WORKORDERNAME = "";
- //model.F_WORKORDERFROM = "";
- //model.F_WORKORDERLEVELID = 0;
- //model.F_ADSLACCOUNT = callid;
- ////model.F_USERID = ua.F_UserId;
- ////model.F_USERNAME = ua.F_UserName;
- ////model.F_USERPHONE = ua.F_WorkNumber;
- //model.F_TypeName = "";
- //model.F_STARTTIME = DateTime.Now;
- //model.F_RETURNVISITFLAG = 0;
- //model.F_LINKMANTELEPHONE = tsdh;
- //model.F_LINKMAN = tskh;
- //model.F_DELETEFLAG = 0;
- //model.F_CUSTOMERTELEPHONE = tsdh;
- //model.F_CUSTOMERNAME = tskh;
- //model.F_CUSTOMERID = 0;//待实现
- //model.F_CREATEDATE = DateTime.Now;
- //model.F_CREATEBY = ua.F_UserId;
- //model.F_CONTENT = cont;
- //model.F_REPAIRMANNAME = tskh;
- //model.F_REPAIRMANPHONE = tsdh;
- //if (new BLL.T_Wo_WorkOrderBase().Add(model) > 0)
- //{
- // return Success("新增成功!");
- //}
- //else
- //{
- // return Error("新增失败!");
- //}
- #endregion
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 获取当前坐席所在部门及坐席组
- /// </summary>
- /// <returns></returns>
- public ActionResult GetCurrUserDep()
- {
-
- if (Request.IsAuthenticated)
- {
- int? groid = CurrentUser.UserData.F_SeartGroupID;
- //string groname = CurrentUser.UserData.F_SeartGroup;
- string groname = "";
- string depname = "";
- int depid = CurrentUser.UserData.F_DeptId;
- if (depid != 0)
- {
- Model.T_Sys_Department depModel = new BLL.T_Sys_Department().GetModel(depid);
- if (depModel != null)
- {
- depname = depModel.F_DeptName;
- Model.T_Sys_SeatGroup groModel = new BLL.T_Sys_SeatGroup().GetModel(groid == null ? 0 : int.Parse(groid.ToString()));
- if (groModel != null)
- {
- groname = groModel.F_ZXZName;
- }
- }
- }
- var obj = new
- {
- depid = depid,
- depname = depname,
- groid = groid,
- groname = groname
- };
- return Success("获取坐席部门成功!", obj);
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 获取所有坐席
- /// </summary>
- /// <returns></returns>
- public ActionResult GetUsers()
- {
-
- if (Request.IsAuthenticated)
- {
- int depid = CurrentUser.UserData.F_DeptId;
- List<Model.T_Sys_UserAccount> userModel = new BLL.T_Sys_UserAccount().GetModelList($"F_DeleteFlag=0 and F_DeptId = {depid} ");
- var list = userModel.Select(p => new { p.F_UserId, p.F_UserCode, p.F_UserName });
- var obj = new
- {
- user = list
- };
- return Success("获取坐席成功!", obj);
- }
- return NoToken("未知错误,请重新登录");
- }
- }
- }
|