Esempio n. 1
0
        //已领取过
        public ActionResult HasReceive(long id)
        {
            BonusModel model = new BonusModel(this._iBonusService.Get(id));

            model.ImagePath = MallIO.GetFilePath(model.ImagePath);
            return(View(model));
        }
Esempio n. 2
0
        //失效
        public ActionResult Invalid(long id)
        {
            BonusModel model = new BonusModel(this._iBonusService.Get(id));

            model.ImagePath = HimallIO.GetFilePath(model.ImagePath);
            return(View(model));
        }
Esempio n. 3
0
    public void AddBonus(BonusModel model)
    {
        var bonus = GetBonus(model.bonusItem, model.bonusCharacteristic);

        if (bonus == null)
        {
            bonus = new AppliedBonus();
            bonus.AddTimeElapseListener(BonusTimeElapsed);
            appliedBonuses.Add(bonus);
        }

        bonus.Activate(model);

        Debug.Log("apply bonus " + bonus.model.bonusItem + " / " + bonus.model.bonusCharacteristic);

        switch (model.bonusItem)
        {
        case BonusModel.BonusItem.Stick:
            levelMan.GetStick().ApplyBonus(model);
            break;

        case BonusModel.BonusItem.Ball:
            levelMan.GetBall().ApplyBonus(model);
            break;

        case BonusModel.BonusItem.Match:
            // TODO
            break;
        }
    }
Esempio n. 4
0
        public ActionResult Edit(long id)
        {
            var        obj   = _iBonusService.Get(id);
            BonusModel model = new BonusModel(obj);

            return(View(model));
        }
Esempio n. 5
0
        public ActionResult Receive(long id, string openId = "")
        {
            ReceiveModel receiveModel = (ReceiveModel)_bonusService.Receive(id, openId);
            BonusModel   bonusModel   = new BonusModel(_bonusService.Get(id));

            if (receiveModel.State == ReceiveStatus.CanReceive)
            {
                object[] objArray = new object[] { "/m-weixin/Bonus/Completed/", bonusModel.Id, "?openId=", openId, "&price=", receiveModel.Price };
                return(Redirect(string.Concat(objArray)));
            }
            if (receiveModel.State == ReceiveStatus.Receive)
            {
                return(Redirect(string.Concat("/m-weixin/Bonus/HasReceive/", bonusModel.Id)));
            }
            if (receiveModel.State == ReceiveStatus.HaveNot)
            {
                return(Redirect(string.Concat("/m-weixin/Bonus/HaveNot/", bonusModel.Id)));
            }
            if (receiveModel.State == ReceiveStatus.NotAttention)
            {
                return(Redirect(string.Concat("/m-weixin/Bonus/NotAttention/", bonusModel.Id)));
            }
            if (receiveModel.State != ReceiveStatus.Invalid)
            {
                throw new Exception("领取发生异常");
            }
            return(Redirect(string.Concat("/m-weixin/Bonus/Invalid/", bonusModel.Id)));
        }
Esempio n. 6
0
        public ActionResult Receive(long id, string openId = "")
        {
            ReceiveModel obj   = ( ReceiveModel )this._iBonusService.Receive(id, openId);
            var          bonus = this._iBonusService.Get(id);
            BonusModel   model = new BonusModel(bonus);

            if (obj.State == ReceiveStatus.CanReceive)
            {
                return(Redirect("/m-weixin/Bonus/Completed/" + model.Id + "?openId=" + openId + "&price=" + obj.Price));
            }
            if (obj.State == ReceiveStatus.CanReceiveNotAttention)
            {
                return(Redirect("/m-weixin/Bonus/CanReceiveNotAttention/" + model.Id + "?openId=" + openId + "&price=" + obj.Price));
            }
            else if (obj.State == ReceiveStatus.Receive)
            {
                return(Redirect("/m-weixin/Bonus/HasReceive/" + model.Id));
            }
            else if (obj.State == ReceiveStatus.HaveNot)
            {
                return(Redirect("/m-weixin/Bonus/HaveNot/" + model.Id));
            }
            else if (obj.State == ReceiveStatus.NotAttention)
            {
                return(Redirect("/m-weixin/Bonus/NotAttention/" + model.Id));
            }
            else if (obj.State == ReceiveStatus.Invalid)
            {
                return(Redirect("/m-weixin/Bonus/Invalid/" + model.Id));
            }
            else
            {
                throw new Exception("领取发生异常");
            }
        }
