コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Users.cs プロジェクト: ichari/ichari
        public int JoinScheme(long SchemeID, int Share, ref string ReturnDescription)
        {
            if (ID < 0)
            {
                throw new Exception("Users 尚未初始化到具体的数据实例上,请先使用 GetUserInformation 等获取数据信息");
            }

            int ReturnValue = -1;
            ReturnDescription = "";

            int Result = SLS.Dal.Procedures.P_JoinScheme(PF.ConnectString,Site.ID, ID, SchemeID, Share, false, ref ReturnValue, ref ReturnDescription);

            if (Result < 0)
            {
                ReturnDescription = "数据库读写错误";

                return -1;
            }

            if (ReturnValue < 0)
            {
                return ReturnValue;
            }

            string ReturnDescription_2 = "";
            GetUserInformationByID(ref ReturnDescription_2);

            //Send Email
            if ((Email != "") && (SLS.Dal.Functions.F_GetIsSendNotification(PF.ConnectString,SiteID, NotificationManners.Email, NotificationTypes.JoinScheme, ID)))
            {
                string EmailSubject = "", EmailBody = "";

                Site.SiteNotificationTemplates.SplitEmailTemplate(Site.SiteNotificationTemplates[NotificationManners.Email, NotificationTypes.JoinScheme], ref EmailSubject, ref EmailBody);

                if ((EmailSubject != "") && (EmailBody != ""))
                {
                    DataTable dt = new SLS.Dal.Tables.T_Schemes().Open("", "[id] = " + SchemeID.ToString(), "");

                    string LotteryNumber = "";
                    int Multiple = 0;
                    double Money = 0;
                    int SumShare = 0;

                    if ((dt != null) && (dt.Rows.Count > 0))
                    {
                        LotteryNumber = dt.Rows[0]["LotteryNumber"].ToString();
                        Multiple = Shove._Convert.StrToInt(dt.Rows[0]["Multiple"].ToString(), 0);
                        Money = Shove._Convert.StrToDouble(dt.Rows[0]["Money"].ToString(), 0);
                        SumShare = Shove._Convert.StrToInt(dt.Rows[0]["Share"].ToString(), 0);
                    }

                    if ((LotteryNumber != "") && (Multiple > 0) && (Money > 0) && (SumShare > 0))
                    {
                        EmailSubject = EmailSubject.Replace("[UserName]", Name);

                        EmailBody = EmailBody.Replace("[UserName]", Name);
                        EmailBody = EmailBody.Replace("[SchemeID]", SchemeID.ToString());
                        EmailBody = EmailBody.Replace("[LotteryNumber]", LotteryNumber.Replace("\n", "<BR />"));
                        EmailBody = EmailBody.Replace("[Multiple]", Multiple.ToString());
                        EmailBody = EmailBody.Replace("[Money]", Money.ToString("N"));
                        EmailBody = EmailBody.Replace("[Share]", SumShare.ToString());
                        EmailBody = EmailBody.Replace("[BuyShare]", Share.ToString());

                        PF.SendEmail(Site, Email, EmailSubject, EmailBody);
                    }
                }
            }

            //Send SMS
            if ((Mobile != "") && isMobileValided && (SLS.Dal.Functions.F_GetIsSendNotification(PF.ConnectString,SiteID, NotificationManners.SMS, NotificationTypes.JoinScheme, ID)))
            {
                string Body = Site.SiteNotificationTemplates[NotificationManners.SMS, NotificationTypes.JoinScheme];

                if (Body != "")
                {
                    Body = Body.Replace("[UserName]", Name);
                    Body = Body.Replace("[SchemeID]", SchemeID.ToString());

                    PF.SendSMS(Site, ID, Mobile, Body);
                }
            }

            //Send StationSMS
            if (SLS.Dal.Functions.F_GetIsSendNotification(PF.ConnectString,SiteID, NotificationManners.StationSMS, NotificationTypes.JoinScheme, ID))
            {
                string Body = Site.SiteNotificationTemplates[NotificationManners.StationSMS, NotificationTypes.JoinScheme];

                if (Body != "")
                {
                    Body = Body.Replace("[UserName]", Name);
                    Body = Body.Replace("[SchemeID]", SchemeID.ToString());

                    PF.SendStationSMS(Site, Site.AdministratorID, ID, StationSMSTypes.SystemMessage, Body);
                }
            }

            return 0;
        }
