= $config[$team_level_id]['direct']) { $result = true; $team_level_id += 1; } }else{ //直推 $teamCount = UserModel::where('parent_id', $user_id)->where('team_level_id', $team_level_id)->count(); //组合套数 $groupCount = UserPledge::getPledgeCount($user_id) + $num; if($team_level_id == 1 && ($groupCount == 0 || $address_level < $config[0]['direct'])){ $result = true; $team_level_id = 0; } //大于1 if($team_level_id > 1){ if($teamCount >= $config[$team_level_id]['direct'] && $groupCount >= $config[$team_level_id]['num']){ $result = true; $team_level_id += 1; //+1 }else{ $result = true; $team_level_id -=1; //-1 } } } return $result? UserModel::where('id', $user_id)->update(['team_level_id'=> $team_level_id]): false; } //发放层级收益 public static function setTeamLevelIncome(int $user_id, float $num, int $team_level_id, string $asset, string $action) { $config = config('team_level_where'); $team_level_id = $team_level_id - 1; $paths = UserPathModel::where('user_id', $user_id)->where('distance', '<=', $config[$team_level_id]['level'])->order('distance', 'asc')->column('parent_id'); if(count($paths) > 0){ //收益 $income = bcmul($num, config('team_level_inc'), 2); //余额记录 foreach($paths as $pathId){ Loader::model('LedgerWalletModel')->changeWalletAccount($pathId, $asset, $income, $action, $user_id); } } return true; } //判断发放茶宝数量 public static function getFrozenIsChabao($token, $frozen) { //标记茶宝 if(bccomp(bcmul($frozen, config('team_level_inc'), 6) , 0.0001, 6) == -1) { return [$token, Asset::TOKEN, LedgerTokenChangeModel::TeamLevel]; }else{ //标记茶宝 return [$frozen, Asset::FROZEN, LedgerFrozenChangeModel::TeamLevel]; } } }