Exemplo n.º 1
0
        /// 其他系统-接口
        /// <summary>
        /// 其他系统-接口
        /// </summary>
        /// <param name="model"></param>
        /// <param name="model_ORIG"></param>
        /// <param name="recID"></param>
        /// <returns></returns>
        public bool InsertCallRecordInfoToHuiMaiChe(CallRecordInfoInfo model, Entities.CallRecord_ORIG model_ORIG, out long recID)
        {
            recID = 0;
            string logDesc = string.Empty;

            if (model_ORIG.EstablishedTime == null)
            {
                logDesc = "该通电话未接通";
                BLL.Loger.Log4Net.Info("【其他系统接口话务调用】【来电去电表插入成功】【失败】" + logDesc);
                return(false);
            }

            CallRecordInfoInfo model_RecordInfo = BLL.CallRecordInfo.Instance.GetCallRecordInfoInfo(model.CallID.Value);

            if (model_RecordInfo != null)
            {
                recID   = model_RecordInfo.RecID_Value;
                logDesc = " 该CallID:" + model.CallID + "记录在CallRecordInfo表中已存在,不能再次插入CallRecordInfo表,返回主键:" + model_RecordInfo.RecID + "!";
                BLL.Loger.Log4Net.Info("【其他系统接口话务调用】【来电去电表插入成功】" + logDesc);
                return(true);
            }
            try
            {
                model.SessionID    = model_ORIG.SessionID;
                model.ExtensionNum = model_ORIG.ExtensionNum;
                model.PhoneNum     = BLL.Util.HaoMaProcess(model_ORIG.ANI);
                model.ANI          = model_ORIG.PhoneNum;
                model.CallStatus   = model_ORIG.CallStatus;
                model.BeginTime    = model_ORIG.EstablishedTime;
                model.EndTime      = model_ORIG.CustomerReleaseTime == null ? model_ORIG.AgentReleaseTime : model_ORIG.CustomerReleaseTime;
                model.TallTime     = model_ORIG.TallTime;
                model.AudioURL     = model_ORIG.AudioURL;
                model.SkillGroup   = model_ORIG.SkillGroup;
                //recordInfo.CallID = long.Parse(info.CallID);// 外面赋值
                //recordInfo.SCID = int.Parse(info.SCID);// 外面赋值
                //recordInfo.TaskID = info.BusinessID;// 外面赋值
                //recordInfo.TaskTypeID = (int)ProjectSource.None;// 外面赋值
                //recordInfo.BGID = int.Parse(info.BGID);// 外面赋值
                //recordInfo.CustID = custId;// 外面赋值
                //recordInfo.CustName = info.CustName;// 外面赋值
                //recordInfo.Contact = info.CustName;// 外面赋值
                model.CreateTime   = DateTime.Now;
                model.CreateUserID = model_ORIG.CreateUserID;
                CommonBll.Instance.InsertComAdoInfo(model);
                recID = model.RecID_Value;
                BLL.Loger.Log4Net.Info("【其他系统接口话务调用】【来电去电表插入成功】返回主键:" + recID);
                return(true);
            }
            catch (Exception ex)
            {
                BLL.Loger.Log4Net.Error("【其他系统接口话务调用】【来电去电表插入成功】", ex);
                return(false);
            }
        }
        public EnumResult InsertCustData(string Verifycode, string jsonDataStr)
        {
            BLL.Loger.Log4Net.Info("准备验证:");
            string msg = string.Empty;

            if (BLL.CallRecord_ORIG_Authorizer.Instance.Verify(Verifycode, 0, ref msg, "插入话务与任务关联数据,授权失败。"))
            {
                BLL.Loger.Log4Net.Info("验证通过");
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                CustBussiness        info       = null;
                try
                {
                    BLL.Loger.Log4Net.Info("Json串:" + jsonDataStr);
                    info = serializer.Deserialize <CustBussiness>(jsonDataStr);
                    BLL.Loger.Log4Net.Info("Json格式转换成功");
                }
                catch (Exception ex)
                {
                    BLL.Loger.Log4Net.Info("Json格式转换失败,失败原因:" + ex.Message);
                    return(EnumResult.JsonPatternError);
                }

                Entities.CallRecord_ORIG orig;
                BitAuto.YanFa.Crm2009.Entities.DMSMember member;
                EnumResult vefiyResult = VefiyCustData(info, out orig, out member);
                if (vefiyResult == EnumResult.Success)
                {
                    try
                    {
                        //0 获取分组分类
                        SetBGIDAndSCID(info);
                        //1 插入个人信息表
                        string custId       = string.Empty;
                        string errMsg       = string.Empty;
                        int    custCategory = 4;
                        if (!string.IsNullOrEmpty(info.MemberCode))
                        {
                            //3-经销商;4-个人
                            custCategory = 3;
                        }
                        if (BLL.CustBasicInfo.Instance.InsertCustInfo(info.CustName, info.Tels, CommonFunction.ObjectToInteger(info.Sex), (int)orig.CreateUserID, custCategory, null, null, out errMsg, out custId))
                        {
                            BLL.Loger.Log4Net.Info("插入客户成功");
                            //删除经销商
                            BLL.DealerInfo.Instance.Delete(custId);

                            if (!string.IsNullOrEmpty(info.MemberCode))
                            {
                                //插入
                                Entities.DealerInfo model_Dealer = new Entities.DealerInfo();
                                model_Dealer.CustID       = custId;
                                model_Dealer.MemberCode   = info.MemberCode;
                                model_Dealer.Name         = member.Name;
                                model_Dealer.Status       = 0;
                                model_Dealer.CreateTime   = DateTime.Now;
                                model_Dealer.CreateUserID = (int)orig.CreateUserID;
                                BLL.DealerInfo.Instance.Insert(model_Dealer);
                                BLL.Loger.Log4Net.Info("插入经销商信息成功");
                            }

                            //2 插入访问记录
                            string tel          = BLL.Util.HaoMaProcess(orig.ANI);
                            long   callid       = CommonFunction.ObjectToLong(info.CallID, -2);
                            int    businesstype = (int)VisitBusinessTypeEnum.S0_其他系统;
                            int    tasksource   = orig.CallStatus == 2 ? 2 : 1;
                            BitAuto.ISDC.CC2012.Web.AjaxServers.CustBaseInfo.OperPopCustBasicInfo.OperCustVisitBusiness(custId, info.BusinessID, callid, businesstype, tasksource, (int)orig.CreateUserID, tel);

                            //3 插入话务业务表
                            UpdateBusinessDataByCallID(info);

                            //插入来去电表
                            CallRecordInfoInfo recordInfo = new CallRecordInfoInfo();
                            recordInfo.CallID     = long.Parse(info.CallID);
                            recordInfo.SCID       = int.Parse(info.SCID);
                            recordInfo.TaskID     = info.BusinessID;
                            recordInfo.TaskTypeID = (int)ProjectSource.None;
                            recordInfo.BGID       = int.Parse(info.BGID);
                            recordInfo.CustID     = custId;
                            recordInfo.CustName   = info.CustName;
                            recordInfo.Contact    = info.CustName;
                            long recId = 0;
                            BLL.CallRecordInfo.Instance.InsertCallRecordInfoToHuiMaiChe(recordInfo, orig, out recId);
                            return(EnumResult.Success);
                        }
                        else
                        {
                            return(EnumResult.Fail);
                        }
                    }
                    catch (Exception ex)
                    {
                        BLL.Loger.Log4Net.Error("【插入客户信息+话务】", ex);
                        return(EnumResult.Fail);
                    }
                }
                else
                {
                    BLL.Loger.Log4Net.Info("Json验证失败:msg=" + vefiyResult.ToString());
                    return(vefiyResult);
                }
            }
            else
            {
                BLL.Loger.Log4Net.Info("验证失败!msg=" + msg);
                return(EnumResult.VerifyError);
            }
        }
        /// 保存来电去电表
        /// <summary>
        /// 保存来电去电表
        /// </summary>
        /// <param name="jsondata"></param>
        /// <param name="loginuserid"></param>
        /// <param name="bgid"></param>
        /// <param name="scid"></param>
        public void SaveCallRecordInfo(CommonCallJsonData jsondata, int loginuserid, int bgid, int scid)
        {
            if (jsondata.CallData.CallID_Out <= 0)
            {
                return;
            }
            CallRecordInfoInfo info = BLL.CallRecordInfo.Instance.GetCallRecordInfoInfo(jsondata.CallData.CallID_Out);
            bool isadd = true;

            if (info == null)
            {
                //新增
                info  = new CallRecordInfoInfo();
                isadd = true;
            }
            else
            {
                //更新
                isadd = false;
            }
            //赋值
            info.SessionID    = jsondata.CallData.SessionID_Out;
            info.ExtensionNum = jsondata.CallData.ExtensionNum_Out;
            info.CallStatus   = jsondata.CallData.CallType_Out;
            if (info.CallStatus == 1)
            {
                //呼入
                //         被叫  主叫
                // 呼入 坐席  用户
                info.PhoneNum = GetTel(CallUserType.坐席, jsondata.CallData.ExtensionNum_Out, jsondata.CallData.Zhujiao_Out, jsondata.CallData.Beijiao_Out);
                info.ANI      = GetTel(CallUserType.用户, jsondata.CallData.ExtensionNum_Out, jsondata.CallData.Zhujiao_Out, jsondata.CallData.Beijiao_Out);
            }
            else
            {
                //呼出
                //         被叫  主叫
                // 呼出 用户  坐席
                info.PhoneNum = GetTel(CallUserType.用户, jsondata.CallData.ExtensionNum_Out, jsondata.CallData.Zhujiao_Out, jsondata.CallData.Beijiao_Out);
                info.ANI      = GetTel(CallUserType.坐席, jsondata.CallData.ExtensionNum_Out, jsondata.CallData.Zhujiao_Out, jsondata.CallData.Beijiao_Out);
            }
            info.BeginTime    = jsondata.CallData.BeginTime_Out;
            info.EndTime      = jsondata.CallData.EndTime_Out;
            info.TallTime     = jsondata.CallData.TallTime_Out;
            info.AudioURL     = jsondata.CallData.AudioURL_Out;
            info.CustID       = jsondata.CBID;
            info.CustName     = jsondata.PageData.CBName_Out;
            info.Contact      = jsondata.PageData.CBName_Out;
            info.TaskTypeID   = (int)jsondata.PageData.TaskType_Out;
            info.TaskID       = jsondata.PageData.TaskID_Out;
            info.SkillGroup   = jsondata.CallData.SkillGroup_Out;
            info.BGID         = bgid;
            info.SCID         = scid;
            info.CallID       = jsondata.CallData.CallID_Out;
            info.CreateTime   = DateTime.Now;
            info.CreateUserID = loginuserid;
            //入库
            if (isadd)
            {
                CommonBll.Instance.InsertComAdoInfo(info);
            }
            else
            {
                CommonBll.Instance.UpdateComAdoInfo(info);
            }
        }