diff --git a/frontend/controllers/DatabaseController.php b/frontend/controllers/DatabaseController.php index 5028be4..fffffab 100644 --- a/frontend/controllers/DatabaseController.php +++ b/frontend/controllers/DatabaseController.php @@ -1055,9 +1055,6 @@ class DatabaseController extends BaseController 'invalid_items' => $invalid_items ]); } - public function actionCSearch() { - return $this->render('c-index-search'); - } public function actionCIndexJson() { Yii::$app->response->format = Response::FORMAT_JSON; @@ -1128,11 +1125,15 @@ class DatabaseController extends BaseController $order_row->engine_no = $c_info->car->engine_no; $order_row->car_frame_no = $c_info->car->car_frame_no; $order_row->car_man = $c_info->car->car_man; + $order_row->car_man_number = $c_info->car->car_man_number; + $order_row->car_man_phone = $c_info->car->phone; $order_row->user_id = $user_id; $order_row->status_id = 1; $order_row->id_man = $c_info->car->car_man; + $order_row->id_man_number = $c_info->car->id_number; $order_row->link_man = $c_info->car->car_man; - $order_row->link_phone = $c_info->car->phone; + $order_row->link_man_phone = $c_info->car->phone; + $order_row->link_man_number = $c_info->car->id_number; if(!$order_row->save()) { throw new \Exception(print_r($order_row->getErrors(),true)); } @@ -1212,7 +1213,7 @@ class DatabaseController extends BaseController foreach($ids as $id) { $c_info = CarCT::findOne(['id'=>$id]); if($c_info->user_id > 0) - $this->addLog($c_info->id,'从业务员:'.$c_info->user->getShowName().'回收跟踪数据',1); + $this->addLog($c_info->id,'从业务员:'.$c_info->user->getShowName().'回收数据',1); //删除预约 AppointmentT::deleteAll('user_id='.$c_info->user_id.' and car_id='.$c_info->id); @@ -1298,25 +1299,37 @@ class DatabaseController extends BaseController $order_row->engine_no = $c_info->car->engine_no; $order_row->car_frame_no = $c_info->car->car_frame_no; $order_row->car_man = $c_info->car->car_man; + $order_row->car_man_number = $c_info->car->car_man_number; + $order_row->car_man_phone = $c_info->car->phone; $order_row->user_id = $c_info->user_id; $order_row->status_id = 1; $order_row->id_man = $c_info->car->car_man; + $order_row->id_man_number = $c_info->car->id_number; $order_row->link_man = $c_info->car->car_man; - $order_row->link_phone = $c_info->car->phone; - $order_row->return_status_id = 0; - $order_row->return_remark = ''; + $order_row->link_man_phone = $c_info->car->phone; + $order_row->link_man_number = $c_info->car->id_number; if(!$order_row->save()) { throw new \Exception(print_r($order_row->getErrors(),true)); } + //添加保单操作员 + $order_user_info = new OrderUserT(); + $order_user_info->user_id = $c_info->user_id; + $order_user_info->order_id = $order_row->id; + $order_user_info->type_id = 1; + $order_user_info->status = 0; + if(!$order_user_info->save()) { + throw new \Exception(print_r($order_user_info->getErrors(),true)); + } + //添加预约 AppointmentT::deleteAll('car_id='.$c_info->id); $row = new AppointmentT(); $row->car_id = $c_info->id; $row->user_id = $c_info->user_id; $row->pdate = date('Y-m-d'); - $row->ptime = '09:00'; $row->ptype = 0; + $row->ptime = '09:00'; $row->remark = '首次分配'; $row->is_first = 1; $row->xdate = date('Y-m-d'); @@ -1331,8 +1344,8 @@ class DatabaseController extends BaseController $h_row->car_id = $c_info->id; $h_row->user_id = $c_info->user_id; $h_row->pdate = date('Y-m-d'); - $h_row->ptime = '09:00'; $h_row->ptype = 0; + $h_row->ptime = '09:00'; $h_row->remark = '首次分配'; $h_row->xdate = date('Y-m-d'); $h_row->xtime = '09:00'; @@ -1355,6 +1368,75 @@ class DatabaseController extends BaseController } return $result; } + public function actionCReturnAll() + { + Yii::$app->response->format = Response::FORMAT_JSON; + $request = Yii::$app->request; + $result = array(); + $result['success'] = false; + $result['msg'] = '操作失败'; + + if($request->isPost) { + + $status = $request->post('status'); + $register_begin = $request->post('register_begin'); + $register_end = $request->post('register_end'); + $insurer1_begin = $request->post('insurer1_begin'); + $insurer1_end = $request->post('insurer1_end'); + + $query = CarCT::find() + ->leftJoin('car_t','`car_t`.`id`=`car_c_t`.`id`'); + + if($register_begin != '') { + $query->andWhere('car_t.register_date>="'.$register_begin.'"'); + } + if($register_end != '') { + $query->andWhere('car_t.register_date<="'.$register_end.'"'); + } + if($insurer1_begin != '') { + $query->andWhere('car_t.insurer1_date>="'.$insurer1_begin.'"'); + } + if($insurer1_end != '') { + $query->andWhere('car_t.insurer1_end<="'.$insurer1_end.'"'); + } + $tran = CarT::getDb()->beginTransaction(); + try { + foreach($query->each(1000) as $item) { + //删除预约 + AppointmentT::deleteAll('car_id='.$item->id); + + //删除保单 还没有正本生成的保单可以直接删除,正本生成后,需要退单操作 + //删除操作人员 + $orders = OrderT::find() + ->where('car_id='.$item->id.' and status_id<5') + ->all(); + foreach($orders as $order_info) { + OrderUserT::deleteAll('order_id='.$order_info->id); + //删除保单 + $order_info->delete(); + } + + $item->user_id = 0; + if(!$item->save()) { + throw new \Exception(print_r($item->getErrors(), true)); + } +// FiltrationT + //删除预约拨打 +// FiltrationT::deleteAll('car_id='.$c_info->id); + $this->addLog($item->id,'从C库业务员手中批量回收数据',1); + } + + $result['success'] = true; + $result['msg'] = '操作成功'; + + $tran->commit(); + } catch (\Exception $e) { + $tran->rollBack(); + $result['msg'] = $e->getMessage(); + } + } + return $result; + } public function actionCD() { Yii::$app->response->format = Response::FORMAT_JSON; @@ -1405,6 +1487,51 @@ class DatabaseController extends BaseController } return $result; } + public function actionCAllD() + { + Yii::$app->response->format = Response::FORMAT_JSON; + $request = Yii::$app->request; + $result = array(); + $result['success'] = false; + $result['msg'] = '操作失败'; + + if($request->isPost) { + $data = $this->getCQuery($request); + $query = $data['query']; + $tran = CarT::getDb()->beginTransaction(); + try { + foreach($query->each(100) as $c_info) { + $car_info = $c_info->car; + if($car_info->location == 3) { + $car_info->location = 4; + if(!$car_info->save(false)) { + throw new Exception(print_r($car_info->getFirstErrors(),true)); + } + + CarCT::deleteAll(['id'=>$car_info->id]); + $d_info = CarDT::findOne(['id'=>$car_info->id]); + if(!$d_info) { + $d_info = new CarDT(false); + $d_info->id = $car_info->id; + $d_info->user_id = 0; + if(!$d_info->save(false)) { + throw new Exception(print_r($d_info->getFirstErrors(),true)); + } + } + $this->addLog($car_info->id,'从C库分配到D库',1); + } + } + $result['success'] = true; + $result['msg'] = '操作成功'; + + $tran->commit(); + } catch (\Exception $e) { + $tran->rollBack(); + $result['msg'] = $e->getMessage(); + } + } + return $result; + } //D库列表页 private function getDQuery($request) diff --git a/frontend/views/database/a-index.php b/frontend/views/database/a-index.php index 0a83549..5466871 100644 --- a/frontend/views/database/a-index.php +++ b/frontend/views/database/a-index.php @@ -92,7 +92,7 @@ use \common\libs\MyLib; -