- 新增违规字典表 store_violation_rules 与推送日志表 store_violation_push_logs;统一表增加预警派生字段(迁移,全部可空带索引) - 预警计算:按平台+违规类型匹配字典(去括号后 相等/前缀/分词/宽松/关键词),匹配不到=不提醒;责任人取店铺账号镜像运营负责人并回退店铺档案;处理截止=申诉截止优先,否则级别天数(P0+1/P1+2/P2+3,当天23:59:59) - 页面:新增预警级别(红/橙/绿标签)、责任人、处理截止、是否超时、推送状态5列;级别/责任人(含我的待办)/超时筛选;默认视图(需提醒&未处理)与全部数据切换;行内 认领/完成/忽略(忽略必填原因) - 处理状态扩为 未处理/处理中/处理完成/已忽略,导入兼容旧值(已处理/无需处理) - 新增「预览统计」页面:平台Tab联动 + 4张KPI卡(今日新增/待处理/P0未处理/已超时)+ 需提醒未处理预览列表与认领 - 群推送先留接口:P0/P1 每天09:00起每5分钟即时推送(责任人、处理建议、去认领签名链接);P2每日10:00汇总(含超时未认领点名);防重与推送日志;新命令 push-instant/push-digest - 同步与导入自动计算派生字段;新增 store-violations:recalc-alerts 重算命令;生产 cron 已登记推送任务 - 测试:StoreViolation 系列 + 部署调度 + 导航 共42项/453断言通过
59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
||
|
||
namespace Modules\EcommerceFinance\Repositories;
|
||
|
||
use Illuminate\Database\Connection;
|
||
use Illuminate\Support\Facades\DB;
|
||
use Illuminate\Support\Facades\Schema;
|
||
|
||
/**
|
||
* 店铺违规信息预警:违规字典(store_violation_rules,business_mirror)。
|
||
*/
|
||
class StoreViolationRuleRepository
|
||
{
|
||
public const TABLE = 'store_violation_rules';
|
||
|
||
private Connection $connection;
|
||
|
||
public function __construct()
|
||
{
|
||
$this->connection = DB::connection((string) config('upstream_mirrors.connection', 'business_mirror'));
|
||
}
|
||
|
||
public function available(): bool
|
||
{
|
||
return Schema::connection($this->connection->getName())->hasTable(self::TABLE);
|
||
}
|
||
|
||
/** @return list<array<string,mixed>> 启用中的规则,按 sort、id 升序 */
|
||
public function activeRules(): array
|
||
{
|
||
if (! $this->available()) {
|
||
return [];
|
||
}
|
||
|
||
return $this->connection->table(self::TABLE)
|
||
->where('enabled', true)
|
||
->orderBy('sort')
|
||
->orderBy('id')
|
||
->get()
|
||
->map(static fn (object $row): array => (array) $row)
|
||
->all();
|
||
}
|
||
|
||
/** @return list<array<string,mixed>> 全部规则(后台维护用),按 sort、id 升序 */
|
||
public function all(): array
|
||
{
|
||
if (! $this->available()) {
|
||
return [];
|
||
}
|
||
|
||
return $this->connection->table(self::TABLE)
|
||
->orderBy('sort')
|
||
->orderBy('id')
|
||
->get()
|
||
->map(static fn (object $row): array => (array) $row)
|
||
->all();
|
||
}
|
||
}
|