예제 #1
0
        /// <summary>
        /// 判断当前用户是否领取优惠卷
        /// </summary>
        /// <param name="couponinfo"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static int CouponIsUse(Entities.CouponInfo couponinfo, long userId)
        {
            var status = 0;
            CouponRecordQuery crQuery = new CouponRecordQuery();

            if (userId > 0)
            {//检验当前会员是否可领
                crQuery.CouponId = couponinfo.Id;
                crQuery.UserId   = userId;
                QueryPageModel <Entities.CouponRecordInfo> pageModel = _iCouponService.GetCouponRecordList(crQuery);
                if (couponinfo.PerMax != 0 && pageModel.Total >= couponinfo.PerMax)
                {
                    //达到个人领取最大张数
                    status = 1;
                }
            }
            if (status == 0)
            {//检验优惠券本身是否可领
                crQuery = new CouponRecordQuery()
                {
                    CouponId = couponinfo.Id
                };
                QueryPageModel <Entities.CouponRecordInfo> pageModel = _iCouponService.GetCouponRecordList(crQuery);
                if (pageModel.Total >= couponinfo.Num)
                {
                    //达到领取最大张数
                    status = 2;
                }
            }
            return(status);
        }
예제 #2
0
        public ActionResult Index(int?status, int pageSize = 10, int pageNo = 1)
        {
            if (!status.HasValue)
            {
                status = 0;
            }

            CouponRecordQuery query = new CouponRecordQuery();

            query.UserId   = CurrentUser.Id;
            query.PageNo   = pageNo;
            query.PageSize = pageSize;
            query.Status   = status;
            var model = _iCouponService.GetCouponRecordList(query);

            var shopBonus = _iShopBonusService.GetDetailByQuery(query);


            #region 分页控制
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = model.Total + shopBonus.Total
            };
            ViewBag.pageInfo = info;
            ViewBag.Bonus    = shopBonus.Models.ToList();
            ViewBag.State    = query.Status;
            #endregion
            return(View(model.Models.ToList()));
        }
        /// <summary>
        /// 优惠券是否可用
        /// </summary>
        /// <param name="couponinfo"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static int CouponIsUse(CouponInfo couponinfo, long userId)
        {
            int num = 0;
            ObsoletePageModel <CouponRecordInfo> couponRecordList = ShopBranchApplication._iCouponService.GetCouponRecordList(new CouponRecordQuery()
            {
                CouponId = new long?(couponinfo.Id),
                UserId   = new long?(userId)
            });

            if (couponinfo.PerMax != 0 && couponRecordList.Total >= couponinfo.PerMax)
            {
                num = 1;
            }
            if (num == 0)
            {
                CouponRecordQuery query = new CouponRecordQuery()
                {
                    CouponId = new long?(couponinfo.Id)
                };
                if (ShopBranchApplication._iCouponService.GetCouponRecordList(query).Total >= couponinfo.Num)
                {
                    num = 2;
                }
            }
            return(num);
        }
예제 #4
0
        public ActionResult GetReceivers(long Id, int page, int rows)
        {
            CouponRecordQuery query = new CouponRecordQuery();

            query.CouponId = Id;
            query.ShopId   = CurrentSellerManager.ShopId;
            query.PageNo   = page;
            query.PageSize = rows;
            var record  = _iCouponService.GetCouponRecordList(query);
            var coupons = CouponApplication.GetCouponInfo(record.Models.Select(p => p.CouponId));
            var list    = record.Models.Select(item =>
            {
                var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId);
                return(new
                {
                    Id = item.Id,
                    Price = Math.Round(coupon.Price, 2),
                    CreateTime = coupon.CreateTime.ToString("yyyy-MM-dd"),
                    CouponSN = item.CounponSN,
                    UsedTime = item.UsedTime.HasValue ? item.UsedTime.Value.ToString("yyyy-MM-dd") : "",
                    ReceviceTime = item.CounponTime.ToString("yyyy-MM-dd"),
                    Recever = item.UserName,
                    OrderId = item.OrderId,
                    Status = item.CounponStatus == Entities.CouponRecordInfo.CounponStatuses.Unuse ? (coupon.EndTime < DateTime.Now.Date ? "已过期" : item.CounponStatus.ToDescription()) : item.CounponStatus.ToDescription(),
                });
            });
            var model = new { rows = list, total = record.Total };

            return(Json(model));
        }
예제 #5
0
        public ActionResult Index(int?status, int pageSize = 10, int pageNo = 1)
        {
            if (!status.HasValue)
            {
                status = new int?(0);
            }
            CouponRecordQuery couponRecordQuery = new CouponRecordQuery()
            {
                UserId   = new long?(base.CurrentUser.Id),
                PageNo   = pageNo,
                PageSize = pageSize,
                Status   = status
            };
            PageModel <CouponRecordInfo>     couponRecordList = ServiceHelper.Create <ICouponService>().GetCouponRecordList(couponRecordQuery);
            PageModel <ShopBonusReceiveInfo> detailByQuery    = ServiceHelper.Create <IShopBonusService>().GetDetailByQuery(couponRecordQuery);
            PagingInfo pagingInfo = new PagingInfo()
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = couponRecordList.Total + detailByQuery.Total
            };

            ViewBag.pageInfo = pagingInfo;
            ViewBag.Bonus    = detailByQuery.Models.ToList();
            ViewBag.State    = couponRecordQuery.Status;
            return(View(couponRecordList.Models.ToList()));
        }
예제 #6
0
        public ActionResult Index(int?status, int pageSize = 10, int pageNo = 1)
        {
            if (!status.HasValue)
            {
                status = 0;
            }

            CouponRecordQuery query = new CouponRecordQuery();

            query.UserId   = CurrentUser.Id;
            query.PageNo   = pageNo;
            query.PageSize = pageSize;
            query.Status   = status;
            var model     = _iCouponService.GetCouponRecordList(query);
            var coupons   = _iCouponService.GetCouponInfo(model.Models.Select(p => p.CouponId).ToArray());
            var shopBonus = ShopBonusApplication.GetShopBouns(query);


            #region 分页控制
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = model.Total > shopBonus.Total ? model.Total : shopBonus.Total
            };
            ViewBag.pageInfo = info;
            ViewBag.Bonus    = shopBonus.Models;
            ViewBag.State    = query.Status;
            ViewBag.Coupons  = coupons;
            #endregion
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            return(View(model.Models.ToList()));
        }