コード例 #3
0
ファイル: eTickets.cs プロジェクト: ichari/ichari
        private void WriteTickets()
        {   
            DataTable dt = new SLS.Dal.Views.V_SchemeSchedules().Open(ConnectionString, "ID, LotteryID, PlayTypeID, LotteryNumber, Multiple, Money, (case LotteryID when 29 then -29 else LotteryID end) as LotteryID_2", "Buyed = 0 and (GetDate() between StartTime and EndTime) and BuyedShare >= Share and PrintOutType = 301 and State = 1 and dateadd(mi, 1, StateUpdateTime) <= GetDate() and LotteryID <> 29", "LotteryID_2, UserType desc, [ID]"); // and isnull(Identifiers, '') = '' removed from condition
            if (dt == null)
            {
                //msg.Send("读取方案错误(WriteTickets)。");
                log.Write("读取方案错误(WriteTickets)。");
                return;
            }

            SLS.Dal.Tables.T_Schemes t_Schemes = new SLS.Dal.Tables.T_Schemes();
            foreach (DataRow dr in dt.Rows)
            {
                long SchemeID = Shove._Convert.StrToLong(dr["ID"].ToString(), -1);
                int LotteryID = Shove._Convert.StrToInt(dr["LotteryID"].ToString(), -1);
                string LotteryNumber = dr["LotteryNumber"].ToString();
                int PlayTypeID = Shove._Convert.StrToInt(dr["PlayTypeID"].ToString(), -1);
                int Multiple = Shove._Convert.StrToInt(dr["Multiple"].ToString(), -1);

                if ((SchemeID < 0) || (LotteryID < 0) || (PlayTypeID < 0) || (Multiple < 1))
                {
                    //msg.Send("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    log.Write("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    continue;
                }

                double Money = 0;
                //etSunLotto.slTicket[] Tickets = null;
                SLS.Lottery.Ticket[] tics = null;
                try
                {
                    if (LotteryID == SLS.Lottery.CQSSC.ID)
                    {
                        if (PlayTypeID == 2803)
                            tics = eTicketProvider.ToElectronicTicket_ZH(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                        else
                            tics = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPCQ(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                    }
                    else
                        tics = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPSH(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                }
                catch(Exception e)
                {
                    log.Write("拆票错误(WriteTickets)。方案号:" + SchemeID.ToString() + "," + e.Message);
                    continue;
                }

                if (tics == null)
                {
                    log.Write("分解票错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    continue;
                }

                if ((LotteryID != SLS.Lottery.CQSSC.ID) && (Money != Shove._Convert.StrToDouble(dr["Money"].ToString(), -1)))
                {
                    log.Write("异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");
                    continue;
                }

                string TicketXML = "<Tickets>";
                foreach (SLS.Lottery.Ticket ticket in tics)
                {
                    TicketXML += "<Ticket LotteryNumber=\"" + ticket.Number + "\" Multiple=\"" + ticket.Multiple + "\" Money=\"" + ticket.Money + "\" />";
                }
                TicketXML += "</Tickets>";

                int ReturnValue = 0;
                string ReturnDescription = "";
                int Result = SLS.Dal.Procedures.P_SchemesSendToCenterAdd(ConnectionString, SchemeID, PlayTypeID, TicketXML, ref ReturnValue, ref ReturnDescription);
                if ((Result < 0) || (ReturnValue < 0))
                {
                    log.Write("票写入错误(WriteTickets):方案号:" + SchemeID.ToString() + "," + ReturnDescription);
                }
            }
        }
コード例 #4
0
ファイル: LotteryOpenNotify.cs プロジェクト: ichari/ichari
        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);
        }
コード例 #5
0
ファイル: eTickets.cs プロジェクト: object8421/ichari
        private void WriteTickets()
        {
            DataTable dt = new SLS.Dal.Views.V_SchemeSchedules().Open(ConnectionString, "ID, LotteryID, PlayTypeID, LotteryNumber, Multiple, Money, (case LotteryID when 29 then -29 else LotteryID end) as LotteryID_2", "Buyed = 0 and (GetDate() between StartTime and EndTime) and BuyedShare >= Share and PrintOutType = 301 and State = 1 and dateadd(mi, 1, StateUpdateTime) <= GetDate() and LotteryID <> 29", "LotteryID_2, UserType desc, [ID]"); // and isnull(Identifiers, '') = '' removed from condition

            if (dt == null)
            {
                //msg.Send("读取方案错误(WriteTickets)。");
                log.Write("读取方案错误(WriteTickets)。");
                return;
            }

            SLS.Dal.Tables.T_Schemes t_Schemes = new SLS.Dal.Tables.T_Schemes();
            foreach (DataRow dr in dt.Rows)
            {
                long   SchemeID      = Shove._Convert.StrToLong(dr["ID"].ToString(), -1);
                int    LotteryID     = Shove._Convert.StrToInt(dr["LotteryID"].ToString(), -1);
                string LotteryNumber = dr["LotteryNumber"].ToString();
                int    PlayTypeID    = Shove._Convert.StrToInt(dr["PlayTypeID"].ToString(), -1);
                int    Multiple      = Shove._Convert.StrToInt(dr["Multiple"].ToString(), -1);

                if ((SchemeID < 0) || (LotteryID < 0) || (PlayTypeID < 0) || (Multiple < 1))
                {
                    //msg.Send("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    log.Write("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    continue;
                }

                double Money = 0;
                //etSunLotto.slTicket[] Tickets = null;
                SLS.Lottery.Ticket[] tics = null;
                try
                {
                    if (LotteryID == SLS.Lottery.CQSSC.ID)
                    {
                        if (PlayTypeID == 2803)
                        {
                            tics = eTicketProvider.ToElectronicTicket_ZH(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                        }
                        else
                        {
                            tics = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPCQ(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                        }
                    }
                    else
                    {
                        tics = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPSH(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                    }
                }
                catch (Exception e)
                {
                    log.Write("拆票错误(WriteTickets)。方案号:" + SchemeID.ToString() + "," + e.Message);
                    continue;
                }

                if (tics == null)
                {
                    log.Write("分解票错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    continue;
                }

                if ((LotteryID != SLS.Lottery.CQSSC.ID) && (Money != Shove._Convert.StrToDouble(dr["Money"].ToString(), -1)))
                {
                    log.Write("异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");
                    continue;
                }

                string TicketXML = "<Tickets>";
                foreach (SLS.Lottery.Ticket ticket in tics)
                {
                    TicketXML += "<Ticket LotteryNumber=\"" + ticket.Number + "\" Multiple=\"" + ticket.Multiple + "\" Money=\"" + ticket.Money + "\" />";
                }
                TicketXML += "</Tickets>";

                int    ReturnValue       = 0;
                string ReturnDescription = "";
                int    Result            = SLS.Dal.Procedures.P_SchemesSendToCenterAdd(ConnectionString, SchemeID, PlayTypeID, TicketXML, ref ReturnValue, ref ReturnDescription);
                if ((Result < 0) || (ReturnValue < 0))
                {
                    log.Write("票写入错误(WriteTickets):方案号:" + SchemeID.ToString() + "," + ReturnDescription);
                }
            }
        }