|
@@ -2,8 +2,10 @@
|
|
|
|
|
|
namespace General\Services\Report;
|
|
|
|
|
|
+use General\Models\Qapp\QappSendOrders;
|
|
|
use General\Models\Report\ReportUserBindRecord;
|
|
|
use App\Consts\BaseConst;
|
|
|
+use General\Models\User\User;
|
|
|
use GuzzleHttp\Client;
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
@@ -13,32 +15,61 @@ use Illuminate\Support\Collection;
|
|
|
class QappXimalayaReport {
|
|
|
public static function reportCharge(ReportUserBindRecord $user) :array
|
|
|
{
|
|
|
- try{
|
|
|
- $path = $user->link . '&event_type=2';
|
|
|
- myLog('ximalaya-charge-buchuan')->info('充值回传:开始浅层转化目标[event_type=2],uid='. $user->uid);
|
|
|
- $requestResult = self::sendRequest($path);
|
|
|
- if($requestResult['result']) {
|
|
|
- $deepPath = $user->link. '&deep_event_type=1';
|
|
|
- myLog('ximalaya-charge-buchuan')->info('充值回传:开始深层转化目标[deep_event_type=1],uid='. $user->uid);
|
|
|
- $deepRequestResult = self::sendRequest($deepPath);
|
|
|
+
|
|
|
+ $sendOrderId = User::where('id', $user->uid)
|
|
|
+ ->value('send_order_id');
|
|
|
+ $chujiaType = 'paid';
|
|
|
+ if($sendOrderId) {
|
|
|
+ $chujiaType = self::getSendOrderChujiaType($sendOrderId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($chujiaType == 'paid') {
|
|
|
+ try {
|
|
|
+ $path = $user->link . '&event_type=7';
|
|
|
+ myLog('ximalaya-charge-buchuan')->info('充值回传:开始浅层转化目标[event_type=7],uid='. $user->uid);
|
|
|
+ $requestResult = self::sendRequest($path);
|
|
|
+ return [
|
|
|
+ 'result' => $requestResult->get('result', false),
|
|
|
+ 'content' => '',
|
|
|
+ 'query_params' => ['path' => $path],
|
|
|
+ ];
|
|
|
+ }catch (\Exception $exception) {
|
|
|
+ myLog('ximalaya-charge-buchuan')->error('回传充值出现异常:'. $exception->getMessage(), $exception->getTrace());
|
|
|
+ return [
|
|
|
+ 'result' => false,
|
|
|
+ 'content' => '回传充值出现异常',
|
|
|
+ 'query_params' => []
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ } else{
|
|
|
+ try{
|
|
|
+ $path = $user->link . '&event_type=2';
|
|
|
+ myLog('ximalaya-charge-buchuan')->info('充值回传:开始浅层转化目标[event_type=2],uid='. $user->uid);
|
|
|
+ $requestResult = self::sendRequest($path);
|
|
|
+ if($requestResult['result']) {
|
|
|
+ $deepPath = $user->link. '&deep_event_type=1';
|
|
|
+ myLog('ximalaya-charge-buchuan')->info('充值回传:开始深层转化目标[deep_event_type=1],uid='. $user->uid);
|
|
|
+ $deepRequestResult = self::sendRequest($deepPath);
|
|
|
+ return [
|
|
|
+ 'result' => $deepRequestResult->get('result', false),
|
|
|
+ 'content' => '',
|
|
|
+ 'query_params' => ['path' => $path, 'deep_path' => $deepPath],
|
|
|
+ ];
|
|
|
+ }
|
|
|
return [
|
|
|
- 'result' => $deepRequestResult->get('result', false),
|
|
|
+ 'result' => $requestResult->get('result', false),
|
|
|
'content' => '',
|
|
|
- 'query_params' => ['path' => $path, 'deep_path' => $deepPath],
|
|
|
+ 'query_params' => ['path' => $path],
|
|
|
+ ];
|
|
|
+ }catch (\Exception $exception) {
|
|
|
+ myLog('ximalaya-charge-buchuan')->error('回传充值出现异常:'. $exception->getMessage(), $exception->getTrace());
|
|
|
+ return [
|
|
|
+ 'result' => false,
|
|
|
+ 'content' => '回传充值出现异常',
|
|
|
+ 'query_params' => []
|
|
|
];
|
|
|
}
|
|
|
- return [
|
|
|
- 'result' => $requestResult->get('result', false),
|
|
|
- 'content' => '',
|
|
|
- 'query_params' => ['path' => $path],
|
|
|
- ];
|
|
|
- }catch (\Exception $exception) {
|
|
|
- myLog('ximalaya-charge-buchuan')->error('回传充值出现异常:'. $exception->getMessage(), $exception->getTrace());
|
|
|
- return [
|
|
|
- 'result' => false,
|
|
|
- 'content' => '回传充值出现异常',
|
|
|
- 'query_params' => []
|
|
|
- ];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -61,4 +92,15 @@ class QappXimalayaReport {
|
|
|
]);
|
|
|
return collect(compact('result', 'content'));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取喜马拉雅派单的出价方式
|
|
|
+ * @param $sendOrderId
|
|
|
+ * @return mixed|string
|
|
|
+ */
|
|
|
+ private static function getSendOrderChujiaType($sendOrderId) {
|
|
|
+ $extraConfig = QappSendOrders::where('send_order_id', $sendOrderId)
|
|
|
+ ->value('extra_config');
|
|
|
+ return (\json_decode($extraConfig, true))['ximalaya_chujia_type'] ?? 'paid';
|
|
|
+ }
|
|
|
}
|