Пример #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);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="pc">pc</param>
        /// <returns>影响的记录行数</returns>
        public int DeleteMultiple(ParameterCollection pc)
        {
            int ret = 0;

            CustomerContactInfoModel customercontactinfo = new CustomerContactInfoModel();

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

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

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

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

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

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

            ret = DbUtil.Current.Update(customercontactinfo);

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

            CustomerContactInfoModel customercontactinfo = new CustomerContactInfoModel();

            customercontactinfo.ContactId = contactid;

            ret = DbUtil.Current.Delete(customercontactinfo);

            return(ret);
        }
Пример #6
0
        //public int UpdateUserId(string business_id, int limit)
        //{
        //    int count = 0;
        //    foreach (var t in _customerRepository.GetCustomers(business_id, new Paging { Limit = limit }).Result)
        //    {
        //        var user_id = FacebookConversationService.GetUniqueUserId(t.avatar, t.ext_id);
        //        if (!string.IsNullOrWhiteSpace(user_id))
        //        {
        //            count++;
        //            _customerRepository.UpdateUserId(business_id, t.key, user_id);
        //        }
        //    }
        //    return count;
        //}

        public void UpdateContactInfo(string business_id, string customer_id, CustomerContactInfoModel data)
        {
            var           customer  = GetById(business_id, customer_id);
            List <string> phoneList = customer.phone_list == null ? new List <string>() : customer.phone_list;

            if (!string.IsNullOrWhiteSpace(data.phone))
            {
                phoneList.Add(data.phone);
                data.phone_list = phoneList;
            }
            _customerRepository.UpdateContactInfo(business_id, customer_id, data);
        }
        /// <summary>
        /// 根据条件获取实体集合
        /// </summary>
        /// <param name="pc">pc</param>
        /// <param name="obc">obc</param>
        /// <returns>实体</returns>
        public List <CustomerContactInfoModel> RetrieveMultiple(ParameterCollection pc, OrderByCollection obc)
        {
            List <CustomerContactInfoModel> customercontactinfos = new List <CustomerContactInfoModel>();

            CustomerContactInfoModel customercontactinfo = new CustomerContactInfoModel();
            DataTable dt = DbUtil.Current.RetrieveMultiple(customercontactinfo, pc, obc);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                customercontactinfo = new CustomerContactInfoModel();
                customercontactinfo.ConvertFrom(dt, i);
                customercontactinfos.Add(customercontactinfo);
            }

            return(customercontactinfos);
        }
Пример #8
0
        public string GetOutCallNumber(CustomerContactInfoModel contactInfo)
        {
            if (contactInfo == null)
            {
                return("");
            }

            if (Framework.Utilities.RegexUtil.IsMobilePhone(contactInfo.CustomerPhone))
            {
                return((contactInfo.FromCityId == 472) ? "9" + contactInfo.CustomerPhone : "90" + contactInfo.CustomerPhone);
            }
            else
            {
                return((contactInfo.FromCityId == 472) ? "9" + contactInfo.CustomerPhone : "9" + contactInfo.CustomerPhone);
            }
        }
        /// <summary>
        /// 根据主键获取实体
        /// </summary>
        /// <param name="contactid"></param>
        /// <returns>实体</returns>
        public CustomerContactInfoModel Retrieve(string contactid)
        {
            CustomerContactInfoModel customercontactinfo = new CustomerContactInfoModel();

            customercontactinfo.ContactId = contactid;

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

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

            customercontactinfo.ConvertFrom(dt);

            return(customercontactinfo);
        }
Пример #10
0
        public ApiResponse CustomerEdit(string business_id, string id, [FromForm] CustomerContactInfoModel data)
        {
            ApiResponse response     = new ApiResponse();
            var         access_token = Request.Cookies["access_token"];
            var         url          = _appSettings.BaseUrls.Api + "customers/info/" + id + "/?business_id=" + business_id + "&access_token=" + access_token;
            var         model        = Core.Helpers.WebHelper.HttpGetAsync <CustomerContactInfoModel>(url).Result;

            if (model == null)
            {
                return(response);
            }
            model.id = id;
            var result = _viewRenderService.RenderToStringAsync("Customer/Edit", model).Result;

            response.view = result;
            response.ok   = true;
            return(response);
        }
Пример #11
0
        public ApiResponse UpdateContactInfo(string id, [FromBody] CustomerContactInfoModel data, [FromQuery] string business_id)
        {
            ApiResponse response = new ApiResponse();

            data.real_name = data.real_name ?? "";
            data.real_name = data.real_name.Trim();

            if (string.IsNullOrWhiteSpace(data.real_name))
            {
                response.msg = "Real name cannot be empty"; return(response);
            }

            data.name = data.name ?? "";
            data.name = data.name.Trim();
            if (string.IsNullOrWhiteSpace(data.name))
            {
                response.msg = "Nick name cannot be empty"; return(response);
            }

            data.phone = data.phone ?? "";
            data.phone = data.phone.Trim().ToLower();
            if (!string.IsNullOrWhiteSpace(data.phone))
            {
                data.phone = Core.Helpers.CommonHelper.FindPhoneNumbers(data.phone).SingleOrDefault();
                if (string.IsNullOrWhiteSpace(data.phone))
                {
                    response.msg = "Phone number is invalid"; return(response);
                }
            }

            data.email = data.email ?? "";
            data.email = data.email.Trim().ToLower();
            //if (!string.IsNullOrWhiteSpace(data.email))
            //{
            //if (Core.Helpers.CommonHelper.ValidEmail(data.email))
            //{
            //   response.msg = "Email address is invalid"; return response;
            //}
            // }
            _customerService.UpdateContactInfo(business_id, id, data);
            response.ok = true;
            return(response);
        }
Пример #12
0
        public ApiResponse CustomerUpdate(string business_id, string customer_id, [FromForm] CustomerContactInfoModel model)
        {
            ApiResponse response     = new ApiResponse();
            var         access_token = Request.Cookies["access_token"];
            var         url          = _appSettings.BaseUrls.Api + "customers/info/" + customer_id + "/?business_id=" + business_id + "&access_token=" + access_token;

            model.id = customer_id;
            response = Core.Helpers.WebHelper.HttpPostAsync <ApiResponse>(url, model).Result;

            if (response.ok)
            {
                return(response);
            }
            var result = _viewRenderService.RenderToStringAsync("Customer/Edit", model).Result;

            response.view = result;
            response.ok   = false;
            return(response);
        }
Пример #13
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);
        }