public JsonResult GiftList(int page, int rows = 12)
        {
            GiftQuery giftQuery = new GiftQuery()
            {
                skey     = "",
                status   = new GiftInfo.GiftSalesStatus?(GiftInfo.GiftSalesStatus.Normal),
                PageSize = rows,
                PageNo   = page
            };
            PageModel <GiftModel> gifts = giftser.GetGifts(giftQuery);
            var list = (
                from d in gifts.Models.ToList()
                select new { Id = d.Id, GiftName = d.GiftName, NeedIntegral = d.NeedIntegral, LimtQuantity = d.LimtQuantity, StockQuantity = d.StockQuantity, EndDate = d.EndDate, NeedGrade = d.NeedGrade, SumSales = d.SumSales, SalesStatus = d.SalesStatus, ImagePath = d.ImagePath, GiftValue = d.GiftValue, ShowImagePath = d.ShowImagePath, NeedGradeName = d.NeedGradeName }).ToList();

            return(Json(list));
        }
        /// <summary>
        /// 积分商城
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            IntegralMallPageModel result = new IntegralMallPageModel();

            //Logo
            ViewBag.Logo = SiteSettings.Logo;

            //优惠券数据
            result.CouponPageSize = 6;
            QueryPageModel <Entities.CouponInfo> coupons = _iCouponService.GetIntegralCoupons(1, result.CouponPageSize);

            result.CouponList    = coupons.Models.ToList();
            result.CouponTotal   = coupons.Total;
            result.CouponMaxPage = GetMaxPage(result.CouponTotal, result.CouponPageSize);

            //礼品数据
            result.GiftPageSize = 12;
            GiftQuery query = new GiftQuery();

            query.skey     = "";
            query.status   = GiftInfo.GiftSalesStatus.Normal;
            query.PageSize = result.GiftPageSize;
            query.PageNo   = 1;
            QueryPageModel <GiftModel> gifts = _iGiftService.GetGifts(query);

            result.GiftList    = gifts.Models.ToList();
            result.GiftTotal   = gifts.Total;
            result.GiftMaxPage = GetMaxPage(result.GiftTotal, result.GiftPageSize);

            if (CurrentUser != null)
            {
                //登录后处理会员积分
                var userInte  = MemberIntegralApplication.GetMemberIntegral(CurrentUser.Id);
                var userGrade = MemberGradeApplication.GetMemberGradeByUserIntegral(userInte.HistoryIntegrals);
                result.MemberAvailableIntegrals = userInte.AvailableIntegrals;
                result.MemberGradeName          = userGrade.GradeName;
            }
            ViewBag.Keyword = SiteSettings.Keyword;

            return(View(result));
        }
        public JsonResult List(GiftInfo.GiftSalesStatus?status, string skey, int rows, int page)
        {
            GiftQuery query = new GiftQuery();

            query.skey     = skey;
            query.status   = status;
            query.PageSize = rows;
            query.PageNo   = page;
            var datalist = _iGiftService.GetGifts(query);
            var data     = datalist.Models.ToList();
            var result   = new { rows = data, total = datalist.Total };

            return(Json(result));
        }
Example #4
0
        public JsonResult List(GiftInfo.GiftSalesStatus?status, string skey, int rows, int page)
        {
            GiftQuery giftQuery = new GiftQuery()
            {
                skey     = skey,
                status   = status,
                PageSize = rows,
                PageNo   = page
            };
            PageModel <GiftModel> gifts = giftser.GetGifts(giftQuery);
            List <GiftModel>      list  = gifts.Models.ToList();

            return(Json(new { rows = list, total = gifts.Total }));
        }
