完整版V1 加入爬虫功能

This commit is contained in:
root
2026-06-09 03:36:30 +08:00
parent 34d76cce74
commit a68b83fcbd
69 changed files with 5058 additions and 56 deletions
@@ -15,6 +15,21 @@ class Number extends Model
{
protected $name = 'split_number';
protected static function init(): void
{
self::beforeInsert(function (self $row): void {
if ((int) ($row['weigh'] ?? 0) > 0) {
return;
}
$linkId = (int) ($row['split_link_id'] ?? 0);
if ($linkId <= 0) {
return;
}
$maxWeigh = (int) self::where('split_link_id', $linkId)->max('weigh');
$row->setAttr('weigh', $maxWeigh + 1);
});
}
protected $autoWriteTimestamp = 'integer';
protected $createTime = 'createtime';
@@ -26,6 +41,7 @@ class Number extends Model
'link_url_text',
'status_text',
'manual_manage_text',
'platform_status_text',
];
/**
@@ -65,6 +81,18 @@ class Number extends Model
];
}
/**
* @return array<string, string>
*/
public function getPlatformStatusList(): array
{
return [
'online' => __('Platform status online'),
'offline' => __('Platform status offline'),
'unknown' => __('Platform status unknown'),
];
}
/**
* 关联分流链接
*/
@@ -123,6 +151,13 @@ class Number extends Model
return $list[$key] ?? $key;
}
public function getPlatformStatusTextAttr($value, $data): string
{
$key = (string) ($data['platform_status'] ?? 'unknown');
$list = $this->getPlatformStatusList();
return $list[$key] ?? $key;
}
/**
* 根据链接码生成完整分流 URL
*/
@@ -127,7 +127,7 @@ class Ticket extends Model
$total = (int) ($data['ticket_total'] ?? 0);
$complete = (int) ($data['complete_count'] ?? 0);
if ($total <= 0) {
return '';
return '0%';
}
$percent = round($complete / $total * 100, 2);
return $percent . '%';
@@ -163,6 +163,9 @@ class Ticket extends Model
if ($status === 'success') {
return sprintf((string) __('Sync display success'), $online);
}
if ($status === 'pending') {
return (string) __('Sync display pending');
}
return (string) __('Sync display error');
}