Ejemplo n.º 1
0
        /// <summary>
        /// 礼品详情
        /// </summary>
        /// <returns></returns>
        public ActionResult Detail(long id)
        {
            GiftsDetailModel result = new GiftsDetailModel();
            var data = _iGiftService.GetById(id);

            Mapper.CreateMap <GiftInfo, GiftsDetailModel>();
            result = Mapper.Map <GiftsDetailModel>(data);
            if (result == null)
            {
                throw new Exception("礼品信息无效!");
            }
            string tmpdefaultimg = result.GetImage(ImageSize.Size_100);

            result.DefaultShowImage = HimallIO.GetRomoteImagePath(tmpdefaultimg);
            result.Images           = new List <string>();
            result.Description      = result.Description.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage/") + "/");

            //补充图片信息
            for (var _n = 1; _n < 6; _n++)
            {
                string _imgpath = data.ImagePath + "/" + _n.ToString() + ".png";
                if (HimallIO.ExistFile(_imgpath))
                {
                    var tmp = HimallIO.GetRomoteImagePath(result.GetImage(ImageSize.Size_500, _n));
                    result.Images.Add(tmp);
                }
            }

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

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

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

            #region 用户信息判断

            if (result.CanBuy && CurrentUser != null)
            {
                //限购数量
                if (result.LimtQuantity > 0)
                {
                    int ownbuynumber = _iGiftsOrderService.GetOwnBuyQuantity(CurrentUser.Id, id);
                    if (ownbuynumber >= result.LimtQuantity)
                    {
                        result.CanBuy       = false;
                        result.CanNotBuyDes = "限兑数量已满";
                    }
                }
                if (result.CanBuy)
                {
                    var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUser.Id);
                    if (userInte.AvailableIntegrals < result.NeedIntegral)
                    {
                        result.CanBuy       = false;
                        result.CanNotBuyDes = "积分不足";
                    }
                }
            }
            #endregion
            return(View(result));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public JsonResult CanBuy(long id, int count)
        {
            Result result = new Result();
            bool   flag   = true;

            if (base.CurrentUser == null)
            {
                flag           = false;
                result.success = false;
                result.msg     = "Please Sign in!";
                result.status  = -1;
                return(Json(result));
            }
            UserMemberInfo member = ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id);
            GiftInfo       byId   = giftser.GetById(id);

            if (flag && byId == null)
            {
                flag           = false;
                result.success = false;
                result.msg     = "Gift isn't exist!";
                result.status  = -2;
            }
            if (flag && byId.GetSalesStatus != GiftInfo.GiftSalesStatus.Normal)
            {
                flag           = false;
                result.success = false;
                result.msg     = "Gift Has Expired !";
                result.status  = -2;
            }
            if (flag && count > byId.StockQuantity)
            {
                flag           = false;
                result.success = false;
                int stockQuantity = byId.StockQuantity;
                result.msg    = string.Concat("Gift inventory shortage, only remain ", stockQuantity.ToString(), " items!");
                result.status = -3;
            }
            if (flag && byId.NeedIntegral < 1)
            {
                flag           = false;
                result.success = false;
                result.msg     = "Gifts associated level information is wrong or points wrong!";
                result.status  = -5;
                return(Json(result));
            }
            if (flag && byId.LimtQuantity > 0 && orderser.GetOwnBuyQuantity(base.CurrentUser.Id, id) + count > byId.LimtQuantity)
            {
                flag           = false;
                result.success = false;
                result.msg     = "Exceed gift exchange quantity!";
                result.status  = -4;
            }
            if (flag && byId.NeedIntegral * count > member.AvailableIntegrals)
            {
                flag           = false;
                result.success = false;
                result.msg     = "Lack of points!";
                result.status  = -6;
            }
            if (flag && member.HistoryIntegral < byId.GradeIntegral)
            {
                flag           = false;
                result.success = false;
                result.msg     = "Lack of level!";
                result.status  = -6;
            }
            if (flag)
            {
                result.success = true;
                result.msg     = "Can Buy!";
                result.status  = 1;
            }
            return(Json(result));
        }
