Ejemplo n.º 1
0
        public ActionResult Detail(long id)
        {
            string           url      = CurrentUrlHelper.CurrentUrlNoPort() + "/m-Mobile/BigWheel/index/";
            WeiActivityModel WeiModel = WeiActivityApplication.GetActivityModel(id, url);

            return(View(WeiModel));
        }
Ejemplo n.º 2
0
        public static long AddActivitySubmit(WeiActivityModel model)
        {
            var weiInfo = new WeiActivityInfoInfo();

            if (model.Id > 0)
            {
                weiInfo.Id = model.Id;
            }
            weiInfo.ActivityTitle      = model.activityTitle;
            weiInfo.ActivityType       = (int)model.activityType;
            weiInfo.ActivityDetails    = model.activityDetails;
            weiInfo.ActivityUrl        = TransferImage(model.activityUrl);
            weiInfo.BeginTime          = model.beginTime;
            weiInfo.EndTime            = model.endTime;
            weiInfo.ParticipationType  = (int)model.participationType;
            weiInfo.ParticipationCount = model.participationCount;
            weiInfo.ConsumePoint       = model.consumePoint;
            weiInfo.CodeUrl            = model.codeUrl;

            var awardInfo = model.awards.Select(item => new WeiActivityAwardInfo
            {
                ActivityId = item.activityId,
                AwardCount = item.awardCount,
                AwardLevel = item.awardLevel,
                AwardType  = (int)item.awardType,
                BonusId    = item.bonusId,
                CouponId   = item.couponId,
                Integral   = item.integral,
                Proportion = item.proportion
            }).ToList();

            return(Service.AddActivity(weiInfo, awardInfo));
        }
Ejemplo n.º 3
0
        public double GetCount(long id, long awardId)
        {
            WeiActivityModel             activityModel = WeiActivityApplication.GetActivityModel(id);
            double                       num           = 0.0;
            float                        num2          = 0f;
            List <WeiActivityAwardModel> list2         = (from p in activityModel.awards
                                                          where p.Id == awardId
                                                          select p).ToList <WeiActivityAwardModel>();

            foreach (WeiActivityAwardModel model2 in activityModel.awards)
            {
                if (!WeiActivityWinApplication.GetWinNumberByAward(id, model2.Id))
                {
                    num += model2.proportion;
                }
                else if (model2.awardLevel < list2[0].awardLevel)
                {
                    num2 += model2.proportion;
                }
            }
            if (!WeiActivityWinApplication.GetWinNumberByAward(id, awardId))
            {
                return(0.0);
            }
            return((num + num2) + list2[0].proportion);
        }
Ejemplo n.º 4
0
        public static WeiActivityModel GetActivityModel(long id, string url = "")
        {
            var model = Service.GetActivityModel(id, url);

            var viewModel = new WeiActivityModel
            {
                Id                 = model.Id,
                activityTitle      = model.ActivityTitle,
                activityType       = (WeiActivityType)model.ActivityType,
                activityDetails    = model.ActivityDetails,
                activityUrl        = HimallIO.GetImagePath(model.ActivityUrl),
                beginTime          = model.BeginTime,
                endTime            = model.EndTime,
                participationType  = (WeiParticipateType)model.ParticipationType,
                participationCount = Convert.ToInt32(model.ParticipationCount),
                consumePoint       = model.ConsumePoint,
                codeUrl            = model.CodeUrl,
                addDate            = model.AddDate
            };
            var awards = Service.GetActivityAwards(model.Id);

            viewModel.awards = awards.Select(item => new WeiActivityAwardModel
            {
                Id         = item.Id,
                activityId = item.ActivityId,
                awardCount = item.AwardCount,
                awardLevel = item.AwardLevel,
                awardType  = (WeiActivityAwardType)item.AwardType,
                bonusId    = item.BonusId,
                couponId   = item.CouponId,
                integral   = item.Integral,
                proportion = item.Proportion
            }).ToList();
            return(viewModel);
        }
Ejemplo n.º 5
0
        public ActionResult Edit(long id)
        {
            ViewBag.BrandDrop = BindDrop(true);
            //查询当前刮刮卡信息
            WeiActivityModel weiAwardModel = WeiActivityApplication.GetActivityModel(id);

            return(View(weiAwardModel));
        }
