Beispiel #1
0
        /// <summary>
        /// 充值完成或失败,扣除冻结金额或返还冻结金额
        /// </summary>
        /// <param name="OrderId"></param>
        /// <param name="IsSuccess"></param>
        /// <returns></returns>
        public CommonActionResult EndFreezeGameRecharge(string orderId, bool isSuccess, string providerSerialNo)
        {
            var oldModel = DB.CreateQuery <C_Game_Transfer>().Where(p => p.OrderId == orderId).FirstOrDefault();

            if (oldModel == null)
            {
                throw new LogicException("发生错误,找不到相关订单");
            }
            if (oldModel.Status != (int)FillMoneyStatus.Requesting)
            {
                throw new LogicException("相关订单已被处理,无需重复操作");
            }
            DB.Begin();
            try
            {
                if (isSuccess)
                {
                    oldModel.Status           = (int)FillMoneyStatus.Success;
                    oldModel.UpdateTime       = DateTime.Now;
                    oldModel.ProviderSerialNo = providerSerialNo;
                    DB.GetDal <C_Game_Transfer>().Update(oldModel);
                    BusinessHelper.Payout_Frozen_To_End(BusinessHelper.FundCategory_GameRecharge, oldModel.UserId, orderId, string.Format("游戏充值成功,扣除冻结{1:N2}元", orderId, oldModel.RequestMoney), oldModel.RequestMoney);
                }
                else
                {
                    oldModel.Status           = (int)FillMoneyStatus.Failed;
                    oldModel.UpdateTime       = DateTime.Now;
                    oldModel.ProviderSerialNo = providerSerialNo;
                    DB.GetDal <C_Game_Transfer>().Update(oldModel);
                    BusinessHelper.Payin_FrozenBack(BusinessHelper.FundCategory_GameRecharge, oldModel.UserId, orderId, oldModel.RequestMoney, string.Format("游戏充值不成功,返还资金{0:N2}元", oldModel.RequestMoney));
                }
                DB.Commit();
            }
            catch (Exception ex)
            {
                DB.Rollback();
                throw ex;
            }
            return(new CommonActionResult()
            {
                IsSuccess = true, ReturnValue = orderId
            });
        }
        /// <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);
            }
        }
        /// <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 });
            }
        }