예제 #1
0
        /// <summary>
        /// 开始抽奖
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int StartDraw(StartDrawModel model)
        {
            const string sqlA = @"update activity_crow_info set `status`=4 where flagcode=@flagcode;";
            const string sqlB = @"update activity_crow_player set `iswinning`=1 where flagcode=@flagcode and openid=@openid;";
            using (var conn = Helper.GetConnection())
            {
                var tran = conn.BeginTransaction();
                try
                {
                    conn.Execute(sqlA, new { flagcode = model.Flagcode }, tran);

                    foreach (var item in model.Openids.Split(','))
                    {
                        conn.Execute(sqlB, new { flagcode = model.Flagcode, openid = item }, tran);
                    }

                    tran.Commit();
                    return 1;
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    LoggerFactories.CreateLogger().Write("开始抽奖记录异常:", TraceEventType.Error, ex);
                    return 0;
                }
            }
        }
예제 #2
0
 /// <summary>
 /// 结束抽奖
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int EndDraw(StartDrawModel model)
 {
     const string sqlA = @"update activity_crow_info set `status`=5 where flagcode=@flagcode;";
     using (var conn = Helper.GetConnection())
     {
         try
         {
             conn.Execute(sqlA, new { flagcode = model.Flagcode });
             return 1;
         }
         catch (Exception ex)
         {
             LoggerFactories.CreateLogger().Write("结束抽奖记录异常:", TraceEventType.Error, ex);
             return 0;
         }
     }
 }