Beispiel #1
0
 public int CreateCustomer(CustomerServiceInfo info, ref string msg)
 {
     msg = "未知错误";
     try
     {
         DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT userver  FROM MeiQia_Userver WHERE userver=@Name");
         this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, info.userver);
         if (Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand)) >= 1)
         {
             msg = "登录手机号重复";
             return(0);
         }
         sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO [MeiQia_Userver]([unit],[userver],[password],[nickname],[realname],[level],[tel]) VALUES (@unit,@userver,@password,@nickname,@realname,@level,@tel); SELECT CAST(scope_identity() AS int);");
         this.database.AddInParameter(sqlStringCommand, "unit", DbType.String, info.unit);
         this.database.AddInParameter(sqlStringCommand, "userver", DbType.String, info.userver);
         this.database.AddInParameter(sqlStringCommand, "password", DbType.String, info.password);
         this.database.AddInParameter(sqlStringCommand, "nickname", DbType.String, info.nickname);
         this.database.AddInParameter(sqlStringCommand, "realname", DbType.String, info.realname);
         this.database.AddInParameter(sqlStringCommand, "level", DbType.String, info.level);
         this.database.AddInParameter(sqlStringCommand, "tel", DbType.String, info.tel);
         int num = (int)this.database.ExecuteScalar(sqlStringCommand);
         msg = "";
         return(num);
     }
     catch (Exception exception)
     {
         msg = exception.Message;
         return(0);
     }
 }
Beispiel #2
0
 public bool UpdateCustomer(CustomerServiceInfo info, ref string msg)
 {
     msg = "未知错误";
     try
     {
         DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT userver  FROM MeiQia_Userver WHERE userver=@Name and id <> @ID");
         this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, info.userver);
         this.database.AddInParameter(sqlStringCommand, "ID", DbType.Int32, info.id);
         if (Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand)) >= 1)
         {
             msg = "登录手机号重复";
             return(false);
         }
         sqlStringCommand = this.database.GetSqlStringCommand("UPDATE [MeiQia_Userver] SET [unit] = @unit,[userver] = @userver,[password] = @password,[nickname] = @nickname,[realname] = @realname,[level] = @level,[tel] = @tel WHERE id=@id");
         this.database.AddInParameter(sqlStringCommand, "unit", DbType.String, info.unit);
         this.database.AddInParameter(sqlStringCommand, "userver", DbType.String, info.userver);
         this.database.AddInParameter(sqlStringCommand, "password", DbType.String, info.password);
         this.database.AddInParameter(sqlStringCommand, "nickname", DbType.String, info.nickname);
         this.database.AddInParameter(sqlStringCommand, "realname", DbType.String, info.realname);
         this.database.AddInParameter(sqlStringCommand, "level", DbType.String, info.level);
         this.database.AddInParameter(sqlStringCommand, "tel", DbType.String, info.tel);
         this.database.AddInParameter(sqlStringCommand, "id", DbType.Int32, info.id);
         int num = this.database.ExecuteNonQuery(sqlStringCommand);
         msg = "";
         return(num > 0);
     }
     catch (Exception exception)
     {
         msg = exception.Message;
         return(false);
     }
 }