예제 #7
0
        public ObsoletePageModel <ShopBonusReceiveInfo> GetDetailByQuery(CouponRecordQuery query)
        {
            if (query.PageNo <= 0)
            {
                query.PageNo = 1;
            }
            int total = 0;
            var bonusReceiveContext = Context.ShopBonusReceiveInfo.Where(p => p.UserId == query.UserId);

            if (query.Status == 0)
            {
                bonusReceiveContext = bonusReceiveContext.Where(
                    p => p.Himall_ShopBonusGrant.Himall_ShopBonus.BonusDateEnd > DateTime.Now &&
                    p.State == ShopBonusReceiveInfo.ReceiveState.NotUse);
            }
            else if (query.Status == 1)
            {
                bonusReceiveContext = bonusReceiveContext.Where(p => p.State == ShopBonusReceiveInfo.ReceiveState.Use);
            }
            if (query.Status == 2)
            {
                bonusReceiveContext = bonusReceiveContext.Where(p => p.Himall_ShopBonusGrant.Himall_ShopBonus.BonusDateEnd < DateTime.Now);
            }

            IQueryable <ShopBonusReceiveInfo>        datas     = bonusReceiveContext.GetPage(out total, p => p.OrderByDescending(o => o.ReceiveTime), query.PageNo, query.PageSize);
            ObsoletePageModel <ShopBonusReceiveInfo> pageModel = new ObsoletePageModel <ShopBonusReceiveInfo>()
            {
                Models = datas,
                Total  = total
            };

            return(pageModel);
        }
예제 #8
0
        public static QueryPageModel <ShopBonus> GetShopBouns(CouponRecordQuery query)
        {
            var data = Service.GetDetailByQuery(query);
            var list = BuildShopBonus(data.Models);

            return(new QueryPageModel <ShopBonus>
            {
                Models = list,
                Total = data.Total
            });
        }
예제 #9
0
        public QueryPageModel <CouponRecordInfo> GetCouponRecordList(CouponRecordQuery query)
        {
            var date    = DateTime.Now;
            var coupons = DbFactory.Default
                          .Get <CouponRecordInfo>()
                          .LeftJoin <CouponInfo>((cri, ci) => cri.CouponId == ci.Id);

            if (query.CouponId.HasValue)
            {
                coupons.Where(d => d.CouponId == query.CouponId);
            }
            if (query.UserId.HasValue)
            {
                coupons.Where(d => d.UserId == query.UserId.Value);
            }
            if (query.ShopId.HasValue)
            {
                coupons.Where(d => d.ShopId == query.ShopId.Value);
            }
            if (!string.IsNullOrWhiteSpace(query.UserName))
            {
                coupons.Where(d => d.UserName.Contains(query.UserName));
            }

            switch (query.Status)
            {
            case 0:
                coupons.Where(item => item.CounponStatus == CouponRecordInfo.CounponStatuses.Unuse);
                coupons.Where <CouponInfo>(item => item.EndTime > date);
                break;

            case 1:
                coupons.Where(item => item.CounponStatus == CouponRecordInfo.CounponStatuses.Used);
                break;

            case 2:
                coupons.Where(item => item.CounponStatus == CouponRecordInfo.CounponStatuses.Unuse);
                coupons.Where <CouponInfo>(item => item.EndTime <= date);
                break;

            case 3:
                coupons.Where <CouponRecordInfo, CouponInfo>((cri, ci) => cri.CounponStatus == CouponRecordInfo.CounponStatuses.Used ||
                                                             (cri.CounponStatus == CouponRecordInfo.CounponStatuses.Unuse && ci.EndTime <= date));
                break;
            }
            var ret = coupons.OrderByDescending(o => o.UsedTime).OrderByDescending(o => o.Id).ToPagedList(query.PageNo, query.PageSize);
            QueryPageModel <CouponRecordInfo> pageModel = new QueryPageModel <CouponRecordInfo>()
            {
                Models = ret, Total = ret.TotalRecordCount
            };

            return(pageModel);
        }
예제 #10
0
        //领取优惠券
        public object PostAcceptCoupon(CouponAcceptCouponModel value)
        {
            CheckUserLogin();
            long vshopId       = value.vshopId;
            long couponId      = value.couponId;
            var  couponService = ServiceProvider.Instance <ICouponService> .Create;
            var  couponInfo    = couponService.GetCouponInfo(couponId);

            if (couponInfo.EndTime < DateTime.Now)
            {
                //已经失效
                return(ErrorResult("优惠券已经过期.", 2));
            }
            CouponRecordQuery crQuery = new CouponRecordQuery();

            crQuery.CouponId = couponId;
            crQuery.UserId   = CurrentUser.Id;
            QueryPageModel <CouponRecordInfo> pageModel = couponService.GetCouponRecordList(crQuery);

            if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
            {
                //达到个人领取最大张数
                return(ErrorResult("达到个人领取最大张数,不能再领取.", 3));
            }
            crQuery = new CouponRecordQuery()
            {
                CouponId = couponId
            };
            pageModel = couponService.GetCouponRecordList(crQuery);
            if (pageModel.Total >= couponInfo.Num)
            {
                //达到领取最大张数
                return(ErrorResult("此优惠券已经领完了.", 4));
            }
            if (couponInfo.ReceiveType == CouponInfo.CouponReceiveType.IntegralExchange)
            {
                var integral = MemberIntegralApplication.GetAvailableIntegral(CurrentUserId);
                if (integral < couponInfo.NeedIntegral)
                {
                    return(ErrorResult("积分不足 " + couponInfo.NeedIntegral.ToString(), 5));
                }
            }
            CouponRecordInfo couponRecordInfo = new CouponRecordInfo()
            {
                CouponId = couponId,
                UserId   = CurrentUser.Id,
                UserName = CurrentUser.UserName,
                ShopId   = couponInfo.ShopId
            };

            couponService.AddCouponRecord(couponRecordInfo);
            return(SuccessResult("", 1));
        }
