示例#1
0
        public ActionResult Edit(long id)
        {
            var        obj   = _iBonusService.Get(id);
            BonusModel model = new BonusModel(obj);

            return(View(model));
        }
        private void InitialBonusModel(BonusAjaxModel model, string name = "", int pageNo = 1)
        {
            var brandList = _iBonusService.Get(1, 1, name, pageNo, 10);
            int pageCount = TemplatePageHelper.GetPageCount(brandList.Total, 10);

            if (brandList != null)
            {
                model.status = 1;
                model.page   = TemplatePageHelper.GetPageHtml(pageCount, pageNo);
                InitialBonusContentModel(brandList.Models, model);
            }
        }
示例#3
0
        public ActionResult Completed(long id, string openId = "", [DecimalConstant(0, 0, 0, 0, 0)] decimal price = default(decimal))
        {
            IWXApiService wXApiService = ServiceHelper.Create <IWXApiService>();
            string        ticket       = wXApiService.GetTicket(_siteSetting.WeixinAppId, _siteSetting.WeixinAppSecret);
            JSSDKHelper   jSSDKHelper  = new JSSDKHelper();
            string        timestamp    = JSSDKHelper.GetTimestamp();
            string        noncestr     = JSSDKHelper.GetNoncestr();
            string        signature    = jSSDKHelper.GetSignature(ticket, noncestr, timestamp, base.Request.Url.AbsoluteUri);

            ViewBag.Timestamp = timestamp;
            ViewBag.NonceStr  = noncestr;
            ViewBag.Signature = signature;
            ViewBag.AppId     = _siteSetting.WeixinAppId;
            ViewBag.Price     = price;
            BonusModel bonusModel = new BonusModel(_bonusService.Get(id))
            {
            };

            bonusModel.ImagePath = string.Concat("http://", base.Request.Url.Host.ToString(), bonusModel.ImagePath);

            ViewBag.OpenId = openId;
            return(View(bonusModel));
        }
        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);
        }
示例#5
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 = ""
            }));
        }
 /// <summary>
 ///  获取红包列表
 /// </summary>
 public static ObsoletePageModel <BonusInfo> Get(int type, int state, string name, int pageIndex, int pageSize)
 {
     return(_iBonusService.Get(type, state, name, pageIndex, pageSize));
 }
示例#7
0
        public ActionResult Get()
        {
            var result = _bonusService.Get();

            return(Ok(result));
        }
示例#8
0
        public ActionResult Apportion(long id)
        {
            BonusInfo bonusInfo = _bonusService.Get(id);

            return(View(new BonusModel(bonusInfo)));
        }