Beispiel #3
0
 public void AddCustomerService(CustomerServiceInfo customerService)
 {
     CheckPropertyWhenAdd(customerService);
     customerService.Name = customerService.Name.Trim();
     context.CustomerServiceInfo.Add(customerService);
     context.SaveChanges();
 }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int result = 0;

            int.TryParse(context.Request["id"].ToString(), out result);
            if (result > 0)
            {
                CustomerServiceInfo customer = CustomerServiceHelper.GetCustomer(result);
                var typea = new {
                    type     = "success",
                    userver  = customer.userver,
                    password = customer.password,
                    nickname = customer.nickname
                };
                string s = JsonConvert.SerializeObject(typea);
                context.Response.Write(s);
            }
            else
            {
                var typea2 = new {
                    type     = "success",
                    userver  = string.Empty,
                    password = string.Empty,
                    nickname = string.Empty
                };
                string str2 = JsonConvert.SerializeObject(typea2);
                context.Response.Write(str2);
            }
        }
        public void UpdateCustomerServicTest()
        {
            var customerService = new CustomerServiceInfo()
            {
                ShopId      = SHOPID,
                Name        = "小黑",
                Tool        = CustomerServiceInfo.ServiceTool.Wangwang,
                Type        = CustomerServiceInfo.ServiceType.AfterSale,
                AccountCode = "564654343"
            };
            var service = Instance <ICustomerService> .Create;

            service.AddCustomerService(customerService);

            var customerService2 = new CustomerServiceInfo()
            {
                Id          = customerService.Id,
                ShopId      = SHOPID,
                Name        = "小黑2",
                Tool        = CustomerServiceInfo.ServiceTool.Wangwang,
                Type        = CustomerServiceInfo.ServiceType.AfterSale,
                AccountCode = Guid.NewGuid().ToString("N").Substring(0, 12)
            };

            service.UpdateCustomerService(customerService2);

            var actualCustomerService2 = service.GetCustomerService(SHOPID, customerService.Id);

            Assert.AreEqual(customerService2.Name, actualCustomerService2.Name);
            Assert.AreEqual(customerService2.Tool, actualCustomerService2.Tool);
            Assert.AreEqual(customerService2.Type, actualCustomerService2.Type);
            Assert.AreEqual(customerService2.AccountCode, actualCustomerService2.AccountCode);
        }
Beispiel #6
0
        private CustomerServiceInfo CheckPropertyWhenUpdate(CustomerServiceInfo customerService)
        {
            if (string.IsNullOrWhiteSpace(customerService.Name))
            {
                throw new InvalidPropertyException("客服名称不能为空");
            }
            if (customerService.Id == 0)
            {
                throw new InvalidPropertyException("客服id必须大于0");
            }
            if (customerService.ShopId == 0)
            {
                throw new InvalidPropertyException("供应商id必须大于0");
            }
            if (string.IsNullOrWhiteSpace(customerService.AccountCode))
            {
                throw new InvalidPropertyException("沟通工具账号不能为空");
            }
            CustomerServiceInfo customerServiceInfo = context.CustomerServiceInfo.FirstOrDefault((CustomerServiceInfo item) => item.Id == customerService.Id && item.ShopId == customerService.ShopId);

            if (customerServiceInfo == null)
            {
                throw new InvalidPropertyException(string.Concat("不存在id为", customerService.Id, "的客服信息"));
            }
            return(customerServiceInfo);
        }
Beispiel #7
0
        public ActionResult CustmerServices(long shopId)
        {
            List <CustomerServiceInfo> list = (
                from m in ServiceHelper.Create <ICustomerService>().GetCustomerService(shopId)
                orderby m.Tool
                select m).ToList();
            List <CustomerServiceInfo> customerServiceInfos = new List <CustomerServiceInfo>();
            CustomerServiceInfo        customerServiceInfo  = list.Where((CustomerServiceInfo a) => {
                if (a.Tool != CustomerServiceInfo.ServiceTool.QQ)
                {
                    return(false);
                }
                return(a.Type == CustomerServiceInfo.ServiceType.AfterSale);
            }).OrderBy <CustomerServiceInfo, string>((CustomerServiceInfo t) => Guid.NewGuid().ToString()).FirstOrDefault();
            CustomerServiceInfo customerServiceInfo1 = list.Where((CustomerServiceInfo a) => {
                if (a.Tool != CustomerServiceInfo.ServiceTool.Wangwang)
                {
                    return(false);
                }
                return(a.Type == CustomerServiceInfo.ServiceType.AfterSale);
            }).OrderBy <CustomerServiceInfo, string>((CustomerServiceInfo t) => Guid.NewGuid().ToString()).FirstOrDefault();

            if (customerServiceInfo != null)
            {
                customerServiceInfos.Add(customerServiceInfo);
            }
            if (customerServiceInfo1 != null)
            {
                customerServiceInfos.Add(customerServiceInfo1);
            }
            return(base.PartialView(customerServiceInfos));
        }