Example #5
0
        public ActionResult Detail(long id)
        {
            GiftDetailPageModel giftDetailPageModel = new GiftDetailPageModel()
            {
                GiftData = giftser.GetById(id)
            };

            if (giftDetailPageModel.GiftData == null)
            {
                throw new HimallException("Gift information invalid!");
            }
            int       num       = 10;
            GiftQuery giftQuery = new GiftQuery()
            {
                skey     = "",
                status   = new GiftInfo.GiftSalesStatus?(GiftInfo.GiftSalesStatus.Normal),
                PageSize = num,
                PageNo   = 1,
                Sort     = GiftQuery.GiftSortEnum.SalesNumber,
                IsAsc    = false
            };
            PageModel <GiftModel> gifts = giftser.GetGifts(giftQuery);

            giftDetailPageModel.HotGifts   = gifts.Models.ToList();
            giftDetailPageModel.GiftCanBuy = true;
            if (giftDetailPageModel.GiftCanBuy && giftDetailPageModel.GiftData.GetSalesStatus != GiftInfo.GiftSalesStatus.Normal)
            {
                giftDetailPageModel.GiftCanBuy = false;
            }
            if (giftDetailPageModel.GiftCanBuy && giftDetailPageModel.GiftData.StockQuantity < 1)
            {
                giftDetailPageModel.GiftCanBuy = false;
            }
            if (giftDetailPageModel.GiftCanBuy && giftDetailPageModel.GiftData.NeedIntegral < 1)
            {
                giftDetailPageModel.GiftCanBuy = false;
            }
            if (giftDetailPageModel.GiftCanBuy && base.CurrentUser != null && giftDetailPageModel.GiftData.LimtQuantity > 0 && orderser.GetOwnBuyQuantity(base.CurrentUser.Id, id) >= giftDetailPageModel.GiftData.LimtQuantity)
            {
                giftDetailPageModel.GiftCanBuy = false;
            }
            return(View(giftDetailPageModel));
        }
Example #6
0
        /// <summary>
        /// 获取礼品列表
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public GiftsListModel GetList(int page = 1, int pagesize = 10)
        {
            GiftsListModel result = new GiftsListModel();

            //礼品数据
            result.PageSize = pagesize;
            GiftQuery query = new GiftQuery();

            query.skey     = "";
            query.status   = GiftInfo.GiftSalesStatus.Normal;
            query.PageSize = result.PageSize;
            query.PageNo   = page;
            QueryPageModel <GiftModel> gifts = _iGiftService.GetGifts(query);

            result.DataList = gifts.Models.ToList();
            foreach (var item in result.DataList)
            {
                item.DefaultShowImage = HimallIO.GetRomoteImagePath(item.GetImage(ImageSize.Size_350));
            }
            result.total   = gifts.Total;
            result.MaxPage = GetMaxPage(result.total, result.PageSize);
            result.success = true;
            return(result);
        }
