コード例 #1
0
        public ActionResult GetAllMemberLevel()
        {
            //获取所有会员等级信息
            var memberLevels = new FCake.Bll.MemberLevelService().GetAllMemberLevel();

            return(Json(memberLevels));
        }
コード例 #2
0
        /// <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 });
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        public ActionResult GetCreatCouponsInfo(string Id)
        {
            CustomersService _cservice = new CustomersService();
            var coupon = CouponsService.GetCreateCouponInfo(Id);

            if (coupon != null)
            {
                var conditionText = "无条件使用";
                if (coupon.ConditionMoney > 0)
                {
                    conditionText = "满 " + String.Format("{0:F}", coupon.ConditionMoney) + "元使用";
                }
                var givenText = "";
                if (coupon.GiveWay == 1)
                {
                    switch (coupon.GivenObjectType)
                    {
                    case 1:
                        givenText = "全部";
                        break;

                    case 2:
                        var allMemberLevel  = new FCake.Bll.MemberLevelService().GetAllMemberLevel();
                        var memberLevelText = "";
                        var ids             = new List <string>();
                        if (coupon.GivenObjectIds.Contains(","))
                        {
                            ids = new List <string>(coupon.GivenObjectIds.Split(','));
                        }
                        else
                        {
                            ids.Add(coupon.GivenObjectIds);
                        }
                        foreach (var item in ids)
                        {
                            foreach (var itm in allMemberLevel)
                            {
                                if (item == itm.MemberLevelValue.ToString())
                                {
                                    memberLevelText += itm.Title + ",";
                                }
                            }
                        }

                        givenText = "指定会员类型:" + memberLevelText.Substring(0, memberLevelText.Length - 1);
                        break;

                    case 3:
                        givenText = "指定用户";
                        break;

                    default:
                        break;
                    }
                }
                var cardNumber = coupon.Quantity;
                if (coupon.GiveWay == 1)
                {
                    if (coupon.GivenObjectType == 1 || coupon.GivenObjectType == 2)
                    {
                        cardNumber = _cservice.GetCustomersCount(coupon.GivenObjectType, coupon.GivenObjectIds);
                    }
                }
                return(Json(new
                {
                    name = coupon.Title,
                    denomination = coupon.Denomination,
                    beginValidDate = coupon.BeginValidDate.ToString("yyyy-MM-dd"),
                    endValidDate = coupon.EndValidDate.ToString("yyyy-MM-dd"),
                    useCondition = conditionText,
                    cardNumber = cardNumber,//发放数量
                    givenObjectStr = givenText,
                    isSendSMS = coupon.IsSendSMS,
                    smsContent = coupon.SMSContent,
                    ConditionMoney = coupon.ConditionMoney,
                    giveWay = coupon.GiveWay,
                    givenObjectType = coupon.GivenObjectType,
                    givenObjectIds = coupon.GivenObjectIds,
                    Id = coupon.Id,
                    couponBatch = coupon.CouponBatch
                }));
            }
            return(Json(""));
        }