예제 #11
0
        //领取优惠券
        public object PostAcceptCoupon(CouponAcceptCouponModel value)
        {
            CheckUserLogin();
            long vshopId       = value.vshopId;
            long couponId      = value.couponId;
            var  couponService = ServiceProvider.Instance <ICouponService> .Create;
            var  couponInfo    = couponService.GetCouponInfo(couponId);

            if (couponInfo.EndTime < DateTime.Now)
            {//已经失效
                return(Json(new { Status = 2, Success = "false", ErrorMsg = "优惠券已经过期." }));
            }
            CouponRecordQuery crQuery = new CouponRecordQuery();

            crQuery.CouponId = couponId;
            crQuery.UserId   = CurrentUser.Id;
            ObsoletePageModel <CouponRecordInfo> pageModel = couponService.GetCouponRecordList(crQuery);

            if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
            {//达到个人领取最大张数
                return(Json(new { Status = 3, Success = "false", ErrorMsg = "达到个人领取最大张数,不能再领取." }));
            }
            crQuery = new CouponRecordQuery()
            {
                CouponId = couponId
            };
            pageModel = couponService.GetCouponRecordList(crQuery);
            if (pageModel.Total >= couponInfo.Num)
            {//达到领取最大张数
                return(Json(new { Status = 4, Success = "false", ErrorMsg = "此优惠券已经领完了." }));
            }
            if (couponInfo.ReceiveType == Himall.Model.CouponInfo.CouponReceiveType.IntegralExchange)
            {
                var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUserId);
                if (userInte.AvailableIntegrals < couponInfo.NeedIntegral)
                {
                    //积分不足
                    return(Json(new { Status = 5, Success = "false", ErrorMsg = "积分不足 " + couponInfo.NeedIntegral.ToString() }));
                }
            }
            CouponRecordInfo couponRecordInfo = new CouponRecordInfo()
            {
                CouponId = couponId,
                UserId   = CurrentUser.Id,
                UserName = CurrentUser.UserName,
                ShopId   = couponInfo.ShopId
            };

            couponService.AddCouponRecord(couponRecordInfo);
            return(Json(new { Status = 1, Success = "true" }));//执行成功
        }
예제 #12
0
        public PageModel <ShopBonusReceiveInfo> GetDetailByQuery(CouponRecordQuery query)
        {
            if (query.PageNo <= 0)
            {
                query.PageNo = 1;
            }
            int num = 0;
            IQueryable <ShopBonusReceiveInfo> shopBonusReceiveInfo =
                from p in context.ShopBonusReceiveInfo
                where p.UserId == query.UserId
                select p;
            int?status = query.Status;

            if ((status.GetValueOrDefault() != 0 ? true : !status.HasValue))
            {
                int?nullable = query.Status;
                if ((nullable.GetValueOrDefault() != 1 ? false : nullable.HasValue))
                {
                    shopBonusReceiveInfo =
                        from p in shopBonusReceiveInfo
                        where (int)p.State == 2
                        select p;
                }
            }
            else
            {
                shopBonusReceiveInfo =
                    from p in shopBonusReceiveInfo
                    where (p.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.BonusDateEnd > DateTime.Now) && (int)p.State == 1
                    select p;
            }
            int?status1 = query.Status;

            if ((status1.GetValueOrDefault() != 2 ? false : status1.HasValue))
            {
                shopBonusReceiveInfo =
                    from p in shopBonusReceiveInfo
                    where p.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.BonusDateEnd < DateTime.Now
                    select p;
            }
            IQueryable <ShopBonusReceiveInfo> page = shopBonusReceiveInfo.GetPage(out num, (IQueryable <ShopBonusReceiveInfo> p) =>
                                                                                  from o in p
                                                                                  orderby o.ReceiveTime descending
                                                                                  select o, query.PageNo, query.PageSize);

            return(new PageModel <ShopBonusReceiveInfo>()
            {
                Models = page,
                Total = num
            });
        }
예제 #13
0
        public JsonResult AcceptCoupon(long vshopid, long couponid)
        {
            var couponService = _iCouponService;
            var couponInfo    = couponService.GetCouponInfo(couponid);

            if (couponInfo.EndTime < DateTime.Now)
            {//已经失效
                return(ErrorResult("优惠券已经过期.", 2, true));
            }
            CouponRecordQuery crQuery = new CouponRecordQuery();

            crQuery.CouponId = couponid;
            crQuery.UserId   = CurrentUser.Id;
            var pageModel = couponService.GetCouponRecordList(crQuery);

            if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
            {//达到个人领取最大张数
                return(Json(new { code = 3, success = false, msg = "达到个人领取最大张数,不能再领取." }));
            }
            crQuery = new CouponRecordQuery()
            {
                CouponId = couponid
            };
            pageModel = couponService.GetCouponRecordList(crQuery);
            if (pageModel.Total >= couponInfo.Num)
            {//达到领取最大张数
                return(Json(new { code = 4, success = false, msg = "此优惠券已经领完了." }));
            }
            int MemberAvailableIntegrals = 0;

            if (couponInfo.ReceiveType == Entities.CouponInfo.CouponReceiveType.IntegralExchange)
            {
                var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUser.Id);
                if (userInte.AvailableIntegrals < couponInfo.NeedIntegral)
                {
                    //积分不足
                    return(Json(new { code = 5, success = false, msg = "积分不足 " + couponInfo.NeedIntegral.ToString() }));
                }
                MemberAvailableIntegrals = userInte.AvailableIntegrals;
            }
            Entities.CouponRecordInfo couponRecordInfo = new Entities.CouponRecordInfo()
            {
                CouponId = couponid,
                UserId   = CurrentUser.Id,
                UserName = CurrentUser.UserName,
                ShopId   = couponInfo.ShopId
            };
            couponService.AddCouponRecord(couponRecordInfo);

            return(Json(new { code = 0, success = true, msg = "领取成功", crid = couponRecordInfo.Id, Integral_balance = MemberAvailableIntegrals }));//执行成功
        }
