/// <summary> /// 添加Player /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddPlayerPayEx(CrowdPayRecordModel model) { const string sql = @"INSERT INTO activity_crow_payrecord (innerid, flagcode, totalfee, openid, orderno, ispay, remark, createdtime, modifiedtime) VALUES (@innerid, @flagcode, @totalfee, @openid, @orderno, @ispay, @remark, @createdtime, @modifiedtime);"; using (var conn = Helper.GetConnection()) { var tran = conn.BeginTransaction(); try { //检查是否已经保存过粉丝信息 const string sqlSel = @"SELECT 1 FROM activity_crow_player where flagcode=@flagcode and openid=@openid;"; var i = conn.Query<int>(sqlSel, new { model.Flagcode, model.Openid }).FirstOrDefault(); if (i != 1) { const string sqlPlayer = @"INSERT INTO activity_crow_player (innerid, flagcode, openid, mobile, wechatnick, wechatheadportrait, isenabled, remark, createrid, createdtime, modifierid, modifiedtime) VALUES (@innerid, @flagcode, @openid, @mobile, @wechatnick, @wechatheadportrait, @isenabled, @remark, @createrid, @createdtime, @modifierid, @modifiedtime);"; conn.Execute(sqlPlayer, model.Player, tran); } conn.Execute(sql, model, tran); tran.Commit(); return 1; } catch (Exception ex) { tran.Rollback(); LoggerFactories.CreateLogger().Write("AddPlayerPayEx异常:", TraceEventType.Error, ex); return 0; } } }
/// <summary> /// 添加Player /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddPlayerPay(CrowdPayRecordModel model) { const string sql = @"INSERT INTO activity_crow_payrecord (innerid, flagcode, totalfee, openid, orderno, ispay, remark, createdtime, modifiedtime) VALUES (@innerid, @flagcode, @totalfee, @openid, @orderno, @ispay, @remark, @createdtime, @modifiedtime);"; using (var conn = Helper.GetConnection()) { int result; try { result = conn.Execute(sql, model); } catch (Exception ex) { LoggerFactories.CreateLogger().Write("AddPlayerPay异常:", TraceEventType.Error, ex); result = 0; } return result; } }