Ejemplo n.º 4
0
        public JsonResult SubmitOrder(long id, long regionId, int count)
        {
            Result result = new Result()
            {
                success = false, msg = "未知错误", status = 0
            };
            bool isdataok = true;

            if (count < 1)
            {
                isdataok       = false;
                result.success = false;
                result.msg     = "错误的兑换数量!";
                result.status  = -8;

                return(Json(result));
            }
            //Checkout
            List <GiftOrderItemModel> gorditemlist = new List <GiftOrderItemModel>();

            #region 礼品信息判断
            //礼品信息
            GiftInfo giftdata = _iGiftService.GetById(id);
            if (giftdata == null)
            {
                isdataok       = false;
                result.success = false;
                result.msg     = "礼品不存在!";
                result.status  = -2;

                return(Json(result));
            }

            if (giftdata.GetSalesStatus != GiftInfo.GiftSalesStatus.Normal)
            {
                isdataok       = false;
                result.success = false;
                result.msg     = "礼品已失效!";
                result.status  = -2;

                return(Json(result));
            }

            //库存判断
            if (count > giftdata.StockQuantity)
            {
                isdataok       = false;
                result.success = false;
                result.msg     = "礼品库存不足,仅剩 " + giftdata.StockQuantity.ToString() + " 件!";
                result.status  = -3;

                return(Json(result));
            }

            //积分数
            if (giftdata.NeedIntegral < 1)
            {
                isdataok       = false;
                result.success = false;
                result.msg     = "礼品关联等级信息有误或礼品积分数据有误!";
                result.status  = -5;

                return(Json(result));
            }
            #endregion

            #region 用户信息判断
            //限购数量
            if (giftdata.LimtQuantity > 0)
            {
                int ownbuynumber = _iGiftsOrderService.GetOwnBuyQuantity(CurrentUser.Id, id);
                if (ownbuynumber + count > giftdata.LimtQuantity)
                {
                    isdataok       = false;
                    result.success = false;
                    result.msg     = "超过礼品限兑数量!";
                    result.status  = -4;

                    return(Json(result));
                }
            }
            var userInte = MemberIntegralApplication.GetMemberIntegral(CurrentUser.Id);
            if (giftdata.NeedIntegral * count > userInte.AvailableIntegrals)
            {
                isdataok       = false;
                result.success = false;
                result.msg     = "积分不足!";
                result.status  = -6;

                return(Json(result));
            }

            //等级判定
            if (!MemberGradeApplication.IsAllowGrade(CurrentUser.Id, giftdata.NeedGrade))
            {
                isdataok       = false;
                result.success = false;
                result.msg     = "用户等级不足!";
                result.status  = -6;
                return(Json(result));
            }

            #endregion

            Entities.ShippingAddressInfo shipdata = GetShippingAddress(regionId);
            if (shipdata == null)
            {
                isdataok       = false;
                result.success = false;
                result.msg     = "错误的收货人地址信息!";
                result.status  = -6;

                return(Json(result));
            }

            if (isdataok)
            {
                gorditemlist.Add(new GiftOrderItemModel {
                    GiftId = giftdata.Id, Counts = count
                });
                GiftOrderModel createorderinfo = new GiftOrderModel();
                createorderinfo.Gifts          = gorditemlist;
                createorderinfo.CurrentUser    = CurrentUser;
                createorderinfo.ReceiveAddress = shipdata;
                Himall.Entities.GiftOrderInfo orderdata = _iGiftsOrderService.CreateOrder(createorderinfo);
                result.success = true;
                result.msg     = orderdata.Id.ToString();
                result.status  = 1;
            }

            return(Json(result));
        }