예제 #14
0
        public ActionResult GetReceivers(long Id, int page, int rows)
        {
            CouponRecordQuery couponRecordQuery = new CouponRecordQuery()
            {
                CouponId = new long?(Id),
                ShopId   = new long?(base.CurrentSellerManager.ShopId),
                PageNo   = page,
                PageSize = rows
            };
            PageModel <CouponRecordInfo> couponRecordList = ServiceHelper.Create <ICouponService>().GetCouponRecordList(couponRecordQuery);
            var array =
                from item in couponRecordList.Models.ToArray()
                select new { Id = item.Id, Price = Math.Round(item.Himall_Coupon.Price, 2), CreateTime = item.Himall_Coupon.CreateTime.ToString("yyyy-MM-dd"), CouponSN = item.CounponSN, UsedTime = (item.UsedTime.HasValue ? item.UsedTime.Value.ToString("yyyy-MM-dd") : ""), ReceviceTime = item.CounponTime.ToString("yyyy-MM-dd"), Recever = item.UserName, OrderId = item.OrderId, Status = (item.CounponStatus == CouponRecordInfo.CounponStatuses.Unuse ? (item.Himall_Coupon.EndTime < DateTime.Now.Date ? "已过期" : item.CounponStatus.ToDescription()) : item.CounponStatus.ToDescription()) };

            return(Json(new { rows = array, total = couponRecordList.Total }));
        }
예제 #15
0
        public JsonResult AcceptCoupon(long vshopid, long couponid)
        {
            if (base.CurrentUser == null)
            {
                return(Json(new { status = 1, success = false, msg = "未登录." }));
            }
            ICouponService service    = ServiceHelper.Create <ICouponService>();
            CouponInfo     couponInfo = service.GetCouponInfo(couponid);

            if (couponInfo.EndTime < DateTime.Now)
            {
                return(Json(new { status = 2, success = false, msg = "优惠券已经过期." }));
            }
            CouponRecordQuery query = new CouponRecordQuery
            {
                CouponId = new long?(couponid),
                UserId   = new long?(base.CurrentUser.Id)
            };
            PageModel <CouponRecordInfo> couponRecordList = service.GetCouponRecordList(query);

            if ((couponInfo.PerMax != 0) && (couponRecordList.Total >= couponInfo.PerMax))
            {
                return(Json(new { status = 3, success = false, msg = "达到个人领取最大张数,不能再领取." }));
            }
            query = new CouponRecordQuery
            {
                CouponId = new long?(couponid)
            };
            if (service.GetCouponRecordList(query).Total >= couponInfo.Num)
            {
                return(Json(new { status = 4, success = false, msg = "此优惠券已经领完了." }));
            }
            if ((couponInfo.ReceiveType == (CouponInfo.CouponReceiveType) 1) && (ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id).AvailableIntegrals < couponInfo.NeedIntegral))
            {
                return(Json(new { status = 5, success = false, msg = "积分不足 " + couponInfo.NeedIntegral.ToString() }));
            }
            CouponRecordInfo info = new CouponRecordInfo
            {
                CouponId = couponid,
                UserId   = base.CurrentUser.Id,
                UserName = base.CurrentUser.UserName,
                ShopId   = couponInfo.ShopId
            };

            service.AddCouponRecord(info);
            return(Json(new { status = 0, success = true, msg = "领取成功", crid = info.Id }));
        }
예제 #16
0
        public JsonResult AcceptCoupon(long vshopid, long couponid)
        {
            ICouponService couponService = ServiceHelper.Create <ICouponService>();
            CouponInfo     couponInfo    = couponService.GetCouponInfo(couponid);

            if (couponInfo.EndTime < DateTime.Now)
            {
                return(Json(new { status = 2, success = false, msg = "优惠券已经过期." }));
            }
            CouponRecordQuery couponRecordQuery = new CouponRecordQuery()
            {
                CouponId = new long?(couponid),
                UserId   = new long?(base.CurrentUser.Id)
            };
            PageModel <CouponRecordInfo> couponRecordList = couponService.GetCouponRecordList(couponRecordQuery);

            if (couponInfo.PerMax != 0 && couponRecordList.Total >= couponInfo.PerMax)
            {
                return(Json(new { status = 3, success = false, msg = "达到个人领取最大张数,不能再领取." }));
            }
            couponRecordQuery = new CouponRecordQuery()
            {
                CouponId = new long?(couponid)
            };
            couponRecordList = couponService.GetCouponRecordList(couponRecordQuery);
            if (couponRecordList.Total >= couponInfo.Num)
            {
                return(Json(new { status = 4, success = false, msg = "此优惠券已经领完了." }));
            }
            if (couponInfo.ReceiveType == CouponInfo.CouponReceiveType.IntegralExchange && ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id).AvailableIntegrals < couponInfo.NeedIntegral)
            {
                int needIntegral = couponInfo.NeedIntegral;
                return(Json(new { status = 5, success = false, msg = string.Concat("积分不足 ", needIntegral.ToString()) }));
            }
            CouponRecordInfo couponRecordInfo = new CouponRecordInfo()
            {
                CouponId = couponid,
                UserId   = base.CurrentUser.Id,
                UserName = base.CurrentUser.UserName,
                ShopId   = couponInfo.ShopId
            };
            CouponRecordInfo couponRecordInfo1 = couponRecordInfo;

            couponService.AddCouponRecord(couponRecordInfo1);
            return(Json(new { status = 0, success = true, msg = "领取成功", crid = couponRecordInfo1.Id }));
        }
예제 #17
0
        /// <summary>
        /// 获取系统可领取优惠券列表
        /// </summary>
        /// <returns></returns>
        public object GetLoadSiteCoupon(string openId = "", int pageSize = 10, int pageIndex = 1, int obtainWay = 1)
        {
            CheckUserLogin();
            int status = 0;
            CouponRecordQuery query = new CouponRecordQuery();

            query.UserId   = CurrentUser.Id;
            query.PageNo   = pageIndex;
            query.PageSize = pageSize;
            if (obtainWay == 1) //(1=未使用 2=已使用 3=已过期)
            {
                query.Status = 0;
            }
            else if (obtainWay == 2)
            {
                query.Status = 1;
            }
            else
            {
                query.Status = obtainWay;
            }
            var record = ServiceProvider.Instance <ICouponService> .Create.GetCouponRecordList(query);

            var list = record.Models.ToArray().Select(
                item => new
            {
                CouponId       = item.Himall_Coupon.Id,
                CouponName     = item.Himall_Coupon.CouponName,
                Price          = Math.Round(item.Himall_Coupon.Price, 2),
                SendCount      = item.Himall_Coupon.Num,
                UserLimitCount = item.Himall_Coupon.PerMax,
                OrderUseLimit  = Math.Round(item.Himall_Coupon.OrderAmount, 2),
                StartTime      = item.Himall_Coupon.StartTime.ToString("yyyy.MM.dd"),
                ClosingTime    = item.Himall_Coupon.EndTime.ToString("yyyy.MM.dd"),
                ObtainWay      = item.Himall_Coupon.ReceiveType,
                NeedPoint      = item.Himall_Coupon.NeedIntegral
            });
            var json = new
            {
                Status = "OK",
                total  = record.Total,
                Data   = list
            };

            return(json);
        }
