修正 Proxied、 SSL/TLS 设为 Flexible、开启 Always Use HTTPS
This commit is contained in:
@@ -17,9 +17,14 @@ class SplitTicketRuleService
|
||||
*/
|
||||
public function applyAfterSync(Ticket $ticket, int $completeCount): void
|
||||
{
|
||||
$this->applyNumberRules($ticket);
|
||||
$this->applyTicketStatusRules($ticket, $completeCount);
|
||||
$this->cascadeTicketClosedToNumbers($ticket);
|
||||
$fresh = Ticket::get((int) $ticket['id']);
|
||||
if ($fresh) {
|
||||
if ((string) $fresh['status'] === 'hidden') {
|
||||
$this->cascadeTicketClosedToNumbers($fresh);
|
||||
}
|
||||
$this->applyNumberRules($fresh);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,23 +46,30 @@ class SplitTicketRuleService
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动切换工单状态时,联动非手动管理的号码(开→全开,关→全关)
|
||||
* 手动切换工单状态时,联动非手动管理的号码
|
||||
*/
|
||||
public function syncNumbersWithTicketStatus(Ticket $ticket): void
|
||||
{
|
||||
$ticketStatus = (string) ($ticket['status'] ?? 'hidden');
|
||||
Number::where('admin_id', (int) $ticket['admin_id'])
|
||||
->where('split_link_id', (int) $ticket['split_link_id'])
|
||||
->where('ticket_name', (string) $ticket['ticket_name'])
|
||||
->where('manual_manage', 0)
|
||||
->update([
|
||||
'status' => $ticketStatus,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
if ($ticketStatus === 'hidden') {
|
||||
$this->cascadeTicketClosedToNumbers($ticket);
|
||||
return;
|
||||
}
|
||||
$this->applyNumberRules($ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单号上限、下号比率
|
||||
* 工单处于开启状态时,将云控在线的非手动号码设为开启
|
||||
*
|
||||
* @deprecated 请使用 applyNumberRules(会校验单号上限/下号比率)
|
||||
*/
|
||||
public function syncOnlineNumbersWhenTicketOpen(Ticket $ticket): void
|
||||
{
|
||||
$this->applyNumberRules($ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单号上限、下号比率、云控在线状态、工单开关综合决定号码状态
|
||||
*/
|
||||
public function applyNumberRules(Ticket $ticket): void
|
||||
{
|
||||
@@ -67,7 +79,6 @@ class SplitTicketRuleService
|
||||
$numbers = Number::where('admin_id', (int) $ticket['admin_id'])
|
||||
->where('split_link_id', (int) $ticket['split_link_id'])
|
||||
->where('ticket_name', (string) $ticket['ticket_name'])
|
||||
->where('manual_manage', 0)
|
||||
->select();
|
||||
|
||||
foreach ($numbers as $number) {
|
||||
@@ -83,31 +94,66 @@ class SplitTicketRuleService
|
||||
$streak = 0;
|
||||
}
|
||||
|
||||
$status = (string) $number['status'];
|
||||
if ($orderLimit > 0 && $inboundCount > $orderLimit) {
|
||||
$status = 'hidden';
|
||||
}
|
||||
if ($assignRatio > 0 && $streak >= $assignRatio) {
|
||||
$status = 'hidden';
|
||||
$update = [
|
||||
'no_inbound_click_streak' => $streak,
|
||||
'last_sync_visit_count' => $visitCount,
|
||||
'last_sync_inbound_count' => $inboundCount,
|
||||
'updatetime' => time(),
|
||||
];
|
||||
|
||||
// 手动管理(含用户手动关闭)的号码:仅更新统计字段,不改状态
|
||||
if ((int) $number['manual_manage'] === 1) {
|
||||
Number::where('id', (int) $number['id'])->update($update);
|
||||
continue;
|
||||
}
|
||||
|
||||
Number::where('id', (int) $number['id'])->update([
|
||||
'no_inbound_click_streak' => $streak,
|
||||
'last_sync_visit_count' => $visitCount,
|
||||
'last_sync_inbound_count' => $inboundCount,
|
||||
'status' => $status,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
$update['status'] = $this->resolveAutomatedStatus(
|
||||
$ticket,
|
||||
(string) ($number['platform_status'] ?? 'unknown'),
|
||||
$inboundCount,
|
||||
$streak,
|
||||
$orderLimit,
|
||||
$assignRatio
|
||||
);
|
||||
|
||||
Number::where('id', (int) $number['id'])->update($update);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成量、时间窗口决定工单开关
|
||||
* 非手动管理号码的自动开关判定
|
||||
*/
|
||||
private function resolveAutomatedStatus(
|
||||
Ticket $ticket,
|
||||
string $platformStatus,
|
||||
int $inboundCount,
|
||||
int $streak,
|
||||
int $orderLimit,
|
||||
int $assignRatio
|
||||
): string {
|
||||
if ((string) ($ticket['status'] ?? 'hidden') !== 'normal') {
|
||||
return 'hidden';
|
||||
}
|
||||
if ($platformStatus !== 'online') {
|
||||
return 'hidden';
|
||||
}
|
||||
if ($orderLimit > 0 && $inboundCount >= $orderLimit) {
|
||||
return 'hidden';
|
||||
}
|
||||
if ($assignRatio > 0 && $streak >= $assignRatio) {
|
||||
return 'hidden';
|
||||
}
|
||||
|
||||
return 'normal';
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成量、时间窗口决定工单开关(定时与手动同步均适用)
|
||||
*/
|
||||
public function applyTicketStatusRules(Ticket $ticket, int $completeCount): void
|
||||
{
|
||||
$status = $this->resolveTicketStatus($ticket, $completeCount);
|
||||
if ($status !== (string) $ticket['status']) {
|
||||
if ($status !== (string) ($ticket['status'] ?? 'hidden')) {
|
||||
Ticket::where('id', (int) $ticket['id'])->update([
|
||||
'status' => $status,
|
||||
'updatetime' => time(),
|
||||
|
||||
Reference in New Issue
Block a user