Exemple #1
0
        public bool CreateContactInfo(CustomerContactInfoModel contactInfo, out string message)
        {
            bool result = false;

            message = "操作失败,请与管理员联系";

            CustomerDomainModel customer = CustomerInfoService.Instance.GetCustomerDomainModelById(contactInfo.CustomerId, false);

            if (customer == null)
            {
                message = "操作失败,目标客户不存在";
                return(false);
            }

            if (contactInfo != null)
            {
                contactInfo.ContactId = GetGuid();
                PhoneLocationInfoModel loc = PhoneLocationInfoService.Instance.GetLocationInfo(contactInfo.CustomerPhone, false);
                if (loc != null)
                {
                    contactInfo.FromCityId   = loc.ChinaId;
                    contactInfo.FromCityName = loc.City;
                }

                try
                {
                    BeginTransaction();
                    if (Create(contactInfo) == 1)
                    {
                        if (contactInfo.CustomerPhone != "")
                        {
                            CustomerPhoneInfoModel phoneInfo = new CustomerPhoneInfoModel();
                            phoneInfo.CustomerId  = contactInfo.CustomerId;
                            phoneInfo.PhoneNumber = contactInfo.CustomerPhone;
                            if (!CustomerPhoneInfoService.Instance.CreateCustomerPhoneInfo(phoneInfo, out message))
                            {
                                RollbackTransaction();
                                message = "添加客户联系号码失败";
                                return(false);
                            }
                        }
                        CommitTransaction();
                        result  = true;
                        message = "成功创建客户联系记录";
                        CustomerInfoService.Instance.GetCustomerDomainModelById(contactInfo.CustomerId, true);
                    }
                }
                catch (Exception ex)
                {
                    RollbackTransaction();
                    LogUtil.Error("建客户联系记录异常", ex);
                    throw ex;
                }
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="pc">pc</param>
        /// <returns>影响的记录行数</returns>
        public int DeleteMultiple(ParameterCollection pc)
        {
            int ret = 0;

            PhoneLocationInfoModel phonelocationinfo = new PhoneLocationInfoModel();

            ret = DbUtil.Current.DeleteMultiple(phonelocationinfo, pc);

            return(ret);
        }
Exemple #3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="phonelocationinfo">实体</param>
        /// <param name="pc">pc</param>
        /// <returns>影响的记录行数</returns>
        public int UpdateMultiple(PhoneLocationInfoModel phonelocationinfo, ParameterCollection pc)
        {
            int ret = 0;

            phonelocationinfo.ModifiedBy = SessionUtil.Current.UserId;
            phonelocationinfo.ModifiedOn = DateTime.Now;

            ret = DbUtil.Current.UpdateMultiple(phonelocationinfo, pc);

            return(ret);
        }
Exemple #4
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="phonelocationinfo">实体</param>
        /// <returns>影响的记录行数</returns>
        public int Update(PhoneLocationInfoModel phonelocationinfo)
        {
            int ret = 0;

            phonelocationinfo.ModifiedBy = SessionUtil.Current.UserId;
            phonelocationinfo.ModifiedOn = DateTime.Now;

            ret = DbUtil.Current.Update(phonelocationinfo);

            return(ret);
        }
Exemple #5
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="phonecode"></param>
        /// <returns>影响的记录行数</returns>
        public int Delete(string phonecode)
        {
            int ret = 0;

            PhoneLocationInfoModel phonelocationinfo = new PhoneLocationInfoModel();

            phonelocationinfo.PhoneCode = phonecode;

            ret = DbUtil.Current.Delete(phonelocationinfo);

            return(ret);
        }
Exemple #6
0
        public bool CreateCustomerPhoneInfo(CustomerPhoneInfoModel phoneInfo, out string message)
        {
            bool result = false;

            message = "操作失败,请与管理员联系";
            if (phoneInfo == null || string.IsNullOrEmpty(phoneInfo.CustomerId) || string.IsNullOrEmpty(phoneInfo.PhoneNumber))
            {
                message = "添加客户联系号码参数错误,请与管理员联系";
                return(false);
            }

            string checkExistsSQL  = "SELECT COUNT(1) FROM customer_phone_info WHERE phone_number = $phoneNumber$ AND customer_id = $CustomerId$";
            ParameterCollection pc = new ParameterCollection();

            pc.Add("CustomerId", phoneInfo.CustomerId);
            pc.Add("phoneNumber", phoneInfo.PhoneNumber);

            bool exists = ExecuteScalar(checkExistsSQL, pc).ToString() != "0";

            if (exists)
            {
                message = "操作中止,该联系号码已经存在";
                return(true);
            }

            phoneInfo.PhoneId    = GetGuid();
            phoneInfo.CallStatus = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("号码状态", false).GetCustomDataValueDomainByDataValue("正常").ValueId;
            phoneInfo.PhoneType  = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("号码类型", false).GetCustomDataValueDomainByDataValue("其他电话").ValueId;
            phoneInfo.Status     = 0;
            PhoneLocationInfoModel loc = PhoneLocationInfoService.Instance.GetLocationInfo(phoneInfo.PhoneNumber, false);

            if (loc != null)
            {
                phoneInfo.FromCityId   = loc.ChinaId.ToString();
                phoneInfo.FromCityName = loc.City;
            }
            else
            {
                message = "填写号码无法判断归属地,请检查。如果是固定电话,请加上区号";
                //return false;
            }

            if (Create(phoneInfo) == 1)
            {
                message = "成功添加客户联系号码";
                return(true);
            }

            return(result);
        }
Exemple #7
0
        /// <summary>
        /// 根据条件获取实体集合
        /// </summary>
        /// <param name="pc">pc</param>
        /// <param name="obc">obc</param>
        /// <returns>实体</returns>
        public List <PhoneLocationInfoModel> RetrieveMultiple(ParameterCollection pc, OrderByCollection obc)
        {
            List <PhoneLocationInfoModel> phonelocationinfos = new List <PhoneLocationInfoModel>();

            PhoneLocationInfoModel phonelocationinfo = new PhoneLocationInfoModel();
            DataTable dt = DbUtil.Current.RetrieveMultiple(phonelocationinfo, pc, obc);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                phonelocationinfo = new PhoneLocationInfoModel();
                phonelocationinfo.ConvertFrom(dt, i);
                phonelocationinfos.Add(phonelocationinfo);
            }

            return(phonelocationinfos);
        }
Exemple #8
0
        /// <summary>
        /// 根据主键获取实体
        /// </summary>
        /// <param name="phonecode"></param>
        /// <returns>实体</returns>
        public PhoneLocationInfoModel Retrieve(string phonecode)
        {
            PhoneLocationInfoModel phonelocationinfo = new PhoneLocationInfoModel();

            phonelocationinfo.PhoneCode = phonecode;

            DataTable dt = DbUtil.Current.Retrieve(phonelocationinfo);

            if (dt.Rows.Count < 1)
            {
                return(null);
            }

            phonelocationinfo.ConvertFrom(dt);

            return(phonelocationinfo);
        }
        // 在此添加你的代码...

        public PhoneLocationInfoModel GetLocationInfo(string phoneNumber, bool clear)
        {
            if (string.IsNullOrEmpty(phoneNumber))
            {
                return(null);
            }

            string cacheKey = CacheKey.LOCATION_MODEL.GetKeyDefine(phoneNumber);
            PhoneLocationInfoModel result = CacheUtil.Get <PhoneLocationInfoModel>(cacheKey);

            if (result == null || clear)
            {
                result = GetLocationInfoFromDatabase(phoneNumber);
                if (result != null)
                {
                    CacheUtil.Set(cacheKey, result);
                }
            }

            return(result);
        }
Exemple #10
0
        // 在此添加你的代码...

        public bool CreateContactByPhoneNumber(string inComePhoneNumber, CustomerContactInfoModel contactInfo, out string message)
        {
            bool result = false;

            message = "操作失败,请与管理员联系";

            string sql             = "SELECT TOP 1 customer_id FROM customer_contact_info WHERE customer_phone = $customer_phone$";
            ParameterCollection pc = new ParameterCollection();

            pc.Add("customer_phone", inComePhoneNumber);

            object customerId = ExecuteScalar(sql, pc);

            if (customerId != null)
            {
                contactInfo.ContactId     = GetGuid();
                contactInfo.CustomerId    = customerId.ToString();
                contactInfo.CustomerPhone = inComePhoneNumber;
                PhoneLocationInfoModel loc = PhoneLocationInfoService.Instance.GetLocationInfo(contactInfo.CustomerPhone, false);
                if (loc != null)
                {
                    contactInfo.FromCityId   = loc.ChinaId;
                    contactInfo.FromCityName = loc.City;
                }


                if (Create(contactInfo) == 1)
                {
                    result  = true;
                    message = "成功根据来电号码创建联系记录";
                    CustomerInfoService.Instance.GetCustomerDomainModelById(contactInfo.CustomerId, true);
                }
            }

            return(result);
        }
        public PhoneLocationInfoModel GetLocationInfoFromDatabase(string phoneNumber)
        {
            PhoneLocationInfoModel result = null;
            string sql = "select top 1 * from phone_location_info where phone_code = $phone_code$;";

            ParameterCollection pc = new ParameterCollection();

            if (phoneNumber.Length < 6)
            {
                return(null);
            }

            pc.Add("phone_code", phoneNumber.Substring(0, 7));
            DataTable dt = ExecuteDataTable(sql, pc);

            if (dt != null && dt.Rows.Count > 0)
            {
                result = new PhoneLocationInfoModel();
                ModelConvertFrom(result, dt, 0);
            }
            else
            {
                sql = @"select top 1 city,china_id from phone_location_info where region_code = substring($phone_code$, 0, datalength(region_code) + 1)";
                pc.Clear();
                pc.Add("phone_code", phoneNumber);
                dt = ExecuteDataTable(sql, pc);

                if (dt != null && dt.Rows.Count > 0)
                {
                    result = new PhoneLocationInfoModel();
                    ModelConvertFrom(result, dt, 0);
                }
            }

            return(result);
        }
Exemple #12
0
        /// <summary>
        /// 批量新建客户信息。
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool BatchCreateCustomeBasicInfo(CustomerBasicInfoModel info, out string message, string phoneNumebr)
        {
            if (locke)
            {
                message = "正在操作,请稍后再试";
                return(false);
            }
            locke = true;
            int  num    = 1;
            bool result = false;

            message = "操作失败,请与管理员联系";
            List <string> PhoneNumebrList = phoneNumebr.Split('\n').ToList();

            if (PhoneNumebrList == null && PhoneNumebrList.Count == 0)
            {
                message = "请输入电话号码";
                locke   = false;
                return(false);
            }

            try
            {
                BeginTransaction();
                foreach (string phone in PhoneNumebrList)
                {
                    //Regex test = new Regex("^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$", RegexOptions.Compiled);
                    //bool isChinese = test.IsMatch(phone);
                    if (RegexUtil.IsMobilePhone(phone))
                    {
                        info.MobilePhone = phone;
                    }
                    else
                    {
                        info.MobilePhone = "";
                    }

                    if (RegexUtil.IsPhone(phone))
                    {
                        info.HomePhone = phone;
                    }
                    else
                    {
                        info.HomePhone = "";
                    }
                    info.CustomerCode = "C" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + num++;
                    PhoneLocationInfoModel loc = PhoneLocationInfoService.Instance.GetLocationInfo(phone, false);
                    if (loc != null)
                    {
                        info.ChinaId  = loc.ChinaId;
                        info.ComeFrom = loc.City;
                    }
                    else
                    {
                        info.ComeFrom = "";
                    }
                    if (!string.IsNullOrEmpty(info.MobilePhone))
                    {
                        if (CheckExistPhoneNumber(info.MobilePhone))
                        {
                            continue;
                        }
                    }
                    if (!string.IsNullOrEmpty(info.HomePhone))
                    {
                        if (CheckExistPhoneNumber(info.HomePhone))
                        {
                            continue;
                        }
                    }
                    if (!string.IsNullOrEmpty(info.OtherPhone))
                    {
                        if (CheckExistPhoneNumber(info.OtherPhone))
                        {
                            continue;
                        }
                    }
                    info.CustomerId = GetGuid();
                    if (CustomerBasicInfoService.Instance.Create(info) > 0)
                    {
                        if (!string.IsNullOrEmpty(info.MobilePhone))
                        {
                            if (!CustomerPhoneInfoService.Instance.CreateCustomerPhoneInfo(info.MobilePhone, info.CustomerId, out message))
                            {
                                RollbackTransaction();
                                locke = false;
                                return(false);
                            }
                        }

                        if (!string.IsNullOrEmpty(info.HomePhone))
                        {
                            if (!CustomerPhoneInfoService.Instance.CreateCustomerPhoneInfo(info.HomePhone, info.CustomerId, out message))
                            {
                                RollbackTransaction();
                                locke = false;
                                return(false);
                            }
                        }
                        if (!string.IsNullOrEmpty(info.OtherPhone))
                        {
                            if (!CustomerPhoneInfoService.Instance.CreateCustomerPhoneInfo(info.OtherPhone, info.CustomerId, out message))
                            {
                                RollbackTransaction();
                                locke = false;
                                return(false);
                            }
                        }
                        CustomerInfoService.Instance.GetCustomerDomainModelById(info.CustomerId, true);
                    }
                }
                CommitTransaction();
                message = "批量添加客户信息成功";
                locke   = false;
                result  = true;
            }

            catch (Exception ex)
            {
                locke = false;
                RollbackTransaction();
                LogUtil.Error(message, ex);
                throw ex;
            }
            locke = false;
            return(result);
        }
Exemple #13
0
        public bool ImportCustomerBasicInfo(DataTable customerTable, out string importLogs, out string message)
        {
            message    = "操作失败,请与管理员联系";
            importLogs = "";
            bool result = false;

            if (customerTable == null && customerTable.Rows.Count == 0)
            {
                message    = "客户信息表为空,请检查Excel文件是否正确";
                importLogs = message;
                return(false);
            }



            #region 验证表头

            List <CustomerAttributeGroupInfoModel> attGrouList   = new List <CustomerAttributeGroupInfoModel>();
            CustomerExtAttributesModel             attributeInfo = null;
            for (int i = 0; i < customerTable.Rows.Count; i++)
            {
                for (int j = 0; j < customerTable.Columns.Count; j++)
                {
                    attributeInfo = CustomerExtAttributesInfoService.Instance.GetCustomerExtAttributeInfoModelByAttributeName(customerTable.Columns[j].ColumnName, true);
                    if (attributeInfo == null)
                    {
                        message = string.Format("【{0}】列不存在数据库中", customerTable.Columns[j].ColumnName);

                        return(false);
                    }
                    switch (attributeInfo.FieldType)
                    {
                    case "string":
                        break;

                    case "text":
                        break;

                    case "custom":
                        List <string> customList = attributeInfo.CustomValue.Split(',').ToList();
                        if (customList != null && customList.Contains(customerTable.Rows[i][j].ToString()) == false)
                        {
                            message = string.Format("因为Excel第【{0}】行第【{0}】列的值不存在于属性名为A的自定义值列表中", customerTable.Rows[i], customerTable.Columns[j]);
                            return(false);
                        }
                        break;

                    case "decimal":
                        if (Framework.Utilities.CharacterUtil.isNumber(customerTable.Rows[i][j].ToString()) == false)
                        {
                            message = string.Format("因为Excel第【{0}】行第【{0}】列的值不为数值", customerTable.Rows[i], customerTable.Columns[j]);
                            return(false);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            #endregion
            CustomerAttributeGroupInfoModel attGroupInfo = CustomerAttributeGroupInfoService.Instance.GetGroupInfoById(attributeInfo.GroupId, false);
            if (attGroupInfo == null)
            {
                message = "操作失败,请与管理员联系";
                return(false);
            }
            attGrouList.Add(attGroupInfo);

            List <string> insertSQLList = new List <string>();

            foreach (CustomerAttributeGroupInfoModel groupInfo in attGrouList)
            {
                StringBuilder insertSQLBuilder = new StringBuilder();
                insertSQLBuilder.AppendFormat("INSERT INTO {0} (customer_id, created_on, created_by, status_code,", groupInfo.Tabname);
                for (int k = 0; k < customerTable.Columns.Count; k++)
                {
                    attributeInfo = CustomerExtAttributesInfoService.Instance.GetCustomerExtAttributeInfoModelByAttributeName(customerTable.Columns[k].ColumnName, true);
                    if (attributeInfo.GroupId == groupInfo.GroupId)
                    {
                        insertSQLBuilder.AppendFormat("[{0}],", attributeInfo.AttributeName);
                    }
                }
                insertSQLBuilder.Length = insertSQLBuilder.Length - 1;
                insertSQLBuilder.Append(" ) VALUES ( $customer_id$, GETDATE(), $created_by$, 0, ");

                for (int k = 0; k < customerTable.Columns.Count; k++)
                {
                    attributeInfo = CustomerExtAttributesInfoService.Instance.GetCustomerExtAttributeInfoModelByAttributeName(customerTable.Columns[k].ColumnName, true);
                    if (attributeInfo.GroupId == groupInfo.GroupId)
                    {
                        insertSQLBuilder.AppendFormat("${0}$,", CharacterUtil.ConvertToPinyin(attributeInfo.AttributeName));
                    }
                }
                insertSQLBuilder.Length = insertSQLBuilder.Length - 1;
                insertSQLBuilder.Append(" )");

                insertSQLList.Add(insertSQLBuilder.ToString());
            }

            try
            {
                ParameterCollection pc = new ParameterCollection();

                CustomerBasicInfoModel basicInfo = null;
                BeginTransaction();

                for (int i = 0; i < customerTable.Rows.Count; i++)
                {
                    #region 插入客户基本信息表数据
                    basicInfo             = new CustomerBasicInfoModel();
                    basicInfo.CustomerId  = GetGuid();
                    basicInfo.MobilePhone = customerTable.Rows[i]["手机号码"].ToString();
                    basicInfo.HomePhone   = customerTable.Rows[i]["电话号码"].ToString();
                    basicInfo.OtherPhone  = customerTable.Rows[i]["其他号码"].ToString();
                    basicInfo.Sex         = (customerTable.Rows[i]["性别"].ToString() == "男") ? 0 : 1;
                    if (!string.IsNullOrEmpty(customerTable.Rows[i]["手机价位"].ToString()))
                    {
                        basicInfo.MobilePhonePrice = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("手机价位", false).GetCustomDataValueDomainByDataValue(customerTable.Rows[i]["手机价位"].ToString()).ValueId;
                    }
                    else
                    {
                        basicInfo.MobilePhonePrice = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("手机价位", false).GetCustomDataValueDomainByDataValue("未知").ValueId;
                    }

                    basicInfo.Level = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("客户等级", false).GetCustomDataValueDomainByDataValue(customerTable.Rows[i]["客户等级"].ToString()).ValueId;
                    if (!string.IsNullOrEmpty(customerTable.Rows[i]["运营商"].ToString()))
                    {
                        basicInfo.Carriers = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("运营商", false).GetCustomDataValueDomainByDataValue(customerTable.Rows[i]["运营商"].ToString()).ValueId;
                    }
                    else
                    {
                        basicInfo.Carriers = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("运营商", false).GetCustomDataValueDomainByDataValue("未知").ValueId;
                    }
                    basicInfo.UsingPhoneType        = customerTable.Rows[i]["手机型号"].ToString();
                    basicInfo.CommunicationConsumer = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("通讯消费", false).GetCustomDataValueDomainByDataValue(customerTable.Rows[i]["通讯消费"].ToString()).ValueId;
                    basicInfo.PreferredPhoneBrand   = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("优选品牌", false).GetCustomDataValueDomainByDataValue(customerTable.Rows[i]["优选品牌"].ToString()).ValueId;
                    basicInfo.UsingPhoneBrand       = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("优选品牌", false).GetCustomDataValueDomainByDataValue(customerTable.Rows[i]["在用品牌"].ToString()).ValueId;
                    basicInfo.UsingSmartphone       = (customerTable.Rows[i]["是否智能机"].ToString() == "是") ? 0 : 1;

                    basicInfo.SalesFrom    = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("客户来源", false).GetCustomDataValueDomainByDataValue(customerTable.Rows[i]["客户来源"].ToString()).ValueId;
                    basicInfo.CustomerCode = "C" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + i;
                    PhoneLocationInfoModel loc = PhoneLocationInfoService.Instance.GetLocationInfo(basicInfo.MobilePhone, false);
                    basicInfo.CustomerId = GetGuid();
                    if (loc != null)
                    {
                        basicInfo.ChinaId  = loc.ChinaId;
                        basicInfo.ComeFrom = loc.City;
                    }
                    else
                    {
                        basicInfo.ComeFrom = "";
                    }
                    if (!string.IsNullOrEmpty(basicInfo.MobilePhone))
                    {
                        if (CheckExistPhoneNumber(basicInfo.MobilePhone))
                        {
                            continue;
                        }
                    }
                    if (!string.IsNullOrEmpty(basicInfo.HomePhone))
                    {
                        if (CheckExistPhoneNumber(basicInfo.HomePhone))
                        {
                            continue;
                        }
                    }
                    if (!string.IsNullOrEmpty(basicInfo.OtherPhone))
                    {
                        if (CheckExistPhoneNumber(basicInfo.OtherPhone))
                        {
                            continue;
                        }
                    }

                    #endregion

                    pc.Clear();
                    pc.Add("customer_id", basicInfo.CustomerId);
                    pc.Add("created_by", SessionUtil.Current.UserId);

                    for (int k = 0; k < customerTable.Columns.Count; k++)
                    {
                        pc.Add(CharacterUtil.ConvertToPinyin(customerTable.Columns[k].ColumnName), customerTable.Rows[i][k].ToString());
                    }

                    if (CustomerBasicInfoService.Instance.Create(basicInfo) > 0)
                    {
                        foreach (string sql in insertSQLList)
                        {
                            if (DbUtil.Current.IData.ExecuteNonQuery(sql, pc) != 1)
                            {
                                RollbackTransaction();
                                message = "";
                                return(false);
                            }
                        }
                        #region 判断插入customer_phone_info表
                        if (!string.IsNullOrEmpty(basicInfo.MobilePhone))
                        {
                            if (!CustomerPhoneInfoService.Instance.CreateCustomerPhoneInfo(basicInfo.MobilePhone, basicInfo.CustomerId, out message))
                            {
                                RollbackTransaction();

                                return(false);
                            }
                        }

                        if (!string.IsNullOrEmpty(basicInfo.HomePhone))
                        {
                            if (!CustomerPhoneInfoService.Instance.CreateCustomerPhoneInfo(basicInfo.HomePhone, basicInfo.CustomerId, out message))
                            {
                                RollbackTransaction();
                                return(false);
                            }
                        }
                        if (!string.IsNullOrEmpty(basicInfo.OtherPhone))
                        {
                            if (!CustomerPhoneInfoService.Instance.CreateCustomerPhoneInfo(basicInfo.OtherPhone, basicInfo.CustomerId, out message))
                            {
                                RollbackTransaction();
                                return(false);
                            }
                        }
                        #endregion
                        CustomerInfoService.Instance.GetCustomerDomainModelById(basicInfo.CustomerId, true);
                    }
                }


                CommitTransaction();
                message = "成功添加客户信息";
                result  = true;
            }
            catch (Exception ex)
            {
                RollbackTransaction();
                LogUtil.Error("导入客户信息异常", ex);
                throw ex;
            }

            return(result);
        }
Exemple #14
0
        public bool UpdateCustomerPhoneInfo(string oldphoneNumber, string phoneNumber, string customerId, out string message)
        {
            bool result = false;

            if (string.IsNullOrEmpty(oldphoneNumber))
            {
                if (CreateCustomerPhoneInfo(phoneNumber, customerId, out message) == true)
                {
                    message = "成功更新客户联系号码";
                    result  = true;
                    return(result);
                }
                else
                {
                    message = "更新客户联系号码参数错误,请与管理员联系";
                    return(false);
                }
            }
            message = "操作失败,请与管理员联系";

            if (string.IsNullOrEmpty(phoneNumber) || string.IsNullOrEmpty(customerId))
            {
                message = "参数错误,联系号码或客户ID不能为空";
                return(false);
            }

            CustomerDomainModel customerInfo = CustomerInfoService.Instance.GetCustomerDomainModelById(customerId, false);

            if (customerInfo == null)
            {
                message = "操作失败,不存在的客户ID";
                return(false);
            }

            CustomerPhoneInfoModel phoneInfo = new CustomerPhoneInfoModel();

            phoneInfo.PhoneNumber = phoneNumber;
            phoneInfo.CustomerId  = customerId;

            string checkExistsSQL  = "SELECT * FROM customer_phone_info WHERE phone_number = $oldphoneNumber$ AND customer_id = $CustomerId$";
            ParameterCollection pc = new ParameterCollection();

            pc.Add("CustomerId", phoneInfo.CustomerId);
            pc.Add("oldphoneNumber", oldphoneNumber);

            string phoneid = ExecuteScalar(checkExistsSQL, pc).ToString();

            if (string.IsNullOrEmpty(phoneid))
            {
                message = "更新客户联系号码参数错误,请与管理员联系";
                return(false);
            }



            phoneInfo.PhoneId    = phoneid;
            phoneInfo.CallStatus = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("号码状态", false).GetCustomDataValueDomainByDataValue("正常").ValueId;
            phoneInfo.PhoneType  = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("号码类型", false).GetCustomDataValueDomainByDataValue("其他电话").ValueId;
            phoneInfo.Status     = 0;
            PhoneLocationInfoModel loc = PhoneLocationInfoService.Instance.GetLocationInfo(phoneInfo.PhoneNumber, false);

            if (loc != null)
            {
                phoneInfo.FromCityId   = loc.ChinaId.ToString();
                phoneInfo.FromCityName = loc.City;
            }
            else
            {
                message = "填写号码无法判断归属地,请检查。如果是固定电话,请加上区号";
                //return false;
            }

            if (Update(phoneInfo) == 1)
            {
                message = "成功更新客户联系号码";
                return(true);
            }

            return(result);
        }