public string Json_GetLotteryPlayInfo(int LotteryId)
        {
            var l = EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId);

            if (l == null)
            {
                return("无该彩种信息");
            }
            var list = new List <LotteryPlay>();

            switch (l.LotteryType)
            {
            case "ssc":
                list = LotteryInfo_SSC.LpList();
                break;

            case "11x5":
                list = LotteryOpenTool_11x5.LpList();
                break;

            case "dpc":
                list = LotteryOpenTool_3D.LpList();
                break;
            }
            return(ObjectToJson(list));
        }
예제 #2
0
 private void FrmLogin_Load(object sender, EventArgs e)
 {
     //decimal b=0;
     //List<int> b2=new List<int>();
     //b2.Add(1);
     //b2.Add(2);
     //b2.Add(3);
     //b2.Add(4);
     //b2.Add(5);
     //LotteryOpenTool_SSC.isWin(3,"55211 54484 12345",null,b2,b2,b2,b2,b2,b2,b2,0,0,120,out b);
     var a = LotteryOpenTool_3D.LpList();
     var b = LotteryInfo_SSC.LpList();
 }
        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);
            }
        }