|
@@ -21,7 +21,6 @@ class JLEventReportChargeService
|
|
|
private $trackRecord;
|
|
|
private $callbackConfig;
|
|
|
private $promotion;
|
|
|
- private $rateConfig;
|
|
|
private $configLog;
|
|
|
public function __construct($uid, $order, $traceInfo)
|
|
|
{
|
|
@@ -164,60 +163,26 @@ class JLEventReportChargeService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ $newConfigLog = DB::table('jl_event_rate_config_log')
|
|
|
+ ->where(['id' => $this->configLog->id])
|
|
|
+ ->select('report_count', 'unreport_count')
|
|
|
+ ->first();
|
|
|
+ if(($newConfigLog->report_count ?? 0 ) + ($newConfigLog->unreport_count ?? 0 )) {
|
|
|
+ $currentRate = bcdiv(($newConfigLog->report_count ?? 0 ) * 100,
|
|
|
+ (($newConfigLog->report_count ?? 0 ) + ($newConfigLog->unreport_count ?? 0 )), 2);
|
|
|
+ } else {
|
|
|
+ $currentRate = 0;
|
|
|
+ }
|
|
|
+ DB::table('callback_report_charge_record')->where([
|
|
|
+ 'order_no' => $this->order->trade_no
|
|
|
+ ])->update([
|
|
|
+ 'current_rate' => $currentRate,
|
|
|
+ ]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- * 判断回传比例
|
|
|
- */
|
|
|
- private function judgeCallbackRate(){
|
|
|
- if(!$this->result['need_report']) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if(!$this->result['continue_judge']) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $this->rateConfig = DB::table('juliang_account_rate_config_log')
|
|
|
- ->where(['company_uid' => $this->promotion->uid,
|
|
|
- 'account_id' => $this->trackRecord->advertiser_id, 'is_enabled' => 1])
|
|
|
- ->first();
|
|
|
- if(!$this->rateConfig) {
|
|
|
- $this->result['need_report'] = false;
|
|
|
- $this->result['info_type'] = 'no_rate_config';
|
|
|
- $this->result['info_str'] = '没有可用的回传比率设置';
|
|
|
- return;
|
|
|
- }
|
|
|
- $configRate = $this->rateConfig->config_per;
|
|
|
- if(0 == $configRate) {
|
|
|
- $this->result['need_report'] = false;
|
|
|
- $this->result['info_type'] = 'rate_eq_0';
|
|
|
- $this->result['info_str'] = '设定比例为0不执行回传';
|
|
|
- return;
|
|
|
- }
|
|
|
- $currentTotalCount = $this->rateConfig->total_count;
|
|
|
- $currentReportCount = $this->rateConfig->report_count;
|
|
|
- if(0 == $currentTotalCount) {
|
|
|
- $currentRate = 0;
|
|
|
- } else {
|
|
|
- $currentRate = min(1, round($currentReportCount / $currentTotalCount, 4)) * 100;
|
|
|
- }
|
|
|
- if($currentRate <= $configRate) {
|
|
|
- $this->result['need_report'] = true;
|
|
|
- $this->result['config_rate'] = $configRate;
|
|
|
- $this->result['current_rate'] = $currentRate;
|
|
|
- } else {
|
|
|
- $this->result['need_report'] = false;
|
|
|
- $this->result['info_type'] = 'rate_filter';
|
|
|
- $this->result['info_str'] = '比率过滤';
|
|
|
- $this->result['config_rate'] = $configRate;
|
|
|
- $this->result['current_rate'] = $currentRate;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
* 判断订单是不是已经处理过了.如果处理过了,就不入库
|
|
|
*/
|
|
|
private function judgeOrderAlreadyDeal() {
|
|
@@ -274,12 +239,11 @@ class JLEventReportChargeService
|
|
|
if($this->configLog->flag) {
|
|
|
$this->configLog->flag_report++;
|
|
|
} else {
|
|
|
- $this->configLog->flag_unport++;
|
|
|
+ $this->configLog->flag_unreport++;
|
|
|
$this->result['continue_judge'] = false;
|
|
|
$this->result['need_report'] = false;
|
|
|
$this->result['info_type'] = 'rate_filter';
|
|
|
- $this->result['info_str'] = sprintf('当前配置传%s卡%s,本轮已传:%s,已卡%s', $sm[0], $sm[1],
|
|
|
- $this->configLog->flag_report, $this->configLog->flag_unport);
|
|
|
+ $this->result['info_str'] = '比率过滤';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -295,7 +259,7 @@ class JLEventReportChargeService
|
|
|
$obj->flag = 0;
|
|
|
}
|
|
|
} else {
|
|
|
- if(($obj->unreport) < $m) {
|
|
|
+ if(($obj->flag_unreport) < $m) {
|
|
|
$obj->flag = 0;
|
|
|
} else {
|
|
|
$obj->flag_unreport = 0;
|
|
@@ -359,9 +323,16 @@ class JLEventReportChargeService
|
|
|
return;
|
|
|
}
|
|
|
$service = new TiktokEventReportService;
|
|
|
- $reportResult = $service->reportCharge((object)[
|
|
|
- 'callback' => $this->trackRecord->callback
|
|
|
- ]);
|
|
|
+ if('roi_report_all' == $this->result['info_type']) {
|
|
|
+ $reportResult = $service->roiReportCharge((object)[
|
|
|
+ 'callback' => $this->trackRecord->callback
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ $reportResult = $service->reportCharge((object)[
|
|
|
+ 'callback' => $this->trackRecord->callback
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
$reportContent = \json_decode($reportResult['content'], true);
|
|
|
if($reportResult['result'] && 0 == $reportContent['code']) {
|
|
|
$this->result['report_success'] = true;
|