예제 #18
0
        public ObsoletePageModel <CouponRecordInfo> GetCouponRecordList(CouponRecordQuery query)
        {
            int total = 0;
            var date  = DateTime.Now;
            IQueryable <CouponRecordInfo> coupons = Context.CouponRecordInfo.AsQueryable();

            if (query.CouponId.HasValue)
            {
                coupons = coupons.Where(d => d.CouponId == query.CouponId);
            }
            if (query.UserId.HasValue)
            {
                coupons = coupons.Where(d => d.UserId == query.UserId.Value);
            }
            if (query.ShopId.HasValue)
            {
                coupons = coupons.Where(d => d.ShopId == query.ShopId.Value);
            }
            if (!string.IsNullOrWhiteSpace(query.UserName))
            {
                coupons = coupons.Where(d => d.UserName.Contains(query.UserName));
            }

            switch (query.Status)
            {
            case 0:
                coupons = coupons.Where(item => item.CounponStatus == CouponRecordInfo.CounponStatuses.Unuse && item.Himall_Coupon.EndTime > date);
                break;

            case 1:
                coupons = coupons.Where(item => item.CounponStatus == CouponRecordInfo.CounponStatuses.Used);
                break;

            case 2:
                coupons = coupons.Where(item => item.CounponStatus == CouponRecordInfo.CounponStatuses.Unuse && item.Himall_Coupon.EndTime <= date);
                break;
            }
            coupons = coupons.GetPage(out total, query.PageNo, query.PageSize);
            ObsoletePageModel <CouponRecordInfo> pageModel = new ObsoletePageModel <CouponRecordInfo>()
            {
                Models = coupons, Total = total
            };

            return(pageModel);
        }
예제 #19
0
        /// <summary>
        /// 获取系统可领取优惠券列表
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetLoadSiteCoupon(string openId = "", int pageSize = 10, int pageIndex = 1, int obtainWay = 1)
        {
            CheckUserLogin();
            CouponRecordQuery query = new CouponRecordQuery();

            query.UserId   = CurrentUser.Id;
            query.PageNo   = pageIndex;
            query.PageSize = pageSize;
            if (obtainWay == 1) //(1=未使用 2=已使用 3=已过期)
            {
                query.Status = 0;
            }
            else if (obtainWay == 2)
            {
                query.Status = 1;
            }
            else
            {
                query.Status = obtainWay;
            }
            var record  = CouponApplication.GetCouponRecordList(query);
            var coupons = CouponApplication.GetCouponInfo(record.Models.Select(p => p.Id));
            var list    = record.Models.Select(
                item => {
                var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId);
                return(new
                {
                    CouponId = coupon.Id,
                    CouponName = coupon.CouponName,
                    Price = Math.Round(coupon.Price, 2),
                    SendCount = coupon.Num,
                    UserLimitCount = coupon.PerMax,
                    OrderUseLimit = Math.Round(coupon.OrderAmount, 2),
                    StartTime = coupon.StartTime.ToString("yyyy.MM.dd"),
                    ClosingTime = coupon.EndTime.ToString("yyyy.MM.dd"),
                    ObtainWay = coupon.ReceiveType,
                    NeedPoint = coupon.NeedIntegral,
                    UseArea = coupon.UseArea,
                    Remark = coupon.Remark
                });
            });

            return(JsonResult <dynamic>(new { total = record.Total, Data = list }));
        }
예제 #20
0
        /// <summary>
        /// 是否可领取优惠券
        /// </summary>
        /// <param name="vshopId"></param>
        /// <param name="couponId"></param>
        /// <returns></returns>
        private int Receive(long vshopId, long couponId)
        {
            if (CurrentUser != null && CurrentUser.Id > 0)//未登录不可领取
            {
                var couponService = ServiceProvider.Instance <ICouponService> .Create;
                var couponInfo    = couponService.GetCouponInfo(couponId);
                if (couponInfo.EndTime < DateTime.Now)
                {
                    return(2);                                  //已经失效
                }
                CouponRecordQuery crQuery = new CouponRecordQuery();
                crQuery.CouponId = couponId;
                crQuery.UserId   = CurrentUser.Id;
                QueryPageModel <CouponRecordInfo> pageModel = couponService.GetCouponRecordList(crQuery);
                if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
                {
                    return(3);                                                               //达到个人领取最大张数
                }
                crQuery = new CouponRecordQuery()
                {
                    CouponId = couponId
                };
                pageModel = couponService.GetCouponRecordList(crQuery);
                if (pageModel.Total >= couponInfo.Num)
                {
                    return(4);                                  //达到领取最大张数
                }
                if (couponInfo.ReceiveType == CouponInfo.CouponReceiveType.IntegralExchange)
                {
                    var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUserId);
                    if (userInte.AvailableIntegrals < couponInfo.NeedIntegral)
                    {
                        return(5);                                                      //积分不足
                    }
                }

                return(1);//可正常领取
            }
            return(0);
        }
예제 #21
0
        /// <summary>
        /// 会员领取优惠券的前置状态判断
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="vshopId"></param>
        /// <param name="couponId"></param>
        /// <returns></returns>
        public static int GetReceiveStatus(long userid, long vshopId, long couponId)
        {
            var couponService = ServiceProvider.Instance <ICouponService> .Create;
            var couponInfo    = couponService.GetCouponInfo(couponId);

            if (couponInfo.EndTime < DateTime.Now)
            {
                return(2);                                  //已经失效
            }
            if (userid > 0)
            {
                CouponRecordQuery crQuery = new CouponRecordQuery();
                crQuery.CouponId = couponId;
                crQuery.UserId   = userid;
                QueryPageModel <CouponRecordInfo> pageModel = couponService.GetCouponRecordList(crQuery);
                if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
                {
                    return(3);                                                               //达到个人领取最大张数
                }
                crQuery = new CouponRecordQuery()
                {
                    CouponId = couponId
                };
                pageModel = couponService.GetCouponRecordList(crQuery);
                if (pageModel.Total >= couponInfo.Num)
                {
                    return(4);                                  //达到领取最大张数
                }
                if (couponInfo.ReceiveType == CouponInfo.CouponReceiveType.IntegralExchange)
                {
                    var integral = MemberIntegralApplication.GetAvailableIntegral(userid);
                    if (integral < couponInfo.NeedIntegral)
                    {
                        return(5);                                   //积分不足
                    }
                }
            }
            return(1);//可正常领取
        }
