42 lines
937 B
PHP
42 lines
937 B
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Agent;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
use Illuminate\Support\Str;
|
|
|
|
class ExampleTest extends TestCase
|
|
{
|
|
/**
|
|
* A basic test example.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function test_example()
|
|
{
|
|
// 过滤掉 不是代理身份 的用户
|
|
// 过滤掉 相同等级 的 后者 用户
|
|
// 过滤掉等级 低于 上一个分钱 的用户
|
|
$parents = [2, 3, 1, 5, 6, null];
|
|
$filtered = [];
|
|
$last = null;
|
|
foreach($parents as $item) {
|
|
if (!$item) {
|
|
continue;
|
|
}
|
|
if (in_array($item, $filtered)) {
|
|
continue;
|
|
}
|
|
if ($last && $item < $last) {
|
|
continue;
|
|
}
|
|
$last = $item;
|
|
array_push($filtered, $item);
|
|
}
|
|
|
|
dd($filtered);
|
|
}
|
|
}
|