Esempio n. 7
0
    public void Setup(BonusModel m)
    {
        model = m;

        CreateVisual();
        SetParams();
    }
Esempio n. 8
0
 private ActionResult SendActivityToUser(BonusModel bonusModel, IRequestMessageBase requestBaseMsg)
 {
     string port = string.IsNullOrEmpty(Request.Url.Port.ToString()) ? "" : ":" + Request.Url.Port;
     string url = "http://" + Request.Url.Host.ToString() + port + "/m-weixin/Bonus/Index/" + bonusModel.Id;
     string content = string.Format("<a href='" + url + "'>您参加{0},成功获得{1}赠送的红包</a>,点击去拆红包", bonusModel.Name, bonusModel.MerchantsName);
     string result = DealTextMsg(requestBaseMsg, content);
     return new XmlResult(result);
 }
Esempio n. 9
0
        //未开始
        public ActionResult NotStart(long id, string openId = "")
        {
            BonusModel model = new BonusModel(this._iBonusService.Get(id));

            model.ImagePath = MallIO.GetFilePath(model.ImagePath);
            ViewBag.OpenId  = openId;
            return(View(model));
        }
Esempio n. 10
0
        private ActionResult SendActivityToUser(BonusModel bonusModel, IRequestMessageBase requestBaseMsg)
        {
            string url     = CurrentUrlHelper.CurrentUrlNoPort() + "/m-weixin/Bonus/Index/" + bonusModel.Id;
            string content = string.Format("<a href='" + url + "'>您参加{0},成功获得{1}赠送的红包</a>,点击去拆红包", bonusModel.Name, bonusModel.MerchantsName);
            string result  = DealTextMsg(requestBaseMsg, content);

            return(new XmlResult(result));
        }
    public void StartBonus(BonusType type, bool wait = false)
    {
        BonusModel model = _bonusModels.Find(b => b.Type == type);

        model.State          = wait ? BonusModel.BonusState.Await : BonusModel.BonusState.Activated;
        model.OnFinishAction = OnFinishTimer;
        model.Start(wait ? WAIT_COOL_DOWN : COOL_DOWN);
    }
Esempio n. 12
0
        public ActionResult Apportion(long id)
        {
            var        obj   = _iBonusService.Get(id);
            BonusModel model = new BonusModel(obj);

            model.QRPath = model.QRPath;
            return(View(model));
        }
Esempio n. 13
0
        //完成
        public ActionResult Completed(long id, string openId = "", decimal price = 0)
        {
            ViewBag.Price = price;
            BonusModel model = new BonusModel(this._iBonusService.Get(id));

            model.ImagePath = MallIO.GetFilePath(model.ImagePath);
            ViewBag.OpenId  = openId;
            return(View(model));
        }
Esempio n. 14
0
 public ActionResult EditData(BonusModel model)
 {
     if (ModelState.IsValid)
     {
         _iBonusService.Update(model);
         return(RedirectToAction("Management"));
     }
     throw new HimallException("验证失败");
 }
