Commit f26a1d2b authored by 刘小敏's avatar 刘小敏

fix(xhs-ad): 修复转化接口改用客户端传入click_id

parent e56e6914
...@@ -84,7 +84,7 @@ class XhsAd extends Common ...@@ -84,7 +84,7 @@ class XhsAd extends Common
$this->error('请求方式错误'); $this->error('请求方式错误');
} }
$params = $this->request->only(['conversion_type', 'value', 'order_id']); $params = $this->request->only(['click_id', 'conversion_type', 'value', 'order_id']);
$this->svalidate($params, '.conversion'); $this->svalidate($params, '.conversion');
$user = auth_user(); $user = auth_user();
...@@ -97,28 +97,20 @@ class XhsAd extends Common ...@@ -97,28 +97,20 @@ class XhsAd extends Common
$this->error('用户未登录'); $this->error('用户未登录');
} }
$clickId = $params['click_id'];
$conversionType = $params['conversion_type']; $conversionType = $params['conversion_type'];
$value = floatval($params['value'] ?? 0); $value = floatval($params['value'] ?? 0);
$orderId = $params['order_id'] ?? ''; $orderId = $params['order_id'] ?? '';
// 查询有效追踪记录 // 查询有效追踪记录(用于关联 tracking_id)
$tracking = AdTrackingModel::getValidByUser($userId); $tracking = AdTrackingModel::getValidByUser($userId);
$clickId = ''; $trackingId = $tracking ? $tracking->id : 0;
$trackingId = 0; $status = ConversionLogModel::STATUS_PENDING;
$status = ConversionLogModel::STATUS_NO_TRACK;
// 去重检查
if ($tracking) { if (ConversionLogModel::isDuplicated($clickId, $conversionType, $orderId)) {
$clickId = $tracking->click_id; custom_log('[xhs.conversion] 重复转化,拒绝记录, click_id=' . $clickId . ', type=' . $conversionType . ', order=' . $orderId, $userId, 'xhs_ad', 'warning');
$trackingId = $tracking->id; $this->error('该转化事件已记录,请勿重复提交');
$status = ConversionLogModel::STATUS_PENDING;
// 去重检查
if (ConversionLogModel::isDuplicated($clickId, $conversionType, $orderId)) {
custom_log('[xhs.conversion] 重复转化,拒绝记录, click_id=' . $clickId . ', type=' . $conversionType . ', order=' . $orderId, $userId, 'xhs_ad', 'warning');
$this->error('该转化事件已记录,请勿重复提交');
}
} else {
custom_log('[xhs.conversion] 无有效追踪记录,记录为无需回传, user_id=' . $userId, $userId, 'xhs_ad', 'warning');
} }
$now = time(); $now = time();
......
...@@ -30,6 +30,6 @@ class XhsAd extends Validate ...@@ -30,6 +30,6 @@ class XhsAd extends Validate
protected $scene = [ protected $scene = [
'track' => ['click_id', 'request_id', 'event_type', 'landing_page'], 'track' => ['click_id', 'request_id', 'event_type', 'landing_page'],
'conversion' => ['conversion_type', 'value', 'order_id'], 'conversion' => ['click_id', 'conversion_type', 'value', 'order_id'],
]; ];
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment