Browse Source

fire report

zz 4 years ago
parent
commit
52955f6f47
2 changed files with 89 additions and 0 deletions
  1. 51 0
      app/Jobs/AsyncOrderStats.php
  2. 38 0
      app/Jobs/AsyncUserRegister.php

+ 51 - 0
app/Jobs/AsyncOrderStats.php

@@ -51,6 +51,8 @@ class AsyncOrderStats implements ShouldQueue
         $this->bookChargeStats();
         //订单上报给渠道
         $this->reportToChannel();
+
+        $this->fireOrderReport();
     }
 
     private function init()
@@ -133,4 +135,53 @@ class AsyncOrderStats implements ShouldQueue
        ]);
    }
 
+
+    private function fireOrderReport(){
+        if ($this->order_info->status != 'PAID') return;
+        $client = new Client();
+        $reportData = [
+            'platform' => 'wangduyun',
+            'order'     => [
+                'uid'        => getProp($this->order_info, 'uid'),
+                'order_no'   => getProp($this->order_info, 'trade_no'),
+                'price'      => getProp($this->order_info, 'price'),
+                'channel_id' => getProp($this->order_info, 'distribution_channel_id'),
+                'pay_time'   => getProp($this->order_info, 'pay_end_at'),
+                'order_created_at'   => $this->order_info->created_at->format('Y-m-d H:i:s'),
+                'order_type'=>  getProp($this->order_info, 'order_type'),
+                'from_bid'=>    getProp($this->order_info, 'from_bid'),
+                'pay_type'=>	getProp($this->order_info, 'pay_type')
+            ]
+        ];
+        $record = [
+            'uid'=>$reportData['order']['uid'],
+            'trade_no'=>$reportData['order']['order_no'],
+            'price'=>$reportData['order']['price'],
+            'distribution_channel_id'=>$reportData['order']['channel_id'],
+            'pay_time'=>$reportData['order']['pay_time'],
+            'msg'=>'',
+            'status'=>0,
+            'created_at'=>date('Y-m-d H:i:s'),
+            'updated_at'=>date('Y-m-d H:i:s'),
+        ];
+        $host = 'https://firetrack.wd.amanbook.com';
+        try{
+            // 执行上报
+            $result = $client->post($host . '/api/reportOrder', [
+                'headers' => [
+                    'x-code' => 'Mvnx1Yr3O8i!TS5u'
+                ],
+                'json'    => $reportData
+            ]);
+            $record['msg'] = $result->getBody()->getContents();
+            $record['status'] = 1;
+        }catch (\Exception $e){
+            $record['status'] = 2;
+            $record['msg'] = '';
+        }
+        try{
+            DB::table('fire_order_report_record')->insert($record);
+        }catch (\Exception $e){}
+    }
+
 }

+ 38 - 0
app/Jobs/AsyncUserRegister.php

@@ -51,6 +51,7 @@ class AsyncUserRegister implements ShouldQueue
     public function handle()
     {
         $this->reportToChannel();
+        $this->fireRegisterReport();
     }
 
     private function reportToChannel(){
@@ -87,5 +88,42 @@ class AsyncUserRegister implements ShouldQueue
         ]);
     }
 
+    private function fireRegisterReport(){
+
+        $client = new Client();
+        $ip = $this->register_ip;
+        $register_time = $this->user_created_at;
+        $reportData = [
+            'platform' => 'wangduyun',
+            'register'     => [
+                'uid'           => $this->uid,
+                'channel_id'    => $this->distribution_channel_id,
+                'register_time' => $register_time,
+                'register_ip' => $ip,
+            ]
+        ];
+        $record = [
+            'uid'=>$this->uid,
+            'ip'=>$ip,
+            'register_time'=>$register_time,
+            'created_at'=>date('Y-m-d H:i:s'),
+            'updated_at'=>date('Y-m-d H:i:s'),
+        ];
+        $host = 'https://firetrack.wd.amanbook.com';
+        try{
+            // 执行上报
+            $client->post($host . '/api/reportRegister', [
+                'headers' => [
+                    'x-code' => 'Mvnx1Yr3O8i!TS5u'
+                ],
+                'json'    => $reportData
+            ]);
+
+        }catch (\Exception $e){
+            $record['status'] = 2;
+            DB::table('fire_user_report_record')->insert($record);
+        }
+
+    }
 
 }