This commit is contained in:
2026-01-18 17:42:46 +08:00
parent 836bdc9409
commit f038dbab41
42 changed files with 3068 additions and 575 deletions

View File

@@ -1,36 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Listeners;
use Modules\Member\Events\LoginBefore;
use Modules\Member\Models\Member;
class UpMemberPaswd {
/**
* @title 会员登录后更新用户信息
*
* @param LoginEvent $event
* @return void
*/
public function handle(LoginBefore $event) {
$username = $event->username;
$password = $event->password;
$member = Member::where('username', '=', $username)->whereNotNull('old_password')->first();
if($member){
if(md5($password . $member->salt) === $member->old_password){
$member->password = $password;
$member->old_password = '';
$member->salt = '';
$member->save();
}
}
}
}

View File

@@ -23,7 +23,7 @@ class Member extends Authenticatable implements JWTSubject {
protected $fillable = ['username', 'nickname', 'email', 'mobile', 'password', 'status'];
protected $hidden = ['password', 'deleted_at'];
protected $dateFormat = 'Y-m-d H:i:s';
protected $with = ['invite:uid,nickname,username,level_id', 'extend', 'level', 'store', 'social', 'pm'];
protected $with = ['invite:uid,nickname,username,level_id', 'extend', 'level'];
/**
* Get the identifier that will be stored in the subject claim of the JWT.
@@ -75,23 +75,7 @@ class Member extends Authenticatable implements JWTSubject {
return $this->hasOne(MemberExtends::class, 'member_id', 'uid');
}
public function social(){
return $this->hasMany(\Modules\Wechat\Models\MemberSocial::class, 'member_id', 'uid');
}
public function level(){
return $this->hasOne(MemberLevel::class, 'id', 'level_id');
}
public function address(){
return $this->hasMany(MemberAddress::class, 'member_id', 'id');
}
public function pm(){
return $this->hasOne(Pm::class, 'member_id', 'pm_uid');
}
public function store(){
return $this->hasOne(Store::class, 'member_id', 'store_uid');
}
}

View File

@@ -1,18 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class MemberAccount extends BaseModel {
protected $table = 'member_account';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
}

View File

@@ -1,18 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class MemberAddress extends BaseModel {
protected $table = 'member_address';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
}

View File

@@ -1,18 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class MemberBank extends BaseModel {
protected $table = 'member_bank';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
}

View File

@@ -1,18 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class MemberCoupon extends BaseModel {
protected $table = 'member_coupon';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
}

View File

@@ -1,18 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class MemberScore extends BaseModel {
protected $table = 'member_score';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
}

View File

@@ -1,18 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class MemberStore extends BaseModel {
protected $table = 'member_store';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
}

View File

@@ -1,18 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class MemberWallet extends BaseModel {
protected $table = 'member_wallet';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
}

View File

@@ -1,22 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class Pm extends BaseModel {
protected $table = 'member_pm';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
public function members(){
return $this->belongsTo(Member::class, 'member_id', 'uid');
}
}

View File

@@ -1,22 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Member\Models;
use App\Models\BaseModel;
class Store extends BaseModel {
protected $table = 'member_store';
protected $fillable = [];
// protected $hidden = ['deleted_at'];
public function members(){
return $this->belongsTo(Member::class, 'member_id', 'uid');
}
}

View File

@@ -18,9 +18,6 @@ class EventServiceProvider extends ServiceProvider
* @var array<string, array<int, string>>
*/
protected $listen = [
\Modules\Member\Events\LoginBefore::class => [
\Modules\Member\Listeners\UpMemberPaswd::class,
],
];
/**

View File

@@ -31,10 +31,10 @@ class AuthService {
$password = $request->input('password');
LoginBefore::dispatch($username, $password);
$token = auth('api')->attempt(['mobile' => $username, 'password' => $password]);
$token = auth('api')->attempt(['username' => $username, 'password' => $password]);
if (!$token) {
throw new \Exception("錄失敗", 1000);
throw new \Exception("录失败", 1000);
}else{
LoginEvent::dispatch(auth('api')->user(), $request->input('openid', ''), $request->input('type'));
// 判断是否到期

View File

@@ -1,72 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void {
Schema::table('member', function (Blueprint $table) {
$table->string('invite_code')->nullable()->after('login_count')->comment('推荐码');
$table->string('old_password')->nullable()->after('password')->comment('旧密码');
$table->string('salt')->nullable()->after('old_password')->comment('密码盐值');
$table->unsignedBigInteger('pm_uid')->nullable()->after('invite_code')->comment('健康管理师id');
$table->unsignedBigInteger('store_id')->nullable()->after('pm_uid')->comment('所属综合服务体');
});
Schema::create('member_pm', function (Blueprint $table) {
$table->id()->uniqid()->comment('主键id');
$table->unsignedBigInteger('member_id')->comment('用户id');
$table->tinyInteger('level')->default(1)->comment('等级');
$table->string('name')->nullable()->comment('名称');
$table->integer('sex')->default(0)->comment('内容');
$table->string('mobile')->nullable()->comment('电话');
$table->string('area')->nullable()->comment('区域');
$table->tinyInteger('store_id')->default(0)->comment('所属综合服务体');
$table->tinyInteger('status')->default(1)->comment('状态');
$table->bigInteger('end_time')->nullable()->comment('到期时间');
$table->timestamp('created_at')->nullable()->comment('创建时间');
$table->timestamp('updated_at')->nullable()->comment('更新时间');
$table->engine = 'InnoDB';
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
$table->comment('会员工作室表');
});
Schema::create('member_store', function (Blueprint $table) {
$table->id()->uniqid()->comment('主键id');
$table->unsignedBigInteger('member_id')->comment('用户id');
$table->string('name')->nullable()->comment('名称');
$table->string('logo')->nullable()->comment('logo');
$table->string('mobile')->nullable()->comment('电话');
$table->string('area')->nullable()->comment('区域');
$table->string('address')->nullable()->comment('地址');
$table->string('map')->nullable()->comment('地图坐标');
$table->string('license')->nullable()->comment('营业执照');
$table->tinyInteger('status')->default(1)->comment('状态');
$table->timestamp('created_at')->nullable()->comment('创建时间');
$table->timestamp('updated_at')->nullable()->comment('更新时间');
$table->engine = 'InnoDB';
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
$table->comment('会员综合服务体表');
});
}
/**
* Reverse the migrations.
*/
public function down(): void {
Schema::table('member', function (Blueprint $table) {
$table->dropColumn('invite_code');
$table->dropColumn('old_password');
$table->dropColumn('salt');
});
Schema::dropIfExists('member_pm');
Schema::dropIfExists('member_store');
}
};

View File

@@ -1,26 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('member', function (Blueprint $table) {
$table->string('date_type', 10)->default('lunar')->comment('会员生日类型')->after('birthday');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@@ -18,12 +18,12 @@ class EventServiceProvider extends ServiceProvider
* @var array<string, array<int, string>>
*/
protected $listen = [
'Modules\Member\Events\LoginEvent' => [
'Modules\Wechat\Listeners\LoginBind',
],
'Modules\Member\Events\Registered' => [
'Modules\Wechat\Listeners\RegisterBind',
],
// 'Modules\Member\Events\LoginEvent' => [
// 'Modules\Wechat\Listeners\LoginBind',
// ],
// 'Modules\Member\Events\Registered' => [
// 'Modules\Wechat\Listeners\RegisterBind',
// ],
];
/**