Ejemplo n.º 6
0
        public int GetParticipationCount(WeiActivityModel activityModel)
        {
            int winModel = WeiActivityWinApplication.GetWinModel(activityModel);

            if (winModel != -1)
            {
                return(activityModel.participationCount - winModel);
            }
            return(winModel);
        }
        /// <summary>
        /// 计算用户可抽奖次数
        /// </summary>
        /// <param name="activityModel"></param>
        /// <returns></returns>
        public int GetParticipationCount(WeiActivityModel activityModel)
        {
            int participationCount = WeiActivityWinApplication.GetWinModel(activityModel);

            if (participationCount != -1)
            {
                return(activityModel.participationCount - participationCount);
            }
            else
            {
                return(participationCount);
            }
        }
Ejemplo n.º 8
0
        public ActionResult Edit(FormCollection fc)
        {
            WeiActivityModel model = WeiActivityApplication.GetActivityModel(Convert.ToInt32(fc["activityId"]));

            if (!string.IsNullOrWhiteSpace(fc["activityTitle"]))
            {
                model.activityTitle = fc["activityTitle"].ToString();
            }
            if (!string.IsNullOrWhiteSpace(fc["activityDetails"]))
            {
                model.activityDetails = fc["activityDetails"].ToString();
            }

            if (!string.IsNullOrWhiteSpace(fc["endTime"]))
            {
                model.endTime = Convert.ToDateTime(fc["endTime"].ToString());
            }
            if (!string.IsNullOrWhiteSpace(fc["participationType"]))
            {
                model.participationType = (WeiParticipateType)Enum.Parse(typeof(WeiParticipateType), fc["participationType"].ToString());
            }
            if (!string.IsNullOrWhiteSpace(fc["participationCount"]))
            {
                model.participationCount = Convert.ToInt32(fc["participationCount"].ToString().Replace(",", " ").Trim());
            }
            if (!string.IsNullOrWhiteSpace(fc["isPoint"]))
            {
                if (Convert.ToInt32(fc["isPoint"]) > 0)
                {
                    model.consumePoint = Convert.ToInt32(fc["consumePoint"].ToString());
                }
                else
                {
                    model.consumePoint = 0;
                }
            }

            //临时图片地址
            model.activityUrl = fc["activityUrl"];
            string url = CurrentUrlHelper.CurrentUrlNoPort() + "/m-Mobile/ScratchCard/index/";

            model.codeUrl = url;

            model.activityType = WeiActivityType.ScratchCard;


            long id = WeiActivityApplication.AddActivitySubmit(model);

            return(RedirectToAction("Detail/" + id));
        }
Ejemplo n.º 9
0
        public ActionResult Add(string productCommentsJSON)
        {
            //用于提交时 积分参数为抽奖需消耗积分
            var productComments = JsonConvert.DeserializeObject <WeiActivityWinModel>(productCommentsJSON);

            if (productComments != null)
            {
                WeiActivityModel activityModel = WeiActivityApplication.GetActivityModel(productComments.activityId);
                int participationCount         = activityModel != null?GetParticipationCount(activityModel) : 0;

                if (participationCount > 0 || participationCount == -1)
                {
                    WeiActivityApplication.WinnerSubmit(productComments);
                }
            }
            return(Json <dynamic>(success: true, msg: "成功"));
        }
        public static int GetWinModel(WeiActivityModel model)
        {
            List <WeiActivityWinInfo> listWinModel = _iWeiActivityWinService.GetWinInfo(model.userId);

            listWinModel = listWinModel.Where(p => p.ActivityId == model.Id).ToList();
            if (model.participationType == WeiParticipateType.DayCount)
            {
                return(listWinModel.Where(p => p.AddDate.Date == DateTime.Now.Date).Count());
            }
            else if (model.participationType == WeiParticipateType.CommonCount)
            {
                return(listWinModel.Count());
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 11
0
        public ActionResult Index(long id)
        {
            WeiActivityModel activityModelByBigWheel = WeiActivityApplication.GetActivityModelByBigWheel(id);

            activityModelByBigWheel.userId = this.curUserId;
            int availableIntegrals = this._iMemberIntegralService.GetMemberIntegral(this.curUserId).AvailableIntegrals;

            activityModelByBigWheel.participationCount = this.GetParticipationCount(activityModelByBigWheel);
            this.consumePoint = activityModelByBigWheel.consumePoint;
            ((dynamic)base.ViewBag).Integrals = availableIntegrals;
            try
            {
                string ticket = QrCodeApi.Create(AccessTokenContainer.TryGetToken(this._siteSetting.WeixinAppId, this._siteSetting.WeixinAppSecret, false), 0x15180, 0x7661b3, 0x2710).ticket;
                ((dynamic)base.ViewBag).QRTicket = ticket;
            }
            catch
            {
            }
            return(base.View(activityModelByBigWheel));
        }
Ejemplo n.º 12
0
        public ActionResult Index(long id)
        {
            WeiActivityModel activityModel = WeiActivityApplication.GetActivityModelByBigWheel(id);

            activityModel.userId = curUserId;
            var integrals = _iMemberIntegralService.GetMemberIntegral(curUserId).AvailableIntegrals;//用户可用积分

            activityModel.participationCount = GetParticipationCount(activityModel);
            consumePoint = activityModel.consumePoint;

            ViewBag.Integrals = integrals;

            //TODO:改成统一的方式取 Token
            var token    = AccessTokenContainer.TryGetToken(this._siteSetting.WeixinAppId, this._siteSetting.WeixinAppSecret);
            var qrTicket = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 86400, 7758259).ticket;

            ViewBag.QRTicket = qrTicket;

            return(View(activityModel));
        }
Ejemplo n.º 13
0
        public ActionResult Index(long id)
        {
            WeiActivityModel activityModel = WeiActivityApplication.GetActivityModelByBigWheel(id);

            activityModel.userId             = curUserId;
            activityModel.participationCount = GetParticipationCount(activityModel);
            consumePoint = activityModel.consumePoint;

            ViewBag.Integrals = MemberIntegralApplication.GetAvailableIntegral(curUserId);

            //TODO:改成统一的方式取 Token
            try
            {
                var settings = SiteSettingApplication.SiteSettings;
                var token    = AccessTokenContainer.TryGetToken(settings.WeixinAppId, settings.WeixinAppSecret);
                var qrTicket = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 86400, 7758259).ticket;
                ViewBag.QRTicket = qrTicket;
            }
            catch { }
            return(View(activityModel));
        }
