小程序用户改用门店登录

This commit is contained in:
liu
2026-08-20 13:46:04 +08:00
parent 6d9f02d831
commit c1d490134e
251 changed files with 689 additions and 2727 deletions
+12
View File
@@ -23,6 +23,10 @@ class StoreModelFactory extends Factory
return [
'name' => '测试门店' . $seq,
'code' => 'S' . str_pad((string) $seq, 6, '0', STR_PAD_LEFT),
'username' => 'store' . $seq,
'password' => password_hash('123456', PASSWORD_DEFAULT),
'avatar' => '',
'last_login_at' => null,
'level_id' => 0,
'contact' => '联系人' . $seq,
'phone' => '138' . str_pad((string) $seq, 8, '0', STR_PAD_LEFT),
@@ -41,6 +45,14 @@ class StoreModelFactory extends Factory
return $this->state(fn () => ['status' => StoreModel::STATUS_DISABLED]);
}
/**
* 指定登录密码(明文,入库自动哈希)
*/
public function withPassword(string $password): static
{
return $this->state(fn () => ['password' => password_hash($password, PASSWORD_DEFAULT)]);
}
/**
* 指定回款周期(天)
*/
-55
View File
@@ -1,55 +0,0 @@
<?php
namespace Database\Factories;
use App\Models\UserModel;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* 小程序用户工厂(微信登录自动生成,供测试使用;无需 Faker)
*
* @extends Factory<UserModel>
*/
class UserModelFactory extends Factory
{
protected $model = UserModel::class;
private static int $sequence = 0;
public function definition(): array
{
$seq = ++self::$sequence;
return [
'username' => null,
'password' => null,
'nickname' => '微信用户' . $seq,
'email' => '',
'openid' => 'openid_' . str_pad((string) $seq, 16, '0', STR_PAD_LEFT),
'unionid' => '',
'phone' => '',
'avatar' => '',
'store_id' => 0,
'status' => UserModel::STATUS_NORMAL,
'last_login_at' => null,
];
}
/**
* 已绑定门店的门店用户
*/
public function forStore(int $storeId): static
{
return $this->state(fn () => [
'store_id' => $storeId,
]);
}
/**
* 停用账号
*/
public function disabled(): static
{
return $this->state(fn () => ['status' => UserModel::STATUS_DISABLED]);
}
}