Beispiel #8
0
 /// <summary>
 /// 添加客服
 /// </summary>
 /// <param name="customerService">客服信息</param>
 public void AddPlateCustomerService(CustomerServiceInfo customerService)
 {
     CheckPlatformCustomerServiceWhenAdd(customerService);
     //Context.CustomerServiceInfo.Add(customerService);
     //Context.SaveChanges();
     DbFactory.Default.Add(customerService);
 }
        public JsonResult Add(CustomerServiceModel customerServiceModel)
        {
            var service = _iCustomerService;
            CustomerServiceInfo customerServiceInfo = new CustomerServiceInfo()
            {
                Id           = customerServiceModel.Id,
                Type         = customerServiceModel.Type.GetValueOrDefault(CustomerServiceInfo.ServiceType.PreSale),
                Tool         = customerServiceModel.Tool,
                Name         = customerServiceModel.Name,
                AccountCode  = customerServiceModel.Account,
                ShopId       = CurrentSellerManager.ShopId,
                TerminalType = Himall.Model.CustomerServiceInfo.ServiceTerminalType.PC,
                ServerStatus = Himall.Model.CustomerServiceInfo.ServiceStatusType.Open
            };

            if (customerServiceInfo.Id > 0)
            {
                service.UpdateCustomerService(customerServiceInfo);
            }
            else
            {
                service.AddCustomerService(customerServiceInfo);
            }

            return(Json(new { success = true }));
        }
        public ActionResult Add(long?id)
        {
            var service = _iCustomerService;
            CustomerServiceInfo customerServiceInfo;

            if (id.HasValue && id > 0)
            {
                customerServiceInfo = service.GetCustomerService(CurrentSellerManager.ShopId, id.Value);
            }
            else
            {
                customerServiceInfo = new CustomerServiceInfo();
            }

            var customerServiceModels = new CustomerServiceModel()
            {
                Id      = customerServiceInfo.Id,
                Account = customerServiceInfo.AccountCode,
                Name    = customerServiceInfo.Name,
                Tool    = customerServiceInfo.Tool,
                Type    = customerServiceInfo.Type
            };

            return(View(customerServiceModels));
        }
Beispiel #11
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int num = 0;

            int.TryParse(context.Request["id"].ToString(), out num);
            if (num > 0)
            {
                CustomerServiceInfo customer = CustomerServiceHelper.GetCustomer(num);
                var value = new
                {
                    type     = "success",
                    userver  = customer.userver,
                    password = customer.password,
                    nickname = customer.nickname
                };
                string s = JsonConvert.SerializeObject(value);
                context.Response.Write(s);
                return;
            }
            var value2 = new
            {
                type     = "success",
                userver  = string.Empty,
                password = string.Empty,
                nickname = string.Empty
            };
            string s2 = JsonConvert.SerializeObject(value2);

            context.Response.Write(s2);
        }
Beispiel #12
0
 public void AddCustomerService(CustomerServiceInfo customerService)
 {
     CheckPropertyWhenAdd(customerService);
     customerService.Name = customerService.Name.Trim();//去除首尾空白
     //Context.CustomerServiceInfo.Add(customerService);
     //Context.SaveChanges();
     DbFactory.Default.Add(customerService);
 }
Beispiel #13
0
        /// <summary>
        /// 更新时检查属性
        /// </summary>
        /// <param name="customerService"></param>
        /// <returns>返回原始客服信息</returns>
        CustomerServiceInfo CheckPropertyWhenUpdate(CustomerServiceInfo customerService)
        {
            if (customerService.ShopId == 0)
            {
                throw new InvalidPropertyException("店铺id必须大于0");
            }

            return(CheckPlatformCustomerServiceWhenUpdate(customerService));
        }
Beispiel #14
0
        /// <summary>
        /// 添加时检查属性
        /// </summary>
        /// <param name="customerService"></param>
        void CheckPropertyWhenAdd(CustomerServiceInfo customerService)
        {
            CheckPlatformCustomerServiceWhenAdd(customerService);

            if (customerService.ShopId == 0)
            {
                throw new InvalidPropertyException("店铺id必须大于0");
            }
        }