Ejemplo n.º 14
0
        public static WeiActivityModel GetActivityModel(long id)
        {
            WeiActivityInfo model = _iActivityInfoService.GetActivityModel(id);

            WeiActivityModel viewModel = new WeiActivityModel();

            viewModel.Id                 = model.Id;
            viewModel.activityTitle      = model.ActivityTitle;
            viewModel.activityType       = model.ActivityType;
            viewModel.activityDetails    = model.ActivityDetails;
            viewModel.activityUrl        = Himall.Core.HimallIO.GetImagePath(model.ActivityUrl);
            viewModel.beginTime          = model.BeginTime;
            viewModel.endTime            = model.EndTime;
            viewModel.participationType  = model.ParticipationType;
            viewModel.participationCount = Convert.ToInt32(model.ParticipationCount);
            viewModel.consumePoint       = model.ConsumePoint;
            viewModel.codeUrl            = model.CodeUrl;
            viewModel.addDate            = model.AddDate;

            List <WeiActivityAwardModel> listAwardModel = new List <WeiActivityAwardModel>();

            foreach (var item in model.Himall_WeiActivityAward)
            {
                WeiActivityAwardModel awardModel = new WeiActivityAwardModel();
                awardModel.Id         = item.Id;
                awardModel.activityId = item.ActivityId;
                awardModel.awardCount = item.AwardCount;
                awardModel.awardLevel = item.AwardLevel;
                awardModel.awardType  = item.AwardType;
                awardModel.bonusId    = item.BonusId == null ? 0 : Convert.ToInt32(item.BonusId);
                awardModel.couponId   = item.CouponId == null ? 0 : Convert.ToInt32(item.CouponId);;
                awardModel.integral   = item.Integral == null ? 0 : Convert.ToInt32(item.Integral);;
                awardModel.proportion = item.Proportion;
                listAwardModel.Add(awardModel);
            }
            viewModel.awards = listAwardModel;
            return(viewModel);
        }
