Пример #1
0
        public bool UpdateOrdersWinInfo(List<BetRecord> betrecord_list)
        {
            List<ProfitLossInfo> pfl_list = new List<ProfitLossInfo>();
            List<Capital> capital_list = new List<Capital>();
            //admin账户========
            User userAdmin = GetAdmin();
            Capital cpAdmin = GetCapitalInfo(userAdmin.UserId);
            //=================
            foreach (BetRecord record in betrecord_list)
            {
                Capital cp = new Capital();
                if (capital_list.Exists(p => p.UserId == record.UserID))
                {
                    cp = capital_list.Find(p => p.UserId == record.UserID);
                    capital_list.Remove(cp);
                }
                else
                    cp = GetCapitalInfo(record.UserID);
                if (cp == null)
                    continue;
                if (record.Direction == 0)
                {
                    cp.GameScores = Math.Round(cp.GameScores + record.WinMoney - record.BetMoney + Math.Round(record.BonusPct / 100 * record.BetMoney, 2), 2);
                    cp.EnableScores = Math.Round(cp.EnableScores + record.WinMoney, 2);
                    cp.DisableScores = Math.Round(cp.DisableScores - (record.BetMoney - Math.Round(record.BonusPct / 100 * record.BetMoney, 2)), 2);
                }
                else
                {
                    User user = GetUserInfo(record.UserID);
                    if (record.IsWin == 1)
                    {
                        double disabledS = record.BetMoney * (Convert.ToDouble(record.OddBonus) - 1);
                        cp.GameScores = Math.Round(cp.GameScores + record.BetMoney + Math.Round(record.BetMoney * user.Bonus / 100, 2), 2);
                        cp.EnableScores = Math.Round(cp.EnableScores + record.BetMoney * (Convert.ToDouble(record.OddBonus) - 1) + record.BetMoney, 2);
                        cp.DisableScores = Math.Round(cp.DisableScores - record.BetMoney * (Convert.ToDouble(record.OddBonus) - 1)
                            + Math.Round(record.BetMoney * user.Bonus / 100, 2), 2);
                    }
                    else
                    {
                        cp.GameScores = Math.Round(cp.GameScores - record.BetMoney + Math.Round(record.BetMoney * user.Bonus / 100, 2), 2);
                        cp.EnableScores = cp.EnableScores + record.BetMoney * (Convert.ToDouble(record.OddBonus) - 1) - record.BetMoney;
                        cp.DisableScores = Math.Round(cp.DisableScores - record.BetMoney * (Convert.ToDouble(record.OddBonus) - 1)
                            + Math.Round(record.BetMoney * user.Bonus / 100, 2), 2);
                    }
                }
                capital_list.Add(cp);
                //admin
                if (record.Direction == 0)
                    cpAdmin.GameScores = Math.Round(cpAdmin.GameScores - record.WinMoney, 2);
                else if (record.Direction == 1 && record.IsWin == 1)
                    cpAdmin.GameScores = Math.Round(cpAdmin.GameScores - record.BetMoney * 2, 2);
                else
                    cpAdmin.GameScores = Math.Round(cpAdmin.GameScores + record.BetMoney * (Convert.ToDouble(record.OddBonus) - 1) - record.BetMoney, 2);
                pfl_list.Add(new ProfitLossInfo()
                {
                    RecordID = record.RecordID,
                    ProfitLossMoney = record.Direction == 0 ? Math.Round(record.WinMoney - record.BetMoney + Math.Round(record.BonusPct / 100 * record.BetMoney, 2), 2) :
                    (record.IsWin == 1 ? Math.Round(record.WinMoney - record.BetMoney + Math.Round(record.BonusPct / 100 * record.BetMoney, 2), 2) : (-record.BetMoney * (Convert.ToDouble(record.OddBonus) - 1))),
                    ProfitLossTime = DateTime.Now,
                    UserID = record.UserID,
                    Memo = record.PlayTypeDirection,
                    ProfitLossType = "盈亏",
                    CurrentEnableScores = cp.EnableScores
                });
                //admin
                pfl_list.Add(new ProfitLossInfo()
                {
                    RecordID = record.RecordID,
                    ProfitLossMoney = record.Direction == 0 ? Math.Round(-record.WinMoney, 2) :
                    (record.IsWin == 1 ? Math.Round(-record.WinMoney, 2) : (record.BetMoney * (Convert.ToDouble(record.OddBonus) - 1) - record.BetMoney)),
                    ProfitLossTime = DateTime.Now,
                    UserID = userAdmin.UserId,
                    Memo = record.UserID + "中奖,下注金额:" + record.BetMoney.ToString() + ",中奖金额:" + record.WinMoney.ToString() + ",玩法:" + record.PlayTypeDirection,
                    ProfitLossType = "盈亏",
                    CurrentEnableScores = cpAdmin.GameScores
                });
            }
            //admin
            capital_list.Add(cpAdmin);
            List<SQLTranCationParaMeters> tran_list = new List<SQLTranCationParaMeters>();
            SQLTranCationParaMeters para = new SQLTranCationParaMeters();
            para.SqlText = @"update BetRecord  set ResultStatus=1,WinCount=@WinCount,
                            WinMoney=@WinMoney,IsWin=@IsWin,UpdateTime=@UpdateTime where RecordID=@RecordID";
            para.ParameterName = new string[] { "WinCount", "WinMoney", "IsWin", "UpdateTime", "RecordID" };
            para.Data = ConvertHelper.ToListDictionary<BetRecord>(betrecord_list);
            para.type = typeof(BetRecord);
            tran_list.Add(para);

            para = new SQLTranCationParaMeters();
            para.SqlText = @"Insert into ProfitLoss values(@UserID,@ProfitLossTime,@Memo,@ProfitLossType,
                             @CurrentEnableScores,@RecordID,@ProfitLossMoney)";
            para.ParameterName = new string[] { "UserID", "ProfitLossTime","Memo","ProfitLossType",
                                                "CurrentEnableScores", "RecordID", "ProfitLossMoney"};
            para.Data = ConvertHelper.ToListDictionary<ProfitLossInfo>(pfl_list);
            para.type = typeof(ProfitLossInfo);
            tran_list.Add(para);

            para = new SQLTranCationParaMeters();
            para.SqlText = @"update CapitalInfo set GameScores=@GameScores,EnableScores=@EnableScores,DisableScores=@DisableScores
                            where UserID=@UserID";
            para.ParameterName = new string[] { "GameScores", "EnableScores", "DisableScores", "UserId" };
            para.Data = ConvertHelper.ToListDictionary<Capital>(capital_list);
            para.type = typeof(Capital);
            tran_list.Add(para);
            return SqlHelper.getInstance.ExcuteInsertTrancation(tran_list);
        }
Пример #2
0
 public int UpdateCapitalInfo(Capital cp)
 {
     string sql = string.Format("update CapitalInfo set EnableScores={0},DisableScores={1},GameScores={2} where UserID='{3}'",
                             cp.EnableScores, cp.DisableScores, cp.GameScores, cp.UserId);
     return SqlHelper.getInstance.ExcuteNonQuery(sql);
 }