Beispiel #1
0
        public JsonResult List(WeiActivityQuery query)
        {
            query.Type = WeiActivityType.ScratchCard;
            var result = WeiActivityApplication.Get(query);

            return(Json(result));
        }
Beispiel #2
0
        public ActionResult Detail(long id)
        {
            string           url      = CurrentUrlHelper.CurrentUrlNoPort() + "/m-Mobile/BigWheel/index/";
            WeiActivityModel WeiModel = WeiActivityApplication.GetActivityModel(id, url);

            return(View(WeiModel));
        }
        /// <summary>
        /// 获取中奖概率
        /// </summary>
        /// <param name="id"></param>
        /// <param name="awardId"></param>
        /// <returns></returns>
        public double GetCount(long id, long awardId)
        {
            var   item        = WeiActivityApplication.GetActivityModel(id);
            var   proportions = 0.0;//抽取完成的概率总和
            float sum         = 0;
            List <WeiActivityAwardModel> listModel = item.awards;
            var model = listModel.Where(p => p.Id == awardId).ToList();

            foreach (var t in item.awards)
            {
                bool falg = WeiActivityWinApplication.GetWinNumberByAward(id, t.Id); //查询当前奖等是否有剩余数量
                if (!falg)                                                           //无剩余数量
                {
                    proportions += t.proportion;
                    continue;
                }
                if (t.awardLevel < model[0].awardLevel)
                {
                    sum += t.proportion;
                }
            }

            var isOver = WeiActivityWinApplication.GetWinNumberByAward(id, awardId);//是否还有奖品

            if (!isOver)
            {
                return(0);
            }
            else
            {
                return(proportions + sum + model[0].proportion);
            }
        }
        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);
        }
Beispiel #5
0
        public ActionResult Edit(long id)
        {
            ViewBag.BrandDrop = BindDrop(true);
            //查询当前刮刮卡信息
            WeiActivityModel weiAwardModel = WeiActivityApplication.GetActivityModel(id);

            return(View(weiAwardModel));
        }
        public JsonResult List(string name, int page = 1, int rows = 20)
        {
            var result = WeiActivityApplication.Get(name.Trim(), WeiActivityType.ScratchCard, page, rows);
            var datas  = result.Models.ToList();
            DataGridModel <WeiActivityModel> weiActivityModel = new DataGridModel <WeiActivityModel>
            {
                rows  = datas,
                total = result.Total
            };

            return(Json(weiActivityModel));
        }
Beispiel #7
0
        public JsonResult WinList(string text, long id, int page = 1, int rows = 20)
        {
            var result = WeiActivityApplication.GetActivityWin(text, id, page, rows);
            var datas  = result.Models.ToList();
            DataGridModel <WeiActivityWinModel> weiActivityWinModel = new DataGridModel <WeiActivityWinModel>
            {
                rows  = datas,
                total = result.Total
            };

            return(Json(weiActivityWinModel));
        }
Beispiel #8
0
        /// <summary>
        /// 计算用户可抽奖次数
        /// </summary>
        /// <param name="activityModel"></param>
        /// <returns></returns>
        public int GetParticipationCount(WeiActivityModel activityModel)
        {
            int participationCount = WeiActivityApplication.GetWinModel(activityModel);

            if (participationCount != -1)
            {
                return(activityModel.participationCount - participationCount);
            }
            else
            {
                return(participationCount);
            }
        }
        public JsonResult SelectAppAds(long id, IntegralMallAdInfo.AdActivityType adtype)
        {
            Result result = new Result()
            {
                success = false, msg = "未知错误"
            };
            string cover = "";

            //获取广告图地址
            switch (adtype)
            {
            case IntegralMallAdInfo.AdActivityType.Roulette:
                var tmpobj1 = WeiActivityApplication.GetActivityModel(id);
                if (tmpobj1 == null)
                {
                    result = new Result()
                    {
                        success = false, msg = "错误活动编号"
                    };
                    return(Json(result));
                }
                cover = tmpobj1.activityUrl;
                break;

            case IntegralMallAdInfo.AdActivityType.ScratchCard:
                var tmpobj2 = WeiActivityApplication.GetActivityModel(id);
                if (tmpobj2 == null)
                {
                    result = new Result()
                    {
                        success = false, msg = "错误活动编号"
                    };
                    return(Json(result));
                }
                cover = tmpobj2.activityUrl;
                break;
            }
            var  data     = _iGiftService.UpdateAdInfo(adtype, id, cover, IntegralMallAdInfo.AdShowStatus.Show, IntegralMallAdInfo.AdShowPlatform.APP);
            long curactid = 0;

            if (data.ShowAdStatus != IntegralMallAdInfo.AdShowStatus.Show)
            {
                curactid = data.ActivityId;
            }
            result = new Result()
            {
                success = true, msg = curactid.ToString()
            };
            return(Json(result));
        }
