private void ExecForOpen_StepOne(string winXml, int lotteryId, string issueNo, string winNumber, double[] winMoneyList, out long _issueId) { //根据彩种ID和期号查询当期的自增ID var dtIssue = new SLS.Dal.Tables.T_Isuses().Open(ConnectString , "*" , string.Format(" LotteryID={0} AND Name='{1}' ", lotteryId, issueNo) , ""); if (dtIssue == null) { throw new SLS.Common.ElectronicException("数据库读写错误"); } if (dtIssue.Rows.Count == 0) { throw new SLS.Common.ElectronicException(string.Format("未查询到当前期次,彩种:{0},期次号:{1}", lotteryId, issueNo)); } var issueId = dtIssue.Rows[0]["ID"].ToString(); _issueId = long.Parse(issueId); var dtIsuseBonuses = new SLS.Dal.Tables.T_IsuseBonuses().Open(ConnectString , "" , "IsuseID = " + issueId , ""); if (dtIsuseBonuses == null) { throw new SLS.Common.ElectronicException("数据库读写错误"); } if (dtIsuseBonuses.Rows.Count < 1) { int ReturnValue = -1; string ReturnDescription = ""; int Result = SLS.Dal.Procedures.P_IsuseBonusesAdd(ConnectString , Shove._Convert.StrToLong(issueId, 0) , 1 //todo : 是否需要修改为自动开奖特殊用户ID , winXml , ref ReturnValue , ref ReturnDescription); if (Result < 0) { throw new SLS.Common.ElectronicException("数据库读写错误"); } if (ReturnValue < 0) { throw new SLS.Common.ElectronicException(ReturnDescription); } } //取出需要开奖的投注记录 var dt = new SLS.Dal.Tables.T_Schemes().Open(ConnectString , "* " , "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(issueId) + " and isOpened = 0 and Buyed = 1" , "[ID]"); if (dt == null) { throw new SLS.Common.ElectronicException("数据库读写错误"); } StringBuilder sb = new StringBuilder(); string NoWinSchemeID = ""; for (int i = 0; i < dt.Rows.Count; i++) { string LotteryNumber = dt.Rows[i]["LotteryNumber"].ToString(); string Description = ""; double WinMoneyNoWithTax = 0; double WinMoney = 0; try { WinMoney = new SLS.Lottery()[lotteryId].ComputeWin(LotteryNumber , winNumber , ref Description , ref WinMoneyNoWithTax , int.Parse(dt.Rows[i]["PlayTypeID"].ToString()) , winMoneyList); } catch { WinMoney = 0; base.WriteLog("方案 ID:" + dt.Rows[i]["ID"].ToString() + " 算奖出现错误!"); } if (WinMoney == 0) { NoWinSchemeID += dt.Rows[i]["ID"].ToString() + ","; continue; } sb.Append("update T_Schemes set EditWinMoney = ").Append(WinMoney * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1)) .Append(", EditWinMoneyNoWithTax = ").Append(WinMoneyNoWithTax * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1)) .Append(", WinDescription = '").Append(Description).Append("'") .Append(" where [ID] = ").AppendLine(dt.Rows[i]["ID"].ToString()); } if (!string.IsNullOrEmpty(sb.ToString())) { Shove.Database.MSSQL.ExecuteNonQuery(ConnectString, sb.ToString(), new Shove.Database.MSSQL.Parameter[0]); } if (NoWinSchemeID.EndsWith(",")) { NoWinSchemeID = NoWinSchemeID.Substring(0, NoWinSchemeID.Length - 1); } if (!string.IsNullOrEmpty(NoWinSchemeID)) { StringBuilder sb1 = new StringBuilder(); sb1.Append("update T_Schemes set EditWinMoney = 0") .Append(", EditWinMoneyNoWithTax = 0, isOpened = 1 , OpenOperatorID=" + 1) //todo : 是否替换userid .Append(", WinDescription = ''") .Append(" where [ID] in (" + NoWinSchemeID + ")"); Shove.Database.MSSQL.ExecuteNonQuery(ConnectString, sb1.ToString(), new Shove.Database.MSSQL.Parameter[0]); } if (dt.Rows.Count == 0) { return; } //执行第三步,派奖逻辑 ExecForOpen_StepThree(issueNo, lotteryId, winNumber, winMoneyList, _issueId); }
private void ExecForOpen_StepOne(string winXml,int lotteryId,string issueNo,string winNumber,double[] winMoneyList,out long _issueId) { //根据彩种ID和期号查询当期的自增ID var dtIssue = new SLS.Dal.Tables.T_Isuses().Open(ConnectString , "*" , string.Format(" LotteryID={0} AND Name='{1}' ",lotteryId,issueNo) , ""); if (dtIssue == null) throw new SLS.Common.ElectronicException("数据库读写错误"); if (dtIssue.Rows.Count == 0) throw new SLS.Common.ElectronicException(string.Format("未查询到当前期次,彩种:{0},期次号:{1}",lotteryId,issueNo)); var issueId = dtIssue.Rows[0]["ID"].ToString(); _issueId = long.Parse(issueId); var dtIsuseBonuses = new SLS.Dal.Tables.T_IsuseBonuses().Open(ConnectString , "" , "IsuseID = " + issueId , ""); if (dtIsuseBonuses == null) throw new SLS.Common.ElectronicException("数据库读写错误"); if (dtIsuseBonuses.Rows.Count < 1) { int ReturnValue = -1; string ReturnDescription = ""; int Result = SLS.Dal.Procedures.P_IsuseBonusesAdd(ConnectString , Shove._Convert.StrToLong(issueId, 0) , 1 //todo : 是否需要修改为自动开奖特殊用户ID , winXml , ref ReturnValue , ref ReturnDescription); if (Result < 0) throw new SLS.Common.ElectronicException("数据库读写错误"); if (ReturnValue < 0) throw new SLS.Common.ElectronicException(ReturnDescription); } //取出需要开奖的投注记录 var dt = new SLS.Dal.Tables.T_Schemes().Open(ConnectString , "* " , "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(issueId) + " and isOpened = 0 and Buyed = 1" , "[ID]"); if (dt == null) throw new SLS.Common.ElectronicException("数据库读写错误"); StringBuilder sb = new StringBuilder(); string NoWinSchemeID = ""; for (int i = 0; i < dt.Rows.Count; i++) { string LotteryNumber = dt.Rows[i]["LotteryNumber"].ToString(); string Description = ""; double WinMoneyNoWithTax = 0; double WinMoney = 0; try { WinMoney = new SLS.Lottery()[lotteryId].ComputeWin(LotteryNumber , winNumber , ref Description , ref WinMoneyNoWithTax , int.Parse(dt.Rows[i]["PlayTypeID"].ToString()) , winMoneyList); } catch { WinMoney = 0; base.WriteLog("方案 ID:" + dt.Rows[i]["ID"].ToString() + " 算奖出现错误!"); } if (WinMoney == 0) { NoWinSchemeID += dt.Rows[i]["ID"].ToString() + ","; continue; } sb.Append("update T_Schemes set EditWinMoney = ").Append(WinMoney * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1)) .Append(", EditWinMoneyNoWithTax = ").Append(WinMoneyNoWithTax * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1)) .Append(", WinDescription = '").Append(Description).Append("'") .Append(" where [ID] = ").AppendLine(dt.Rows[i]["ID"].ToString()); } if(!string.IsNullOrEmpty(sb.ToString())) Shove.Database.MSSQL.ExecuteNonQuery(ConnectString,sb.ToString(), new Shove.Database.MSSQL.Parameter[0]); if (NoWinSchemeID.EndsWith(",")) { NoWinSchemeID = NoWinSchemeID.Substring(0, NoWinSchemeID.Length - 1); } if (!string.IsNullOrEmpty(NoWinSchemeID)) { StringBuilder sb1 = new StringBuilder(); sb1.Append("update T_Schemes set EditWinMoney = 0") .Append(", EditWinMoneyNoWithTax = 0, isOpened = 1 , OpenOperatorID=" + 1) //todo : 是否替换userid .Append(", WinDescription = ''") .Append(" where [ID] in (" + NoWinSchemeID + ")"); Shove.Database.MSSQL.ExecuteNonQuery(ConnectString,sb1.ToString(), new Shove.Database.MSSQL.Parameter[0]); } if (dt.Rows.Count == 0) return; //执行第三步,派奖逻辑 ExecForOpen_StepThree(issueNo, lotteryId, winNumber, winMoneyList,_issueId); }