/// <summary> /// 根据条件查找用户信息 /// </summary> /// <param name="ids"></param> /// <param name="tel"></param> /// <param name="pageInfo"></param> /// <returns></returns> public object SearchCustomersByWhere(string ids, string name, string tel, PageInfo pageInfo) { var svc = new CommonService(); var memberLevel = new MemberLevelService();//12-22新增 var customerData = context.Customers.Where(p => p.IsDeleted != 1); if (!name.IsNullOrTrimEmpty()) { customerData = customerData.Where(p => p.FullName.Contains(name)); } if (!tel.IsNullOrTrimEmpty()) { customerData = customerData.Where(p => p.Tel.Contains(tel) || p.Mobile.Contains(tel)); } if (ids.IsNotNullOrEmpty()) { customerData = customerData.Where(p => !ids.Contains(p.Id)); } var result = customerData.OrderBy(a => a.Id).Skip((pageInfo.Page - 1) * pageInfo.Rows).Take(pageInfo.Rows).ToList() .Select(a => new { Id = a.Id, FullName = a.FullName + "", Tel = a.Tel + "", Mobile = a.Mobile + "", Email = a.Email + "", Sex = EnumHelper.GetDescription(((Sex)(a.Sex ?? 3))), CustomerType = svc.GetDictionaryName("CustomerCategory", a.CustomerType + ""), Integral = a.Integral, //12-22新增 MemberLevelText = memberLevel.GetMemberLevelByLevelVal(a.MemberLevelValue).Title //12-22新增 }); return(new { total = customerData.Count(), rows = result }); }
public object SearchCustomersByPhoneOrder(string name, string tel, int page, int rows) { var svc = new CommonService(); var customerData = context.Customers.Where(p => p.IsDeleted != 1); if (!name.IsNullOrTrimEmpty()) { customerData = customerData.Where(p => p.FullName.Contains(name)); } if (!tel.IsNullOrTrimEmpty()) { customerData = customerData.Where(p => p.Tel.Contains(tel) || p.Mobile.Contains(tel)); } var result = customerData.OrderBy(a => a.Id).Skip((page - 1) * rows).Take(rows).ToList() .Select(a => new { Id = a.Id, FullName = a.FullName + "", Tel = a.Tel + "", Mobile = a.Mobile + "", Email = a.Email + "", Sex = EnumHelper.GetDescription(((Sex)(a.Sex ?? 3))), CustomerType = svc.GetDictionaryName("CustomerCategory", a.CustomerType + "") }); return(new { total = customerData.Count(), rows = result }); }
/// <summary> /// 根据子产品Id获得其产品规格单位 /// </summary> /// <param name="subProductId"></param> /// <returns></returns> public string GetSizeTitleBuySubProductId(string subProductId) { string sizeTitle = ""; var subProduct = context.SubProducts.Include(o => o.Product).Where(o => o.Id == subProductId).FirstOrDefault(); if (subProduct != null) { if (subProduct.Product != null) { sizeTitle = subProduct.Product.Type == CommonRules.OtherProductTypeDicValue ? _commonService.GetDictionaryName("ProductUnitOther", subProduct.Size) : _commonService.GetDictionaryName("ProductUnitCake", subProduct.Size); } } return(sizeTitle); }
public object GetCustomerByID(string id) { var svc = new CommonService(); var a = context.Customers.Find(id); return(new { Id = a.Id, FullName = a.FullName + "", Tel = a.Tel + "", Mobile = a.Mobile + "", Email = a.Email + "", Sex = EnumHelper.GetDescription(((Sex)(a.Sex ?? 3))), CustomerType = svc.GetDictionaryName("CustomerCategory", a.CustomerType + "") }); }
/// <summary> /// 根据一堆id查询客户信息 /// </summary> /// <param name="ids"></param> /// <param name="pageinfo"></param> /// <returns></returns> public object GetCustomerIdByIds(string ids, out int totalCount, PageInfo pageinfo) { var svc = new CommonService(); var memberLevel = new MemberLevelService(); var queryData = context.Customers.Where(p => ids.Contains(p.Id) && p.IsDeleted != 1); totalCount = queryData.Count(); var result = queryData.OrderByDescending(p => p.CreatedOn).Skip((pageinfo.Page - 1) * pageinfo.Rows).Take(pageinfo.Rows).ToList() .Select(a => new { Id = a.Id, FullName = a.FullName + "", Tel = a.Tel + "", Mobile = a.Mobile + "", Email = a.Email + "", Sex = EnumHelper.GetDescription(((Sex)(a.Sex ?? 3))), CustomerType = svc.GetDictionaryName("CustomerCategory", a.CustomerType + ""), Integral = a.Integral, MemberLevelText = memberLevel.GetMemberLevelByLevelVal(a.MemberLevelValue).Title }); return(result); }
public object CreateCustomerByPhone(string fullName, string mobile, string tel) { try { var svc = new CommonService(); if (mobile != "" || tel != "") { var isExits = false; if (mobile != "") { isExits = context.Customers.Any(p => p.Mobile == mobile); } else { isExits = context.Customers.Any(p => p.Tel == tel); } if (isExits) { return(new { status = false, message = "添加失败:联系号码已存在" }); } FCake.Domain.Entities.Customers customer = new FCake.Domain.Entities.Customers(); customer.FullName = fullName; customer.Mobile = mobile; customer.Tel = tel; customer.IsDeleted = 0; customer.Id = FCake.Core.Common.DataHelper.GetSystemID(); customer.CustomerType = 2; //2=电话会员 customer.MemberLevelValue = 1; //首次创建默认为普通卡会员 customer.UpdateMemberLevelTime = DateTime.Now; //首次创建默认为当前时间 context.Customers.Add(customer); int result = context.SaveChanges(); if (result > 0) { return new { status = true, message = "添加成功", customer = new { Id = customer.Id, FullName = customer.FullName, Tel = customer.Tel, Mobile = customer.Mobile, Email = customer.Email + "", Sex = EnumHelper.GetDescription(((Sex)(customer.Sex ?? 3))), CustomerType = svc.GetDictionaryName("CustomerCategory", customer.CustomerType + "") } } } ; else { return new { status = false, message = "添加失败" } }; } else { return(new { status = false, message = "添加失败,手机号码、固定电话至少填一项" }); } } catch (Exception e) { return(new { status = false, message = "添加出错:" + e.Message }); } }