public static string AnyCodeInvalid(this Settle settle)
        {
            var result = settle == null ? "未设置家庭信息" : $"{settle.Self?.CheckValid("本人")}{settle.Lover?.CheckValid("配偶")}{settle.Parent?.CheckValid("父母")}{settle.LoversParent.CheckValid("岳父岳母")}";

            if (settle?.Self?.Valid == false)
            {
                result += " 本人地址信息必须为[启用]";
            }
            return(result.Length == 0 ? null : result);
        }
    static void Main(string[] args)
    {
        var settle = new Settle {
            Pixels = 1.5, Time = 8, Timeout = 40
        };
        var parameterList = new ArrayList {
            10, false, settle
        };
        var dither = new Dither {
            Method = "dither", Parameters = parameterList, Id = 42
        };

        string temp = JsonConvert.SerializeObject(dither);
    }
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static SettleDto ToDto(this Settle model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new SettleDto()
     {
         Lover = model.Lover.ToDto(),
         LoversParent = model.LoversParent.ToDto(),
         Parent = model.Parent.ToDto(),
         Self = model.Self.ToDto(),
         PrevYearlyComsumeLength = model.PrevYearlyComsumeLength,
     });
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="db"></param>
        /// <param name="raw"></param>
        /// <returns></returns>
        public static Settle ToModel(this SettleDto model, DbSet <AdminDivision> db, Settle raw = null)
        {
            if (model == null)
            {
                return(raw);
            }
            if (raw == null)
            {
                raw = new Settle();
            }

            raw.Lover        = model.Lover.ToModel(db, raw.Lover);
            raw.LoversParent = model.LoversParent.ToModel(db, raw.LoversParent);
            raw.Parent       = model.Parent.ToModel(db, raw.Parent);
            raw.Self         = model.Self.ToModel(db, raw.Self);
            return(raw);
        }
Beispiel #5
0
 public SettleDetail(Settle model)
 {
     m_model = model;
 }
Beispiel #6
0
        /// <summary>
        /// 检查竞技场是否可以开始
        /// </summary>
        /// <param name="model">竞技场</param>
        /// <returns></returns>
        private static void CheckArenaStart(ArenaBase model)
        {
            Dictionary<string, int> dic = new Dictionary<string, int>();
            foreach (Pet p in model.Pets.Values)
            {
                if (!dic.ContainsKey(p.GroupName))
                {
                    dic.Add(p.GroupName, 1);
                }
                else
                {
                    dic[p.GroupName]++;
                }

                PlayerBusiness user;
                if (model.Players.TryGetValue(p.PlayerID, out user))
                {
                    Settle settle;
                    if (!model.SettleInfo.TryGetValue(p.PlayerID, out settle))
                    {
                        settle = new Settle();
                        settle.PlayerID = p.PlayerID;
                        settle.GroupName = p.GroupName;
                        settle.PlayerName = user.Name;
                        settle.ResultType = 0;
                        model.SettleInfo.TryAdd(p.PlayerID, settle);
                    }
                }
            }

            if (dic.Count <= 1)
            {
                //竞技场不满足开始条件
                model.CallAll(ArenaCommand.ArenaStartR, false,TipManager.GetMessage(ArenaReturn.CheckArenaStart1));
                ArenaBase tmp;
                if (ArenaBusiness.ArenaList.TryRemove(model.SoleID, out tmp))
                {
                    PlayerOut(tmp);
                }
                return;
            }

            model.Status = 1;
            //竞技场开始
            model.CallAll(ArenaCommand.ArenaStartR, true, TipManager.GetMessage(ArenaReturn.CheckArenaStart2));
        }
