更新
This commit is contained in:
@@ -93,6 +93,13 @@ class QywxCustomerAcquisitionCustomerService
|
||||
'event_time' => $eventTime,
|
||||
'snapshot' => $message,
|
||||
], false);
|
||||
self::recordPromotionAssignment(
|
||||
(string) ($message['State'] ?? $message['state'] ?? ''),
|
||||
$remoteLinkId,
|
||||
$userId,
|
||||
$externalUserId,
|
||||
$eventTime
|
||||
);
|
||||
self::finishEvent($eventId, 1, '', $remoteLinkId, $externalUserId, $userId);
|
||||
|
||||
return ['duplicate' => false, 'status' => 'success'];
|
||||
@@ -126,6 +133,13 @@ class QywxCustomerAcquisitionCustomerService
|
||||
'event_time' => $eventTime,
|
||||
'snapshot' => $chat,
|
||||
], true);
|
||||
self::recordPromotionAssignment(
|
||||
(string) ($chatInfo['state'] ?? $message['State'] ?? ''),
|
||||
$remoteLinkId,
|
||||
$userId,
|
||||
$externalUserId,
|
||||
$eventTime
|
||||
);
|
||||
self::finishEvent($eventId, 1, '', $remoteLinkId, $externalUserId, $userId);
|
||||
|
||||
return ['duplicate' => false, 'status' => 'success'];
|
||||
@@ -419,6 +433,40 @@ class QywxCustomerAcquisitionCustomerService
|
||||
return [$adminId, $deptId];
|
||||
}
|
||||
|
||||
private static function recordPromotionAssignment(
|
||||
string $state,
|
||||
string $remoteLinkId,
|
||||
string $userId,
|
||||
string $externalUserId,
|
||||
int $eventTime
|
||||
): void {
|
||||
$result = QywxPromotionMemberSchedulerService::recordFromState(
|
||||
$state,
|
||||
$userId,
|
||||
$externalUserId,
|
||||
$eventTime,
|
||||
'customer_acquisition'
|
||||
);
|
||||
if ((int) ($result['pool_id'] ?? 0) <= 0) {
|
||||
$result = QywxPromotionMemberSchedulerService::recordFromRemoteLink(
|
||||
$remoteLinkId,
|
||||
$userId,
|
||||
$externalUserId,
|
||||
$eventTime,
|
||||
'customer_acquisition'
|
||||
);
|
||||
}
|
||||
if (($result['status'] ?? '') !== 'counted' || (int) ($result['pool_id'] ?? 0) <= 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 优先在本次回调完成后切换,后台分钟任务继续承担失败重试。
|
||||
(new QywxPromotionRangeSyncService())->syncPool((int) $result['pool_id']);
|
||||
} catch (\Throwable) {
|
||||
// 同步服务已经保存失败原因和下次重试时间,不能让远端网络错误回滚已记账的客户。
|
||||
}
|
||||
}
|
||||
|
||||
private static function encodeJson(mixed $value): string
|
||||
{
|
||||
$json = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
|
||||
Reference in New Issue
Block a user