/// <summary>
 /// 实例化一个新的佣金记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="source">来源</param>
 /// <param name="isImmediate">一个布尔值,表示该返点记录是否由直属下级触发</param>
 /// <param name="sum">返点金额</param>
 public CommissionRecord(Author owner, Author source, bool isImmediate, double sum)
 {
     this.Owner = owner;
     this.Source = source;
     this.IsImmediate = isImmediate;
     this.Sum = sum;
 }
 /// <summary>
 /// 实例化一个新的个人/团队统计
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="date">日期</param>
 /// <param name="money">资金余额</param>
 /// <param name="timesOfLogin">登陆次数</param>
 /// <param name="amountOfBets">投注额</param>
 /// <param name="rebate">返点</param>
 /// <param name="bonus">奖金</param>
 /// <param name="commission">佣金</param>
 /// <param name="reward">活动奖励</param>
 /// <param name="dividend">分红</param>
 /// <param name="recharge">充值</param>
 /// <param name="withdrawal">提现</param>
 public RersonalAndTeamReportBase(Author owner, string date, double money, int timesOfLogin, double amountOfBets
     , double rebate, double bonus, double commission, double reward, double dividend, double recharge, double withdrawal)
     : base(date, timesOfLogin, amountOfBets, rebate, bonus, commission, reward, dividend, recharge, withdrawal)
 {
     this.Owner = owner;
     this.Money = money;
 }
 /// <summary>
 /// 实例化一个新的基本的自身数据信息
 /// </summary>
 /// <param name="model">用户信息的数据模型</param>
 public BasicSelfInfoExport(Author model)
 {
     this.Money = model.Money;
     this.Money_Frozen = model.Money_Frozen;
     this.Consumption = model.Consumption;
     this.Integral = model.Integral;
 }
 /// <summary>
 /// 实例化一个新的注册奖励的参与记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="plan">对应的计划(快照)</param>
 public RewardForRegisterRecord(Author owner, RewardForRegisterSnapshot plan)
 {
     this.Owner = owner;
     this.Plan = plan;
     this.PrizeType = plan.PrizeType;
     this.Sum = plan.Sum;
 }
 /// <summary>
 /// 实例化一个新的返点记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="source">来源</param>
 /// <param name="isImmediate">一个布尔值,表示该返点记录是否由直属下级触发</param>
 /// <param name="gameName">游戏</param>
 /// <param name="sum">返点金额</param>
 public RebateRecord(Author owner, Author source, bool isImmediate, string gameName, double sum)
 {
     this.Owner = owner;
     this.Source = source;
     this.IsImmediate = isImmediate;
     this.GameName = gameName;
     this.Sum = sum;
 }
 /// <summary>
 /// 实例化一个新的推广记录
 /// </summary>
 /// <param name="owner">推广人</param>
 /// <param name="rebate_Normal">正常返点数</param>
 /// <param name="rebate_IndefinitePosition">不定位返点数</param>
 public SpreadRecord(Author owner, double rebate_Normal, double rebate_IndefinitePosition)
 {
     this.Owner = owner;
     this.Code = Guid.NewGuid().ToString("N");
     this.Rebate_Normal = rebate_Normal;
     this.Rebate_IndefinitePosition = rebate_IndefinitePosition;
     this.HadUsed = false;
 }
 /// <summary>
 /// 实例化一个新的通知
 /// </summary>
 /// <param name="owner">接收人</param>
 /// <param name="context">正文</param>
 /// <param name="sourceType">通知类型</param>
 /// <param name="sourceId">目标对象的存储指针</param>
 public Notice(Author owner, string context, string sourceType, int sourceId)
 {
     this.Owner = owner;
     this.Context = context;
     this.IsReaded = false;
     this.SourceType = sourceType;
     this.SourceId = sourceId;
 }
 /// <summary>
 /// 实例化一个新的充值记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="comeFrom">来源银行</param>
 /// <param name="serialNumber">流水号</param>
 public RechargeRecord(Author owner, Bank comeFrom, string serialNumber)
 {
     this.Owner = owner;
     this.ComeFrom = comeFrom;
     this.SerialNumber = serialNumber;
     this.Sum = 0;
     this.Status = RechargeStatus.等待银行确认;
 }
 /// <summary>
 /// 实例化一个新的分红记录
 /// </summary>
 /// <param name="title">标题</param>
 /// <param name="owner">用户</param>
 /// <param name="profit">下线盈亏</param>
 /// <param name="scale">分红比例</param>
 /// <param name="sum">分红金额</param>
 public DividendRecord(string title, Author owner, double profit, double scale, double sum)
 {
     this.Title = title;
     this.Owner = owner;
     this.Profit = profit;
     this.Scale = scale;
     this.Sum = sum;
     this.Status = DividendStatus.开放申请;
     this.Remark = "";
 }
 /// <summary>
 /// 实例化一个新的帐变记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="type">帐变类型</param>
 /// <param name="description">描述</param>
 /// <param name="income">收入</param>
 /// <param name="expenses">支出</param>
 public MoneyChangeRecord(Author owner, string type, string description, double income, double expenses)
 {
     this.Owner = owner;
     this.Type = type;
     this.Description = description;
     this.Income = income;
     this.Expenses = expenses;
     this.Sum = this.Income - this.Expenses;
     this.Money = this.Owner.Money + this.Sum;
 }
 /// <summary>
 /// 实例化一个新的积分兑换的参与记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="plan">对应的计划(快照)</param>
 /// <param name="sum">兑换数量</param>
 public RedeemRecord(Author owner, RedeemSnapshot plan, int sum)
 {
     this.Owner = owner;
     this.Plan = plan;
     this.Sum = sum;
     this.PriceOfIntegral = plan.Integral;
     this.PriceOfMoney = plan.Money;
     this.SumOfIntegral = this.PriceOfIntegral * this.Sum;
     this.SumOfMoney = Math.Round(this.PriceOfMoney * this.Sum, 2);
 }
 /// <summary>
 /// 实例化一个新的提现记录
 /// </summary>
 /// <param name="owner">申请人</param>
 /// <param name="sum">金额</param>
 public WithdrawalsRecord(Author owner, double sum)
 {
     this.Owner = owner;
     this.Sum = sum;
     this.Card = owner.Binding.Card;
     this.HolderOfTheCard = owner.Binding.HolderOfTheCard;
     this.BankOfTheCard = owner.Binding.BankOfTheCard;
     this.Status = WithdrawalsStatus.处理中;
     this.Remark = "";
 }
 /// <summary>
 /// 实例化一个新的消费奖励的参与记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="plan">对应的计划(快照)</param>
 /// <param name="postIn">输入金额</param>
 public RewardForConsumptionRecord(Author owner, RewardForConsumptionSnapshot plan, double postIn)
 {
     this.Owner = owner;
     this.Plan = plan;
     this.PostIn = postIn;
     this.ValidDetail = plan.Details.First(x => x.LowerConsumption >= this.PostIn && x.CapsConsumption < this.PostIn);
     this.PrizeType = this.ValidDetail.PrizeType;
     this.Sum = this.ValidDetail.WaysToReward == WaysToRewardOfActivity.绝对值
         ? this.ValidDetail.Sum
         : Math.Round(this.PostIn * this.ValidDetail.Sum / 100, 2);
 }
 /// <summary>
 /// 实例化一个新的找回密码记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="code">标识码</param>
 /// <param name="hadUsed">一个布尔值,表示该找回密码记录是否已经被使用</param>
 public ForgotPasswordRecord(Author owner, string code, bool hadUsed)
 {
     this.Owner = owner;
     this.Code = code;
     this.HadUsed = hadUsed;
 }
 /// <summary>
 /// 实例化一个新的用户登陆记录
 /// </summary>
 /// <param name="owner">用户</param>
 /// <param name="ip">网络地址</param>
 /// <param name="address">实际地址</param>
 public AuthorLandingRecord(Author owner, string ip, string address)
 {
     this.Owner = owner;
     this.Ip = ip;
     this.Address = address;
 }
        /// <summary>
        /// 实例化一个新的单日个人统计
        /// </summary>
        /// <param name="owner">用户</param>
        /// <param name="date">日期</param>
        /// <param name="money">资金余额</param>
        /// <param name="timesOfLogin">登陆次数</param>
        /// <param name="amountOfBets">投注额</param>
        /// <param name="rebate">返点</param>
        /// <param name="bonus">奖金</param>
        /// <param name="commission">佣金</param>
        /// <param name="reward">活动奖励</param>
        /// <param name="dividend">分红</param>
        /// <param name="recharge">充值</param>
        /// <param name="withdrawal">提现</param>
        public RersonalReportForOneDay(Author owner, string date, double money, int timesOfLogin, double amountOfBets
            , double rebate, double bonus, double commission, double reward, double dividend, double recharge, double withdrawal)
            : base(owner, date, money, timesOfLogin, amountOfBets, rebate, bonus, commission, reward, dividend, recharge, withdrawal)
        {

        }
 /// <summary>
 /// 判定当前用户是否允许执行操作
 /// </summary>
 /// <param name="db">数据库连接对象</param>
 public override void CheckAllowExecuteOrNot(ModelToDbContext db)
 {
     this.Self = AuthorLoginInfoPond.GetUserInfo(db, this.Token);
 }
 /// <summary>
 /// 实例化一个新的用户信息(基本)
 /// </summary>
 /// <param name="model">用户的数据模型</param>
 /// <param name="group">所属的用户组</param>
 public BasicAuthorExport(Author model, UserGroup group)
 {
     this.Id = model.Id;
     this.Username = model.Username;
     this.Group = group.Name;
     this.Status = model.Status;
     this.CreatedTime = model.CreatedTime;
     this.LastLoginTime = model.LastLoginTime;
     this.LastLoginIp = model.LastLoginIp;
     this.LastLoginAddress = model.LastLoginAddress;
     this.PlayInfo = new UserPlayInfoExport(model.PlayInfo);
     this.Money = model.Money;
     this.Money_Frozen = model.Money_Frozen;
     this.Consumption = model.Consumption;
     this.Integral = model.Integral;
     this.Subordinate = model.Subordinate;
 }
        /// <summary>
        /// 实例化一个新的投注
        /// </summary>
        /// <param name="owner">投注人</param>
        /// <param name="issue">期号</param>
        /// <param name="multiple">倍数</param>
        /// <param name="points">用于转换为赔率的点数</param>
        /// <param name="howToPlay">玩法</param>
        /// <param name="seats">位</param>
        /// <param name="unitPrice">单价</param>
        public Betting(Author owner, string issue, double multiple, double points, HowToPlay howToPlay
            , List<BettingSeat> seats, double unitPrice)
        {
            this.Owner = owner;
            this.Issue = issue;
            this.Multiple = multiple;
            this.Points = points;
            this.HowToPlay = howToPlay;
            this.Seats = seats;
            this.Status = BettingStatus.等待开奖;
            this.Bonus = 0;
            this.LotteryValues = "";

            this.Notes = GetNotes();
            double t = howToPlay.Interface == LotteryInterface.任N不定位
                ? owner.PlayInfo.Rebate_IndefinitePosition
                : owner.PlayInfo.Rebate_Normal;
            t -= this.Points;
            t = (1 - t) / 100;
            this.Pay = Math.Round(unitPrice * this.Notes * this.Multiple * t, 2);
        }
 /// <summary>
 /// 实例化一个新的用户信息
 /// </summary>
 /// <param name="username">用户名</param>
 /// <param name="password">密码</param>
 /// <param name="playInfo">游戏资料</param>
 /// <param name="parent">父节点</param>
 public Author(string username, string password, UserPlayInfo playInfo, Author parent = null)
     : base(parent)
 {
     this.Username = username;
     this.Password = password;
     this.FundsCode = "未设置";
     this.SafeCode = "未设置";
     this.PlayInfo = playInfo;
     this.Status = UserStatus.未激活;
     this.LastLoginIp = "从未登陆";
     this.LastLoginAddress = "从未登陆";
     this.LastLoginTime = DateTime.Now;
     this.Binding = new UserBinding();
     this.ExtraQuotas = new List<ExtraQuota>();
 }
        /// <summary>
        /// 实例化一个新的追号
        /// </summary>
        /// <param name="owner">投注人</param>
        /// <param name="startIssue">起始期号</param>
        /// <param name="continuance">持续期数</param>
        /// <param name="notes">注数</param>
        /// <param name="points">用于转换为赔率的点数</param>
        /// <param name="howToPlay">玩法</param>
        /// <param name="seats">位</param>
        /// <param name="pay">投注总金额</param>
        public Chasing(Author owner, string startIssue, int continuance, double points, HowToPlay howToPlay, List<ChasingSeat> seats, double pay)
        {
            this.Owner = owner;
            this.StartIssue = startIssue;
            this.Continuance = continuance;
            this.Gone = 0;
            this.Points = points;
            this.HowToPlay = howToPlay;
            this.Seats = seats;
            this.Status = ChasingStatus.未开始;
            this.Repay = 0;
            this.Bonus = 0;

            this.Notes = GetNotes();
            double t = howToPlay.Interface == LotteryInterface.任N不定位
                ? owner.PlayInfo.Rebate_IndefinitePosition
                : owner.PlayInfo.Rebate_Normal;
            t -= this.Points;
            t = (1 - t) / 100;
            this.Pay = Math.Round(pay * t, 2);
        }
        /// <summary>
        /// 实例化一个新的用户信息
        /// </summary>
        /// <param name="model">用户的数据模型</param>
        /// <param name="group">所属的用户组</param>
        /// <param name="systemQuotas">系统设置的高点号配额方案</param>
        public AuthorExport(Author model, UserGroup group, List<SystemQuotaDetail> systemQuotas)
        {
            this.Id = model.Id;
            this.Username = model.Username;
            this.Group = new UserGroupExport(group);
            this.Status = model.Status;
            this.CreatedTime = model.CreatedTime;
            this.LastLoginTime = model.LastLoginTime;
            this.LastLoginIp = model.LastLoginIp;
            this.LastLoginAddress = model.LastLoginAddress;
            this.Binding = new UserBindingExport(model.Binding);
            this.PlayInfo = new UserPlayInfoExport(model.PlayInfo);
            this.Money = model.Money;
            this.Money_Frozen = model.Money_Frozen;
            this.Consumption = model.Consumption;
            this.Integral = model.Integral;
            this.Subordinate = model.Subordinate;

            this.UserQuotas = systemQuotas.OrderByDescending(x => x.Rebate).ToList()
                .ConvertAll(sq =>
                {
                    ExtraQuota eq = model.ExtraQuotas.FirstOrDefault(x => x.Rebate == sq.Rebate);
                    if (eq == null)
                    {
                        eq = new ExtraQuota(sq.Rebate, 0);
                    }
                    SubordinateData sd = model.SubordinateOfHighRebate.FirstOrDefault(x => x.Rebate == sq.Rebate);
                    if (sd == null)
                    {
                        sd = new SubordinateData(sq.Rebate, 0);
                    }
                    int sum = sq.Sum + eq.Sum - sd.Sum;
                    if (sum < 0)
                    {
                        sum = 0;
                    }
                    return new UserQuotaExport(sq.Rebate, sum);
                });
        }