示例#1
0
 private void dgvHistory_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvHistory.SelectedRows.Count > 0)
     {
         var percent = Convert.ToDecimal(dgvHistory.SelectedRows[0].Cells[2].Value);
         dgvjj.DataSource = AgentCalculateTool.GetAgentBackMoney(percent);
     }
 }
        public string SendBetInfo_ZH(string Guid, int LotteryId, bool isWinCancel, List <WS_ZHInfo> ZHInfo)
        {
            if (!isLogin(Guid))
            {
                return(null);
            }
            var l = EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId);

            if (l == null)
            {
                return("无该彩种信息");
            }
            try
            {
                var t     = new List <WS_BetInfo>();
                var accId = GetLoginId(Guid);
                var acc   = AccountDAL.GetAccount(accId);
                var list  = ZHInfo;
                #region 验证下注信息

                var minDec = new decimal(0.2);
                if (list.Exists(n => n.BetMoney < minDec))
                {
                    return("每种玩法的下注金额不能少于" + minDec + "元");
                }
                if (list.Sum(n => n.BetMoney) > acc.AccountBalance)
                {
                    return("余额不足");
                }
                var returnStr = LotteryOpenInfoDAL.IsExistsExpect(LotteryId, ZHInfo[0].Except, EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId).IsPrivate);
                if (returnStr != "")
                {
                    return(returnStr);
                }
                var wBetList = new List <BetInfo>();
                var addNumNo = "ZH" + DateTime.Now.Ticks + random.Next(1000, 10000);
                foreach (var item in list)
                {
                    var betU = Tools.Calculate(l.LotteryType, item.BetPlayTypeCode, item.BetNum, item.ChoicePosition, item.BetUnit);
                    if (betU != item.BetUnit)
                    {
                        return("下单注数验证失败");
                    }
                    if (betU <= 0)
                    {
                        return("下单注数应大于0");
                    }
                    decimal mm = 0;
                    switch (item.BetMoneyMode)
                    {
                    case "元":
                        mm = 2;
                        break;

                    case "角":
                        mm = new decimal(0.2);
                        break;

                    case "分":
                        mm = new decimal(0.02);
                        break;

                    case "厘":
                        mm = new decimal(0.002);
                        break;
                    }
                    if (betU * mm * item.BetTimes != item.BetMoney)
                    {
                        return("下单金额有误");
                    }

                    var betInfo = new BetInfo
                    {
                        AccountId        = acc.Id,
                        ResultType       = (int)Enum_ResultType.Wait,
                        BetNum           = item.BetNum,
                        BetPlayTypeCode  = item.BetPlayTypeCode,
                        BetTimes         = item.BetTimes,
                        BetUnit          = item.BetUnit,
                        BetMoney         = item.BetMoney,
                        ChoicePosition   = item.ChoicePosition,
                        IsGetBackPercent = item.IsGetBackPercent,
                        LotteryId        = LotteryId,
                        LotteryExcept    = item.Except,
                        IsWinCancel      = isWinCancel,//中奖后停止追号
                        //追号单号
                        AddNumNo = addNumNo,
                    };
                    switch (l.LotteryType)
                    {
                    case "ssc":
                        betInfo.GetBackPercent = acc.AgentPercentSSC;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryInfo_SSC.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryInfo_SSC.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;

                    case "11x5":
                        betInfo.GetBackPercent = acc.AgentPercent11X5;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryOpenTool_11x5.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryOpenTool_11x5.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;

                    case "dpc":
                        betInfo.GetBackPercent = acc.AgentPercentDPC;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryOpenTool_3D.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryOpenTool_3D.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;
                    }
                    wBetList.Add(betInfo);
                }
                #endregion
                if (wBetList.Count == 0)
                {
                    return("无有效下注信息");
                }
                var dt = EntitiesTool.GetDateTimeNow(new LotteryAPPEntities());
                wBetList.ForEach(n => n.CreateTime = dt);
                var account = AccountDAL.BalanceChange(acc.Id, wBetList);
                return(account.AccountBalance + "(元)");
            }
            catch (Exception ex)
            {
                return("错误的下注信息" + ex.Message);
            }
        }
        public string SendBetInfo(string Guid, int LotteryId, string Except, List <WS_BetInfo> BetInfo)
        {
            if (!isLogin(Guid))
            {
                return(null);
            }
            var l = EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId);

            if (l == null)
            {
                return("无该彩种信息");
            }
            //if (l.LotteryType == "ssc")
            //{
            //    t.Add(new WS_BetInfo
            //        {
            //            BetMoney = 2,
            //            BetMoneyMode = "元",
            //            BetNum = "0|0|0|0|0",
            //            BetPlayTypeCode = 2,
            //            BetTimes = 1,
            //            BetUnit = 1,
            //            ChoicePosition = "",
            //            IsGetBackPercent = true,
            //        });
            //    t.Add(new WS_BetInfo
            //    {
            //        BetMoney = 6,
            //        BetMoneyMode = "角",
            //        BetNum = "0 1 2|0 1 2",
            //        BetPlayTypeCode = 116,
            //        BetTimes = 1,
            //        BetUnit = 30,
            //        ChoicePosition = "0,1,2,3,4",
            //        IsGetBackPercent = true,
            //    });
            //}
            //if (l.LotteryType == "11x5")
            //{
            //    t.Add(new WS_BetInfo
            //    {
            //        BetMoney = 2,
            //        BetMoneyMode = "元",
            //        BetNum = "04|05|06",
            //        BetPlayTypeCode = 1,
            //        BetTimes = 1,
            //        BetUnit = 1,
            //        ChoicePosition = "",
            //        IsGetBackPercent = false,
            //    });
            //}
            //BetInfo = ObjectToJson(t);//示例[{"BetNum":"0","BetPlayTypeCode":1,"BetUnit":1,"BetTimes":1,"BetMoneyMode":"元","BetMoney":0.0,"ChoicePosition":"","IsGetBackPercent":true}]
            try
            {
                var t     = new List <WS_BetInfo>();
                var accId = GetLoginId(Guid);
                var acc   = AccountDAL.GetAccount(accId);
                //var acc = AccountDAL.GetAccount(2);//jix008
                var list = BetInfo; //JsonToObject(BetInfo, new List<WS_BetInfo>()) as List<WS_BetInfo>;
                #region 验证下注信息
                var returnStr = LotteryOpenInfoDAL.IsExistsExpect(LotteryId, Except, EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId).IsPrivate);
                if (returnStr != "")
                {
                    return(returnStr);
                }
                var minDec = new decimal(0.2);
                if (list.Exists(n => n.BetMoney < minDec))
                {
                    return("每种玩法的下注金额不能少于" + minDec + "元");
                }
                if (list.Sum(n => n.BetMoney) > acc.AccountBalance)
                {
                    return("余额不足");
                }
                var wBetList = new List <BetInfo>();
                foreach (var item in list)
                {
                    var betU = Tools.Calculate(l.LotteryType, item.BetPlayTypeCode, item.BetNum, item.ChoicePosition, item.BetUnit);
                    if (betU != item.BetUnit)
                    {
                        return("下单注数验证失败");
                    }
                    if (betU <= 0)
                    {
                        return("下单注数应大于0");
                    }
                    decimal mm = 0;
                    switch (item.BetMoneyMode)
                    {
                    case "元":
                        mm = 2;
                        break;

                    case "角":
                        mm = new decimal(0.2);
                        break;

                    case "分":
                        mm = new decimal(0.02);
                        break;

                    case "厘":
                        mm = new decimal(0.002);
                        break;
                    }
                    if (betU * mm * item.BetTimes != item.BetMoney)
                    {
                        return("下单金额有误");
                    }
                    var betInfo = new BetInfo
                    {
                        AccountId        = acc.Id,
                        ResultType       = (int)Enum_ResultType.Wait,
                        BetNum           = item.BetNum,
                        BetPlayTypeCode  = item.BetPlayTypeCode,
                        BetTimes         = item.BetTimes,
                        BetUnit          = item.BetUnit,
                        BetMoney         = item.BetMoney,
                        ChoicePosition   = item.ChoicePosition,
                        IsGetBackPercent = item.IsGetBackPercent,
                        LotteryId        = LotteryId,
                        LotteryExcept    = Except,
                    };
                    switch (l.LotteryType)
                    {
                    case "ssc":
                        betInfo.GetBackPercent = acc.AgentPercentSSC;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryInfo_SSC.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryInfo_SSC.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;

                    case "11x5":
                        betInfo.GetBackPercent = acc.AgentPercent11X5;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryOpenTool_11x5.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryOpenTool_11x5.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;

                    case "dpc":
                        betInfo.GetBackPercent = acc.AgentPercentDPC;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryOpenTool_3D.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryOpenTool_3D.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;
                    }
                    wBetList.Add(betInfo);
                }
                #endregion
                if (wBetList.Count == 0)
                {
                    return("无有效下注信息");
                }
                var dt = EntitiesTool.GetDateTimeNow(new LotteryAPPEntities());
                wBetList.ForEach(n => n.CreateTime = dt);
                var account = AccountDAL.BalanceChange(acc.Id, wBetList);
                return(account.AccountBalance + "(元)");
            }
            catch (Exception ex)
            {
                return("错误的下注信息" + ex.Message);
            }
        }