Beispiel #15
0
        public void UpdateCustomerService(CustomerServiceInfo customerService)
        {
            CustomerServiceInfo name = CheckPropertyWhenUpdate(customerService);

            name.Name        = customerService.Name;
            name.Type        = customerService.Type;
            name.Tool        = customerService.Tool;
            name.AccountCode = customerService.AccountCode;
            context.SaveChanges();
        }
Beispiel #16
0
 /// <summary>
 /// 添加时检查属性
 /// </summary>
 /// <param name="customerService"></param>
 void CheckPlatformCustomerServiceWhenAdd(CustomerServiceInfo customerService)
 {
     if (string.IsNullOrWhiteSpace(customerService.Name))
     {
         throw new InvalidPropertyException("客服名称不能为空");
     }
     if (string.IsNullOrWhiteSpace(customerService.AccountCode))
     {
         throw new InvalidPropertyException("沟通工具账号不能为空");
     }
 }
Beispiel #17
0
        public CustomerServiceInfo GetCustomer(int id)
        {
            CustomerServiceInfo result = null;

            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM MeiQia_Userver WHERE id = @ID");
            this.database.AddInParameter(sqlStringCommand, "ID", System.Data.DbType.Int32, id);
            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                result = ReaderConvert.ReaderToModel <CustomerServiceInfo>(dataReader);
            }
            return(result);
        }
        public void AddCustomerServiceTest()
        {
            var customerService = new CustomerServiceInfo()
            {
                ShopId      = SHOPID,
                Name        = "小黑",
                Tool        = CustomerServiceInfo.ServiceTool.Wangwang,
                Type        = CustomerServiceInfo.ServiceType.AfterSale,
                AccountCode = "564654343"
            };
            var service = Instance <ICustomerService> .Create;

            service.AddCustomerService(customerService);
        }
Beispiel #19
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (Globals.GetCurrentManagerUserId() <= 0)
            {
                context.Response.Write("{\"type\":\"error\",\"data\":\"请先登录\"}");
                context.Response.End();
            }
            int result = 0;

            int.TryParse(context.Request["id"].ToString(), out result);
            if (result > 0)
            {
                CustomerServiceInfo     customer       = CustomerServiceHelper.GetCustomer(result);
                CustomerServiceSettings masterSettings = CustomerServiceManager.GetMasterSettings(false);
                string tokenValue = TokenApi.GetTokenValue(masterSettings.AppId, masterSettings.AppSecret);
                if (!string.IsNullOrEmpty(tokenValue))
                {
                    string str2 = CustomerApi.DeleteCustomer(tokenValue, customer.unit, customer.userver);
                    if (!string.IsNullOrWhiteSpace(str2))
                    {
                        string jsonValue = Hishop.MeiQia.Api.Util.Common.GetJsonValue(str2, "errcode");
                        string str4      = Hishop.MeiQia.Api.Util.Common.GetJsonValue(str2, "errmsg");
                        if (jsonValue == "0")
                        {
                            if (CustomerServiceHelper.DeletCustomer(result))
                            {
                                context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                            }
                        }
                        else
                        {
                            context.Response.Write("{\"type\":\"error\",\"data\":\"" + str4 + "\"}");
                        }
                    }
                    else
                    {
                        context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                    }
                }
                else
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"获取access_token失败!\"}");
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            wid = context.Session[DTKeys.SESSION_WEB_ID] as string;
            if (string.IsNullOrEmpty(wid))
            {
                return;
            }
            context.Response.ContentType = "text/plain";
            int result = 0;

            int.TryParse(context.Request["id"].ToString(), out result);
            if (result > 0)
            {
                CustomerServiceInfo     customer       = CustomerServiceHelper.GetCustomer(result);
                CustomerServiceSettings masterSettings = CustomerServiceManager.GetMasterSettings(false);
                string tokenValue = TokenApi.GetTokenValue(masterSettings.AppId, masterSettings.AppSecret);
                if (!string.IsNullOrEmpty(tokenValue))
                {
                    string str2 = CustomerApi.DeleteCustomer(tokenValue, customer.unit, customer.userver);
                    if (!string.IsNullOrWhiteSpace(str2))
                    {
                        string jsonValue = Common.GetJsonValue(str2, "errcode");
                        string str4      = Common.GetJsonValue(str2, "errmsg");
                        if (jsonValue == "0")
                        {
                            if (CustomerServiceHelper.DeletCustomer(result))
                            {
                                context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                            }
                        }
                        else
                        {
                            context.Response.Write("{\"type\":\"error\",\"data\":\"" + str4 + "\"}");
                        }
                    }
                    else
                    {
                        context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                    }
                }
                else
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"获取access_token失败!\"}");
                }
            }
        }