예제 #22
0
        public QueryPageModel <ShopBonusReceiveInfo> GetDetailByQuery(CouponRecordQuery query)
        {
            if (query.PageNo <= 0)
            {
                query.PageNo = 1;
            }

            var bonusReceiveContext = DbFactory.Default.Get <ShopBonusReceiveInfo>().Where(p => p.UserId == query.UserId);

            if (query.Status == 0)
            {
                bonusReceiveContext.InnerJoin <ShopBonusGrantInfo>((r, b) => r.BonusGrantId == b.Id && r.State == ShopBonusReceiveInfo.ReceiveState.NotUse)
                .InnerJoin <ShopBonusInfo, ShopBonusGrantInfo>((s, b) => b.ShopBonusId == s.Id && s.BonusDateEnd > DateTime.Now && s.BonusDateStart < DateTime.Now);
                //bonusReceiveContext.Where(
                //    p => p.ShopBonusGrantInfo.ShopBonusInfo.BonusDateEnd > DateTime.Now &&
                //    p.State == ShopBonusReceiveInfo.ReceiveState.NotUse);
            }
            else if (query.Status == 1)
            {
                bonusReceiveContext.Where(p => p.State == ShopBonusReceiveInfo.ReceiveState.Use);
            }
            else if (query.Status == 2)
            {
                bonusReceiveContext.InnerJoin <ShopBonusGrantInfo>((r, b) => r.BonusGrantId == b.Id)
                .InnerJoin <ShopBonusInfo, ShopBonusGrantInfo>((s, b) => b.ShopBonusId == s.Id && s.BonusDateEnd < DateTime.Now);
                //bonusReceiveContext.Where(p => p.ShopBonusGrantInfo.ShopBonusInfo.BonusDateEnd < DateTime.Now);
            }

            var datas = bonusReceiveContext.OrderByDescending(o => o.ReceiveTime).ToPagedList(query.PageNo, query.PageSize);
            QueryPageModel <ShopBonusReceiveInfo> pageModel = new QueryPageModel <ShopBonusReceiveInfo>()
            {
                Models = datas,
                Total  = datas.TotalRecordCount
            };

            return(pageModel);
        }
예제 #23
0
        /// <summary>
        /// 领取优惠券
        /// </summary>
        /// <returns></returns>
        public object GetUserCoupon(string openId, long couponId)
        {
            CheckUserLogin();
            bool   status  = true;
            string message = "";
            //long vshopId = vspId;// value.vshopId; 店铺Id
            //long couponId = couponId;// value.couponId; 优惠劵Id
            var couponService = ServiceProvider.Instance <ICouponService> .Create;
            var couponInfo    = couponService.GetCouponInfo(couponId);

            if (couponInfo.EndTime < DateTime.Now)
            {//已经失效
                status  = false;
                message = "优惠券已经过期";
            }
            CouponRecordQuery crQuery = new CouponRecordQuery();

            crQuery.CouponId = couponId;
            crQuery.UserId   = CurrentUser.Id;
            ObsoletePageModel <CouponRecordInfo> pageModel = couponService.GetCouponRecordList(crQuery);

            if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
            {//达到个人领取最大张数
                status  = false;
                message = "达到领取最大张数";
            }
            crQuery = new CouponRecordQuery()
            {
                CouponId = couponId
            };
            pageModel = couponService.GetCouponRecordList(crQuery);
            if (pageModel.Total >= couponInfo.Num)
            {//达到领取最大张数
                status  = false;
                message = "此优惠券已经领完了";
            }
            if (couponInfo.ReceiveType == Himall.Model.CouponInfo.CouponReceiveType.IntegralExchange)
            {
                var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUserId);
                if (userInte.AvailableIntegrals < couponInfo.NeedIntegral)
                {
                    //积分不足
                    status  = false;
                    message = "积分不足 ";
                }
            }
            if (status)
            {
                CouponRecordInfo couponRecordInfo = new CouponRecordInfo()
                {
                    CouponId = couponId,
                    UserId   = CurrentUser.Id,
                    UserName = CurrentUser.UserName,
                    ShopId   = couponInfo.ShopId
                };
                couponService.AddCouponRecord(couponRecordInfo);
                return(Json(new { Status = "OK", Message = "领取成功" }));//执行成功
            }
            else
            {
                return(Json(new { Status = "NO", Message = message }));
            }
        }
예제 #24
0
        public PageModel <CouponRecordInfo> GetCouponRecordList(CouponRecordQuery query)
        {
            int      num = 0;
            DateTime now = DateTime.Now;
            IQueryable <CouponRecordInfo> couponId = context.CouponRecordInfo.AsQueryable <CouponRecordInfo>();

            if (query.CouponId.HasValue)
            {
                couponId =
                    from d in couponId
                    where d.CouponId == query.CouponId
                    select d;
            }
            if (query.UserId.HasValue)
            {
                couponId =
                    from d in couponId
                    where d.UserId == query.UserId.Value
                    select d;
            }
            if (query.ShopId.HasValue)
            {
                couponId =
                    from d in couponId
                    where d.ShopId == query.ShopId.Value
                    select d;
            }
            if (!string.IsNullOrWhiteSpace(query.UserName))
            {
                couponId =
                    from d in couponId
                    where d.UserName.Contains(query.UserName)
                    select d;
            }
            int?status         = query.Status;
            int valueOrDefault = status.GetValueOrDefault();

            if (status.HasValue)
            {
                switch (valueOrDefault)
                {
                case 0:
                    {
                        couponId =
                            from item in couponId
                            where item.CounponStatus == 0 && (item.Himall_Coupon.EndTime > now)
                            select item;
                        break;
                    }

                case 1:
                    {
                        couponId =
                            from item in couponId
                            where (int)item.CounponStatus == 1
                            select item;
                        break;
                    }

                case 2:
                {
                    couponId =
                        from item in couponId
                        where item.CounponStatus == 0 && (item.Himall_Coupon.EndTime <= now)
                        select item;
                    break;
                }
                }
            }
            couponId = couponId.GetPage(out num, query.PageNo, query.PageSize, null);
            return(new PageModel <CouponRecordInfo>()
            {
                Models = couponId,
                Total = num
            });
        }