Esempio n. 15
0
        /// <summary>
        /// 微信红包支付
        /// </summary>
        /// <returns></returns>
        public static string GetBonus(string CurrentWXID, string act_id, string act_name, int money, string wishing, string remark, string nick_name, string send_name)
        {
            //构建微信红包接口参数对象
            BonusModel bonusModel = new BonusModel()
            {
                sign         = "",
                mch_billno   = Privacy.PartnerID + DateTime.Now.ToString("yyyyMMdd") + GetTenRandomNum(),
                mch_id       = Privacy.PartnerID,
                wxappid      = Privacy.AppId,
                nick_name    = nick_name,
                send_name    = send_name,
                re_openid    = CurrentWXID,
                total_amount = money,
                min_value    = money,
                max_value    = money,
                total_num    = 1,
                wishing      = wishing,
                client_ip    = System.Configuration.ConfigurationManager.AppSettings["serverIP"].ToString(),              //"219.234.83.88",
                act_name     = act_name,
                act_id       = act_id,
                remark       = remark,
                nonce_str    = RandomCode.createRandomCode(16, true),
            };
            Dictionary <string, string> singWXBonusParams = new Dictionary <string, string>();

            singWXBonusParams.Add("nonce_str", bonusModel.nonce_str);
            singWXBonusParams.Add("mch_billno", bonusModel.mch_billno);
            singWXBonusParams.Add("mch_id", bonusModel.mch_id);
            singWXBonusParams.Add("wxappid", bonusModel.wxappid);
            singWXBonusParams.Add("nick_name", bonusModel.nick_name);
            singWXBonusParams.Add("send_name", bonusModel.send_name);
            singWXBonusParams.Add("re_openid", bonusModel.re_openid);
            singWXBonusParams.Add("total_amount", bonusModel.total_amount.ToString());
            singWXBonusParams.Add("min_value", bonusModel.min_value.ToString());
            singWXBonusParams.Add("max_value", bonusModel.max_value.ToString());
            singWXBonusParams.Add("total_num", bonusModel.total_num.ToString());
            singWXBonusParams.Add("wishing", bonusModel.wishing);
            singWXBonusParams.Add("client_ip", bonusModel.client_ip);
            singWXBonusParams.Add("act_name", bonusModel.act_name);
            singWXBonusParams.Add("remark", bonusModel.remark);
            singWXBonusParams.Add("act_id", bonusModel.act_id);
            string sign    = "";
            string package = GetPackage(singWXBonusParams, out sign);

            bonusModel.sign = sign;
            string tempxmlstr = WeChatHelper4Net.XmlHelper.Serialize(bonusModel);
            string xml        = tempxmlstr.Substring(tempxmlstr.IndexOf("<sign>"));

            xml = "<xml>" + xml;
            //调用微信红包接口,支付用户红包奖金
            string resultXml = Send(xml, "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack");

            //处理接口返回数据
            resultXml = resultXml.Replace("<xml>", "<BonusResultModel>").Replace("</xml>", "</BonusResultModel>");
            return(resultXml);
        }
Esempio n. 16
0
        private ActionResult SendActivityToUser(BonusModel bonusModel, Senparc.Weixin.MP.Entities.IRequestMessageBase requestBaseMsg)
        {
            string str = (string.IsNullOrEmpty(base.Request.Url.Port.ToString()) ? "" : string.Concat(":", base.Request.Url.Port));

            object[] objArray = new object[] { "http://", base.Request.Url.Host.ToString(), str, "/m-weixin/Bonus/Index/", bonusModel.Id };
            string   str1     = string.Concat(objArray);
            string   str2     = string.Format(string.Concat("<a href='", str1, "'>您参加{0},成功获得{1}赠送的红包</a>,点击去拆红包"), bonusModel.Name, bonusModel.MerchantsName);

            return(new XmlResult(DealTextMsg(requestBaseMsg, str2)));
        }
Esempio n. 17
0
        private void InitializeData(SettingsRakeBackViewModelInfo <BonusModel> info)
        {
            infoViewModel = info;
            settingsModel = infoViewModel?.Model;

            BonusName = settingsModel?.BonusName ?? string.Empty;
            Player    = StorageModel.PlayerCollection.OfType <PlayerCollectionItem>().FirstOrDefault(pl => pl.DecodedName == (settingsModel?.Player ?? string.Empty));
            Date      = settingsModel?.Date ?? DateTime.Now;
            Amount    = settingsModel?.Amount ?? 0m;
        }
