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
+54
View File
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace app\api\model;
use think\Model;
/**
* 抖音发布日志模型(对应分表 dys_video_log_{userid % 1000}
*
* 该表在 douying 库中按用户取模分表,首页“发布作品”统计需要按原系统规则动态定位表名。
*/
class DysVideoLog extends Model
{
protected $connection = 'dbdouying';
// 仅作为默认占位,真正查询时会按用户ID动态切换分表名。
protected $name = 'dys_video_log_0';
protected $pk = 'id';
protected $autoWriteTimestamp = false;
/**
* 统计当前用户已发布作品数量。
*
* 此处按 acgpmw 首页逻辑对齐,仅统计 status<=1 的发布记录。
*
* @param int $userid 用户ID
* @return int
*/
public static function countPublishedByUserId(int $userid): int
{
$tableName = self::resolveTableName($userid);
return (int) (new self())
->db()
->name($tableName)
->where('userid', $userid)
->where('status', '<=', 1)
->count();
}
/**
* 根据用户ID计算分表名。
*
* @param int $userid 用户ID
* @return string
*/
private static function resolveTableName(int $userid): string
{
return sprintf('dys_video_log_%d', $userid % 1000);
}
}