Beispiel #10
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));
        }
Beispiel #11
0
        public JsonResult GetRouletteList(string name, int page = 1, int rows = 10)
        {
            var query = new WeiActivityQuery {
                Name = name,
                Type = WeiActivityType.Roulette,
                IsIntegralActivity = true,
                IsShowAll          = false,
                PageNo             = page,
                PageSize           = rows
            };
            var result = WeiActivityApplication.Get(query);

            return(Json(new { rows = result.Models, total = result.Total }));
        }
Beispiel #12
0
        public JsonResult GetScratchCardList(string name, int page = 1, int rows = 10)
        {
            var query = new WeiActivityQuery
            {
                Name = name,
                Type = WeiActivityType.ScratchCard,
                IsIntegralActivity = true,
                IsShowAll          = false,
                PageNo             = page,
                PageSize           = rows
            };
            var result = WeiActivityApplication.Get(query);

            return(Json(new { rows = result.Models, total = result.Total }, JsonRequestBehavior.AllowGet));
        }
Beispiel #13
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: "成功"));
        }
Beispiel #14
0
        private List <SelectListItem> BindDrop(bool Edit)
        {
            List <SelectListItem> bonusList = new List <SelectListItem> {
                new SelectListItem
                {
                    Selected = true,
                    Text     = "请选择红包...",
                    Value    = "0"
                }
            };
            var bonus = WeiActivityApplication.GetBonusByType(Himall.Entities.BonusInfo.BonusType.Prize);

            if (Edit)//是否是修改
            {
                foreach (var item in bonus)
                {
                    bonusList.Add(new SelectListItem
                    {
                        Selected = false,
                        Text     = item.Name,
                        Value    = item.Id.ToString()
                    });
                }
            }
            else
            {
                foreach (var item in bonus)
                {
                    var count = int.Parse(GetBonusSurplus(item.Id));
                    if (count > 0)
                    {
                        bonusList.Add(new SelectListItem
                        {
                            Selected = false,
                            Text     = item.Name + " 剩余:" + count + " 个",
                            Value    = item.Id.ToString()
                        });
                    }
                }
            }
            return(bonusList);
        }
Beispiel #15
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));
        }
        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));
        }
Beispiel #17
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));
        }
Beispiel #18
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));
        }
        public JsonResult GetScratchCardList(string name, int page = 1, int rows = 10)
        {
            var result = WeiActivityApplication.Get(name, CommonModel.WeiActivityType.ScratchCard, page, rows, true, false);

            return(Json(new { rows = result.Models, total = result.Total }, JsonRequestBehavior.AllowGet));
        }
Beispiel #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));
        }
Beispiel #21
0
        public ActionResult Detail(long id)
        {
            WeiActivityModel WeiModel = WeiActivityApplication.GetActivityModel(id);

            return(View(WeiModel));
        }
Beispiel #22
0
 public JsonResult Deleteid(long id)
 {
     WeiActivityApplication.DeleteActivity(id);
     return(Json(true));
 }
Beispiel #23
0
        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)
                    {
                        Entities.BonusInfo bonusInfo = _iBonusService.Get(item.bonusId);
                        string             Surplus   = _iBonusService.GetBonusSurplus(item.bonusId);
                        if (bonusInfo.IsInvalid)//红包已经失效 返回 未中奖
                        {
                            break;
                        }
                        if (Convert.ToInt32(Surplus) <= 0)//当前红包已经领取完 设置未中奖
                        {
                            break;
                        }

                        //获取红包名称

                        activityWinModel.awardName = BonusApplication.GetFirstReceivePriceByBonus(bonusInfo.Id) + "元红包";
                        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      = WeiActivityApplication.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);
        }
Beispiel #24
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 = ""
            }));
        }
        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));
        }
Beispiel #26
0
 /// <summary>
 /// 用于显示 查询红包剩余数量
 /// </summary>
 /// <param name="id">红包ID</param>
 /// <returns></returns>
 private string GetBonusSurplus(long id)
 {
     return(WeiActivityApplication.GetBonusSurplus(id));
 }