6b46767d86
- 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.
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?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);
|
||
}
|
||
}
|