Example #7
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            //轮播图
            GiftsIndexModel result  = new GiftsIndexModel();
            var             slidads = SlideApplication.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.AppGifts).ToList();

            foreach (var item in slidads)
            {
                item.ImageUrl = HimallIO.GetRomoteImagePath(item.ImageUrl);
            }
            result.SlideAds = slidads;

            //大转盘刮刮卡
            var robj = _iGiftService.GetAdInfo(IntegralMallAdInfo.AdActivityType.Roulette, IntegralMallAdInfo.AdShowPlatform.APP);

            if (robj != null)
            {
                robj.LinkUrl = "/m-wap/BigWheel/index/" + robj.ActivityId;
                result.WeiActives.Add(robj);
            }
            var cobj = _iGiftService.GetAdInfo(IntegralMallAdInfo.AdActivityType.ScratchCard, IntegralMallAdInfo.AdShowPlatform.APP);

            if (cobj != null)
            {
                cobj.LinkUrl = "/m-wap/ScratchCard/index/" + cobj.ActivityId;
                result.WeiActives.Add(cobj);
            }

            //首页礼品
            GiftQuery query = new GiftQuery();

            query.skey     = "";
            query.status   = GiftInfo.GiftSalesStatus.Normal;
            query.PageSize = 4;
            query.PageNo   = 1;
            QueryPageModel <GiftModel> gifts = _iGiftService.GetGifts(query);

            result.HomeGiftses  = gifts.Models.ToList();
            result.HasMoreGifts = gifts.Total > 4;
            foreach (var item in result.HomeGiftses)
            {
                item.DefaultShowImage = HimallIO.GetRomoteImagePath(item.GetImage(ImageSize.Size_350));
            }

            //积分优惠券
            var coupons = _iCouponService.GetIntegralCoupons(1, 3);

            Mapper.CreateMap <CouponInfo, CouponGetIntegralCouponModel>();
            if (coupons.Models.Count > 0)
            {
                var datalist = coupons.Models.ToList();
                var objlist  = new List <CouponGetIntegralCouponModel>();
                foreach (var item in datalist)
                {
                    var tmp = Mapper.Map <CouponGetIntegralCouponModel>(item);
                    tmp.ShowIntegralCover = HimallIO.GetRomoteImagePath(item.IntegralCover);
                    var vshopobj = _iVShopService.GetVShopByShopId(tmp.ShopId);
                    if (vshopobj != null)
                    {
                        tmp.VShopId = vshopobj.Id;
                        //优惠价封面为空时,取微店Logo,微店Logo为空时,取商城微信Logo
                        if (string.IsNullOrWhiteSpace(tmp.ShowIntegralCover))
                        {
                            if (!string.IsNullOrWhiteSpace(vshopobj.WXLogo))
                            {
                                tmp.ShowIntegralCover = HimallIO.GetRomoteImagePath(vshopobj.WXLogo);
                            }
                        }
                    }
                    if (string.IsNullOrWhiteSpace(tmp.ShowIntegralCover))
                    {
                        var siteset = SiteSettingApplication.SiteSettings;
                        tmp.ShowIntegralCover = HimallIO.GetRomoteImagePath(siteset.WXLogo);
                    }
                    objlist.Add(tmp);
                }
                result.IntegralCoupons        = objlist.ToList();
                result.HasMoreIntegralCoupons = coupons.Total > 3;
            }

            result.HasLogined = false;

            //用户积分与等级
            if (CurrentUser != null)
            {
                //登录后处理会员积分
                var userInte  = MemberIntegralApplication.GetMemberIntegral(CurrentUser.Id);
                var userGrade = MemberGradeApplication.GetMemberGradeByUserIntegral(userInte.HistoryIntegrals);
                result.MemberAvailableIntegrals = userInte.AvailableIntegrals;
                result.MemberGradeName          = userGrade.GradeName;
                result.HasLogined = true;
            }

            return(View(result));
        }
