Esempio n. 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));
        }