示例#4
0
        /// <summary>
        /// 刷新注数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            LotteryInptuNoControl tb = null;

            foreach (var item in ChoiceTabPage.Controls)
            {
                if (item.GetType() == typeof(LotteryInptuNoControl))
                {
                    tb = (LotteryInptuNoControl)item;
                    break;
                }
            }
            if (tb != null)
            {
                var betStr = tb.GetBetNo();
                var bet    = betStr == "" ? 0 : betStr.Split('|').Length;
                lblTotal.Tag  = bet + " " + ChoiceTabPage.Parent.Tag + ChoiceTabPage.Text;
                lblTotal.Text = BetCalculateTool.GetTotalMoney(bet, (int)nudBS.Value, cboDW.SelectedIndex);
                MessageBox.Show("自动剔除不符合规范号码");
            }
            else
            {
                calculate();
            }
            #region  注
            if (lblTotal.Tag == null)
            {
                return;
            }
            var sp = lblTotal.Tag.ToString().Split(' ');
            if (sp[0] == "0")
            {
                return;
            }
            var     lp = LotteryOpenTool_11x5.LpList().FirstOrDefault(n => n.LotteryPlayName == sp[1]);
            BetInfo b  = new BetInfo
            {
                BetPlayTypeCode = lp.BetPlayTypeCode,
                BetTimes        = Convert.ToInt32(nudBS.Value),
                BetUnit         = Convert.ToInt32(sp[0]),
                BetMoney        = Convert.ToDecimal(lblTotal.Text.Substring(lblTotal.Text.IndexOf("¥") + 1, lblTotal.Text.IndexOf("元") - lblTotal.Text.IndexOf("¥") - 1)),
                AccountId       = account.Id,
                CreateTime      = EntitiesTool.GetDateTimeNow(),
                //LotteryOpenId = nextOpen.Id,
                ResultType       = (int)Enum_ResultType.Wait,
                GetBackPercent   = account.AgentPercent11X5,
                IsGetBackPercent = cboFandian.SelectedIndex != 0,
            };
            if (sp[1].Contains("趣味定_"))
            {
                StringBuilder sb = new StringBuilder();
                foreach (var item in txtBetNo.Text.Split(' '))
                {
                    sb.Append(' ' + item[0].ToString());
                }
                b.BetNum = sb.ToString().Trim();
            }
            else
            {
                b.BetNum = txtBetNo.Text;
            }

            b.MaxBackMoney = (b.IsGetBackPercent?AgentCalculateTool.GetAgentBackMoney_11x5(lp.PayBack, account.AgentPercent11X5):lp.PayBack) * (b.BetMoney / b.BetUnit / 2); //根据是否要返点产生中奖金额
            if (string.IsNullOrEmpty(b.BetNum))
            {
                return;
            }
            wBetList.Add(b);
            #endregion
            var row = dgvwBet.Rows[dgvwBet.Rows.Add()];
            row.Cells[0].Value = sp[1];
            row.Cells[1].Value = b.BetNum;
            row.Cells[2].Value = b.BetUnit;
            row.Cells[3].Value = b.BetTimes;
            row.Cells[4].Value = b.BetMoney;
            row.Cells[5].Value = "X";
        }