在读取车辆详情时,自动调用壁虎接口,获取车辆信息和历史保单

dev
曾超新 5 years ago
parent b7125c97ed
commit 156178c503
  1. 1
      frontend/config/params.php
  2. 22
      frontend/controllers/CarController.php

@ -6,5 +6,6 @@ return [
'phone_url' => 'http://user.banmacar.com/api/phone/op', 'phone_url' => 'http://user.banmacar.com/api/phone/op',
'sms_url' => 'http://user.banmacar.com/api/sms/single-send', 'sms_url' => 'http://user.banmacar.com/api/sms/single-send',
'myinfo_url' => 'http://user.banmacar.com/api/user/myinfo', 'myinfo_url' => 'http://user.banmacar.com/api/user/myinfo',
'search_car_url' => 'http://user.banmacar.com/api/car/search-car',
], ],
]; ];

@ -63,6 +63,7 @@ use common\models\OrderAddress;
use common\models\InvalidNew; use common\models\InvalidNew;
use common\models\InvalidRenewal; use common\models\InvalidRenewal;
use common\models\ZhongjiGiftT; use common\models\ZhongjiGiftT;
use GuzzleHttp\Client;
use Yii; use Yii;
use yii\data\Pagination; use yii\data\Pagination;
use yii\db\Exception; use yii\db\Exception;
@ -503,6 +504,27 @@ class CarController extends BaseController
$id = $request->get('id',0); $id = $request->get('id',0);
$car_info = CarT::findOne(['id'=>$id]); $car_info = CarT::findOne(['id'=>$id]);
if($car_info) {
$url = Yii::$app->params['userPanel']['search_car_url'];
$token = Yii::$app->params['userPanel']['token'];
$params = [
'token' => $token,
'LicenseNo' => $car_info->car_no,
'EngineNo' => $car_info->engine_no,
'CarVin' => $car_info->car_frame_no
];
if($car_info->car_man_number != '' && substr($car_info->car_man_number, -6) != '') {
$params['SixDigitsAfterIdCard'] = substr($car_info->car_man_number, -6);
}
$client = new Client(['timeout'=> 120]);
$res = $client->request('POST', $url, [
'form_params' => $params,
'http_errors' => false,
]);
if($res->getStatusCode() == 200) {
$obj = json_decode($res->getBody());
}
}
$order_info = $car_info->getOrders()->orderBy('id DESC')->one(); $order_info = $car_info->getOrders()->orderBy('id DESC')->one();
if(!$order_info) { if(!$order_info) {
$user_id = 0; $user_id = 0;

Loading…
Cancel
Save