添加获取报价功能

dev
曾超新 5 years ago
parent 1600836b49
commit c0ca220828
  1. 4
      frontend/config/params.php
  2. 206
      frontend/controllers/CarController.php
  3. 32
      frontend/views/car/order-add.php

@ -7,6 +7,8 @@ return [
'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', 'search_car_url' => 'http://user.banmacar.com/api/car/search-car',
'car_info_url' => 'http://user.banmacar.com/api/car/car-info' 'car_info_url' => 'http://user.banmacar.com/api/car/car-info',
'post-precise-price' => 'http://user.banmacar.com/api/car/post-precise-price',
'get-precise-price' => 'http://user.banmacar.com/api/car/get-precise-price',
], ],
]; ];

@ -67,6 +67,7 @@ use GuzzleHttp\Client;
use Yii; use Yii;
use yii\data\Pagination; use yii\data\Pagination;
use yii\db\Exception; use yii\db\Exception;
use yii\web\Request;
use yii\web\Response; use yii\web\Response;
class CarController extends BaseController class CarController extends BaseController
@ -565,6 +566,211 @@ class CarController extends BaseController
return MyLib::error3('车辆信息不存在'); return MyLib::error3('车辆信息不存在');
} }
public function actionPostPrecisePrice()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$url = Yii::$app->params['userPanel']['post-precise-price'];
$token = Yii::$app->params['userPanel']['token'];
$types = $request->post('types');
$nopays = $request->post('nopays');
$params = [
'token' => $token,
'LicenseNo' => $request->post('car_no'),
'CarOwnersName' => $request->post('car_man'),
'IdCard' => strtoupper($request->post('car_man_number')),
'OwnerIdCardType' => $request->post('car_man_type'), //
'QuoteGroup' => $request->post('company_id'), //
'InsuredName' => $request->post('id_man'),
'InsuredIdCard' => strtoupper($request->post('id_man_number')),
'InsuredIdType' => $request->post('id_man_type'), //
'HolderIdCard' => strtoupper($request->post('link_man_number')),
'HolderName' => $request->post('link_man'),
'HolderIdType' => $request->post('link_man_type'), //
'CarUsedType' => $request->post('car_use_id'),
'EngineNo' => strtoupper($request->post('engine_no')),
'CarVin' => strtoupper($request->post('car_frame_no')),
'RegisterDate' => $request->post('register_date'),
'MoldName' => $request->post('factory_model'),
'ForceTax' => 1,
'BizTimeStamp' => $request->post('insurer1_begin_date'),
'ForceTimeStamp' => $request->post('insurer2_begin_date'),
'BoLi' => $types[6] == '否' ? 0 : $types[6] == '国产' ? 1 : 2,
'BuJiMianCheSun' => isset($nopays[1])?1:0,
'BuJiMianDaoQiang' => isset($nopays[3])?1:0,
'BuJiMianSanZhe' => isset($nopays[2])?1:0,
'BuJiMianChengKe' => isset($nopays[5])?1:0,
'BuJiMianSiJi' => isset($nopays[4])?1:0,
'BuJiMianHuaHen' => isset($nopays[7])?1:0,
'BuJiMianSheShui' => isset($nopays[8])?1:0,
'BuJiMianZiRan' => isset($nopays[9])?1:0,
'SheShui' => $types[8]=='是'?1:0,
'HuaHen' => $types[7],
'SiJi' => $types[4],
'ChengKe' => $types[5],
'CheSun' => $types[1],
'DaoQiang' => $types[3]=='是'?1:0,
'SanZhe' => $types[2],
'ZiRan' => $types[9]=='是'?1:0,
'SeatCount' => $request->post('seats'),
'HcSanFangTeYue' => $types[12]=='是'?1:0,
'PurchasePrice' => $request->post('purchase_price'),
'AutoMoldCode' => $request->post('auto_mold_code'),
'VehicleYear' => $request->post('vehicle_year'),
'AutoMoldCodeSource' => 3,
];
if($params['OwnerIdCardType'] == '身份证') $params['OwnerIdCardType'] = 1;
else $params['OwnerIdCardType'] = 9;
if($params['InsuredIdType'] == '身份证') $params['InsuredIdType'] = 1;
else $params['InsuredIdType'] = 9;
if($params['HolderIdType'] == '身份证') $params['HolderIdType'] = 1;
else $params['HolderIdType'] = 9;
if($types[1] > 0 && $types[10] == '是' && $types[11] == '是') {
$params['ForceTax'] = 1;
} else if($types[10] == '是' && $types[11] == '是') {
$params['ForceTax'] = 2;
} else if($types[10] > 0) {
$params['ForceTax'] = 0;
}
switch($types[7]) {
case '2000元':
$params['HuaHen'] = 2000;
break;
case '5000元':
$params['HuaHen'] = 5000;
break;
case '10000元':
$params['HuaHen'] = 10000;
break;
case '20000元':
$params['HuaHen'] = 20000;
break;
default:
$params['HuaHen'] = 0;
}
switch($types[4]) {
case '1万':
$params['SiJi'] = 10000;
break;
case '2万':
$params['SiJi'] = 20000;
break;
case '3万':
$params['SiJi'] = 30000;
break;
case '4万':
$params['SiJi'] = 40000;
break;
case '5万':
$params['SiJi'] = 50000;
break;
case '10万':
$params['SiJi'] = 100000;
break;
default:
$params['SiJi'] = 0;
}
switch($types[5]) {
case '1万':
$params['ChengKe'] = 10000;
break;
case '2万':
$params['ChengKe'] = 20000;
break;
case '3万':
$params['ChengKe'] = 30000;
break;
case '4万':
$params['ChengKe'] = 40000;
break;
case '5万':
$params['ChengKe'] = 50000;
break;
case '10万':
$params['ChengKe'] = 100000;
break;
default:
$params['ChengKe'] = 0;
}
switch($types[2]) {
case '5万':
$params['SanZhe'] = 50000;
break;
case '10万':
$params['SanZhe'] = 100000;
break;
case '15万':
$params['SanZhe'] = 150000;
break;
case '20万':
$params['SanZhe'] = 200000;
break;
case '30万':
$params['SanZhe'] = 300000;
break;
case '50万':
$params['SanZhe'] = 500000;
break;
case '100万':
$params['SanZhe'] = 1000000;
break;
case '150万':
$params['SanZhe'] = 1500000;
break;
case '200万':
$params['SanZhe'] = 2000000;
break;
default:
$params['SanZhe'] = 0;
}
$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());
if($obj->data && $obj->data->UserInfo && $obj->data->UserInfo->CarUsedType != '') {
$car_user_info = CarUseT::find()->where(['name'=>$obj->data->UserInfo->CarUsedType])->one();
if($car_user_info) {
$obj->data->UserInfo->CarUsedType = $car_user_info->id;
}
}
return MyLib::ok3($obj->data);
}
return MyLib::error3($res->getBody());
}
public function actionGetPrecisePrice()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$url = Yii::$app->params['userPanel']['post-precise-price'];
$token = Yii::$app->params['userPanel']['token'];
$params = [
'token' => $token,
'LicenseNo' => $request->post('car_no'),
'QuoteGroup' => $request->post('company_id'),
];
$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());
if($obj->data && $obj->data->UserInfo && $obj->data->UserInfo->CarUsedType != '') {
$car_user_info = CarUseT::find()->where(['name'=>$obj->data->UserInfo->CarUsedType])->one();
if($car_user_info) {
$obj->data->UserInfo->CarUsedType = $car_user_info->id;
}
}
return MyLib::ok3($obj->data);
}
return MyLib::error3($res->getBody());
}
public function actionInfo() public function actionInfo()
{ {
$request = Yii::$app->request; $request = Yii::$app->request;

@ -15,6 +15,8 @@ use common\models\PriceT;
<input type="hidden" name="id" value="<?=$order_info->id?>"> <input type="hidden" name="id" value="<?=$order_info->id?>">
<input type="hidden" name="celuo_id" id="celuo_id" value="<?=$order_info->celuo_id?>"> <input type="hidden" name="celuo_id" id="celuo_id" value="<?=$order_info->celuo_id?>">
<input type="hidden" name="fanxian_id" id="fanxian_id" value="<?=$order_info->fanxian_id?>"> <input type="hidden" name="fanxian_id" id="fanxian_id" value="<?=$order_info->fanxian_id?>">
<input type="hidden" name="auto_mold_code" id="auto_mold_code" value="">
<input type="hidden" name="vehicle_year" id="vehicle_year" value="">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<h5>保单信息</h5> <h5>保单信息</h5>
@ -37,7 +39,7 @@ use common\models\PriceT;
<th class="bg-warning" nowrap>发动机号</th> <th class="bg-warning" nowrap>发动机号</th>
<td><input name="engine_no" class="form-control date" style="width:100%;" type="text" value="<?=$order_info->engine_no!='' ? $order_info->engine_no:$car_info->engine_no?>"></td> <td><input name="engine_no" class="form-control date" style="width:100%;" type="text" value="<?=$order_info->engine_no!='' ? $order_info->engine_no:$car_info->engine_no?>"></td>
<th class="bg-warning" nowrap>厂牌型号</th> <th class="bg-warning" nowrap>厂牌型号</th>
<td><input name="factory_model" class="form-control" style="width:100%;" type="text" value="<?=$order_info->factory_model!='' ? $order_info->factory_model:$car_info->factory_model?>"></td> <td><input name="factory_model" id="factory_model" class="form-control" style="width:100%;" type="text" value="<?=$order_info->factory_model!='' ? $order_info->factory_model:$car_info->factory_model?>"></td>
<th class="bg-warning" nowrap>新车购置价</th> <th class="bg-warning" nowrap>新车购置价</th>
<td><input name="purchase_price" id="purchase_price" class="form-control" style="width:100%;" type="text" value="<?=$order_info->purchase_price!='' ? $order_info->purchase_price:$car_info->purchase_price?>"></td> <td><input name="purchase_price" id="purchase_price" class="form-control" style="width:100%;" type="text" value="<?=$order_info->purchase_price!='' ? $order_info->purchase_price:$car_info->purchase_price?>"></td>
</tr> </tr>
@ -458,6 +460,15 @@ use common\models\PriceT;
} }
} }
if(obj.data.VehicleItems && obj.data.VehicleItems[0]) { if(obj.data.VehicleItems && obj.data.VehicleItems[0]) {
if(obj.data.VehicleItems[0].VehicleNo) {
$('#auto_mold_code').val(obj.data.VehicleItems[0].VehicleNo);
}
if(obj.data.VehicleItems[0].VehicleYear) {
$('#vehicle_year').val(obj.data.VehicleItems[0].VehicleYear);
}
if(obj.data.VehicleItems[0].VehicleName) {
$('#factory_model').val(obj.data.VehicleItems[0].VehicleName);
}
if(obj.data.VehicleItems[0].PurchasePrice) { if(obj.data.VehicleItems[0].PurchasePrice) {
$('#purchase_price').val(obj.data.VehicleItems[0].PurchasePrice); $('#purchase_price').val(obj.data.VehicleItems[0].PurchasePrice);
} }
@ -473,6 +484,25 @@ use common\models\PriceT;
} }
}, 'json'); }, 'json');
} }
//算费
function cal() {
var index = parent.layer.load(1, {
shade: [0.1,'#fff'] //0.1透明度的白色背景
});
var params = $('#orderFrm').serialize();
$.post('/car/post-precise-price', params, function(obj) {
if(obj.code == 200) {
$.post('/car/get-precise-price', params, function(obj) {
parent.layer.close(index);
if(obj.code == 200) {
parent.layer.msg('获取成功');
} else {
parent.layer.msg(obj.msg);
}
}, 'json');
}
}, 'json');
}
//获取策略 //获取策略
function getYingXiao() { function getYingXiao() {
var params = $('#orderFrm').serialize(); var params = $('#orderFrm').serialize();

Loading…
Cancel
Save