Ejemplo n.º 5
0
        public JsonResult SubmitOrder(long id, long regionId, int count)
        {
            Result result = new Result()
            {
                success = false,
                msg     = "未知错误",
                status  = 0
            };
            Result str  = result;
            bool   flag = true;

            if (count < 1)
            {
                flag        = false;
                str.success = false;
                str.msg     = "错误的兑换数量!";
                str.status  = -8;
                return(Json(str));
            }
            List <GiftOrderItemModel> giftOrderItemModels = new List <GiftOrderItemModel>();
            UserMemberInfo            member = ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id);
            GiftInfo byId = giftser.GetById(id);

            if (byId == null)
            {
                flag        = false;
                str.success = false;
                str.msg     = "礼品不存在!";
                str.status  = -2;
                return(Json(str));
            }
            if (byId.GetSalesStatus != GiftInfo.GiftSalesStatus.Normal)
            {
                flag        = false;
                str.success = false;
                str.msg     = "礼品己失效!";
                str.status  = -2;
                return(Json(str));
            }
            if (count > byId.StockQuantity)
            {
                flag        = false;
                str.success = false;
                int stockQuantity = byId.StockQuantity;
                str.msg    = string.Concat("礼品库存不足,仅剩 ", stockQuantity.ToString(), " 件!");
                str.status = -3;
                return(Json(str));
            }
            if (byId.NeedIntegral < 1)
            {
                flag        = false;
                str.success = false;
                str.msg     = "礼品关联等级信息有误或礼品积分数据有误!";
                str.status  = -5;
                return(Json(str));
            }
            if (byId.LimtQuantity > 0 && orderser.GetOwnBuyQuantity(base.CurrentUser.Id, id) + count > byId.LimtQuantity)
            {
                flag        = false;
                str.success = false;
                str.msg     = "超过礼品限兑数量!";
                str.status  = -4;
                return(Json(str));
            }
            if (byId.NeedIntegral * count > member.AvailableIntegrals)
            {
                flag        = false;
                str.success = false;
                str.msg     = "积分不足!";
                str.status  = -6;
                return(Json(str));
            }
            if (member.HistoryIntegral < byId.GradeIntegral)
            {
                flag        = false;
                str.success = false;
                str.msg     = "用户等级不足!";
                str.status  = -6;
                return(Json(str));
            }
            ShippingAddressInfo shippingAddress = GetShippingAddress(new long?(regionId));

            if (shippingAddress == null)
            {
                flag        = false;
                str.success = false;
                str.msg     = "错误的收货人地址信息!";
                str.status  = -6;
                return(Json(str));
            }
            if (flag)
            {
                GiftOrderItemModel giftOrderItemModel = new GiftOrderItemModel()
                {
                    GiftId = byId.Id,
                    Counts = count
                };
                giftOrderItemModels.Add(giftOrderItemModel);
                GiftOrderModel giftOrderModel = new GiftOrderModel()
                {
                    Gifts          = giftOrderItemModels,
                    CurrentUser    = member,
                    ReceiveAddress = shippingAddress
                };
                GiftOrderInfo giftOrderInfo = orderser.CreateOrder(giftOrderModel);
                str.success = true;
                str.msg     = giftOrderInfo.Id.ToString();
                str.status  = 1;
            }
            return(Json(str));
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        public JsonResult CanBuy(long id, int count)
        {
            Result result = new Result();
            bool   flag   = true;

            if (base.CurrentUser == null)
            {
                flag           = false;
                result.success = false;
                result.msg     = "您还未登录!";
                result.status  = -1;
                return(Json(result));
            }
            UserMemberInfo member = ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id);
            GiftInfo       byId   = giftser.GetById(id);

            if (flag && byId == null)
            {
                flag           = false;
                result.success = false;
                result.msg     = "礼品不存在!";
                result.status  = -2;
            }
            if (flag && byId.GetSalesStatus != GiftInfo.GiftSalesStatus.Normal)
            {
                flag           = false;
                result.success = false;
                result.msg     = "礼品己失效!";
                result.status  = -2;
            }
            if (flag && count > byId.StockQuantity)
            {
                flag           = false;
                result.success = false;
                int stockQuantity = byId.StockQuantity;
                result.msg    = string.Concat("礼品库存不足,仅剩 ", stockQuantity.ToString(), " 件!");
                result.status = -3;
            }
            if (flag && byId.NeedIntegral < 1)
            {
                flag           = false;
                result.success = false;
                result.msg     = "礼品关联等级信息有误或礼品积分数据有误!";
                result.status  = -5;
                return(Json(result));
            }
            if (flag && byId.LimtQuantity > 0 && orderser.GetOwnBuyQuantity(base.CurrentUser.Id, id) + count > byId.LimtQuantity)
            {
                flag           = false;
                result.success = false;
                result.msg     = "超过礼品限兑数量!";
                result.status  = -4;
            }
            if (flag && byId.NeedIntegral * count > member.AvailableIntegrals)
            {
                flag           = false;
                result.success = false;
                result.msg     = "积分不足!";
                result.status  = -6;
            }
            if (flag && member.HistoryIntegral < byId.GradeIntegral)
            {
                flag           = false;
                result.success = false;
                result.msg     = "用户等级不足!";
                result.status  = -6;
            }
            if (flag)
            {
                result.success = true;
                result.msg     = "可以购买!";
                result.status  = 1;
            }
            return(Json(result));
        }
