Test.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @Created by PhpStorm
  4. * @author: Kirin
  5. * @day: 2024/9/28
  6. * @time: 0:14
  7. */
  8. namespace app\command;
  9. use app\services\system\config\SystemConfigServices;
  10. use app\services\TestServices;
  11. use app\services\user\UserBillServices;
  12. use app\validate\admin\TestValidate;
  13. use qiniu\exceptions\AdminException;
  14. use qiniu\services\sms\Sms;
  15. use Swoole\Process;
  16. use think\console\Command;
  17. use think\console\Input;
  18. use think\console\Output;
  19. class Test extends Command
  20. {
  21. protected $service;
  22. protected function configure()
  23. {
  24. // 指令配置
  25. $this->setName('test')
  26. ->setDescription('调试用');
  27. }
  28. protected function execute(Input $input, Output $output)
  29. {
  30. $validate = new TestValidate();
  31. $date = [
  32. 'cates' => [1, 2],
  33. 'inteval' => 1,
  34. 'number' => 1.9,
  35. ];
  36. $res = $validate->check($date);
  37. /** @var TestServices $service */
  38. $service = app()->make(TestServices::class);
  39. var_dump($service->get(1)->toArray());
  40. }
  41. public function get_tree_children($data, $id = 0, $field = 'id', $pid = 'pid', $init = true)
  42. {
  43. static $children;
  44. if ($init) {
  45. $children = [];
  46. foreach ($data as $v) {
  47. $children[$v[$pid]][] = $v;
  48. }
  49. $this->log(count($children));
  50. }
  51. var_dump($children[16]);
  52. $arr = ($children[$id] ?? []);
  53. // if (count($arr) > 0) {
  54. // foreach ($arr as &$v) {
  55. // $this->log($v[$field]);
  56. // $v['children'] = $this->get_tree_children($data, $v[$field], $field, $pid, false);
  57. // }
  58. // }
  59. return $arr;
  60. }
  61. /**
  62. * 日志输出
  63. * @param string $msg
  64. */
  65. private function log($msg)
  66. {
  67. $str = "";
  68. $str .= $msg;
  69. $str .= " 时间:" . date('Y - m - d H:i:s') . PHP_EOL;
  70. @file_put_contents('test.log', "[" . date('Y - m - d H:i:s') . "]:" . $msg . PHP_EOL, FILE_APPEND);
  71. echo $str;
  72. }
  73. }