Beispiel #7
0
        /// <summary>
        /// 中途断线处理
        /// </summary>
        public static void UseDis(ArenaBase model, string playerid)
        {
            PlayerBusiness user;
            if (!model.Players.TryGetValue(playerid, out user))
                return;
            //表示没有参战竞技场
            if (string.IsNullOrEmpty(user.GroupName))
                return;
            GameConfig gc = GameConfigAccess.Instance.FindOneById(model.ArenaID);
            if (gc == null) return;
            Variant t = gc.Value;
            Variant petLevel = t.GetValueOrDefault<Variant>("PetLevel").GetValueOrDefault<Variant>(model.PetMin + "-" + model.PetMax);
            if (petLevel == null)
                return;

            Settle s;
            if (model.SettleInfo.TryGetValue(playerid, out s))
            {
                s.ResultType = 0;
                s.GroupName = user.GroupName;
            }
            else
            {
                s = new Settle();
                s.PlayerID = playerid;
                s.ResultType = 0;
                s.GroupName = user.GroupName;
                model.SettleInfo.TryAdd(playerid, s);
            }
            s.OtherFight = Convert.ToInt32(s.WinFight * 0.15 - s.LossFight * 1.5) - petLevel.GetIntOrDefault("LossFight");
            s.TotalFight = s.OtherFight + s.WinFight + s.LossFight;
            user.AddFightValue(s.TotalFight, false, FinanceType.AuctionSell);

            AddFatigue(model, user, 0);

            string title = "";
            string content = "";
            if (s.TotalFight >= 0)
            {
                // "致光荣的战场逃亡者";
                title = TipManager.GetMessage(ArenaReturn.UseDis1);
                //"你在竞技场的脱逃让人失望,不过凭着卓越的战斗技巧,仍然获得了X点附加战绩奖励。希望勇者不再以战败者的方式离开战场!";
                content = TipManager.GetMessage(ArenaReturn.UseDis2);
            }
            else
            {
                //"致可耻的战场逃亡者";
                title = TipManager.GetMessage(ArenaReturn.UseDis3);
                //"你在竞技场的脱逃行为被人唾弃,你在这次战斗中被判定为失败者,扣除了X点附加战绩惩罚。你的行为背离了竞技场精神!";
                content = TipManager.GetMessage(ArenaReturn.UseDis4);
            }
            int reTime = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay));
            if (EmailAccess.Instance.SendEmail(title, TipManager.GetMessage(ArenaReturn.UseDis5), user.ID, user.Name, content, string.Empty, null, reTime))
            {
                if (user.Online)
                {
                    user.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(user.ID));
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// 结算战绩值
        /// </summary>
        protected void GetFightValue()
        {
            //得到被攻击者的当前成长度
            Variant target = m_target.Value;
            if (target == null)
                return;

            Variant ccd = target.GetValueOrDefault<Variant>("ChengChangDu");
            if (ccd == null)
                return;
            //胜利方得到战绩值
            int fightValue = ccd.GetIntOrDefault("V") * 1;//战绩基础值

            int tlevel = target.GetIntOrDefault("PetsLevel");

            Variant root = m_root.Value;
            if (root == null)
                return;

            int rlevel = root.GetIntOrDefault("PetsLevel");
            int lp = rlevel-tlevel;//等级差
            if(lp>10 && lp<=15)
            {
                fightValue = Convert.ToInt32(fightValue * 0.8);
            }
            else if (lp > 15 && lp <= 20)
            {
                fightValue = Convert.ToInt32(fightValue * 0.5);
            }
            else if(lp>20 &&lp<=25)
            {
                fightValue = Convert.ToInt32(fightValue * 0.2);
            }
            else if (lp > 25)
            {
                fightValue = 0;
            }

            //被攻击者
            FrontServer.PlayerBusiness lossUser;
            Int64 tfv = 0;//被攻击者,当前战绩值
            if (m_model.Players.TryGetValue(m_target.PlayerID, out lossUser))
            {
                tfv = lossUser.FightValue;
            }

            //攻击者
            FrontServer.PlayerBusiness winUser;
            Int64 rfv = 0;//攻击者,当前战绩值
            if (m_model.Players.TryGetValue(m_root.PlayerID, out winUser))
            {
                rfv = winUser.FightValue;
            }

            Int64 fvp = rfv - tfv;//战绩差
            if (fvp > 500 && fvp <= 1000)
            {
                fightValue = Convert.ToInt32(Math.Ceiling(fightValue * 0.8));
            }
            else if (fvp > 1000 && fvp <= 1500)
            {
                fightValue = Convert.ToInt32(Math.Ceiling(fightValue * 0.5));
            }
            else if (fvp > 1500 && fvp <= 2000)
            {
                fightValue = Convert.ToInt32(Math.Ceiling(fightValue * 0.2));
            }
            else if (fvp > 2000)
            {
                fightValue = 0;
            }

            //胜利方得到的战绩值数量
            //if (fightValue > 0)
            //{
            //    winUser.FightValue+=fightValue;
            //    PlayerAccess.Instance.SaveValue(winUser.ID, new Tuple<string, BsonValue>("FightValue", winUser.FightValue));

            //    Variant v = new Variant(2);
            //    v["FightValue"] = winUser.FightValue;
            //    v["ID"] = winUser.ID;
            //    winUser.Call(ClientCommand.UpdateActorR, v);
            //}

            int fv = fightValue <= 0 ? 1 : fightValue;
            //失败方损失战绩值
            int f = Convert.ToInt32(Math.Ceiling(fv * 0.2));
            //if (f > 0)
            //{
            //    lossUser.FightValue -= f;
            //    ////PlayerAccess.Instance.SaveValue(lossUser.ID, new Tuple<string, BsonValue>("FightValue", lossUser.FightValue));
            //    Variant v = new Variant(2);
            //    v["FightValue"] = lossUser.FightValue;
            //    v["ID"] = lossUser.ID;
            //    winUser.Call(ClientCommand.UpdateActorR, v);
            //}

            //胜利方相关记录
            Settle winSettle;
            if (m_model.SettleInfo.TryGetValue(winUser.ID, out winSettle))
            {
                winSettle.WinFight += fightValue;
                winSettle.TotalWin++;
            }
            else
            {
                winSettle = new Settle();
                winSettle.PlayerID = winUser.ID;
                winSettle.GroupName = m_root.GroupName;
                winSettle.PlayerName = winUser.Name;
                winSettle.WinFight = fightValue;
                winSettle.TotalWin++;
                m_model.SettleInfo.TryAdd(winUser.ID, winSettle);
            }

            //失败方记录
            Settle lossSettle;
            if (m_model.SettleInfo.TryGetValue(lossUser.ID, out lossSettle))
            {
                lossSettle.LossFight -= f;
                lossSettle.TotalLoss++;
            }
            else
            {
                lossSettle = new Settle();
                lossSettle.PlayerID = lossUser.ID;
                lossSettle.GroupName = m_target.GroupName;
                lossSettle.PlayerName = lossUser.Name;
                lossSettle.LossFight = -f;
                lossSettle.TotalLoss++;
                m_model.SettleInfo.TryAdd(lossUser.ID, lossSettle);
            }
        }
Beispiel #9
0
        public ResultInfo SettleCalVerion2(int y, int m)
        {
            db0 = getDB0;
            var r = new ResultInfo();
            try
            {
                #region MyRegion
                //上個月日期
                var p_date = DateTime.Parse(y + "/" + m + "/1").AddMonths(-1);
                //上上個月日期
                var pp_date = DateTime.Parse(y + "/" + m + "/1").AddMonths(-2);

                //清空 SettleCal 資料
                string sql = "delete from SettleCal where sales_no!='A'";
                db0.Database.ExecuteSqlCommandAsync(sql).Wait();

                //清楚計算月的資料
                sql = "delete from SettleDetail where y=@y and m=@m";
                SqlParameter[] sps = new SqlParameter[] { new SqlParameter("@y", y), new SqlParameter("@m", m) };
                db0.Database.ExecuteSqlCommandAsync(sql, sps).Wait();

                var sales_colle = db0.Sales.Select(x => new SalesCalInfo()
                {
                    sales_no = x.sales_no,
                    sales_name = x.sales_name,
                    rank = x.rank,
                    recommend_no = x.recommend_no,
                    recommend_name = x.recommend_name,
                    share_sn = x.share_sn,
                    share_level = x.share_level,
                    share_name = x.ShareParent.sales_name
                }).Where(x => x.sales_no != "A").ToList(); //取得會員

                var sales_sum_kv = db0.PurchaseDetail
                .Where(x => x.Purchase.set_date.Year == y && x.Purchase.set_date.Month == m & (x.Purchase.state == (int)PurchaseState.complete || x.Purchase.state == (int)PurchaseState.onSite))
                .GroupBy(x => new { x.Purchase.sales_no })
                .Select(g => new { sales_no = g.Key.sales_no, sum_kv = g.Sum(x => x.kv_sub_total) }).ToList();

                foreach (var sales in sales_colle)
                {
                    var md = new SettleCal();
                    var obj = sales_sum_kv.FirstOrDefault(x => x.sales_no == sales.sales_no);
                    if (obj != null)
                    {
                        md.sales_no = sales.sales_no;
                        md.sales_name = sales.sales_name;
                        md.rank = sales.rank;
                        md.share_level = sales.share_level;
                        md.share_sn = sales.share_sn;
                        md.share_name = sales.share_name;
                        md.recommend_no = sales.recommend_no;
                        md.recommend_name = sales.recommend_name;
                        md.KV = obj.sum_kv;
                    }
                    else
                    {
                        md.sales_no = sales.sales_no;
                        md.sales_name = sales.sales_name;
                        md.rank = sales.rank;
                        md.share_level = sales.share_level;
                        md.share_sn = sales.share_sn;
                        md.share_name = sales.share_name;
                        md.recommend_no = sales.recommend_no;
                        md.recommend_name = sales.recommend_name;
                        md.KV = 0;
                    }
                    db0.SettleCal.Add(md);
                }

                #region 取出該月獎金計算主檔

                var settle = db0.Settle.Where(x => x.y == y & x.m == m).FirstOrDefault();
                if (settle == null)
                {
                    settle = new Settle()
                    {
                        settle_id = GetNewId(CodeTable.Settle),
                        y = y,
                        m = m,
                        state = (int)SettleState.progress,
                        set_date = DateTime.Now
                    };
                    db0.Settle.Add(settle);
                }
                #endregion

                //以上只算出每位會員KV值
                db0.SaveChangesAsync().Wait();

                var sales_kv_data = db0.SettleCal.Where(x => x.KV >= 1000).ToList();

                //取得上個月結算全部資料
                var sales_settle_pre = db0.SettleDetail.Where(x => x.y == p_date.Year && x.m == p_date.Month).ToList();
                //取得上上個月結算全部資料
                var sales_settle_prepre = db0.SettleDetail.Where(x => x.y == pp_date.Year && x.m == pp_date.Month).ToList();

                #endregion

                #region 消費滿1000kv
                foreach (var sales in sales_kv_data)
                {
                    #region MyRegion
                    var p = sales_settle_pre.FirstOrDefault(x => x.sales_no == sales.sales_no);
                    var md = new SettleDetail();

                    #region 計算共享圈消費總kv
                    //加總子系KV值 且往下只探四層,取當月總消費(未滿1000kv也列入)
                    var cal_kv_sum = sales.SettleCalSub
                        .Traverse(x => x.SettleCalSub)
                        .Where(x => (x.share_level <= sales.share_level + 4))
                        .Sum(x => x.KV);
                    #endregion
                    #region 計算直推會員總kv
                    var r_kv_sum = 0;
                    //加總子系KV值 ,取當月總消費(未滿1000kv也列入)
                    if (sales.rank >= (int)SalesRankState.manager)
                    {//經理人以上才需要計算
                        r_kv_sum = sales.SettleCalRSub.Sum(x => x.KV);
                    }
                    #endregion
                    #region 計算直推經理人是否達30在線&下線總消費額
                    int count_manager = 0;
                    int l_kv_sum = 0;
                    //找出消費滿1000kv且等級為經理人以上且下線有達三位消費滿1000kv
                    if (sales.rank >= (int)SalesRankState.operationsCenter)
                    {//營運中心以上才需要計算                                           
                        foreach (var sub in sales.SettleCalRSub.Where(x => x.KV >= 1000 & x.rank >= (int)SalesRankState.manager))
                        {
                            if (sub.SettleCalRSub.Where(x => x.KV >= 1000).Count() >= 3)
                                count_manager++;
                        }
                        if (count_manager >= 30)
                        {
                            l_kv_sum = sales.SettleCalRSub.Traverse(x => x.SettleCalRSub).Sum(x => x.KV);
                        }
                    }
                    #endregion
                    #region 計算直推營運中心營業總kv
                    var rc_kv_sum = 0;
                    if (sales.rank == (int)SalesRankState.managementOffice)
                    {//管理處以上才需要計算
                        rc_kv_sum = sales.SettleCalRSub.Where(x => x.rank >= (int)SalesRankState.operationsCenter)
                                                             .Traverse(x => x.SettleCalRSub).Sum(x => x.KV);
                    }
                    #endregion

                    md.settle_id = settle.settle_id;
                    md.y = y;
                    md.m = m;

                    md.sales_no = sales.sales_no;
                    md.sales_name = sales.sales_name;
                    md.rank = sales.rank;

                    md.kv_p_sum = sales.KV;//個人_kv總計
                    md.kv_g_sum = cal_kv_sum;//共享圈_kv總計
                    md.kv_r_sum = r_kv_sum;//直推會員_kv總計
                    md.kv_l_sum = l_kv_sum;//直推+間接會員_kv總計
                    md.kv_rc_sum = rc_kv_sum;//直推營運中心營業額_kv總計

                    md.count_manager = count_manager;//直推經理人在線人數

                    var x1 = Convert.ToInt32(cal_kv_sum * 0.01);
                    var x2 = Convert.ToInt32(sales.KV * 0.75);

                    md.a = x1 > x2 ? x2 : x1;

                    #region 上月累計獎金
                    if (p != null)
                    {
                        md.a_p = p.a;
                        md.b_p = p.b;
                    }
                    else
                    {
                        md.a_p = 0;
                        md.b_p = 0;
                    }
                    #endregion

                    //計算本月累計回饋金
                    md.b = x2 + md.b_p - md.a;

                    if (sales.rank >= (int)SalesRankState.manager) //經理人獎金
                    {
                        md.bound = Convert.ToInt32(md.kv_r_sum * 0.12);
                    }
                    if (sales.rank == (int)SalesRankState.operationsCenter & count_manager >= 30) //營運中心
                    {//30位經理人在線
                        md.center_bonus = Convert.ToInt32(md.kv_l_sum * 0.02);
                    }
                    if (sales.rank == (int)SalesRankState.managementOffice & count_manager >= 30)//管理處
                    {//30位經理人在線
                        md.center_bonus = Convert.ToInt32((md.kv_l_sum - md.kv_rc_sum) * 0.02);//管理處的營運中心紅利算法(與rank=營運中心)不太一樣
                        md.office_bonus = Convert.ToInt32(md.kv_rc_sum * 0.01);
                    }

                    db0.SettleDetail.Add(md);

                    #endregion
                }
                #endregion

                #region 消費未滿1000kv(計算累計回饋)
                var accumulate_kv_data = db0.SettleCal.Where(x => x.KV < 1000 & x.sales_no != "A").ToList();
                foreach (var sales in accumulate_kv_data)
                {
                    #region MyRegion
                    var p = sales_settle_pre.FirstOrDefault(x => x.sales_no == sales.sales_no);
                    var pp = sales_settle_pre.FirstOrDefault(x => x.sales_no == sales.sales_no);
                    var md = new SettleDetail();

                    md.settle_id = settle.settle_id;
                    md.y = y;
                    md.m = m;

                    md.sales_no = sales.sales_no;
                    md.sales_name = sales.sales_name;
                    md.rank = sales.rank;

                    md.kv_p_sum = sales.KV;//個人_kv總計
                    md.kv_g_sum = 0;//共享圈_kv總計
                    md.kv_r_sum = 0;//直推會員_kv總計
                    md.kv_l_sum = 0;//直推+間接會員_kv總計
                    md.kv_rc_sum = 0;//直推營運中心營業額_kv總計

                    md.count_manager = 0;//直推經理人在線人數
                    md.bound = 0;//經理人獎金
                    md.center_bonus = 0;//營運中心獎金
                    md.office_bonus = 0;//管理處獎金

                    //var x1 = Convert.ToInt32(cal_kv_sum * 0.01);
                    var x2 = Convert.ToInt32(sales.KV * 0.75);

                    md.a = 0;//未滿1000kv回饋金為0

                    #region 上月累計獎金
                    int pp_kv_p_sum = 0;//上上個月個人_kv總計
                    int p_kv_p_sum = 0;//上個月個人_kv總計
                    if (p != null)
                    {
                        md.a_p = p.a;
                        md.b_p = p.b;
                        p_kv_p_sum = p.kv_p_sum;
                    }
                    else
                    {
                        md.a_p = 0;
                        md.b_p = 0;
                    }
                    pp_kv_p_sum = pp != null ? pp.kv_p_sum : 0;
                    #endregion

                    //計算本月累計回饋金
                    md.b = x2 + md.b_p - md.a;
                    //連續三個月消費未滿1000kv累計回饋金歸0
                    if (pp_kv_p_sum < 1000 & p_kv_p_sum < 1000)
                        md.b = 0;

                    db0.SettleDetail.Add(md);

                    #endregion
                }
                #endregion

                db0.SaveChangesAsync().Wait();

                r.result = true;
                return r;
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
                return r;
            }
            finally
            {
                db0.Dispose();
            }
        }
        /// <summary>
        ///  获取全年总假期,每年12月25日后,开始统计第二年休假
        /// </summary>
        /// <param name="settle"></param>
        /// <param name="TargetUser"></param>
        /// <returns>
        /// double 结果
        /// <param name="requireToAdd">当需要添加记录时返回非空</param>
        /// <param name="maxOnTripTime">全年可休几次路途</param>
        /// <param name="description">全年假期的描述</param>
        /// </returns>
        public static Tuple <double, AppUsersSettleModifyRecord, int, string> GetYearlyLength(this Settle settle, User TargetUser, out bool requireUpdate)
        {
            if (settle == null)
            {
                throw new ArgumentNullException(nameof(settle));
            }
            AppUsersSettleModifyRecord requireToAdd;
            var nowVacationLength        = settle.GetYearlyLengthInner(TargetUser, out int maxOnTripTime, out string description, out var actionOnDate, out requireUpdate); // 本次应休假长度
            var userFinnalModifyDate     = TargetUser.CheckUpdateDate();                                                                                                    // 本次用户家庭最后变更时间
            var vacationModifyRecords    = settle.PrevYealyLengthHistory?.OrderByDescending(rec => rec.UpdateDate);                                                         // 用户假期变更记录
            var lastVacationModify       = vacationModifyRecords?.FirstOrDefault();                                                                                         // 上次假期变更记录
            var lastFamilyVacationModify = vacationModifyRecords?.FirstOrDefault(rec => !rec.IsNewYearInitData);                                                            // 上次因家庭变更而假期变更记录

            // 通过用户家庭情况变更记录来计算

            // 如果今年已有变更记录
            if (lastVacationModify != null && lastVacationModify.UpdateDate.Year == DateTime.Now.XjxtNow().Year)
            {
                // 本次假期长度同上次,则无更改
                if (lastVacationModify.Length == nowVacationLength)
                {
                    description  = lastVacationModify.Description;
                    requireToAdd = null;
                    return(new Tuple <double, AppUsersSettleModifyRecord, int, string>(nowVacationLength, requireToAdd, maxOnTripTime, description));
                }
                // 上次是否是新年初始化 或 上次的家庭情况时间不同于本次
                else if (lastVacationModify.IsNewYearInitData || lastVacationModify.UpdateDate != userFinnalModifyDate)
                {
                    var nowY = DateTime.Now.XjxtNow().Year;
                    var thisYearModifyRecords = vacationModifyRecords.Where(rec => rec.UpdateDate.Year == nowY);                     // 今年以来的变更记录
                    var newLength             = thisYearModifyRecords.CaculateLengthByWeight(userFinnalModifyDate, nowVacationLength, out var weightDescription);

                    // 如果最新更新时间早于上次更新时间,则使用当期时间作为基准,且天数不进行加权处理
                    if (userFinnalModifyDate.Year != nowY)
                    {
                        newLength            = nowVacationLength;
                        weightDescription    = "";
                        userFinnalModifyDate = thisYearModifyRecords.LastOrDefault()?.UpdateDate ?? SystemNowDate();
                    }
                    requireToAdd = new AppUsersSettleModifyRecord()
                    {
                        Description       = $"{description} {weightDescription}",
                        IsNewYearInitData = false,
                        Length            = newLength,
                        UpdateDate        = userFinnalModifyDate
                    };
                    return(new Tuple <double, AppUsersSettleModifyRecord, int, string>(newLength, requireToAdd, maxOnTripTime, description));
                }
                // 否则只是因为加权导致的天数不同而已,返回上次的值即可
                else
                {
                    requireToAdd = null;
                    description  = lastVacationModify.Description;
                    return(new Tuple <double, AppUsersSettleModifyRecord, int, string>(lastVacationModify.Length, requireToAdd, maxOnTripTime, description));
                }
            }
            // 若今年无变更记录,则创建一条记录
            else
            {
                var newRecord = new DateTime(DateTime.Now.XjxtNow().Year, 1, 1);
                requireToAdd = new AppUsersSettleModifyRecord()
                {
                    Description       = description,
                    IsNewYearInitData = true,
                    UpdateDate        = newRecord,
                    Length            = nowVacationLength
                };
                return(new Tuple <double, AppUsersSettleModifyRecord, int, string>(nowVacationLength, requireToAdd, maxOnTripTime, description));
            }
        }
        /// <summary>
        /// 根据用户条件获取当前用户的全年总假期长度
        /// </summary>
        /// <param name="settle"></param>
        /// <param name="targetUser"></param>
        /// <param name="maxOnTripTime"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public static int GetYearlyLengthInner(this Settle settle, User targetUser, out int maxOnTripTime, out string description, out DateTime actionOnDate, out bool requireUpdate)
        {
            maxOnTripTime = 0;
            actionOnDate  = SystemNowDate();
            requireUpdate = false;
            if (targetUser == null || settle?.Self == null || (!settle.Self?.Valid ?? false))
            {
                description = "无休假:本人地址无效,请填写正确地址。";
                return(0);
            }
            var title = targetUser.CompanyInfo.Title;
            var isNoVacationOptionSet = ((int)targetUser.AccountStatus & (int)AccountStatus.DisableVacation) > 0;

            if (title?.DisableVacation ?? false)
            {
                if (!isNoVacationOptionSet)
                {
                    targetUser.AccountStatus += (int)AccountStatus.DisableVacation; requireUpdate = true;
                }
                description = $"职务为{title.Name},无假期。";
                return(0);
            }
            if (isNoVacationOptionSet)
            {
                description = "当年无假期选项已设定,无假期";
                return(0);
            }
            if (settle?.Lover == null || (!settle.Lover?.Valid ?? false))
            {
                if (title?.EnableVacationDay ?? false)
                {
                    maxOnTripTime = 1;
                    description   = $"未婚,且职务为{title.Name},假期天数{title.VacationDay}天";
                    actionOnDate  = targetUser.CompanyInfo.TitleDate ?? SystemNowDate();
                    return(title.VacationDay);
                }
                description   = "未婚,探父母假30天。";
                maxOnTripTime = 1;
                actionOnDate  = settle?.Self?.Date ?? SystemNowDate();
                return(30);
            }

            var dis_lover  = IsAllopatry(settle.Self, settle.Lover);                                                     //与配偶不在一地
            var dis_parent = IsAllopatry(settle.Self, settle.Parent);                                                    // 与自己的家长不在一地
            var dis_l_p    = IsAllopatry(settle.Lover, settle.Parent) || IsAllopatry(settle.LoversParent, settle.Lover); //配偶与任意一方家长不在一地

            if (dis_lover && dis_parent && dis_l_p)
            {
                maxOnTripTime = 3;
                actionOnDate  = Max(settle.Lover.Date, settle.Self.Date, settle.Parent.Date, settle.LoversParent.Date);
                description   = "已婚且三方异地,探父母假、探配偶假共计45天。"; return(45);
            }

            if (dis_lover)
            {
                maxOnTripTime = 2;
                actionOnDate  = Max(settle.Lover.Date, settle.Self.Date, settle.Parent.Date, settle.LoversParent.Date);
                description   = "已婚两方异地,探父母假、探配偶假共计40天。"; return(40);
            }

            var workYears = SystemNowDate().Year - targetUser?.BaseInfo.Time_Work.Year;

            if (workYears >= 20)
            {
                maxOnTripTime = 0;
                actionOnDate  = SystemNowDate();
                description   = "工作满20年,驻地假30天。"; return(30);
            }

            if (!dis_lover)
            {
                if (dis_l_p)
                {
                    maxOnTripTime = 1;
                    actionOnDate  = Max(settle.Lover.Date, settle.Self.Date, settle.Parent.Date, settle.LoversParent.Date);
                    description   = "已婚且与配偶同地,与父母异地,探父母假计20天。"; return(20);
                }
                else
                {
                    maxOnTripTime = 0;
                    description   = "已婚且与配偶、父母同地,驻地假计20天。"; return(20);
                }
            }

            description = "无休假:异常的个人信息,请核实。";

            return(0);
        }