예제 #25
0
        /// <summary>
        /// 领取优惠券
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <int> > GetUserCoupon(string openId, long couponId)
        {
            CheckUserLogin();
            bool   status  = true;
            string message = "";
            //long vshopId = vspId;// value.vshopId; 店铺Id
            //long couponId = couponId;// value.couponId; 优惠劵Id
            var couponInfo = CouponApplication.GetCouponInfo(couponId);

            if (couponInfo.EndTime < DateTime.Now)
            {//已经失效
                status  = false;
                message = "优惠券已经过期";
            }
            CouponRecordQuery crQuery = new CouponRecordQuery();

            crQuery.CouponId = couponId;
            crQuery.UserId   = CurrentUser.Id;
            QueryPageModel <CouponRecordInfo> pageModel = CouponApplication.GetCouponRecordList(crQuery);

            if (couponInfo.PerMax != 0 && pageModel.Total >= couponInfo.PerMax)
            {//达到个人领取最大张数
                status  = false;
                message = "达到领取最大张数";
            }
            crQuery = new CouponRecordQuery()
            {
                CouponId = couponId
            };
            pageModel = CouponApplication.GetCouponRecordList(crQuery);
            if (pageModel.Total >= couponInfo.Num)
            {//达到领取最大张数
                status  = false;
                message = "此优惠券已经领完了";
            }
            if (couponInfo.ReceiveType == CouponInfo.CouponReceiveType.IntegralExchange)
            {
                var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUserId);
                if (userInte.AvailableIntegrals < couponInfo.NeedIntegral)
                {
                    //积分不足
                    status  = false;
                    message = "积分不足 ";
                }
            }
            if (status)
            {
                CouponRecordInfo couponRecordInfo = new CouponRecordInfo()
                {
                    CouponId = couponId,
                    UserId   = CurrentUser.Id,
                    UserName = CurrentUser.UserName,
                    ShopId   = couponInfo.ShopId
                };
                CouponApplication.AddCouponRecord(couponRecordInfo);
                return(JsonResult <int>(msg: "领取成功"));//执行成功
            }
            else
            {
                return(Json(ErrorResult <int>(message)));
            }
        }
예제 #26
0
        public ActionResult CouponInfo(long id, int?accept)
        {
            VshopCouponInfoModel model   = new VshopCouponInfoModel();
            ICouponService       service = ServiceHelper.Create <ICouponService>();
            CouponInfo           info    = service.GetCouponInfo(id) ?? new CouponInfo();

            if (info.EndTime < DateTime.Now)
            {
                model.CouponStatus = (CouponInfo.CouponReceiveStatus) 2;
            }
            if (base.CurrentUser != null)
            {
                CouponRecordQuery query = new CouponRecordQuery
                {
                    CouponId = new long?(id),
                    UserId   = new long?(base.CurrentUser.Id)
                };
                PageModel <CouponRecordInfo> couponRecordList = service.GetCouponRecordList(query);
                if ((info.PerMax != 0) && (couponRecordList.Total >= info.PerMax))
                {
                    model.CouponStatus = (CouponInfo.CouponReceiveStatus) 3;
                }
                query = new CouponRecordQuery
                {
                    CouponId = new long?(id),
                    PageNo   = 1,
                    PageSize = 0x270f
                };
                if (service.GetCouponRecordList(query).Total >= info.Num)
                {
                    model.CouponStatus = (CouponInfo.CouponReceiveStatus) 4;
                }
                if (((int)info.ReceiveType == 1) && (ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id).AvailableIntegrals < info.NeedIntegral))
                {
                    model.CouponStatus = (CouponInfo.CouponReceiveStatus) 5;
                }
                if (ServiceHelper.Create <IShopService>().IsFavoriteShop(base.CurrentUser.Id, info.ShopId))
                {
                    model.IsFavoriteShop = true;
                }
            }
            model.CouponId = id;
            if (accept.HasValue)
            {
                model.AcceptId = new int?(accept.Value);
            }
            VShopInfo vShopByShopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(info.ShopId);
            string    wxlogo        = this.wxlogo;

            if (vShopByShopId != null)
            {
                model.VShopid = vShopByShopId.Id;
                if (!string.IsNullOrWhiteSpace(vShopByShopId.WXLogo))
                {
                    wxlogo = vShopByShopId.WXLogo;
                }
                if (string.IsNullOrWhiteSpace(this.wxlogo) && !string.IsNullOrWhiteSpace(_siteSetting.WXLogo))
                {
                    wxlogo = _siteSetting.WXLogo;
                }
            }
            ((dynamic)base.ViewBag).ShopLogo = wxlogo;
            WXShopInfo vShopSetting = ServiceHelper.Create <IVShopService>().GetVShopSetting(info.ShopId);

            if (vShopSetting != null)
            {
                model.FollowUrl = vShopSetting.FollowUrl;
            }
            model.ShopId     = info.ShopId;
            model.CouponData = info;
            ((dynamic)base.ViewBag).ShopId    = model.ShopId;
            ((dynamic)base.ViewBag).FollowUrl = model.FollowUrl;
            ((dynamic)base.ViewBag).FavText   = model.IsFavoriteShop ? "己收藏" : "收藏供应商";
            ((dynamic)base.ViewBag).VShopid   = model.VShopid;
            return(View(model));
        }
예제 #27
0
 public static QueryPageModel <ShopBonusReceiveInfo> GetDetailByQuery(CouponRecordQuery query)
 {
     return(Service.GetDetailByQuery(query));
 }
