示例#1
0
        public bool AddRules(Ruleinfo model)
        {
            bool reuslt;

            if (model.ID > 0)
            {
                reuslt = Update(model);
            }
            else
            {
                reuslt = Add(model);
            }
            return(reuslt);
        }
示例#2
0
        public Ruleinfo GetRuleinfo(int id)
        {
            var data = new Ruleinfo();

            try
            {
                var sql = $@"select  ID,OddsID,
            RuleType,
            OnlineBetID,
            OpenContent,
            JudgeCondition,
            JudgeNumber,
            BetContent,
            NoWinBetNumber,
            NoWinBetConent,
            StopProfit,
            StopLoss,
            StopBetHours,
            intervalBetHours,
            IsTurnBet,
            ProfitMultiple,
            LossMultiple,
            IsProfitBetNow,
            IsLossBetNow,
            BetGearStop,
            CreationTime from ruleinfo where id={id}";

                var ds = DAL.DbHelper.MySqlQueryBySqlstring(sql, _connString);

                if (ds != null && ds.Tables.Count > 0)
                {
                    data = Tool.Helper.ToList <Ruleinfo>(ds.Tables[0]).FirstOrDefault(x => x.ID == id);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(data);
        }
示例#3
0
        private bool Update(Ruleinfo model)
        {
            try
            {
                var sql = $@"UPDATE ruleinfo SET
            OddsID = {model.OddsID},
            OnlineBetID = {model.OnlineBetID}, 
            OpenContent= '{model.OpenContent}',
            JudgeCondition = '{model.JudgeCondition}',
            JudgeNumber = {model.JudgeNumber},
            BetContent = '{model.BetContent}',
            NoWinBetNumber = {model.NoWinBetNumber},
            NoWinBetConent = '{model.NoWinBetConent}',
            StopProfit = {model.StopProfit},
            StopLoss = {model.StopLoss},
            StopBetHours = {model.StopBetHours},
            intervalBetHours = {model.intervalBetHours},
            IsTurnBet = {model.IsTurnBet},
            ProfitMultiple = '{model.ProfitMultiple}',
            LossMultiple = '{model.LossMultiple}',
            IsProfitBetNow = {model.IsProfitBetNow},
            IsLossBetNow = {model.IsLossBetNow},
            BetGearStop = {model.BetGearStop},
            CrackAfterBet = {model.CrackAfterBet},
            RuleType ={model.RuleType}
            WHERE ID = {model.ID}";

                var result = DAL.DbHelper.MysqlExecuteSql(sql, _connString);

                if (result > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
            }
            return(true);
        }
示例#4
0
        private bool Add(Ruleinfo model)
        {
            try
            {
                var sql = $@"insert into ruleinfo(
            OddsID,
            RuleType,
            OnlineBetID,
            OpenContent,
            JudgeCondition,
            JudgeNumber,
            BetContent,
            NoWinBetNumber,
            NoWinBetConent,
            StopProfit,
            StopLoss,
            StopBetHours,
            intervalBetHours,
            IsTurnBet,
            ProfitMultiple,
            LossMultiple,
            IsProfitBetNow,
            IsLossBetNow,
            BetGearStop,
            CrackAfterBet,
            CreationTime)
            values
            (
            {model.OddsID}, 
            {model.RuleType},
            {model.OnlineBetID}, 
            '{model.OpenContent}', 
            '{model.JudgeCondition}', 
            {model.JudgeNumber}, 
            '{model.BetContent}',
            {model.NoWinBetNumber}, 
            '{model.NoWinBetConent}', 
            {model.StopProfit}, 
            {model.StopLoss},
            {model.StopBetHours}, 
            {model.intervalBetHours}, 
            {model.IsTurnBet}, 
            '{model.ProfitMultiple}', 
            '{model.LossMultiple}',
            {model.IsProfitBetNow},
            {model.IsLossBetNow},
            {model.BetGearStop}, 
            {model.CrackAfterBet},
            now()
                )";

                var result = DAL.DbHelper.MysqlExecuteSql(sql, _connString);

                if (result > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
            }

            return(false);
        }
示例#5
0
        /// <summary>
        /// 投注算法(通用)
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public AnalogData BetAlgorithm(Ruleinfo rule, DataInfo item, out bool IsSatisfyBetGearStop)
        {
            IsSatisfyBetGearStop = false;
            AnalogData model;

            try
            {
                //倍投金额
                var lossMultiple   = rule.LossMultiple.Split('|').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
                var profitMultiple = rule.ProfitMultiple.Split('|').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();

                decimal betMoney = 0;
                if (lossMultiple.Length > 0 && rule.LossMultipleLevel > -1)
                {
                    betMoney = Convert.ToDecimal(lossMultiple[rule.LossMultipleLevel]);
                }
                else
                {
                    if (profitMultiple.Length > 0)
                    {
                        betMoney = Convert.ToDecimal(profitMultiple[rule.ProfitMultipleLevel]);
                    }
                }

                //是否中奖并计算赔率
                var data = WinOrNot(item, rule.BetContent, betMoney, rule.OddsID);

                if (Convert.ToDecimal(data.yingkuijine) >= 0)
                {
                    if (rule.LossMultipleLevel > -1)
                    {
                        rule.ProfitMultipleLevel = 0;
                    }
                    else
                    {
                        rule.ProfitMultipleLevel++;
                    }

                    if (rule.ProfitMultipleLevel >= profitMultiple.Length)
                    {
                        //倍投完档位后立即停止
                        if (rule.BetGearStop == 1 && profitMultiple.Length > 0)
                        {
                            IsSatisfyBetGearStop = true;
                        }
                        rule.ProfitMultipleLevel = 0;
                    }
                    rule.LossMultipleLevel = -1;
                }
                else
                {
                    if (rule.LossMultipleLevel >= lossMultiple.Length - 1)
                    {
                        //倍投完档位后立即停止
                        if (rule.BetGearStop == 1 && lossMultiple.Length > 0)
                        {
                            IsSatisfyBetGearStop = true;
                        }
                        rule.LossMultipleLevel = 0;
                    }
                    else
                    {
                        rule.LossMultipleLevel++;
                    }
                    rule.ProfitMultipleLevel = 0;
                }

                model = new AnalogData
                {
                    id            = item.id.ToString(),
                    biaozhu       = data.biaozhu,
                    xiazhuneirong = data.xiazhuneirong,
                    yingkuijine   = data.yingkuijine
                };
            }
            catch (Exception ex)
            {
                throw;
            }
            return(model);
        }
示例#6
0
        /// <summary>
        /// 断开后投注算法
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="dataList"></param>
        /// <returns></returns>
        public List <AnalogData> DuanKaiHouTouZhu(Ruleinfo rule, List <DataInfo> dataList)
        {
            var initList = InitAnalogData(dataList);

            try
            {
                var number               = 0;
                var isSatisfied          = false;
                var isBet                = false; //是否投注
                var IsSatisfyBetGearStop = false; //倍投完档位后立即停止变量

                var lossMultipleList   = rule.LossMultiple.Split('|').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
                var profitMultipleList = rule.ProfitMultiple.Split('|').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();

                //投注条件算法
                for (int i = 0; i < dataList.Count; i++)
                {
                    var item = dataList[i];
                    if (isSatisfied)
                    {
                        if (JudgeBetCondition(rule.OpenContent, rule.JudgeCondition, item) == (rule.JudgeCondition == "连续开出" ? 0 : 1))
                        {
                            isBet       = true;
                            isSatisfied = false;
                            continue;
                        }
                        number = 0;
                    }

                    var tempNumber = JudgeBetCondition(rule.OpenContent, rule.JudgeCondition, item);
                    if (tempNumber == 0)
                    {
                        number = 0;
                    }
                    else
                    {
                        number += tempNumber;
                    }

                    if (number == rule.JudgeNumber && !isBet && !isSatisfied)
                    {
                        isSatisfied = true;
                        continue;
                    }

                    if (isBet)
                    {
                        isBet  = false;
                        number = 0;
                        var model = BetAlgorithm(rule, item, out IsSatisfyBetGearStop);//投注算法
                        initList = Assignment(initList, model);

                        if (IsSatisfyBetGearStop) //满足倍投完后停止条件
                        {
                            break;
                        }

                        if (rule.IsLossBetNow == 1)
                        {
                            while (Convert.ToDecimal(model.yingkuijine) < 0)
                            {
                                model = BetAlgorithm(rule, dataList[i + 1], out IsSatisfyBetGearStop);//投注算法

                                initList = Assignment(initList, model);
                                i++;

                                if (IsSatisfyBetGearStop) //满足倍投完后停止条件
                                {
                                    break;
                                }
                            }
                        }
                        else if (rule.IsProfitBetNow == 1)
                        {
                            while (Convert.ToDecimal(model.yingkuijine) > 0)
                            {
                                model = BetAlgorithm(rule, dataList[i + 1], out IsSatisfyBetGearStop);//投注算法

                                initList = Assignment(initList, model);
                                i++;
                                if (IsSatisfyBetGearStop) //满足倍投完后停止条件
                                {
                                    break;
                                }
                            }
                        }
                    }
                    if (IsSatisfyBetGearStop) //满足倍投完后停止条件
                    {
                        break;
                    }
                }

                //这里单独计算当前金额
                initList = CalculateCurrentAmount(initList);
            }
            catch (Exception ex)
            {
                throw;
            }
            return(initList);
        }
示例#7
0
        /// <summary>
        /// 连续倍投
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="dataList"></param>
        /// <returns></returns>
        public List <AnalogData> ContinuityDoubleBet(Ruleinfo rule, List <DataInfo> dataList)
        {
            var initList = InitAnalogData(dataList);

            try
            {
                var number = 0;
                var isBet  = false;
                var IsSatisfyBetGearStop = false;//倍投完档位后立即停止变量
                var lossMultipleList     = rule.LossMultiple.Split('|').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
                var profitMultipleList   = rule.ProfitMultiple.Split('|').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();

                //投注条件算法
                for (int i = 0; i < dataList.Count; i++)
                {
                    var item = dataList[i];

                    var tempNumber = JudgeBetCondition(rule.OpenContent, rule.JudgeCondition, item);
                    if (tempNumber == 0)
                    {
                        number = 0;
                    }
                    else
                    {
                        number += tempNumber;
                    }

                    if (number == rule.JudgeNumber && !isBet)
                    {
                        isBet = true;
                        continue;
                    }

                    if (isBet)
                    {
                        isBet  = false;
                        number = 0;
                        var noWinBetNumber = 0;
                        var model          = BetAlgorithm(rule, item, out IsSatisfyBetGearStop); //投注算法

                        if (IsSatisfyBetGearStop)                                                //满足倍投完后停止条件
                        {
                            break;
                        }

                        if (JudgeBetCondition(rule.OpenContent, "连续开出", item) == 1) //这里也要把当前投注的也算进去
                        {
                            noWinBetNumber++;
                        }
                        initList = Assignment(initList, model);

                        var over = false;
                        while (noWinBetNumber < rule.NoWinBetNumber)
                        {
                            if (i == dataList.Count - 1)
                            {
                                break;
                            }
                            var temp = dataList[i + 1];
                            if (JudgeBetCondition(rule.OpenContent, "连续开出", temp) == 1)
                            {
                                noWinBetNumber++;
                            }
                            else
                            {
                                noWinBetNumber = 0;
                            }
                            if (rule.NoWinBetNumber >= noWinBetNumber)
                            {
                                model    = BetAlgorithm(rule, temp, out IsSatisfyBetGearStop);//投注算法
                                initList = Assignment(initList, model);

                                if (IsSatisfyBetGearStop) //满足倍投完后停止条件
                                {
                                    break;
                                }
                            }
                            i++;
                        }

                        if (over)
                        {
                            continue;
                        }
                        initList = Assignment(initList, model);
                        if (rule.IsLossBetNow == 1)
                        {
                            while (Convert.ToDecimal(model.yingkuijine) < 0)
                            {
                                model    = BetAlgorithm(rule, dataList[i + 1], out IsSatisfyBetGearStop);//投注算法
                                initList = Assignment(initList, model);
                                i++;

                                if (IsSatisfyBetGearStop) //满足倍投完后停止条件
                                {
                                    break;
                                }
                            }
                        }
                        else if (rule.IsProfitBetNow == 1)
                        {
                            while (Convert.ToDecimal(model.yingkuijine) > 0)
                            {
                                model    = BetAlgorithm(rule, dataList[i + 1], out IsSatisfyBetGearStop);//投注算法
                                initList = Assignment(initList, model);
                                i++;

                                if (IsSatisfyBetGearStop) //满足倍投完后停止条件
                                {
                                    break;
                                }
                            }
                        }
                    }

                    if (IsSatisfyBetGearStop) //满足倍投完后停止条件
                    {
                        break;
                    }
                }
                //这里单独计算当前金额
                initList = CalculateCurrentAmount(initList);
            }
            catch (Exception ex)
            {
                ex.ToString().Log();
                throw;
            }
            return(initList);
        }