Ejemplo n.º 15
0
        public static long AddActivitySubmit(WeiActivityModel model)
        {
            WeiActivityInfo weiInfo = new WeiActivityInfo();

            if (model.Id > 0)
            {
                weiInfo.Id = model.Id;
            }
            weiInfo.ActivityTitle      = model.activityTitle;
            weiInfo.ActivityType       = model.activityType;
            weiInfo.ActivityDetails    = model.activityDetails;
            weiInfo.ActivityUrl        = TransferImage(model.activityUrl);
            weiInfo.BeginTime          = model.beginTime;
            weiInfo.EndTime            = model.endTime;
            weiInfo.ParticipationType  = model.participationType;
            weiInfo.ParticipationCount = model.participationCount;
            weiInfo.ConsumePoint       = model.consumePoint;
            weiInfo.CodeUrl            = model.codeUrl;

            List <WeiActivityAwardInfo> listAwardInfo = new List <WeiActivityAwardInfo>();

            foreach (var item in model.awards)
            {
                WeiActivityAwardInfo awardInfo = new WeiActivityAwardInfo();
                awardInfo.ActivityId = item.activityId;
                awardInfo.AwardCount = item.awardCount;
                awardInfo.AwardLevel = item.awardLevel;
                awardInfo.AwardType  = item.awardType;
                awardInfo.BonusId    = item.bonusId;
                awardInfo.CouponId   = item.couponId;
                awardInfo.Integral   = item.integral;
                awardInfo.Proportion = item.proportion;
                listAwardInfo.Add(awardInfo);
            }
            weiInfo.Himall_WeiActivityAward = listAwardInfo;
            return(_iActivityInfoService.AddActivity(weiInfo));
        }
Ejemplo n.º 16
0
        public ActionResult Index(long id)
        {
            //TODO:改成统一的方式取 Token
            var settings = SiteSettingApplication.SiteSettings;

            if (settings.IsOpenH5)
            {
                var token = AccessTokenContainer.TryGetAccessToken(settings.WeixinAppId, settings.WeixinAppSecret);

                SceneHelper helper   = new SceneHelper();
                var         qrTicket = QrCodeApi.Create(token, 86400, 7758258, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null).ticket;

                ViewBag.QRTicket = qrTicket;
            }

            WeiActivityModel activityModel = WeiActivityApplication.GetActivityModel(id);

            activityModel.userId             = curUserId;
            activityModel.winModel           = AddWinInfo(activityModel);
            activityModel.winModel.integrals = MemberIntegralApplication.GetAvailableIntegral(curUserId);
            activityModel.participationCount = GetParticipationCount(activityModel);
            consumePoint = activityModel.consumePoint;
            return(View(activityModel));
        }
Ejemplo n.º 17
0
        public ActionResult Add(long id, long userId)
        {
            WeiActivityModel activityModel = WeiActivityApplication.GetActivityModel(id);

            this.activityWinModel = new WeiActivityWinModel();
            int num = new Random().Next(1, 100);

            this.activityWinModel.activityId = id;
            this.activityWinModel.addDate    = DateTime.Now;
            this.activityWinModel.userId     = userId;
            this.activityWinModel.integrals  = activityModel.consumePoint;
            this.activityWinModel.isWin      = false;
            this.activityWinModel.awardId    = 0L;
            this.activityWinModel.awardName  = "未中奖";
            foreach (WeiActivityAwardModel model2 in activityModel.awards)
            {
                if (num <= this.GetCount(activityModel.Id, model2.Id))
                {
                    this.activityWinModel.isWin = true;
                    if (model2.awardType == WeiActivityAwardType.Integral)
                    {
                        this.activityWinModel.awardName = model2.integral.ToString();
                        this.activityWinModel.awardId   = model2.Id;
                        this.activityWinModel.awardType = model2.awardType;
                        break;
                    }
                    if (model2.awardType == WeiActivityAwardType.Bonus)
                    {
                        BonusInfo info = this._iBonusService.Get(model2.bonusId);
                        if (info == null)
                        {
                            this.activityWinModel.isWin = false;
                        }
                        else
                        {
                            string bonusSurplus = this._iBonusService.GetBonusSurplus(model2.bonusId);
                            if (info.IsInvalid)
                            {
                                this.activityWinModel.isWin = false;
                            }
                            else if (Convert.ToInt32(bonusSurplus) <= 0)
                            {
                                this.activityWinModel.isWin = false;
                            }
                            else
                            {
                                this.activityWinModel.awardName = info.Name;
                                this.activityWinModel.awardId   = model2.Id;
                                this.activityWinModel.awardType = model2.awardType;
                                this.activityWinModel.bonusId   = model2.bonusId;
                            }
                        }
                        break;
                    }
                    if (model2.awardType == WeiActivityAwardType.Coupon)
                    {
                        CouponModel model3 = CouponApplication.Get(model2.couponId);
                        if (model3 == null)
                        {
                            this.activityWinModel.isWin = false;
                        }
                        else
                        {
                            int num2 = WeiActivityWinApplication.GetCouPonMax(this.activityWinModel.userId, this.activityWinModel.activityId, model2.Id);
                            if (model3.Num <= 0)
                            {
                                this.activityWinModel.isWin = false;
                            }
                            else if ((model3.perMax != 0) && (num2 >= model3.perMax))
                            {
                                this.activityWinModel.isWin = false;
                            }
                            else if (model3.EndTime < DateTime.Now)
                            {
                                this.activityWinModel.isWin = false;
                            }
                            else
                            {
                                string couponName = model3.CouponName;
                                if (model3.ShopName != "")
                                {
                                    couponName = couponName + "(" + model3.ShopName + ")";
                                }
                                if (model3.OrderAmount != "")
                                {
                                    couponName = couponName + "(" + model3.OrderAmount + ")";
                                }
                                this.activityWinModel.awardName = couponName;
                                this.activityWinModel.awardId   = model2.Id;
                                this.activityWinModel.awardType = model2.awardType;
                                this.activityWinModel.couponId  = model2.couponId;
                            }
                        }
                        break;
                    }
                }
            }
            WeiActivityWinApplication.WinnerSubmit(this.activityWinModel);
            decimal receivePriceByUserId = 0M;

            if (this.activityWinModel.bonusId > 0L)
            {
                receivePriceByUserId = this._iBonusService.GetReceivePriceByUserId(this.activityWinModel.bonusId, userId);
            }
            BaseController.Result data = new BaseController.Result
            {
                success = true,
                msg     = this.activityWinModel.awardId.ToString() + "," + receivePriceByUserId.ToString()
            };
            return(base.Json(data));
        }
