Files
park/application/api/controller/YqDatainfo.php
MeSHard b22d09bd39 init
2025-12-01 11:19:23 +08:00

130 lines
4.9 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | 数据信息
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\common\controller\Api;
use think\Db;
class YqDatainfo extends Api {
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
//车辆运单上报
public function waybill_reporting(){
$map['tow_license'] = input('tow_license');
$map['is_del'] = 1;
$waybill_id = Db::name($this->bcapi_waybill)->whereTime('waybill_date','d')->where($map)->value('id');
if ($waybill_id){
$this->alertMsg(300,'该牵引车当日运单已上报,请勿重复上报');
}
$arr = [
'create_time' => date('Y-m-d H:i:s'),
'waybill_order' => input('waybill_order'),
'tow_license' => input('tow_license'),
'mount_license' => input('mount_license'),
'driver_tel' => input('driver_tel'),
'sale_product' => input('sale_product'),
'waybill_name' => input('waybill_name'),
'waybill_date' => input('waybill_date'),
'waybill_loading' => input('waybill_loading'),
'waybill_unloading' => input('waybill_unloading'),
'carriers_code' => input('carriers_code'),
'vehicle_type' => input('vehicle_type'),
'cargocount' => input('cargocount'),
'cargocategory' => input('cargocategory'),
'waybill_cas' => input('waybill_cas'),
];
$driver_id = Db::name($this->bcapi_driver)->where('phone',input('driver_tel'))->value('id');
if (!$driver_id){
$this->alertMsg(300,'该司机暂未注册请先在APP上注册');
}
$arr['driverid'] = $driver_id;
if (input('w_mission') == 1){
$arr['w_mission'] = '装货';
}else{
$arr['w_mission'] = '卸货';
}
$waybill_id = Db::name($this->bcapi_waybill)->insertGetId($arr);
if ($waybill_id !== false){
$data['waybill_id'] = $waybill_id;
$this->alertMsg(200,'上报成功',$data);
}else{
$this->alertMsg(300,'网络异常,请稍后再试');
}
}
//车辆绑定
public function vehicle_binding($param){
if (empty($param['tel'])){
$this->alertMsg(300,'缺少参数');
}
$driver_where['phone'] = $param['tel'];
$driver_where['status'] = 1;
$driver_id = Db::name($this->bcapi_driver)->where($driver_where)->value('id');
if (!$driver_id){
$this->alertMsg(300,'账号不存在,请先注册');
}
Db::name($this->bcapi_driver_vehicle)->where('license',$param['vehicle_no'])->update(['is_del'=>0]);
$vehicle_where['driver_id'] = $driver_id;
$vehicle_where['license'] = $param['vehicle_no'];
$vehicle_id = Db::name($this->bcapi_driver_vehicle)->where($vehicle_where)->value('id');
if ($vehicle_id){
$rse = Db::name($this->bcapi_driver_vehicle)->where($vehicle_where)->update(['is_del'=>1]);
}else{
$arr = [
'license' => $param['vehicle_no'],
'driver_id' => $driver_id,
'create_time' => date('Y-m-d H:i:s'),
'is_del' => 1,
];
$rse = Db::name($this->bcapi_driver_vehicle)->insert($arr);
}
if($rse !== false){
$this->alertMsg(200,'绑定成功');
}else{
$this->alertMsg(300,'网络异常,请稍后再试');
}
}
//查验结果提交
public function check_submit($param){
if (empty($param['waybill_order']) || empty($param['check_uid'])){
$this->alertMsg(300,'缺少参数');
}
$waybill_id = Db::name($this->bcapi_waybill)->where('waybill_order',$param['waybill_order'])->value('id');
if (!$waybill_id){
$this->alertMsg(300,'异常操作,请稍后再试');
}
$id = Db::name($this->bcapi_check_record)->where('waybill_id',$waybill_id)->value('id');
if ($id){
$this->alertMsg(300,'该车辆信息已审核,请勿重复操作');
}
$arr = [
'waybill_id' => $waybill_id,
'check_uid' => 3,//重庆宝丞炭材有限公司
'check_status' => 1,
'check_where' => '1,2,3,4,5,6',
'check_time' => date('Y-m-d H:i:s'),
];
Db::startTrans();
try{
Db::name($this->bcapi_waybill)->where('id',$waybill_id)->update(['check_status'=>1]);
Db::name($this->bcapi_check_record)->insert($arr);
$see = true;
Db::commit();
} catch (\Exception $e) {
$see = false;
Db::rollback();
}
if($see) {
$this->alertMsg(200,'操作成功');
}else{
$this->alertMsg(300,'网络异常,请稍后再试');
}
}
}