Beispiel #21
0
 private void CheckPropertyWhenAdd(CustomerServiceInfo customerService)
 {
     if (string.IsNullOrWhiteSpace(customerService.Name))
     {
         throw new InvalidPropertyException("客服名称不能为空");
     }
     if (customerService.ShopId == 0)
     {
         throw new InvalidPropertyException("供应商id必须大于0");
     }
     if (string.IsNullOrWhiteSpace(customerService.AccountCode))
     {
         throw new InvalidPropertyException("沟通工具账号不能为空");
     }
 }
        public void UpdateCustomerService(CustomerServiceInfo customerService)
        {
            //检查
            var ori = CheckPropertyWhenUpdate(customerService);

            //更新信息
            ori.Name         = customerService.Name;
            ori.Type         = customerService.Type;
            ori.Tool         = customerService.Tool;
            ori.AccountCode  = customerService.AccountCode;
            ori.TerminalType = customerService.TerminalType;
            ori.ServerStatus = customerService.ServerStatus;

            //保存更改
            Context.SaveChanges();
        }
        public ActionResult Add(long?id)
        {
            CustomerServiceInfo  customerServiceInfo;
            CustomerServiceModel customerServiceModel;
            ICustomerService     customerService = ServiceHelper.Create <ICustomerService>();

            if (id.HasValue)
            {
                long?nullable = id;
                if ((nullable.GetValueOrDefault() <= 0 ? true : !nullable.HasValue))
                {
                    customerServiceInfo  = new CustomerServiceInfo();
                    customerServiceModel = new CustomerServiceModel()
                    {
                        Id      = customerServiceInfo.Id,
                        Account = customerServiceInfo.AccountCode,
                        Name    = customerServiceInfo.Name,
                        Tool    = customerServiceInfo.Tool,
                        Type    = new CustomerServiceInfo.ServiceType?(customerServiceInfo.Type)
                    };
                    return(View(customerServiceModel));
                }
                customerServiceInfo  = customerService.GetCustomerService(base.CurrentSellerManager.ShopId, id.Value);
                customerServiceModel = new CustomerServiceModel()
                {
                    Id      = customerServiceInfo.Id,
                    Account = customerServiceInfo.AccountCode,
                    Name    = customerServiceInfo.Name,
                    Tool    = customerServiceInfo.Tool,
                    Type    = new CustomerServiceInfo.ServiceType?(customerServiceInfo.Type)
                };
                return(View(customerServiceModel));
            }
            customerServiceInfo  = new CustomerServiceInfo();
            customerServiceModel = new CustomerServiceModel()
            {
                Id      = customerServiceInfo.Id,
                Account = customerServiceInfo.AccountCode,
                Name    = customerServiceInfo.Name,
                Tool    = customerServiceInfo.Tool,
                Type    = new CustomerServiceInfo.ServiceType?(customerServiceInfo.Type)
            };
            return(View(customerServiceModel));
        }
        public void ProcessRequest(System.Web.HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int num = 0;

            int.TryParse(context.Request["id"].ToString(), out num);
            if (num > 0)
            {
                CustomerServiceInfo     customer       = CustomerServiceHelper.GetCustomer(num);
                CustomerServiceSettings masterSettings = CustomerServiceManager.GetMasterSettings(false);
                string tokenValue = TokenApi.GetTokenValue(masterSettings.AppId, masterSettings.AppSecret);
                if (!string.IsNullOrEmpty(tokenValue))
                {
                    string text = CustomerApi.DeleteCustomer(tokenValue, customer.unit, customer.userver);
                    if (string.IsNullOrWhiteSpace(text))
                    {
                        context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                        return;
                    }
                    string jsonValue  = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text, "errcode");
                    string jsonValue2 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text, "errmsg");
                    if (!(jsonValue == "0"))
                    {
                        context.Response.Write("{\"type\":\"error\",\"data\":\"" + jsonValue2 + "\"}");
                        return;
                    }
                    bool flag = CustomerServiceHelper.DeletCustomer(num);
                    if (flag)
                    {
                        context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                        return;
                    }
                    context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                    return;
                }
                else
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"获取access_token失败!\"}");
                }
            }
        }
        public ActionResult addMobile()
        {
            var service = _iCustomerService;
            CustomerServiceInfo customerServiceInfo;

            customerServiceInfo = service.GetCustomerServiceForMobile(CurrentSellerManager.ShopId);
            if (customerServiceInfo == null)
            {
                customerServiceInfo = new CustomerServiceInfo();
            }
            var customerServiceModels = new CustomerServiceModel()
            {
                Id      = customerServiceInfo.Id,
                Account = customerServiceInfo.AccountCode,
                Name    = customerServiceInfo.Name,
                Tool    = customerServiceInfo.Tool,
                Type    = customerServiceInfo.Type
            };

            return(View(customerServiceModels));
        }
        public void GetCustomerServiceByIdTest()
        {
            var customerService = new CustomerServiceInfo()
            {
                ShopId      = SHOPID,
                Name        = "小黑",
                Tool        = CustomerServiceInfo.ServiceTool.Wangwang,
                Type        = CustomerServiceInfo.ServiceType.AfterSale,
                AccountCode = "564654343"
            };
            var service = Instance <ICustomerService> .Create;

            service.AddCustomerService(customerService);

            var customerService2 = service.GetCustomerService(SHOPID, customerService.Id);

            Assert.AreEqual(customerService.Name, customerService2.Name);
            Assert.AreEqual(customerService.Tool, customerService2.Tool);
            Assert.AreEqual(customerService.Type, customerService2.Type);
            Assert.AreEqual(customerService.AccountCode, customerService2.AccountCode);
        }
        public void DeleteCustomerServiceTest()
        {
            var customerService = new CustomerServiceInfo()
            {
                ShopId      = SHOPID,
                Name        = "小黑",
                Tool        = CustomerServiceInfo.ServiceTool.Wangwang,
                Type        = CustomerServiceInfo.ServiceType.AfterSale,
                AccountCode = "564654343"
            };
            var service = Instance <ICustomerService> .Create;

            service.AddCustomerService(customerService);
            var customerService2 = service.GetCustomerService(SHOPID, customerService.Id);

            Assert.IsNotNull(customerService2);

            service.DeleteCustomerService(SHOPID, customerService.Id);
            customerService2 = service.GetCustomerService(SHOPID, customerService.Id);
            Assert.IsNull(customerService2);
        }
        /// <summary>
        /// 更新时检查属性
        /// </summary>
        /// <param name="customerService"></param>
        /// <returns>返回原始客服信息</returns>
        CustomerServiceInfo CheckPlatformCustomerServiceWhenUpdate(CustomerServiceInfo customerService)
        {
            if (string.IsNullOrWhiteSpace(customerService.Name))
            {
                throw new InvalidPropertyException("客服名称不能为空");
            }
            if (customerService.Id == 0)
            {
                throw new InvalidPropertyException("客服id必须大于0");
            }
            if (string.IsNullOrWhiteSpace(customerService.AccountCode))
            {
                throw new InvalidPropertyException("沟通工具账号不能为空");
            }

            var ori = Context.CustomerServiceInfo.FirstOrDefault(item => item.Id == customerService.Id && item.ShopId == customerService.ShopId); //查找指定店铺下指定id的客服

            if (ori == null)                                                                                                                      //查询不到,说明店铺id与客服id不匹配或至少有一个不存在
            {
                throw new InvalidPropertyException("不存在id为" + customerService.Id + "的客服信息");
            }
            return(ori);
        }
        public JsonResult Add(CustomerServiceModel customerServiceModel)
        {
            ICustomerService    customerService     = ServiceHelper.Create <ICustomerService>();
            CustomerServiceInfo customerServiceInfo = new CustomerServiceInfo()
            {
                Id          = customerServiceModel.Id,
                Type        = customerServiceModel.Type.GetValueOrDefault(CustomerServiceInfo.ServiceType.PreSale),
                Tool        = customerServiceModel.Tool,
                Name        = customerServiceModel.Name,
                AccountCode = customerServiceModel.Account,
                ShopId      = base.CurrentSellerManager.ShopId
            };
            CustomerServiceInfo customerServiceInfo1 = customerServiceInfo;

            if (customerServiceInfo1.Id <= 0)
            {
                customerService.AddCustomerService(customerServiceInfo1);
            }
            else
            {
                customerService.UpdateCustomerService(customerServiceInfo1);
            }
            return(Json(new { success = true }));
        }
