朋友圈内容库优化
This commit is contained in:
@@ -85,6 +85,7 @@ class WorkbenchMomentsJob
|
||||
|
||||
// 获取设备
|
||||
$devices = $this->getDevice($workbench, $config);
|
||||
|
||||
if (empty($devices)) {
|
||||
continue;
|
||||
}
|
||||
@@ -94,7 +95,6 @@ class WorkbenchMomentsJob
|
||||
if (empty($contentLibrary)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 处理内容发送
|
||||
$this->handleContentSend($workbench, $config, $devices, $contentLibrary);
|
||||
}
|
||||
@@ -234,27 +234,30 @@ class WorkbenchMomentsJob
|
||||
|
||||
$newList = [];
|
||||
foreach ($list as $val) {
|
||||
// 检查今日发送次数
|
||||
// 检查发送间隔(新逻辑:根据startTime、endTime、syncCount动态计算)
|
||||
$today = date('Y-m-d');
|
||||
$startTimestamp = strtotime($today . ' ' . $config['startTime'] . ':00');
|
||||
$endTimestamp = strtotime($today . ' ' . $config['endTime'] . ':00');
|
||||
$totalSeconds = $endTimestamp - $startTimestamp;
|
||||
if ($totalSeconds <= 0 || empty($config['syncCount'])) {
|
||||
continue;
|
||||
}
|
||||
$interval = floor($totalSeconds / $config['syncCount']);
|
||||
|
||||
// 查询今日已同步次数
|
||||
$count = Db::name('workbench_moments_sync_item')
|
||||
->where('workbenchId', $workbench->id)
|
||||
->where('deviceId', $val['deviceId'])
|
||||
->whereTime('createTime', 'between', [
|
||||
strtotime(date('Y-m-d') . '00:00:00'),
|
||||
strtotime(date('Y-m-d') . '23:59:59')
|
||||
])->count();
|
||||
->whereTime('createTime', 'between', [$startTimestamp, $endTimestamp])
|
||||
->count();
|
||||
|
||||
if ($count >= $config['syncCount']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查发送间隔
|
||||
$prevSend = Db::name('workbench_moments_sync_item')
|
||||
->where('workbenchId', $workbench->id)
|
||||
->where('deviceId', $val['deviceId'])
|
||||
->order('createTime DESC')
|
||||
->find();
|
||||
|
||||
if (!empty($prevSend) && ($prevSend['createTime'] + $config['syncInterval'] * 60) > time()) {
|
||||
// 计算本次同步的最早允许时间
|
||||
$nextSyncTime = $startTimestamp + $count * $interval;
|
||||
if (time() < $nextSyncTime) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user