123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * @Created by PhpStorm
- * @author: Kirin
- * @day: 2024/9/28
- * @time: 0:14
- */
- namespace app\command;
- use app\services\system\config\SystemConfigServices;
- use app\services\TestServices;
- use app\services\user\UserBillServices;
- use app\validate\admin\TestValidate;
- use qiniu\exceptions\AdminException;
- use qiniu\services\sms\Sms;
- use Swoole\Process;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- class Test extends Command
- {
- protected $service;
- protected function configure()
- {
- // 指令配置
- $this->setName('test')
- ->setDescription('调试用');
- }
- protected function execute(Input $input, Output $output)
- {
- $validate = new TestValidate();
- $date = [
- 'cates' => [1, 2],
- 'inteval' => 1,
- 'number' => 1.9,
- ];
- $res = $validate->check($date);
- /** @var TestServices $service */
- $service = app()->make(TestServices::class);
- var_dump($service->get(1)->toArray());
- }
- public function get_tree_children($data, $id = 0, $field = 'id', $pid = 'pid', $init = true)
- {
- static $children;
- if ($init) {
- $children = [];
- foreach ($data as $v) {
- $children[$v[$pid]][] = $v;
- }
- $this->log(count($children));
- }
- var_dump($children[16]);
- $arr = ($children[$id] ?? []);
- // if (count($arr) > 0) {
- // foreach ($arr as &$v) {
- // $this->log($v[$field]);
- // $v['children'] = $this->get_tree_children($data, $v[$field], $field, $pid, false);
- // }
- // }
- return $arr;
- }
- /**
- * 日志输出
- * @param string $msg
- */
- private function log($msg)
- {
- $str = "";
- $str .= $msg;
- $str .= " 时间:" . date('Y - m - d H:i:s') . PHP_EOL;
- @file_put_contents('test.log', "[" . date('Y - m - d H:i:s') . "]:" . $msg . PHP_EOL, FILE_APPEND);
- echo $str;
- }
- }
|