Example #8
0
        /// <summary>
        /// 礼品详情
        /// </summary>
        /// <returns></returns>
        public ActionResult Detail(long id)
        {
            GiftDetailPageModel result = new Models.GiftDetailPageModel();
            var data = _iGiftService.GetById(id);

            if (data == null)
            {
                throw new HimallException("礼品信息无效!");
            }
            Mapper.CreateMap <GiftInfo, GiftModel>();
            result.GiftData = Mapper.Map <GiftModel>(data);

            int       hotnum = 10;
            GiftQuery query  = new GiftQuery();

            query.skey     = "";
            query.status   = GiftInfo.GiftSalesStatus.Normal;
            query.PageSize = hotnum;
            query.PageNo   = 1;
            query.Sort     = "SalesNumber";
            query.IsAsc    = false;
            QueryPageModel <GiftModel> hotgifts = _iGiftService.GetGifts(query);

            result.HotGifts = hotgifts.Models.ToList();

            #region 礼品是否可兑
            result.GiftCanBuy = true;
            //礼品信息
            if (result.GiftCanBuy)
            {
                if (result.GiftData.GetSalesStatus != GiftInfo.GiftSalesStatus.Normal)
                {
                    result.GiftCanBuy   = false;
                    result.CanNotBuyDes = "礼品" + result.GiftData.ShowSalesStatus;
                    if (result.GiftData.GetSalesStatus == GiftInfo.GiftSalesStatus.HasExpired)
                    {
                        result.CanNotBuyDes = "活动已结束";//统一app名称而加
                    }
                }
            }

            if (result.GiftCanBuy)
            {
                //库存判断
                if (result.GiftData.StockQuantity < 1)
                {
                    result.GiftCanBuy   = false;
                    result.CanNotBuyDes = "已兑完";
                }
            }

            if (result.GiftCanBuy)
            {
                //积分数
                if (result.GiftData.NeedIntegral < 1)
                {
                    result.GiftCanBuy   = false;
                    result.CanNotBuyDes = "礼品信息错误";
                }
            }
            #endregion

            #region 用户信息判断

            if (result.GiftCanBuy && CurrentUser != null)
            {
                //限购数量
                if (result.GiftData.LimtQuantity > 0)
                {
                    int ownbuynumber = _iGiftsOrderService.GetOwnBuyQuantity(CurrentUser.Id, id);
                    if (ownbuynumber >= result.GiftData.LimtQuantity)
                    {
                        result.GiftCanBuy   = false;
                        result.CanNotBuyDes = "限兑数量已满";
                    }
                }
                if (result.GiftCanBuy)
                {
                    var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUser.Id);
                    if (userInte.AvailableIntegrals < result.GiftData.NeedIntegral)
                    {
                        result.GiftCanBuy   = false;
                        result.CanNotBuyDes = "积分不足";
                    }
                }
            }
            #endregion

            ViewBag.Keyword = SiteSettings.Keyword;
            return(View(result));
        }
Example #9
0
        public JsonResult List(GiftQuery query)
        {
            var datalist = _iGiftService.GetGifts(query);

            return(Json(datalist));
        }
Example #10
0
        /// <summary>
        /// 礼品详情
        /// </summary>
        /// <returns></returns>
        public ActionResult Detail(long id)
        {
            GiftDetailPageModel result = new Models.GiftDetailPageModel();

            result.GiftData = _iGiftService.GetById(id);
            if (result.GiftData == null)
            {
                throw new HimallException("礼品信息无效!");
            }
            int       hotnum = 10;
            GiftQuery query  = new GiftQuery();

            query.skey     = "";
            query.status   = GiftInfo.GiftSalesStatus.Normal;
            query.PageSize = hotnum;
            query.PageNo   = 1;
            query.Sort     = GiftQuery.GiftSortEnum.SalesNumber;
            query.IsAsc    = false;
            ObsoletePageModel <GiftModel> hotgifts = _iGiftService.GetGifts(query);

            result.HotGifts = hotgifts.Models.ToList();

            #region 礼品是否可兑
            result.GiftCanBuy = true;
            //礼品信息
            if (result.GiftCanBuy)
            {
                if (result.GiftData.GetSalesStatus != GiftInfo.GiftSalesStatus.Normal)
                {
                    result.GiftCanBuy = false;
                }
            }

            if (result.GiftCanBuy)
            {
                //库存判断
                if (result.GiftData.StockQuantity < 1)
                {
                    result.GiftCanBuy = false;
                }
            }

            if (result.GiftCanBuy)
            {
                //积分数
                if (result.GiftData.NeedIntegral < 1)
                {
                    result.GiftCanBuy = false;
                }
            }
            #endregion

            #region 用户信息判断

            if (result.GiftCanBuy && CurrentUser != null)
            {
                //限购数量
                if (result.GiftData.LimtQuantity > 0)
                {
                    int ownbuynumber = _iGiftsOrderService.GetOwnBuyQuantity(CurrentUser.Id, id);
                    if (ownbuynumber >= result.GiftData.LimtQuantity)
                    {
                        result.GiftCanBuy = false;
                    }
                }
            }
            #endregion

            return(View(result));
        }