/// <summary> /// 是否中奖并计算赔率 /// </summary> /// <returns></returns> public AnalogData WinOrNot(DataInfo dataInfo, string betContent, decimal betMoney, int oddsID) { var data = new AnalogData(); //判断是否中奖 foreach (var item in betContent.Split('|')) { data.yingkuijine = (Convert.ToDecimal(data.yingkuijine) - betMoney).ToString(); var openContent = GetWinContent(dataInfo, item); if (!string.IsNullOrWhiteSpace(openContent)) { //计算赔率后的金额 var teshuzuhe = dataInfo.zuhe + "|" + dataInfo.teshu; var money = CalculateOdds(dataInfo, oddsID, betMoney, openContent, teshuzuhe, dataInfo.sum); data.xiazhuneirong = data.xiazhuneirong + item + "," + betMoney + "|"; data.yingkuijine = (Convert.ToDecimal(data.yingkuijine) + money).ToString(); data.biaozhu += "中奖|"; } else { //data.yingkuijine = (Convert.ToDecimal(data.yingkuijine) + (-betMoney)).ToString(); data.xiazhuneirong = data.xiazhuneirong + item + "," + betMoney + "|"; data.biaozhu += "未中|"; } } data.biaozhu = data.biaozhu.Substring(0, data.biaozhu.Length - 1); data.xiazhuneirong = data.xiazhuneirong.Substring(0, data.xiazhuneirong.Length - 1); return(data); }
public List <AnalogData> Assignment(List <AnalogData> initList, AnalogData model) { foreach (var temp in initList.Where(temp => temp.id == model.id)) { temp.biaozhu = model.biaozhu ?? string.Empty; temp.xiazhuneirong = model.xiazhuneirong; temp.yingkuijine = model.yingkuijine; } return(initList); }
/// <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); }