|
@@ -20,18 +20,19 @@ class UserRententionJob implements ShouldQueue
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
protected $uid;
|
|
|
-
|
|
|
- protected $time;
|
|
|
+ protected $read_time;
|
|
|
+ protected $register_time;
|
|
|
|
|
|
/**
|
|
|
* Create a new job instance.
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function __construct(int $uid, string $time)
|
|
|
+ public function __construct(int $uid, string $read_time, string $register_time)
|
|
|
{
|
|
|
$this->uid = $uid;
|
|
|
- $this->time = $time;
|
|
|
+ $this->read_time = $read_time;
|
|
|
+ $this->register_time = $register_time;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -41,33 +42,29 @@ class UserRententionJob implements ShouldQueue
|
|
|
*/
|
|
|
public function handle()
|
|
|
{
|
|
|
- $user = User::find($this->uid);
|
|
|
- $date = date('Y-m-d', strtotime($this->time));
|
|
|
- $is_next_day = date('Y-m-d', strtotime($user->created_at)) == date('Y-m-d', strtotime('-1 days', strtotime($this->time)));
|
|
|
- if ($is_next_day) {
|
|
|
- $exists = QappUserRententionLog::where('uid', $this->uid)->exists();
|
|
|
- if ($exists) {
|
|
|
- return;
|
|
|
- }
|
|
|
- $client = new Client();
|
|
|
- $params = [
|
|
|
- 'uid' => $this->uid,
|
|
|
- 'source' => 'zsy'
|
|
|
- ];
|
|
|
- $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
|
|
|
- $url = 'https://newtrackapi.zhuishuyun.com/api/qappuser/rentention';
|
|
|
- $response = $client->post($url, ['form_params' => $params])->getBody()->getContents();
|
|
|
- myLog('new_user_rentention')->info($response);
|
|
|
- $result = json_decode($response);
|
|
|
- if ($result) {
|
|
|
- if ($result->code == 0) {
|
|
|
- QappUserRententionLog::create([
|
|
|
- 'date' => $date,
|
|
|
- 'uid' => $this->uid,
|
|
|
- 'register_time' => $user->created_at,
|
|
|
- 'read_time' => $this->time,
|
|
|
- ]);
|
|
|
- }
|
|
|
+ $date = date('Y-m-d', strtotime($this->read_time));
|
|
|
+ $exists = QappUserRententionLog::where('uid', $this->uid)->exists();
|
|
|
+ if ($exists) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $client = new Client();
|
|
|
+ $params = [
|
|
|
+ 'uid' => $this->uid,
|
|
|
+ 'source' => 'zsy'
|
|
|
+ ];
|
|
|
+ $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
|
|
|
+ $url = 'https://newtrackapi.zhuishuyun.com/api/qappuser/rentention';
|
|
|
+ $response = $client->post($url, ['form_params' => $params])->getBody()->getContents();
|
|
|
+ myLog('new_user_rentention')->info($response);
|
|
|
+ $result = json_decode($response);
|
|
|
+ if ($result) {
|
|
|
+ if ($result->code == 0) {
|
|
|
+ QappUserRententionLog::create([
|
|
|
+ 'date' => $date,
|
|
|
+ 'uid' => $this->uid,
|
|
|
+ 'register_time' => $this->register_time,
|
|
|
+ 'read_time' => $this->read_time,
|
|
|
+ ]);
|
|
|
}
|
|
|
}
|
|
|
}
|