예제 #1
0
        public JsonResult Coupon()
        {
            int  memberIntegral = 0; List <Coupon> baseCoupons = new List <Coupon>();
            long shopId = CurrentSellerManager != null ? CurrentSellerManager.ShopId : 0;

            if (CurrentUser != null)
            {
                memberIntegral = MemberIntegralApplication.GetMemberIntegral(CurrentUser.Id).AvailableIntegrals;

                //优惠卷
                var coupons = CouponApplication.GetAllUserCoupon(CurrentUser.Id).ToList();
                coupons = coupons == null ? new List <UserCouponInfo>() : coupons;
                if (coupons != null)
                {
                    baseCoupons.AddRange(coupons.Select(p => new Coupon()
                    {
                        BasePrice    = p.Price,
                        BaseShopId   = p.ShopId,
                        BaseShopName = p.ShopName,
                        BaseType     = p.BaseType,
                        OrderAmount  = p.OrderAmount
                    }));
                }

                //红包
                var shopBonus = ShopBonusApplication.GetCanUseDetailByUserId(CurrentUser.Id);
                shopBonus = shopBonus == null ? new List <ShopBonusReceiveInfo>() : shopBonus;
                if (shopBonus != null)
                {
                    baseCoupons.AddRange(shopBonus.Select(p => {
                        var grant = _iShopBonusService.GetGrant(p.BonusGrantId);
                        var bonus = _iShopBonusService.GetShopBonus(grant.ShopBonusId);
                        var shop  = ShopApplication.GetShop(bonus.ShopId);

                        return(new Coupon()
                        {
                            BasePrice = p.Price,
                            BaseShopId = shop.Id,
                            BaseShopName = shop.ShopName,
                            BaseType = p.BaseType,
                            UseState = bonus.UseState,
                            UsrStatePrice = bonus.UsrStatePrice
                        });
                    }));
                }
            }
            return(Json(new
            {
                memberIntegral = memberIntegral,
                baseCoupons = baseCoupons,
                shopId = shopId
            }, true));
        }
예제 #2
0
        public ActionResult EditData(ShopBonusModel datamodel)
        {
            var market  = this._bonusService.GetShopBonusService(CurrentSellerManager.ShopId);
            var olddata = _bonusService.GetShopBonus(datamodel.Id);

            Mapper.CreateMap <Entities.ShopBonusInfo, ShopBonusModel>();
            ShopBonusModel model = Mapper.Map <Entities.ShopBonusInfo, ShopBonusModel>(olddata);

            UpdateModel(model);
            if (olddata == null)
            {
                throw new HimallException("错误的参数!");
            }
            var time = MarketApplication.GetServiceEndTime(market.Id);

            if (model.BonusDateEnd > time || model.DateEnd > time)
            {
                throw new HimallException("随机红包截止日期不允许超过您购买的服务到期时间。");
            }
            if (model.Count < 1 || model.Count > 1000)
            {
                throw new HimallException("红包个数请控制在1-1000个!");
            }
            string image     = model.ShareImg;
            string imageName = Guid.NewGuid().ToString() + ".png";
            string moveDir   = "/Storage/Shop/Bonus/";

            if (image.Contains("/temp/"))
            {
                var source = image.Substring(image.LastIndexOf("/temp"));
                Core.HimallIO.CopyFile(source, moveDir + imageName);
                model.ShareImg = "/Storage/Shop/Bonus/" + imageName;
            }
            else if (image.Contains("/Storage/"))
            {
                model.ShareImg = image.Substring(image.LastIndexOf("/Storage/"));
            }
            else
            {
                model.ShareImg = "";
            }
            if (string.IsNullOrEmpty(model.QRPath))
            {
                model.QRPath = "";
            }
            this._bonusService.Update(model);
            return(RedirectToAction("Management"));
        }