Ejemplo n.º 18
0
        public static WeiActivityModel GetActivityModelByBigWheel(long id)
        {
            WeiActivityInfo model = _iActivityInfoService.GetActivityModel(id);

            WeiActivityModel viewModel = new WeiActivityModel();

            viewModel.Id                 = model.Id;
            viewModel.activityTitle      = model.ActivityTitle;
            viewModel.activityType       = model.ActivityType;
            viewModel.activityDetails    = model.ActivityDetails;
            viewModel.activityUrl        = model.ActivityUrl;
            viewModel.beginTime          = model.BeginTime;
            viewModel.endTime            = model.EndTime;
            viewModel.participationType  = model.ParticipationType;
            viewModel.participationCount = Convert.ToInt32(model.ParticipationCount);
            viewModel.consumePoint       = model.ConsumePoint;
            viewModel.codeUrl            = model.CodeUrl;
            viewModel.addDate            = model.AddDate;

            List <WeiActivityAwardModel> listAwardModel = new List <WeiActivityAwardModel>();
            var item     = model.Himall_WeiActivityAward.ToList();
            int awardNum = 0;//获取奖等序号
            int falg     = 9 - item.Count();

            for (int i = 0; i < 9; i++)//创建9宫格实体
            {
                //放空值 ,未中奖
                if (i % 2 == 0)
                {
                    //最高奖等6 ,4以内奖等能均匀分布
                    if (item.Count() <= 4)
                    {
                        //获取奖项
                        WeiActivityAwardModel awardModel = new WeiActivityAwardModel();
                        listAwardModel.Add(awardModel);
                    }
                    else //大于4组奖项  未中奖显示不能均匀分布
                    {
                        if (falg > 0)
                        {
                            //获取奖项
                            WeiActivityAwardModel awardModel = new WeiActivityAwardModel();
                            listAwardModel.Add(awardModel);
                            falg--;
                        }
                        else
                        {
                            //获取奖项
                            WeiActivityAwardModel awardModel = new WeiActivityAwardModel();
                            awardModel.Id         = item[awardNum].Id;
                            awardModel.activityId = item[awardNum].ActivityId;
                            awardModel.awardCount = item[awardNum].AwardCount;
                            awardModel.awardLevel = item[awardNum].AwardLevel;
                            awardModel.awardType  = item[awardNum].AwardType;
                            awardModel.bonusId    = item[awardNum].BonusId == null ? 0 : Convert.ToInt32(item[awardNum].BonusId);
                            awardModel.couponId   = item[awardNum].CouponId == null ? 0 : Convert.ToInt32(item[awardNum].CouponId);
                            awardModel.integral   = item[awardNum].Integral == null ? 0 : Convert.ToInt32(item[awardNum].Integral);
                            awardModel.couponId   = item[awardNum].CouponId == null ? 0 : Convert.ToInt32(item[awardNum].CouponId);
                            awardModel.integral   = item[awardNum].Integral == null ? 0 : Convert.ToInt32(item[awardNum].Integral);
                            if (awardModel.couponId != 0)
                            {
                                awardModel.couponName = _iCouponService.GetCouponInfo(long.Parse(item[awardNum].CouponId.ToString())).CouponName;
                            }
                            awardModel.proportion = item[awardNum].Proportion;
                            listAwardModel.Add(awardModel);
                            awardNum++;
                        }
                    }
                }
                else
                {
                    //奖等未取完
                    if (item.Count() > awardNum)
                    {
                        //获取奖项
                        WeiActivityAwardModel awardModel = new WeiActivityAwardModel();
                        awardModel.Id         = item[awardNum].Id;
                        awardModel.activityId = item[awardNum].ActivityId;
                        awardModel.awardCount = item[awardNum].AwardCount;
                        awardModel.awardLevel = item[awardNum].AwardLevel;
                        awardModel.awardType  = item[awardNum].AwardType;
                        awardModel.bonusId    = item[awardNum].BonusId == null ? 0 : Convert.ToInt32(item[awardNum].BonusId);

                        awardModel.couponId = item[awardNum].CouponId == null ? 0 : Convert.ToInt32(item[awardNum].CouponId);
                        awardModel.integral = item[awardNum].Integral == null ? 0 : Convert.ToInt32(item[awardNum].Integral);
                        if (awardModel.couponId != 0)
                        {
                            awardModel.couponName = _iCouponService.GetCouponInfo(long.Parse(item[awardNum].CouponId.ToString())).CouponName;
                        }

                        awardModel.proportion = item[awardNum].Proportion;
                        listAwardModel.Add(awardModel);
                        awardNum++;
                    }
                    else
                    {
                        //获取奖项
                        WeiActivityAwardModel awardModel = new WeiActivityAwardModel();
                        listAwardModel.Add(awardModel);
                    }
                }
            }
            viewModel.awards = listAwardModel;
            return(viewModel);
        }
        public WeiActivityWinModel AddWinInfo(WeiActivityModel activityModel)
        {
            activityWinModel = new WeiActivityWinModel();
            Random r   = new Random();
            int    num = r.Next(1, 101);//获取随机数做为中奖信息

            activityWinModel.activityId = activityModel.Id;
            activityWinModel.addDate    = DateTime.Now;
            activityWinModel.userId     = curUserId;

            activityWinModel.isWin     = false;
            activityWinModel.awardId   = 0;
            activityWinModel.awardName = "未中奖";
            activityWinModel.awardType = WeiActivityAwardType.Integral;
            // var activityModel=WeiActivityWinApplication.GetWinModel()
            foreach (var item in activityModel.awards)
            {
                //获取的随机数在该奖等区域类
                if (num <= GetCount(activityModel.Id, item.Id))
                {
                    if (item.awardType == WeiActivityAwardType.Integral)
                    {
                        activityWinModel.awardName = item.integral.ToString();
                        activityWinModel.awardId   = item.Id;
                        activityWinModel.awardType = item.awardType;
                        activityWinModel.isWin     = true;
                        return(activityWinModel);
                    }
                    else if (item.awardType == WeiActivityAwardType.Bonus)
                    {
                        Model.BonusInfo bonusInfo = _iBonusService.Get(item.bonusId);
                        string          Surplus   = _iBonusService.GetBonusSurplus(item.bonusId);
                        if (bonusInfo.IsInvalid)//红包已经失效 返回 未中奖
                        {
                            break;
                        }
                        if (Convert.ToInt32(Surplus) <= 0)//当前红包已经领取完 设置未中奖
                        {
                            break;
                        }

                        //获取红包名称
                        activityWinModel.awardName = bonusInfo.Himall_BonusReceive.Where(p => p.IsShare == false && p.UserId == null).FirstOrDefault().Price.ToString() + "元红包";
                        activityWinModel.awardId   = item.Id;
                        activityWinModel.awardType = item.awardType;
                        activityWinModel.bonusId   = bonusInfo.Id;
                        activityWinModel.isWin     = true;
                        return(activityWinModel);
                    }
                    else if (item.awardType == WeiActivityAwardType.Coupon)
                    {
                        CouponModel couponModel = CouponApplication.Get(item.couponId);
                        int         perMax      = WeiActivityWinApplication.GetCouPonMax(activityWinModel.userId, activityWinModel.activityId, item.Id);

                        if (couponModel == null)
                        {
                            break;
                        }
                        if (couponModel.Num <= 0)//无库存 返回 未中奖
                        {
                            break;
                        }
                        if (couponModel.EndTime < DateTime.Now)//优惠券失效
                        {
                            break;
                        }
                        if (couponModel.perMax != 0 && perMax >= couponModel.perMax)
                        {
                            break;
                        }

                        //获取优惠券名称
                        string awardName = couponModel.CouponName;
                        if (couponModel.ShopName != "")
                        {
                            awardName = awardName + "(" + couponModel.ShopName + ")";
                        }
                        if (couponModel.OrderAmount != "")
                        {
                            activityWinModel.amount = "(" + couponModel.OrderAmount + ")";
                        }
                        activityWinModel.awardName = awardName;
                        activityWinModel.awardId   = item.Id;
                        activityWinModel.awardType = item.awardType;
                        activityWinModel.couponId  = couponModel.Id;
                        activityWinModel.isWin     = true;
                        return(activityWinModel);
                    }
                }
            }
            return(activityWinModel);
        }