Esempio n. 18
0
    public void UpdateItem(BonusModel model)
    {
        RandomColor();

        bonusData = model;
        if (bonusData != null)
        {
            Desc.text = bonusData.Name + "\n" + bonusData.Reward;
        }
    }
        private void AddBonus(BonusModel bonus)
        {
            if (bonus == null)
            {
                return;
            }

            BonusesList.Add(bonus);
            PopupModel.ClosePopup();
        }
Esempio n. 20
0
        public ActionResult NotAttention(long id)
        {
            BonusModel  bonusModel  = new BonusModel(_bonusService.Get(id));
            string      str         = AccessTokenContainer.TryGetToken(_siteSetting.WeixinAppId, _siteSetting.WeixinAppSecret, false);
            SceneHelper sceneHelper = new SceneHelper();
            int         num         = sceneHelper.SetModel(new SceneModel(QR_SCENE_Type.Bonus, bonusModel), 600);
            string      str1        = QrCodeApi.Create(str, 86400, num, 10000).ticket;

            ViewBag.ticket = str1;
            return(View("~/Areas/Mobile/Templates/Default/Views/Bonus/NotAttention.cshtml", bonusModel));
        }
 private void RemoveBonus(BonusModel model)
 {
     if (_removeBonusAction != null)
     {
         _removeBonusAction(model.Type, () =>
         {
             model.State          = BonusModel.BonusState.Await;
             model.OnFinishAction = OnFinishTimer;
             model.Start(WAIT_COOL_DOWN);
         });
     }
 }
Esempio n. 22
0
    public void RemoveBonus(BonusModel m)
    {
        switch (m.bonusCharacteristic)
        {
        case BonusModel.BonusCharacteristic.Speed:
            visual.SetParams(model.speed);
            break;

        default:

            break;
        }
    }
Esempio n. 23
0
    /// <summary>
    /// 创建奖池
    /// </summary>
    public void CreateRewardPool(int count)
    {
        for (int i = 0; i < count; ++i)
        {
            //int id = 0;
            string     name  = REWARD_NAME[Random.Range(0, REWARD_NAME.Length)];
            int        price = REWARD_PRICE[Random.Range(0, REWARD_PRICE.Length)];
            BonusModel model = new BonusModel(i + 1, name, price);
            BonusLists.Add(model);
        }

        //更新UI的通知也可以在这里写
    }
Esempio n. 24
0
    public void ApplyBonus(BonusModel m)
    {
        switch (m.bonusCharacteristic)
        {
        case BonusModel.BonusCharacteristic.Speed:
            float newSpeed = model.speed * m.value;
            visual.SetParams(newSpeed);
            break;

        default:

            break;
        }
    }
    public void Initialize(IProvider <SpecificCountDownTimer> timerProvider, List <BonusType> bonusTypes, SetBonus setBonusAction, Action <BonusType, Action> removeBonusAction)
    {
        _timerProvider = timerProvider;

        SetBonusAction     = setBonusAction;
        _removeBonusAction = removeBonusAction;
        _bonusPauseTimer   = _timerProvider.Get();

        foreach (BonusType type in bonusTypes)
        {
            BonusModel model = new BonusModel(_timerProvider.Get(), type);
            _bonusModels.Add(model);
        }
    }
Esempio n. 26
0
        //未关注
        public ActionResult NotAttention(long id)
        {
            BonusModel model    = new BonusModel(this._iBonusService.Get(id));
            var        settings = SiteSettingApplication.SiteSettings;
            //TODO:改成统一的方式取 Token
            var token = AccessTokenContainer.TryGetAccessToken(settings.WeixinAppId, settings.WeixinAppSecret);

            SceneHelper helper  = new SceneHelper();
            SceneModel  scene   = new SceneModel(QR_SCENE_Type.Bonus, model);
            int         sceneId = helper.SetModel(scene);
            var         ticket  = QrCodeApi.Create(token, 86400, sceneId, QrCode_ActionName.QR_LIMIT_SCENE, null, 10000).ticket;

            ViewBag.ticket = ticket;
            return(View("~/Areas/Mobile/Templates/Default/Views/Bonus/NotAttention.cshtml", model));
        }
