diff --git a/app/Console/Commands/UpdateUserNo.php b/app/Console/Commands/UpdateUserNo.php new file mode 100755 index 0000000..6b3c7eb --- /dev/null +++ b/app/Console/Commands/UpdateUserNo.php @@ -0,0 +1,52 @@ +id); + $this->info($no . '更新成功'); + } + return $this->info('更新完成'); + } + + +} diff --git a/app/Http/Controllers/Mobile/UserController.php b/app/Http/Controllers/Mobile/UserController.php index 1212011..56d89da 100755 --- a/app/Http/Controllers/Mobile/UserController.php +++ b/app/Http/Controllers/Mobile/UserController.php @@ -72,6 +72,8 @@ class UserController extends CommonController $score = Config::getValueByKey('share_score'); ScoreLog::add($pid, $score, '分享获得'); } + // 更新编号 + User::updateNo($user->id); } $token = $user->createToken("mobile-token")->plainTextToken; return $this->success(compact('token')); diff --git a/app/Models/User.php b/app/Models/User.php index 4347efc..4478058 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -124,4 +124,16 @@ class User extends Authenticatable implements Auditable return $user->appointment_total - $useTotal >= 0 ? $user->appointment_total - $useTotal : 0; } + /** + * 更新用户编号 + */ + public static function updateNo($userId) + { + $user = self::find($userId); + $no = date('Ymd', strtotime($user->created_at)) . str_pad($userId, 6, '0', STR_PAD_LEFT); + $user->no = $no; + $user->save(); + return $user->no; + } + } diff --git a/database/migrations/2025_06_19_105447_alert_users_table.php b/database/migrations/2025_06_19_105447_alert_users_table.php new file mode 100644 index 0000000..d0ac907 --- /dev/null +++ b/database/migrations/2025_06_19_105447_alert_users_table.php @@ -0,0 +1,32 @@ +string('no')->nullable()->comment('学号'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + // + }); + } +};