Beispiel #30
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int num = 0;

            int.TryParse(context.Request["id"].ToString(), out num);
            CustomerServiceSettings masterSettings = CustomerServiceManager.GetMasterSettings(false);
            string unit       = masterSettings.unit;
            string text       = context.Request["userver"].ToString();
            string password   = context.Request["password"].ToString();
            string text2      = context.Request["nickname"].ToString();
            string value      = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            string tokenValue = TokenApi.GetTokenValue(masterSettings.AppId, masterSettings.AppSecret);

            if (string.IsNullOrEmpty(tokenValue))
            {
                context.Response.Write("{\"type\":\"error\",\"data\":\"获取access_token失败!\"}");
                return;
            }
            System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
            dictionary.Add("unit", unit);
            dictionary.Add("userver", text);
            dictionary.Add("password", value);
            dictionary.Add("nickname", text2);
            dictionary.Add("realname", "");
            dictionary.Add("level", "");
            dictionary.Add("tel", "");
            string empty = string.Empty;
            CustomerServiceInfo customerServiceInfo = new CustomerServiceInfo();

            if (num != 0)
            {
                string text3 = CustomerApi.UpdateCustomer(tokenValue, dictionary);
                if (string.IsNullOrWhiteSpace(text3))
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"修改客服信息失败!\"}");
                    return;
                }
                string jsonValue  = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text3, "errcode");
                string jsonValue2 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text3, "errmsg");
                if (!(jsonValue == "0"))
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"" + jsonValue2 + "\"}");
                    return;
                }
                customerServiceInfo          = CustomerServiceHelper.GetCustomer(num);
                customerServiceInfo.unit     = unit;
                customerServiceInfo.userver  = text;
                customerServiceInfo.password = password;
                customerServiceInfo.nickname = text2;
                bool flag = CustomerServiceHelper.UpdateCustomer(customerServiceInfo, ref empty);
                if (flag)
                {
                    context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                    return;
                }
                context.Response.Write("{\"type\":\"error\",\"data\":\"" + empty + "\"}");
                return;
            }
            else
            {
                string text4 = CustomerApi.CreateCustomer(tokenValue, dictionary);
                if (string.IsNullOrWhiteSpace(text4))
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"注册客服用户失败!\"}");
                    return;
                }
                string jsonValue3 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text4, "errcode");
                string jsonValue4 = Hishop.MeiQia.Api.Util.Common.GetJsonValue(text4, "errmsg");
                if (!(jsonValue3 == "0"))
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"" + jsonValue4 + "\"}");
                    return;
                }
                customerServiceInfo.unit     = unit;
                customerServiceInfo.userver  = text;
                customerServiceInfo.password = password;
                customerServiceInfo.nickname = text2;
                int num2 = CustomerServiceHelper.CreateCustomer(customerServiceInfo, ref empty);
                if (num2 > 0)
                {
                    context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                    return;
                }
                context.Response.Write("{\"type\":\"error\",\"data\":\"" + empty + "\"}");
                return;
            }
        }