예제 #1
0
파일: BMAEvent.cs 프로젝트: quwujin/SM297
 /// <summary>
 /// 执行指定方法
 /// </summary>
 private static void ExecuteMethod(Model.DelayedAwardsModel DelayedModel, PrizeParameter Parameter)
 {
     try
     {
         if (DelayedModel.Id > 0 && DelayedModel.StatusId == 0)
         {
             Model.OrderInfoModel OrderModel = new Db.OrderInfoDal().GetModel(DelayedModel.OrderId);
             if (OrderModel.Id > 0)
             {
                 //发放奖品
                 SendPrize(DelayedModel, OrderModel, Parameter);
             }
         }
     }
     catch (Exception ex)
     {
         Common.Email.EmailTool.sendEmail(System.Configuration.ConfigurationManager.AppSettings["LogErrorEmailTo"], "延时发奖异常", ex.ToString(), "");
     }
 }
예제 #2
0
파일: BMAEvent.cs 프로젝트: quwujin/SM297
        /// <summary>
        /// 事件处理程序
        /// </summary>
        /// <param name="state">参数对象</param>
        private static void Processor(object state)
        {
            try
            {
                PrizeParameter Parameter = (PrizeParameter)state;

                List <Model.DelayedAwardsModel> delayedAwardsModelList = delayedAwardsDal.GetModelList(500, string.Format(" and StatusId=0 and DelayedTime<=getdate()"));

                if (delayedAwardsModelList.Count == 0)
                {
                    return;
                }

                #region 修改订单状态为发送中
                if (delayedAwardsDal.Update(delayedAwardsModelList) <= 0)
                {
                    return;
                }
                #endregion

                //循环执行每个事件
                foreach (Model.DelayedAwardsModel model in delayedAwardsModelList)
                {
                    //如果订单已执行
                    if (model.StatusId != 0)
                    {
                        continue;
                    }

                    ExecuteMethod(model, Parameter);
                }
            }
            catch (Exception ex) {
                Common.LogCommon.WriteFileLog(ex.ToString(), "DelayedError");
            }
        }
예제 #3
0
파일: BMAEvent.cs 프로젝트: quwujin/SM297
        /// <summary>
        /// 发放奖品
        /// </summary>
        /// <param name="OrderModel">订单</param>
        /// <returns></returns>
        private static void SendPrize(Model.DelayedAwardsModel DelayedModel, Model.OrderInfoModel OrderModel, PrizeParameter Parameter)
        {
            //具体发奖逻辑根据项目来


            Common.RedPackHelper rp = new Common.RedPackHelper();

            int moeny = OrderModel.RedPackMoney;

            if (Parameter.IsTest == 1)
            {
                moeny = 100;
            }

            if (Parameter.RedSwitch == 0) //红包开关
            {
                return;
            }

            Common.RedPackHelper.result result = rp.send(Parameter.acid, Parameter.acid, OrderModel.OpenId, OrderModel.HbOrderCode, moeny, Parameter.ckey, Parameter.hkey);

            if (result.SendStatus)
            {
                DelayedModel.StatusId = 1;
                OrderModel.States     = 1;
                OrderModel.IsGrant    = 1;
            }
            else
            {
                DelayedModel.StatusId = -1;
                OrderModel.IsGrant    = -1;
            }

            //执行时间
            DelayedModel.UpdateTime = DateTime.Now;
            OrderModel.GrantTime    = DelayedModel.UpdateTime;

            delayedAwardsDal.Edit(DelayedModel, OrderModel);
        }