|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
use App\Consts\SysConsts;
|
|
|
+use App\Modules\Trade\Models\OceanengineReportRateConfig;
|
|
|
use GuzzleHttp\Client;
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
@@ -11,6 +12,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
use App\Modules\Trade\Models\Order;
|
|
|
use App\Modules\User\Models\User;
|
|
|
+use Redis;
|
|
|
|
|
|
/**
|
|
|
* 抖音用户推送数据
|
|
@@ -67,6 +69,9 @@ class TikTokUserCharge implements ShouldQueue
|
|
|
$order = Order::where('uid', $this->uid)->where('status', 'PAID')->orderBy('id', 'desc')->first();
|
|
|
$current_day_register = date('Y-m-d', strtotime($order->created_at)) == date('Y-m-d', strtotime($user->created_at));
|
|
|
if ($order && $current_day_register && $order->price >= 30) {
|
|
|
+ if(!$this->reportRate($user->distribution_channel_id)){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
$count = Order::where('uid', $this->uid)->where('status', 'PAID')->where('price', '>=', '30')->count();
|
|
|
if ($count == 1) {
|
|
|
} else {
|
|
@@ -75,7 +80,7 @@ class TikTokUserCharge implements ShouldQueue
|
|
|
} else {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
|
|
|
$url = 'https://newtrackapi.zhuishuyun.com/api/user/tiktokUserChargePush';
|
|
|
$response = $client->request('post', $url, ['form_params' => $params])->getBody()->getContents();
|
|
@@ -87,4 +92,40 @@ class TikTokUserCharge implements ShouldQueue
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private function reportRate($channel_id){
|
|
|
+ //OceanengineRechargeRecord::
|
|
|
+ $rate = Redis::hget('channel:setting:'.$channel_id,'orange_site_report_rate');
|
|
|
+ $rate = (int)$rate;
|
|
|
+ if(!$rate || $rate == 100){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ $config = OceanengineReportRateConfig::where('channel_id',$channel_id)->first();
|
|
|
+ if(!$config){
|
|
|
+ OceanengineReportRateConfig::create(['channel_id'=>$channel_id,'report_rate'=>$rate,'report_num'=>1,'report_success_num'=>1]);
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ if($config->report_rate == $rate){
|
|
|
+ $now_report_num = $config->report_num+1;
|
|
|
+ $now_rate = round($config->report_success_num/$now_report_num,4)*100;
|
|
|
+ if($now_rate <= $rate){
|
|
|
+ $config->report_num = $config->report_num+1;
|
|
|
+ $config->report_success_num = $config->report_success_num+1;
|
|
|
+ $config->save();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ $config->report_num = $config->report_num+1;
|
|
|
+ $config->save();
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ $config->report_rate = $rate;
|
|
|
+ $config->report_num = 1;
|
|
|
+ $config->report_success_num = 1;
|
|
|
+ $config->save();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|