//打印系统设置信息 private static void printStates(BonusState defaultBonus, WalletState defaultWallet, List <MemberLevel> defaultMemberLevels) { printTitle(); printBonusState(defaultBonus); printWalletState(defaultWallet); printMemberLevels(defaultMemberLevels); }
public Member(List <MemberLevel> levels, BonusState bonusState, WalletState walletState, IWalletPolicy walletPolicy, IBonusPolicy bonusPolicy, IMemberPolicy memberPolicy) { this._bonusState = bonusState; this._levels = levels; this._walletState = walletState; this._walletPolicy = walletPolicy; this._bonusPolicy = bonusPolicy; this._memberPolicy = memberPolicy; this.Children = new List <Member>(); }
private static void printBonusState(BonusState defaultBonus) { System.Console.WriteLine("当前系统的【红利指数】为:{0}", defaultBonus.Index); System.Console.WriteLine("当前系统的【静态释放比例】为:{0}", defaultBonus.StaticReleaseRatio); System.Console.WriteLine("当前系统的【见点奖起始层数】为:{0}", defaultBonus.StartTierOfWatchPointsReward); System.Console.WriteLine("当前系统的【见点奖持续层数】为:{0}", defaultBonus.TiersOfOfWatchPointsReward); System.Console.WriteLine("当前系统的【见点奖比例】为:{0}", defaultBonus.WatchPointsRewardRatio); System.Console.WriteLine("当前系统的【推荐奖是否开启】为:{0}", defaultBonus.IsRecommendingOn); System.Console.WriteLine("当前系统的【领导奖起始代数】为:{0}", defaultBonus.StartOfLeaderReward); System.Console.WriteLine("--------------------------------------------------------------"); }
//会员初始化构建器 private static List <Member> memberInitGenarator( List <string> memberTierNums, List <string> memberGenerationNums, int levelNumLen, List <MemberLevel> levels, BonusState bonusState, WalletState walletState, IWalletPolicy walletPolicy, IBonusPolicy bonusPolicy, IMemberPolicy memberPolicy ) { if (memberTierNums.Count != memberGenerationNums.Count) { throw new Exception("两个编号列表必须数量一致"); } Random random = new Random(); List <Member> members = new List <Member>(); Dictionary <string, Member> tierMembers = new Dictionary <string, Member>(); Dictionary <string, Member> generationMembers = new Dictionary <string, Member>(); for (int i = 0; i < memberTierNums.Count; i++) { string tierNum = memberTierNums[i]; string generationNum = memberGenerationNums[i]; Member member = new Member(levels, bonusState, walletState, walletPolicy, bonusPolicy, memberPolicy) { Name = string.Format("{0}-{1}", tierNum, generationNum), ID = Guid.NewGuid(), RangeRatio = random.NextDouble() }; members.Add(member); tierMembers.Add(tierNum, member); generationMembers.Add(generationNum, member); //根据编号层级添加关系 if (i != 0) { Member topMember = tierMembers[tierNum.Substring(0, tierNum.Length - levelNumLen)]; Member parent = generationMembers[generationNum.Substring(0, generationNum.Length - levelNumLen)]; member.TopMember = topMember; if (topMember.LeftMember == null) { topMember.LeftMember = member; } else { topMember.RightMember = member; } member.Parent = parent; parent.Children.Add(member); } } return(members); }
static void Main(string[] args) { IBasePolicy basePolicy = new BasePolicy(); IMemberPolicy memberPolicy = new MemberPolicy(); IBonusPolicy bonusPolicy = new BonusPolicy(basePolicy); IWalletPolicy walletPolicy = new WalletPolicy(basePolicy); BonusState defaultBonus = bonusPolicy.DefaultState(); WalletState defaultWallet = walletPolicy.DefaultState(); List <MemberLevel> defaultMemberLevels = memberPolicy.DefaultLevels(); printStates(defaultBonus, defaultWallet, defaultMemberLevels); List <string> memberTierNums = memberNumGenerator("00", 2, 2, 2, false, 30); List <string> memberGenerationNums = memberNumGenerator("00", 2, 2, 3, true, 30); List <Member> members = memberInitGenarator( memberTierNums, memberGenerationNums, 2, defaultMemberLevels, defaultBonus, defaultWallet, walletPolicy, bonusPolicy, memberPolicy ); //充值和推荐奖和拍点极差奖测试 testOfRecharge(1000, 100000, members); //见点奖测试 testOfWatchPointsReward(members); //对碰奖测试 testOfBinaryReward(members); //领导奖测试 testOfLeaderReward(members); //静态释放测试 testOfStaticReleaseBonus(members); //输出结果 printResult(members); }