12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Console\Commands;
- use App\Model\AccountInfo;
- use App\Model\DeliverInfo;
- use App\Model\RechargeInfo;
- use App\Model\UserInfo;
- use Illuminate\Console\Command;
- class UserRepair extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'user:reset';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '测试用户数据重置';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- */
- public function handle()
- {
- // TODO 10465 宣传员展示不删除
- $ids = [9997, 10025, 10318, 10340, 10024, 10572, 10517, 10690, 10538, 10533, 10044, 10679, 10347, 10142, 10190, 10329, 11036, 11460, 10004, 10045, 10446, 12000, 12031];
- foreach ($ids as $id) {
- $user = UserInfo::where(['id' => $id])->first();
- if (empty($user)) {
- continue;
- }
- $user_arr = [];
- // echo '用户id:'.$id.' 角色'.$user->role.PHP_EOL;
- if (!in_array($user->role, $user_arr)) {
- $user_arr[] = $user->role;
- }
- DeliverInfo::where(['user_id' => $id])->delete();
- AccountInfo::where(['user_id' => $id])->delete();
- RechargeInfo::where(['user_id' => $id])->delete();
- $data['account'] = 0;
- if (2 == $user->role) {
- $data['agent_account'] = 0;
- }
- UserInfo::where(['id' => $id])->update($data);
- }
- }
- }
|