|
@@ -53,7 +53,13 @@ class ReportService
|
|
|
// 判断是否是次留回传
|
|
|
if ($registerYmd === $activeYmd && $todayYmd === $registerNextYmd) {
|
|
|
myLog('reportSActive')->info('', compact('uid', 'registerYmd'));
|
|
|
- self::report($userCache);
|
|
|
+ self::report('/api/reportSActive', [
|
|
|
+ 'uid' => getProp($userCache, 'uid'),
|
|
|
+ 'channel_id' => getProp($userCache, 'channel_id'),
|
|
|
+ 'register_time' => getProp($userCache, 'register_time'),
|
|
|
+ 'active_time' => getProp($userCache, 'active_time'),
|
|
|
+ 'platform' => 'zhuishuyun',
|
|
|
+ ]);
|
|
|
}
|
|
|
|
|
|
// 更新用户活跃时间
|
|
@@ -61,26 +67,69 @@ class ReportService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @param $user
|
|
|
+ * @return ResponseInterface
|
|
|
+ */
|
|
|
+ public static function reportRegister($user)
|
|
|
+ {
|
|
|
+ return self::report('/api/reportRegister', [
|
|
|
+ 'platform' => 'zhuishuyun',
|
|
|
+ 'register' => [
|
|
|
+ 'uid' => $user->id,
|
|
|
+ 'channel_id' => $user->channel_id,
|
|
|
+ 'register_time' => $user->created_at->format('Y-m-d H:i:s'),
|
|
|
+ 'register_ip' => $user->register_ip,
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param $order
|
|
|
+ * @return false|ResponseInterface
|
|
|
+ */
|
|
|
+ public static function reportRecharge($order)
|
|
|
+ {
|
|
|
+ $channelId = getProp($order, 'distribution_channel_id');
|
|
|
+ if (empty($channelId)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::report('/api/reportOrder', [
|
|
|
+ 'platform' => 'zhuishuyun',
|
|
|
+ 'order' => [
|
|
|
+ 'uid' => getProp($order, 'uid'),
|
|
|
+ 'order_no' => getProp($order, 'trade_no'),
|
|
|
+ 'price' => getProp($order, 'price'),
|
|
|
+ 'channel_id' => $channelId,
|
|
|
+ 'pay_time' => getProp($order, 'pay_end_at'),
|
|
|
+ 'order_created_at' => $order->created_at->format('Y-m-d H:i:s')
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 上报
|
|
|
- * @param $userCache
|
|
|
+ * @param $uri
|
|
|
+ * @param $data
|
|
|
* @return ResponseInterface
|
|
|
*/
|
|
|
- private static function report($userCache)
|
|
|
+ private static function report($uri, $data)
|
|
|
{
|
|
|
$client = new Client(['timeout' => 3, 'verify' => false]);
|
|
|
|
|
|
// 执行上报
|
|
|
- return $client->post(env('REPORT_URI') . '/api/reportSActive', [
|
|
|
+ $url = env('REPORT_URI') . $uri;
|
|
|
+ $result = $client->post($url, [
|
|
|
'headers' => [
|
|
|
'x-code' => 'Mvnx1Yr3O8i!TS5u'
|
|
|
],
|
|
|
- 'json' => [
|
|
|
- 'uid' => getProp($userCache, 'uid'),
|
|
|
- 'channel_id' => getProp($userCache, 'channel_id'),
|
|
|
- 'register_time' => getProp($userCache, 'register_time'),
|
|
|
- 'active_time' => getProp($userCache, 'active_time'),
|
|
|
- 'platform' => 'zhuishuyun',
|
|
|
- ]
|
|
|
+ 'json' => $data
|
|
|
]);
|
|
|
+ $statusCode = $result->getStatusCode();
|
|
|
+ $contentJson = $result->getBody()->getContents();
|
|
|
+ $contentArr = json_decode($contentJson, true);
|
|
|
+ myLog('report')->info($uri, compact('data', 'statusCode', 'contentArr'));
|
|
|
+
|
|
|
+ return $contentArr;
|
|
|
}
|
|
|
}
|