Ejemplo n.º 20
0
        public ActionResult Add(FormCollection fc)
        {
            WeiActivityModel model = new WeiActivityModel();

            if (!string.IsNullOrWhiteSpace(fc["activityTitle"]))
            {
                model.activityTitle = fc["activityTitle"].ToString();
            }
            if (!string.IsNullOrWhiteSpace(fc["activityDetails"]))
            {
                model.activityDetails = fc["activityDetails"].ToString();
            }
            if (!string.IsNullOrWhiteSpace(fc["beginTime"]))
            {
                model.beginTime = Convert.ToDateTime(fc["beginTime"].ToString());
            }
            if (!string.IsNullOrWhiteSpace(fc["endTime"]))
            {
                model.endTime = Convert.ToDateTime(fc["endTime"].ToString());
            }
            if (!string.IsNullOrWhiteSpace(fc["participationType"]))
            {
                model.participationType = (WeiParticipateType)Enum.Parse(typeof(WeiParticipateType), fc["participationType"].ToString());
            }
            if (!string.IsNullOrWhiteSpace(fc["participationCount"]))
            {
                model.participationCount = Convert.ToInt32(fc["participationCount"].ToString().Replace(",", " ").Trim());
            }
            if (!string.IsNullOrWhiteSpace(fc["isPoint"]))
            {
                if (Convert.ToInt32(fc["isPoint"]) > 0)
                {
                    model.consumePoint = Convert.ToInt32(fc["consumePoint"].ToString());
                }
                else
                {
                    model.consumePoint = 0;
                }
            }



            //临时图片地址
            model.activityUrl = fc["activityUrl"];
            string url = CurrentUrlHelper.CurrentUrlNoPort() + "/m-Mobile/ScratchCard/index/";

            model.codeUrl = url;

            model.activityType = WeiActivityType.ScratchCard;
            model.addDate      = DateTime.Now;

            if (!string.IsNullOrWhiteSpace(fc["harward"]))
            {
                List <WeiActivityAwardModel> listAwardModel = new List <WeiActivityAwardModel>();
                for (int i = 1; i <= Convert.ToInt32(fc["harward"]); i++)
                {
                    WeiActivityAwardModel awardModel = new WeiActivityAwardModel();
                    awardModel.activityId = model.Id;
                    if (!string.IsNullOrWhiteSpace(fc["integral" + i]))
                    {
                        awardModel.integral = Convert.ToInt32(fc["integral" + i].ToString());
                    }
                    awardModel.awardType = (WeiActivityAwardType)Enum.Parse(typeof(WeiActivityAwardType), fc["ReceiveType" + i].ToString());
                    if (!string.IsNullOrWhiteSpace(fc["brand" + i]))
                    {
                        awardModel.bonusId = Convert.ToInt32(fc["brand" + i].ToString());
                    }
                    if (!string.IsNullOrWhiteSpace(fc["coupon" + i]))
                    {
                        awardModel.couponId = Convert.ToInt32(fc["coupon" + i].ToString());
                    }
                    if (!string.IsNullOrWhiteSpace(fc["awardCount" + i]))
                    {
                        awardModel.awardCount = Convert.ToInt32(fc["awardCount" + i].ToString());
                    }
                    if (!string.IsNullOrWhiteSpace(fc["proportion" + i]))
                    {
                        awardModel.proportion = Convert.ToInt32(fc["proportion" + i].ToString());
                    }
                    awardModel.awardLevel = i;
                    if (awardModel.awardCount > 0 && awardModel.proportion > 0)
                    {
                        listAwardModel.Add(awardModel);
                    }
                }
                model.awards = listAwardModel;
            }

            long id = WeiActivityApplication.AddActivitySubmit(model);

            return(RedirectToAction("Detail/" + id));
        }
