UserRepair.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Model\AccountInfo;
  4. use App\Model\DeliverInfo;
  5. use App\Model\RechargeInfo;
  6. use App\Model\UserInfo;
  7. use Illuminate\Console\Command;
  8. class UserRepair extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'user:reset';
  16. /**
  17. * The console command description.
  18. *
  19. * @var string
  20. */
  21. protected $description = '测试用户数据重置';
  22. /**
  23. * Create a new command instance.
  24. *
  25. * @return void
  26. */
  27. public function __construct()
  28. {
  29. parent::__construct();
  30. }
  31. /**
  32. * Execute the console command.
  33. */
  34. public function handle()
  35. {
  36. // TODO 10465 宣传员展示不删除
  37. $ids = [9997, 10025, 10318, 10340, 10024, 10572, 10517, 10690, 10538, 10533, 10044, 10679, 10347, 10142, 10190, 10329, 11036, 11460, 10004, 10045, 10446, 12000, 12031];
  38. foreach ($ids as $id) {
  39. $user = UserInfo::where(['id' => $id])->first();
  40. if (empty($user)) {
  41. continue;
  42. }
  43. $user_arr = [];
  44. // echo '用户id:'.$id.' 角色'.$user->role.PHP_EOL;
  45. if (!in_array($user->role, $user_arr)) {
  46. $user_arr[] = $user->role;
  47. }
  48. DeliverInfo::where(['user_id' => $id])->delete();
  49. AccountInfo::where(['user_id' => $id])->delete();
  50. RechargeInfo::where(['user_id' => $id])->delete();
  51. $data['account'] = 0;
  52. if (2 == $user->role) {
  53. $data['agent_account'] = 0;
  54. }
  55. UserInfo::where(['id' => $id])->update($data);
  56. }
  57. }
  58. }