refactor(member, auth): streamline product info retrieval and enhance dashboard statistics

- Updated `getProductInfo` method in `Member` model to use a unified model for fetching product data.
- Refactored `logLogin` method to utilize `MemberLoginLog` for logging login attempts.
- Introduced `getDashboardStats` method in `AuthService` to gather user-specific statistics, including remaining quotas and counts of authorized accounts, published tasks, and works.
- Added new database configuration for Douyin business statistics.
This commit is contained in:
nepiedg
2026-04-02 07:09:29 +00:00
parent 7dbd84ea98
commit 6b46767d86
8 changed files with 281 additions and 19 deletions
+14 -19
View File
@@ -95,13 +95,10 @@ class Member extends Model
*/
public function getProductInfo(): ?array
{
// 从主库获取套餐信息
$product = \think\facade\Db::connect('dbbiz')
->name('product_list')
->where('v_type', $this->v_type)
->find();
// 套餐配置改由模型统一封装,避免业务层散落裸表查询。
$product = ProductList::findByVType((int) $this->v_type);
return $product;
return $product ? $product->toArray() : null;
}
/**
@@ -126,19 +123,17 @@ class Member extends Model
public function logLogin(bool $success, string $loginType = 'password'): void
{
try {
\think\facade\Db::connect('dbmember')
->name('member_login_log')
->insert([
'userid' => $this->userid,
'ip' => request()->ip(),
'time' => time(),
'succeed' => $success ? 1 : 0,
'diqu' => '',
'login_type' => $loginType,
'adminid' => 0,
'v_type' => $this->v_type ?? 0,
]);
} catch (\Exception $e) {
MemberLoginLog::recordLogin([
'userid' => $this->userid,
'ip' => request()->ip(),
'time' => time(),
'succeed' => $success ? 1 : 0,
'diqu' => '',
'login_type' => $loginType,
'adminid' => 0,
'v_type' => $this->v_type ?? 0,
]);
} catch (\Throwable $e) {
// 日志记录失败不影响登录
}
}