Ejemplo n.º 21
0
        public ActionResult Detail(long id)
        {
            WeiActivityModel WeiModel = WeiActivityApplication.GetActivityModel(id);

            return(View(WeiModel));
        }
Ejemplo n.º 22
0
        public ActionResult Add(long id, long userId)
        {
            WeiActivityModel activityModel = WeiActivityApplication.GetActivityModel(id);

            activityWinModel = new WeiActivityWinModel();
            Random r   = new Random();
            int    num = r.Next(1, 100);//获取随机数做为中奖信息

            activityWinModel.activityId = id;
            activityWinModel.addDate    = DateTime.Now;
            activityWinModel.userId     = userId;
            activityWinModel.integrals  = activityModel.consumePoint;
            //int activityNum = 0;

            activityWinModel.isWin     = false;
            activityWinModel.awardId   = 0;
            activityWinModel.awardName = "未中奖";
            foreach (var item in activityModel.awards)
            {
                //累加计算奖等区域
                //activityNum = activityNum + GetCount(activityModel.Id, item.Id);
                //获取的随机数在该奖等区域类
                if (num <= GetCount(activityModel.Id, item.Id))
                {
                    activityWinModel.isWin = true;

                    if (item.awardType == WeiActivityAwardType.Integral)
                    {
                        activityWinModel.awardName = item.integral.ToString();
                        activityWinModel.awardId   = item.Id;
                        activityWinModel.awardType = item.awardType;
                        break;
                    }
                    else if (item.awardType == WeiActivityAwardType.Bonus)
                    {
                        Entities.BonusInfo bonusInfo = _iBonusService.Get(item.bonusId);
                        if (bonusInfo == null)
                        {
                            //activityNum = 0;
                            activityWinModel.isWin = false;
                            break;
                        }
                        string Surplus = _iBonusService.GetBonusSurplus(item.bonusId);
                        if (bonusInfo.IsInvalid)//红包已经失效 返回 未中奖
                        {
                            //activityNum = 0;
                            activityWinModel.isWin = false;
                            break;
                        }
                        if (Convert.ToInt32(Surplus) <= 0)//当前红包已经领取完 设置未中奖
                        {
                            //activityNum = 0;
                            activityWinModel.isWin = false;
                            break;
                        }

                        //获取红包名称
                        activityWinModel.awardName = bonusInfo.Name;
                        activityWinModel.awardId   = item.Id;
                        activityWinModel.awardType = item.awardType;
                        activityWinModel.bonusId   = item.bonusId;
                        break;
                    }
                    else if (item.awardType == WeiActivityAwardType.Coupon)
                    {
                        CouponModel couponModel = CouponApplication.Get(item.couponId);
                        if (couponModel == null)
                        {
                            //activityNum = 0;
                            activityWinModel.isWin = false;
                            break;
                        }
                        int perMax = WeiActivityApplication.GetCouPonMax(activityWinModel.userId, activityWinModel.activityId, item.Id);
                        if (couponModel.Num <= 0)//优惠券无库存 返回 未中奖
                        {
                            //activityNum = 0;
                            activityWinModel.isWin = false;
                            break;
                        }
                        if (couponModel.perMax != 0 && perMax >= couponModel.perMax)
                        {
                            //activityNum = 0;
                            activityWinModel.isWin = false;
                            break;
                        }
                        if (couponModel.EndTime < DateTime.Now)//优惠券已经失效
                        {
                            //activityNum = 0;
                            activityWinModel.isWin = false;
                            break;
                        }

                        string awardName = couponModel.CouponName;
                        if (couponModel.ShopName != "")
                        {
                            awardName = awardName + "(" + couponModel.ShopName + ")";
                        }
                        if (couponModel.OrderAmount != "")
                        {
                            awardName = awardName + "(" + couponModel.OrderAmount + ")";
                        }
                        //获取红包名称
                        activityWinModel.awardName = awardName;
                        activityWinModel.awardId   = item.Id;
                        activityWinModel.awardType = item.awardType;
                        activityWinModel.couponId  = item.couponId;
                        break;
                    }
                }
            }

            WeiActivityApplication.WinnerSubmit(activityWinModel);
            decimal bonusPrice = 0;

            if (activityWinModel.bonusId > 0)
            {
                bonusPrice = _iBonusService.GetReceivePriceByUserId(activityWinModel.bonusId, userId);
            }

            return(Json(new Result()
            {
                success = true, data = activityWinModel.awardId.ToString() + "," + bonusPrice.ToString(), msg = ""
            }));
        }