123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- /**
- * Created by PhpStorm.
- * User: kang
- * Date: 2021/4/14
- * Time: 9:38
- */
- namespace JinDouYun\Controller\System;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\System\MDriver;
- class Driver extends BaseController
- {
- private $objMDriver;
-
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
-
- $this->objMDriver = new MDriver($this->onlineEnterpriseId,$this->onlineUserId);
-
- }
-
- /**
- * 添加和编辑司机信息管理公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
-
- if( empty($params) ){
- $this->sendOutput('参数为空', ErrorCode::$paramError );
- }
- $DriverData = [
- 'enterpriseId'=> $this->onlineEnterpriseId,
- 'driverName' => getArrayItem($params,'driverName'),
- 'phone' => getArrayItem($params,'phone'),
- 'plateNumber' => getArrayItem($params,'plateNumber'),
- 'state' => getArrayItem($params,'state',StatusCode::$standard),
- ];
- foreach($DriverData as $key => $value){
- if(empty($value) && $value !== 0){
- $this->sendOutput($key.'参数错误', ErrorCode::$paramError );
- }
- }
- $DriverData['remark'] = getArrayItem($params,'remark');
- return $DriverData;
- }
-
- /**
- * 添加司机信息
- */
- public function addDriver()
- {
- $DriverData = $this->commonFieldFilter();
- $result = $this->objMDriver->addDriver($DriverData);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
-
- /**
- * 获取指定司机信息
- */
- public function getDriverInfo()
- {
- $driverId = $this->request->param('request_id');
- if ( !$driverId ) {
- $this->sendOutput('参数错误', ErrorCode::$paramError );
- }
- $result = $this->objMDriver->getDriverInfo($driverId);
- if($result->isSuccess()){
- $this->sendOutput($result->getData());
- }else{
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- }
-
- /**
- * 编辑司机资料
- */
- public function editDriver()
- {
- $params = $this->request->getRawJson();
- if(empty($params)){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMDriver->editDriver($params);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
-
- /**
- * 删除司机信息
- */
- public function delDriver()
- {
- $driverId = $this->request->param('request_id');
- if ( !$driverId ) {
- $this->sendOutput('参数错误', ErrorCode::$paramError );
- }
- $result = $this->objMDriver->delDriver($driverId);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
-
- /**
- * 后台所有司机信息列表
- */
- public function getAllDriver()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $pageParams = pageToOffset($params['page']?:1, $params['pageSize']?:10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- if(isset($params['state']) && !empty($params['state'])){
- $selectParams['state'] = $params['state'];
- }
- $result = $this->objMDriver->getAllDriver($selectParams);
- if($result->isSuccess()){
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
-
- /**
- * 后台所有启用司机信息列表
- */
- public function getAllOpenDriver()
- {
- $result = $this->objMDriver->getAllOpenDriver();
- if($result->isSuccess()){
- parent::sendOutput($result->getData(), 0);
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- }
|