Example #1
0
        public ActionResult GetCouponSuccess(long id)
        {
            VshopCouponInfoModel vshopCouponInfoModel = new VshopCouponInfoModel();
            ICouponService       couponService        = ServiceHelper.Create <ICouponService>();
            CouponRecordInfo     couponRecordById     = couponService.GetCouponRecordById(id);

            if (couponRecordById == null)
            {
                throw new HimallException("错误的优惠券编号");
            }
            CouponInfo couponInfo = couponService.GetCouponInfo(couponRecordById.ShopId, couponRecordById.CouponId);

            if (couponInfo == null)
            {
                throw new HimallException("错误的优惠券编号");
            }
            vshopCouponInfoModel.CouponData       = couponInfo;
            vshopCouponInfoModel.CouponId         = couponInfo.Id;
            vshopCouponInfoModel.CouponRecordId   = couponRecordById.Id;
            vshopCouponInfoModel.ShopId           = couponInfo.ShopId;
            vshopCouponInfoModel.IsShowSyncWeiXin = false;
            if (base.CurrentUser != null && ServiceHelper.Create <IShopService>().IsFavoriteShop(base.CurrentUser.Id, couponInfo.ShopId))
            {
                vshopCouponInfoModel.IsFavoriteShop = true;
            }
            vshopCouponInfoModel.CouponId = id;
            if (couponInfo.IsSyncWeiXin == 1 && base.PlatformType == ChemCloud.Core.PlatformType.WeiXin)
            {
                vshopCouponInfoModel.WXJSInfo = ser_wxcard.GetSyncWeiXin(couponInfo.Id, couponRecordById.Id, ThisCouponType, base.Request.Url.AbsoluteUri);
                if (vshopCouponInfoModel.WXJSInfo != null)
                {
                    vshopCouponInfoModel.IsShowSyncWeiXin = true;
                }
            }
            string    wXLogo        = wxlogo;
            VShopInfo vShopByShopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(couponInfo.ShopId);

            if (vShopByShopId != null)
            {
                vshopCouponInfoModel.VShopid = vShopByShopId.Id;
                if (!string.IsNullOrWhiteSpace(vShopByShopId.WXLogo))
                {
                    wXLogo = vShopByShopId.WXLogo;
                }
                if (string.IsNullOrWhiteSpace(wxlogo) && !string.IsNullOrWhiteSpace(_siteSetting.WXLogo))
                {
                    wXLogo = _siteSetting.WXLogo;
                }
            }
            ViewBag.ShopLogo     = wXLogo;
            ViewBag.ShopId       = vshopCouponInfoModel.ShopId;
            ViewBag.FollowUrl    = vshopCouponInfoModel.FollowUrl;
            base.ViewBag.FavText = (vshopCouponInfoModel.IsFavoriteShop ? "己收藏" : "收藏供应商");
            ViewBag.VShopid      = vshopCouponInfoModel.VShopid;
            return(View(vshopCouponInfoModel));
        }
Example #2
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));
        }