예제 #1
0
        /// <summary>
        /// 执行拆票(普通投注)
        /// </summary>
        public static void DoSplitOrderTicket(RedisWaitTicketOrder order)
        {
            //if (!BusinessHelper.CanRequestBet(order.RunningOrder.GameCode))
            //    return;
            var DB = new DBbase().DB;// DBbase

            try
            {
                var sportsManager = new Sports_Manager();
                var oldCount      = DB.CreateQuery <C_Sports_Ticket>().Count(p => p.SchemeId == order.RunningOrder.SchemeId); //sportsManager.QueryTicketCount(order.RunningOrder.SchemeId);
                if (oldCount <= 0)
                {
                    //清理冻结
                    if (order.RunningOrder.SchemeType == (int)SchemeType.ChaseBetting)
                    {
                        BusinessHelper.Payout_Frozen_To_End(BusinessHelper.FundCategory_Betting, order.RunningOrder.UserId, order.RunningOrder.SchemeId, string.Format("订单{0}出票完成,扣除冻结{1:N2}元", order.RunningOrder.SchemeId, order.RunningOrder.TotalMoney), order.RunningOrder.TotalMoney);
                    }

                    //普通投注
                    var jcGameCodeArray = new string[] { "BJDC", "JCZQ", "JCLQ" };
                    if (jcGameCodeArray.Contains(order.RunningOrder.GameCode))
                    {
                        //竞彩
                        #region 拆票

                        var betInfo = new GatewayTicketOrder_Sport
                        {
                            Amount          = order.RunningOrder.Amount,
                            Attach          = order.RunningOrder.Attach,
                            GameCode        = order.RunningOrder.GameCode,
                            GameType        = order.RunningOrder.GameType,
                            IssuseNumber    = order.RunningOrder.IssuseNumber,
                            IsVirtualOrder  = order.RunningOrder.IsVirtualOrder,
                            OrderId         = order.RunningOrder.SchemeId,
                            PlayType        = order.RunningOrder.PlayType,
                            UserId          = order.RunningOrder.UserId,
                            TotalMoney      = order.RunningOrder.TotalMoney,
                            Price           = 2M,
                            IsRunningTicket = true,
                        };
                        foreach (var code in order.AnteCodeList)
                        {
                            betInfo.AnteCodeList.Add(new GatewayAnteCode_Sport
                            {
                                AnteCode = code.AnteCode,
                                GameType = code.GameType,
                                IsDan    = code.IsDan,
                                MatchId  = code.MatchId,
                            });
                        }
                        new Sports_Business().RequestTicket_Sport(betInfo);

                        //new Thread(() =>
                        //{
                        try
                        {
                            //生成文件
                            var json = JsonHelper.Serialize(betInfo);
                            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CacheData", "Orders", DateTime.Today.ToString("yyyyMMdd"), order.RunningOrder.GameCode, order.RunningOrder.SchemeId.Substring(0, 10));
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            var fileName = Path.Combine(path, string.Format("{0}.json", order.RunningOrder.SchemeId));
                            File.WriteAllText(fileName, json, Encoding.UTF8);
                        }
                        catch (Exception)
                        {
                        }
                        //}).Start();
                        #endregion
                    }
                    else
                    {
                        //数字彩、传统足球
                        #region 拆票

                        var betInfo = new GatewayTicketOrder
                        {
                            Amount          = order.RunningOrder.Amount,
                            GameCode        = order.RunningOrder.GameCode,
                            IssuseNumber    = order.RunningOrder.IssuseNumber,
                            OrderId         = order.RunningOrder.SchemeId,
                            Price           = ((order.RunningOrder.IsAppend && order.RunningOrder.GameCode == "DLT") ? 3M : 2M),
                            TotalMoney      = order.RunningOrder.TotalMoney,
                            IsVirtualOrder  = false,
                            Attach          = "",
                            IsAppend        = order.RunningOrder.IsAppend,
                            UserId          = order.RunningOrder.UserId,
                            IsRunningTicket = true,
                        };
                        foreach (var item in order.AnteCodeList)
                        {
                            betInfo.AnteCodeList.Add(new GatewayAnteCode
                            {
                                AnteNumber = item.AnteCode,
                                GameType   = item.GameType,
                            });
                        }

                        //new Sports_Business().RequestTicket(betInfo, order.KeyLine, order.StopAfterBonus, order.SchemeType);

                        new Sports_Business().RequestTicket2(betInfo, order.KeyLine, order.StopAfterBonus, order.SchemeType);
                        //new Thread(() =>
                        //{

                        try
                        {
                            //生成文件
                            var json = JsonHelper.Serialize(betInfo);
                            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CacheData", "Orders", DateTime.Today.ToString("yyyyMMdd"), order.RunningOrder.GameCode, order.RunningOrder.SchemeId.Substring(0, 10));
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            var fileName = Path.Combine(path, string.Format("{0}.json", order.RunningOrder.SchemeId));
                            File.WriteAllText(fileName, json, Encoding.UTF8);
                        }
                        catch (Exception)
                        {
                        }

                        //}).Start();

                        #endregion
                    }

                    //更新订单状态
                    UpdateOrderTicketStatus(order.RunningOrder.SchemeId);

                    //触发出票完成接口
                    BusinessHelper.ExecPlugin <IComplateTicket>(new object[] { order.RunningOrder.UserId, order.RunningOrder.SchemeId, order.RunningOrder.TotalMoney, order.RunningOrder.TotalMoney });
                }
            }
            catch (Exception exp)
            {
                // writerLog("Redis_DoSplitOrderTicket-DoSplitOrderTicketWithThread", ex);
                writerLog.WriteLog("追号订单自动拆票任务", "DoSplitOrderTicket", (int)LogType.Information, "追号订单自动拆票任务日志", exp.Message);
            }
        }
