This commit is contained in:
unknown 2023-10-11 14:55:39 +08:00
parent b5a1930e48
commit 0ae6ecaf6f
2 changed files with 16 additions and 6 deletions

View File

@ -13,7 +13,7 @@ class ContractController extends BaseApiController
public array $notNeedLogin = ['signContract','contractUpdate','checkCarNum','getAvailableVehicles'];
public function signContract() {
//获取参数
$params = $this->request->post(['num','company_id','company_name','company_code','company_user','company_phone','company_email']);
$params = $this->request->post(['num','company_id','company_name','company_code','company_user','company_phone','company_email','cars_info','type']);
//验证参数
if(empty($params['num']) || empty($params['company_id']) || empty($params['company_name']) || empty($params['company_code']) || empty($params['company_user']) || empty($params['company_phone']) || empty($params['company_email'])){
return $this->fail('缺少必要参数');
@ -38,7 +38,8 @@ class ContractController extends BaseApiController
'company_b_phone' => $params['company_phone'],
'company_b_email' => $params['company_email'],
'num' => $params['num'],
'cars_info' => null,
'cars_info' => isset($params['cars_info']) && !empty($params['cars_info']) ? $params['cars_info'] : null,
'type' => isset($params['type']) && !empty($params['type']) ? $params['type'] : 0,
'status' => 0,
'create_time' => time(),
'update_time' => time(),
@ -48,7 +49,6 @@ class ContractController extends BaseApiController
$res1 = Contract::create($data);
if($res1->id){
$data['contract_logistic_id'] = $res1->id;
$data['type'] = 0;
Db::commit();
return $this->success('合同发起成功,等待审核',$data);
}else{

View File

@ -151,8 +151,18 @@ class VehicleController extends BaseApiController
}
//获取空闲车辆
public function getFreeCars() {
$data = Vehicle::field('id,pic,license')->where('status',0)->where('type',0)->select();
return $this->success('请求成功',$data->toArray());
public function getFreeCars(): Json
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
$ids = $this->request->post('ids');
if(!empty($ids)){
$rentCars = Vehicle::field('id,pic,license')->where('id','in',$ids)->select()->toArray();
}else{
$rentCars = [];
}
$data = Vehicle::field('id,pic,license')->where('status',0)->where('type',0)->select()->toArray();
return $this->success('请求成功',array_merge($rentCars,$data));
}
}