Esempio n. 27
0
        //未关注
        public ActionResult NotAttention(long id)
        {
            BonusModel model = new BonusModel(this._iBonusService.Get(id));
            //TODO:改成统一的方式取 Token
            var token = AccessTokenContainer.TryGetToken(this._siteSetting.WeixinAppId, this._siteSetting.WeixinAppSecret);

            SceneHelper helper = new SceneHelper();

            Himall.Model.SceneModel scene = new SceneModel(QR_SCENE_Type.Bonus, model);
            int sceneId = helper.SetModel(scene);
            var ticket  = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 86400, sceneId).ticket;

            ViewBag.ticket = ticket;
            return(View("~/Areas/Mobile/Templates/Default/Views/Bonus/NotAttention.cshtml", model));
        }
Esempio n. 28
0
        public ActionResult CanReceiveNotAttention(long id, string openId = "", decimal price = 0)
        {
            ViewBag.Price = price;
            BonusModel model = new BonusModel(this._iBonusService.Get(id));
            //TODO:改成统一的方式取 Token
            var token = AccessTokenContainer.TryGetToken(this._siteSetting.WeixinAppId, this._siteSetting.WeixinAppSecret);

            SceneHelper helper   = new SceneHelper();
            var         qrTicket = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 86400, 123456789).ticket;

            ViewBag.ticket   = Application.WXApiApplication.GetTicket(this._siteSetting.WeixinAppId, this._siteSetting.WeixinAppSecret);
            model.ImagePath  = HimallIO.GetFilePath(model.ImagePath);
            ViewBag.OpenId   = openId;
            ViewBag.QRTicket = qrTicket;
            return(View(model));
        }
Esempio n. 29
0
        public async Task <IActionResult> Bonus(BonusModel model)
        {
            if (_signInManager.Context.User.Identity.IsAuthenticated)
            {
                if (_signInManager.Context.User.IsInRole("DepartmentHead"))
                {
                    await Initializer.InitialLayout("Department", ViewBag, _db, _signInManager, "Bonus");

                    BonusModel bm = new BonusModel
                    {
                        Employee = await _db.Employees
                                   .Where(e => e.Id == model.EmployeeId)
                                   .FirstOrDefaultAsync()
                    };
                    if (ModelState.IsValid)
                    {
                        if (bm.Employee.LastCalculate < model.GivenDate)
                        {
                            Bonus bonus = new Bonus
                            {
                                GivenDate  = model.GivenDate,
                                Price      = model.Price,
                                EmployeeId = model.EmployeeId
                            };
                            await _db.Bonuses.AddAsync(bonus);

                            await _db.SaveChangesAsync();
                        }
                        else
                        {
                            ModelState.AddModelError("", "You can't add bonus to this time");
                        }
                    }
                    else
                    {
                        bm.GivenDate = model.GivenDate;
                        bm.Price     = model.Price;
                    }
                    bm.Bonuses = await _db.Bonuses
                                 .Where(b => b.EmployeeId == model.EmployeeId)
                                 .ToListAsync();

                    return(View(bm));
                }
            }
            return(RedirectToAction("Forbidden", "Error"));
        }
Esempio n. 30
0
        public ActionResult CanReceiveNotAttention(long id, string openId = "", decimal price = 0)
        {
            ViewBag.Price = price;
            BonusModel model = new BonusModel(this._iBonusService.Get(id));
            //TODO:改成统一的方式取 Token
            var settings = SiteSettingApplication.SiteSettings;
            var token    = AccessTokenContainer.TryGetAccessToken(settings.WeixinAppId, settings.WeixinAppSecret);

            SceneHelper helper   = new SceneHelper();
            var         qrTicket = QrCodeApi.Create(token, 86400, 123456789, QrCode_ActionName.QR_LIMIT_SCENE, null).ticket;

            ViewBag.ticket   = WXApiApplication.GetTicket(settings.WeixinAppId, settings.WeixinAppSecret);
            model.ImagePath  = MallIO.GetFilePath(model.ImagePath);
            ViewBag.OpenId   = openId;
            ViewBag.QRTicket = qrTicket;
            return(View(model));
        }