Ejemplo n.º 8
0
        public JsonResult SubmitOrder(long id, long regionId, int count)
        {
            Result result = new Result()
            {
                success = false,
                msg     = "Unknown error",
                status  = 0
            };
            Result str  = result;
            bool   flag = true;

            if (count < 1)
            {
                flag        = false;
                str.success = false;
                str.msg     = "Exchange quantity error!";
                str.status  = -8;
                return(Json(str));
            }
            List <GiftOrderItemModel> giftOrderItemModels = new List <GiftOrderItemModel>();
            UserMemberInfo            member = ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id);
            GiftInfo byId = giftser.GetById(id);

            if (byId == null)
            {
                flag        = false;
                str.success = false;
                str.msg     = "Gift does not exist!";
                str.status  = -2;
                return(Json(str));
            }
            if (byId.GetSalesStatus != GiftInfo.GiftSalesStatus.Normal)
            {
                flag        = false;
                str.success = false;
                str.msg     = "Gift expired!";
                str.status  = -2;
                return(Json(str));
            }
            if (count > byId.StockQuantity)
            {
                flag        = false;
                str.success = false;
                int stockQuantity = byId.StockQuantity;
                str.msg    = string.Concat("Gift inventory shortage, only remain ", stockQuantity.ToString(), " items!");
                str.status = -3;
                return(Json(str));
            }
            if (byId.NeedIntegral < 1)
            {
                flag        = false;
                str.success = false;
                str.msg     = "Gifts associated level information is wrong or points wrong!";
                str.status  = -5;
                return(Json(str));
            }
            if (byId.LimtQuantity > 0 && orderser.GetOwnBuyQuantity(base.CurrentUser.Id, id) + count > byId.LimtQuantity)
            {
                flag        = false;
                str.success = false;
                str.msg     = "Exceed gift exchange quantity!";
                str.status  = -4;
                return(Json(str));
            }
            if (byId.NeedIntegral * count > member.AvailableIntegrals)
            {
                flag        = false;
                str.success = false;
                str.msg     = "Lack of points!";
                str.status  = -6;
                return(Json(str));
            }
            if (member.HistoryIntegral < byId.GradeIntegral)
            {
                flag        = false;
                str.success = false;
                str.msg     = "Lack of Level!";
                str.status  = -6;
                return(Json(str));
            }
            ShippingAddressInfo shippingAddress = GetShippingAddress(new long?(regionId));

            if (shippingAddress == null)
            {
                flag        = false;
                str.success = false;
                str.msg     = "Shipping address error!";
                str.status  = -6;
                return(Json(str));
            }
            if (flag)
            {
                GiftOrderItemModel giftOrderItemModel = new GiftOrderItemModel()
                {
                    GiftId = byId.Id,
                    Counts = count
                };
                giftOrderItemModels.Add(giftOrderItemModel);
                GiftOrderModel giftOrderModel = new GiftOrderModel()
                {
                    Gifts          = giftOrderItemModels,
                    CurrentUser    = member,
                    ReceiveAddress = shippingAddress
                };
                GiftOrderInfo giftOrderInfo = orderser.CreateOrder(giftOrderModel);
                str.success = true;
                str.msg     = giftOrderInfo.Id.ToString();
                str.status  = 1;
            }
            return(Json(str));
        }