예제 #2
0
        /// <summary>
        /// 执行拆票(单式投注)
        /// </summary>
        public static void DoSplitOrderTicket_Single(RedisWaitTicketOrderSingle order)
        {
            //if (!BusinessHelper.CanRequestBet(order.RunningOrder.GameCode))
            //    return;

            var sportsManager = new Sports_Manager();
            var oldCount      = sportsManager.QueryTicketCount(order.RunningOrder.SchemeId);

            if (oldCount <= 0)
            {
                //清理冻结
                if (order.RunningOrder.SchemeType == (int)SchemeType.ChaseBetting)
                {
                    BusinessHelper.Payout_Frozen_To_End(BusinessHelper.FundCategory_Betting, order.RunningOrder.UserId, order.RunningOrder.SchemeId, string.Format("订单{0}出票完成,扣除冻结{1:N2}元", order.RunningOrder.SchemeId, order.RunningOrder.TotalMoney), order.RunningOrder.TotalMoney);
                }

                #region 拆票

                new Sports_Business().RequestTicketByGateway_SingleScheme_New(new GatewayTicketOrder_SingleScheme
                {
                    AllowCodes      = order.AnteCode.AllowCodes,
                    Amount          = order.RunningOrder.Amount,
                    ContainsMatchId = order.AnteCode.ContainsMatchId,
                    FileBuffer      = order.AnteCode.FileBuffer,
                    GameCode        = order.RunningOrder.GameCode,
                    GameType        = order.RunningOrder.GameType,
                    IsRunningTicket = true,
                    IssuseNumber    = order.RunningOrder.IssuseNumber,
                    IsVirtualOrder  = false,
                    OrderId         = order.RunningOrder.SchemeId,
                    PlayType        = order.RunningOrder.PlayType,
                    SelectMatchId   = order.AnteCode.SelectMatchId,
                    TotalMoney      = order.RunningOrder.TotalMoney,
                    UserId          = order.RunningOrder.UserId,
                });

                //new Thread(() =>
                //{
                try
                {
                    //生成文件
                    var json = Encoding.UTF8.GetString(order.AnteCode.FileBuffer);
                    var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CacheData", "Orders", DateTime.Today.ToString("yyyyMMdd"), order.RunningOrder.GameCode, order.RunningOrder.SchemeId.Substring(0, 10));
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    var fileName = Path.Combine(path, string.Format("{0}.json", order.RunningOrder.SchemeId));
                    File.WriteAllText(fileName, json, Encoding.UTF8);
                }
                catch (Exception)
                {
                }
                //}).Start();


                #endregion

                //更新订单状态
                UpdateOrderTicketStatus(order.RunningOrder.SchemeId);

                //触发出票完成接口
                BusinessHelper.ExecPlugin <IComplateTicket>(new object[] { order.RunningOrder.UserId, order.RunningOrder.SchemeId, order.RunningOrder.TotalMoney, order.RunningOrder.TotalMoney });
            }
        }