예제 #28
0
 /// <summary>
 /// 获取领取的优惠券列表
 /// </summary>
 /// <returns></returns>
 public static QueryPageModel <CouponRecordInfo> GetCouponRecordList(CouponRecordQuery query)
 {
     return(Service.GetCouponRecordList(query));
 }
예제 #29
0
 /// <summary>
 /// 获取领取的优惠券列表
 /// </summary>
 /// <returns></returns>
 public static ObsoletePageModel <CouponRecordInfo> GetCouponRecordList(CouponRecordQuery query)
 {
     return(_iCouponService.GetCouponRecordList(query));
 }
예제 #30
0
        /// <summary>
        /// 获取用户优惠券列表
        /// </summary>
        /// <returns></returns>
        public object GetLoadCoupon(string openId = "", int pageSize = 10, int pageIndex = 1, int couponType = 1)
        {
            CheckUserLogin();
            CouponRecordQuery query = new CouponRecordQuery();

            query.UserId   = CurrentUser.Id;
            query.PageNo   = pageIndex;
            query.PageSize = pageSize;
            if (couponType == 1) //(1=未使用 2=已使用 3=已过期)
            {
                query.Status = 0;
            }
            else if (couponType == 2)
            {
                query.Status = 1;
            }
            else
            {
                query.Status = 2;
            }

            var model = ServiceProvider.Instance <ICouponService> .Create.GetCouponRecordList(query);

            var couponlist = new Object();
            var json       = new object();

            if (model.Models != null)
            {
                //优惠券
                if (model.Models != null)
                {
                    //CouponType   1=未使用 2=已使用 3=已过期
                    couponlist = model.Models.ToArray().Select(a => new
                    {
                        CouponId      = a.Himall_Coupon.Id,
                        RedEnvelopeId = "",
                        CouponName    = a.Himall_Coupon.CouponName,
                        ClaimCode     = a.CounponSN,
                        UserId        = a.UserId,
                        UserName      = a.UserName,
                        ShopId        = a.ShopId,
                        GetDate       = a.CounponTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Price         = a.Himall_Coupon.Price,
                        StartTime     = a.Himall_Coupon.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        ClosingTime   = a.Himall_Coupon.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        //UsedTime = a.UsedTime,
                        //OrderId = a.OrderId,
                        OrderUseLimit      = Math.Round(a.Himall_Coupon.OrderAmount, 2),
                        CanUseProducts     = "",
                        UseWithGroup       = false, //团购
                        UseWithPanicBuying = false, //抢购
                        UseWithFireGroup   = false, //拼团
                        RowNumber          = 1,
                        //VShop = GetVShop(a.ShopId),
                        ShopName = a.ShopName
                    });
                }
                else
                {
                    couponlist = null;
                }
                //代金红包
                //var userBonus = new object();
                //if (shopBonus != null)
                //{
                //    userBonus = shopBonus.ToArray().Select(item =>
                //    {
                //        var Price = item.Price.Value;
                //        var showOrderAmount = item.Himall_ShopBonusGrant.Himall_ShopBonus.UsrStatePrice > 0 ? item.Himall_ShopBonusGrant.Himall_ShopBonus.UsrStatePrice : item.Price.Value;
                //        if (item.Himall_ShopBonusGrant.Himall_ShopBonus.UseState != ShopBonusInfo.UseStateType.FilledSend)
                //            showOrderAmount = item.Price.Value;
                //        var Logo = string.Empty;
                //        long VShopId = 0;
                //        if (item.Himall_ShopBonusGrant.Himall_ShopBonus.Himall_Shops.Himall_VShop != null && item.Himall_ShopBonusGrant.Himall_ShopBonus.Himall_Shops.Himall_VShop.Count() > 0)
                //        {
                //            //Logo ="http://" + Url.Request.RequestUri.Host+ item.Himall_ShopBonusGrant.Himall_ShopBonus.Himall_Shops.Himall_VShop.FirstOrDefault().Logo;
                //            Logo = Core.HimallIO.GetRomoteImagePath(item.Himall_ShopBonusGrant.Himall_ShopBonus.Himall_Shops.Himall_VShop.FirstOrDefault().Logo);
                //            VShopId = item.Himall_ShopBonusGrant.Himall_ShopBonus.Himall_Shops.Himall_VShop.FirstOrDefault().Id;
                //        }

                //        var State = (int)item.State;
                //        if (item.State != ShopBonusReceiveInfo.ReceiveState.Use && item.Himall_ShopBonusGrant.Himall_ShopBonus.DateEnd < DateTime.Now)
                //            State = (int)ShopBonusReceiveInfo.ReceiveState.Expired;
                //        var BonusDateEnd = item.Himall_ShopBonusGrant.Himall_ShopBonus.BonusDateEnd.ToString("yyyy-MM-dd");

                //        return new
                //        {
                //            Price = Price,
                //            ShowOrderAmount = showOrderAmount,
                //            Logo = Logo,
                //            VShopId = VShopId,
                //            State = State,
                //            BonusDateEnd = BonusDateEnd,
                //            ShopName = item.BaseShopName
                //        };
                //    });
                //}
                //else
                //    shopBonus = null;
                //优惠券
                //int NoUseCouponCount = 0;//未使用
                //int UseCouponCount = 0;//已使用
                //if (model.Models != null)
                //{
                //    NoUseCouponCount = model.Models.Count(item => (item.Himall_Coupon.EndTime > DateTime.Now && item.UseStatus == CouponRecordInfo.CounponStatuses.Unuse));
                //    UseCouponCount = model.Models.Count() - NoUseCouponCount;
                //}
                //红包
                //int NoUseBonusCount = 0;
                //int UseBonusCount = 0;
                //if (shopBonus != null)
                //{
                //    NoUseBonusCount = shopBonus.Count(r => r.State == ShopBonusReceiveInfo.ReceiveState.NotUse && r.Himall_ShopBonusGrant.Himall_ShopBonus.DateEnd > DateTime.Now);
                //    UseBonusCount = shopBonus.Count() - NoUseBonusCount;
                //}
                //int UseCount = UseCouponCount;// +UseBonusCount;
                //int NotUseCount = NoUseCouponCount;// +NoUseBonusCount;

                json = new
                {
                    Status = "OK",
                    Data   = couponlist
                };
            }
            else
            {
                json = new
                {
                    Status = "NO",
                    Data   = "[]"
                };
            }
            return(json);
        }