优化ctms-api语法、修复已知BUG;

主要修复ctms-api、dacms对PHP新版本的支持问题
This commit is contained in:
fm453 2024-08-10 12:27:26 +08:00
parent b944fa7bb4
commit 314745edf8
413 changed files with 107271 additions and 72326 deletions

5
.gitignore vendored
View File

@ -34,6 +34,7 @@ Network Trash Folder
Temporary Items
.apdisk
.well-known
.gitee
YII.sublime-project
YII.sublime-workspace
@ -53,10 +54,12 @@ private.html
/front-hiluker/嗨路客官网.sublime-project
/front-hiluker/嗨路客官网.sublime-workspace
/front-hiluker/嗨路客官网.txt
/front-hiluker/web/assets/
/dacms-api/API站点专用.txt
/dacms-api/API站点系统.sublime-workspace
/dacms-api/cert/*
/dacms-api/cert/
/dacms-api/web/assets/
/dacms-home/web/assets/
/ctms-home/web/assets/
/ctms-admin/web/assets/
/assets/

25
.idea/php.xml generated
View File

@ -1,5 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/phpspec/php-diff" />
@ -101,10 +111,21 @@
<path value="$PROJECT_DIR$/vendor/sebastian/lines-of-code" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit" />
<path value="$PROJECT_DIR$/vendor/yiisoft/yii2-symfonymailer" />
<path value="$PROJECT_DIR$/vendor/yiisoft/yii2-bootstrap5" />
<path value="$PROJECT_DIR$/vendor/doctrine/deprecations" />
<path value="$PROJECT_DIR$/vendor/aliyun/dysms3" />
<path value="$PROJECT_DIR$/vendor/yiisoft/yii2-bootstrap5" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.1" />
<component name="PhpProjectSharedConfiguration" php_language_level="8.0" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PhpUnit">
<phpunit_settings>
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
</phpunit_settings>
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,6 @@ class AppAsset extends AssetBundle
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yii\bootstrap5\BootstrapAsset',
];
}

View File

@ -4,9 +4,9 @@ $config = [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=120.79.11.71;dbname=dacms_dev',
'username' => 'dacms_dev',
'password' => 'HS8wRyTT2sKeLdAJ',
'dsn' => 'mysql:host=127.0.0.1;dbname=sass',
'username' => 'sass',
'password' => 'ejxsrxZCP34xNjF2',
'charset' => 'utf8',
'tablePrefix' => '',
],

View File

@ -13,7 +13,7 @@ $config = [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=dacms',
'username' => 'dacms',
'password' => 'eydnsidc',
'password' => 'CiwE5YbLnL7Yw8zs',
'charset' => 'utf8',
'tablePrefix' => '',
],

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -6,12 +6,13 @@
use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\bootstrap5\Nav;
use yii\bootstrap5\NavBar;
use yii\bootstrap5\ActiveForm;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;
// AppAsset::register($this);
//AppAsset::register($this);
$keywords = '';
$description = '';
$routes = ['data']; //自添加的controllers列表集用于为新添加的控制器在渲染视图时自动加入HTML代码段以便兼容h+的后台模板

View File

@ -14,8 +14,8 @@
},
"minimum-stability": "dev",
"require": {
"php": ">=8.1.0",
"yiisoft/yii2": "~2.0.51",
"php": ">=8.0.0",
"yiisoft/yii2": "~2.0.45",
"yiisoft/yii2-bootstrap5": "~2.0.2",
"yiisoft/yii2-symfonymailer": "~2.0.3"
},
@ -48,8 +48,10 @@
"enabled": false
}
},
"repositories": [{
"type": "composer",
"url": "https://asset-packagist.org"
}]
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
}

View File

@ -8,6 +8,7 @@ use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap5\Nav;
use yii\bootstrap5\NavBar;
use yii\bootstrap5\ActiveForm;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;

View File

@ -1,2 +1,10 @@
<?php
Yii::setAlias('@backend', dirname(__DIR__));
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2021-03-25T10:36:00+08:00
# @Email: 1280880631@qq.com
# @Last modified by: fm453
# @Last modified time: 2024-08-09T09:09:28+08:00
# @Copyright: www.hiluker.cn
Yii::setAlias('@api', dirname(__DIR__));

View File

@ -4,7 +4,7 @@
# @Date: 1970-01-01T08:00:00+08:00
# @Email: fm43@hiluker.com
# @Last modified by: fm453
# @Last modified time: 2024-07-09T17:19:59+08:00
# @Last modified time: 2024-08-09T08:21:21+08:00
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
@ -20,7 +20,7 @@ $params = array_merge(
$config = [
'id' => 'api-ctms-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'controllerNamespace' => 'api\controllers',
'defaultRoute' => 'index', //默认路由
'bootstrap' => ['log'],
'modules' => [

View File

@ -1,415 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:27:54+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:27:54+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCar;
use addons\models\AcAlbums;
use addons\models\AcAlbumPics;
use addons\models\AcAlbumVersion;
class AlbumsController extends Common
{
//主界面
public function actionIndex()
{
global $_HI,$_FM;
return $this->render('../layouts/dev', []);
}
//相册列表
public function actionList()
{
return $this->render('../layouts/dev');
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$model = new AcAlbums();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = Yii::$app->request->post();
$get = Yii::$app->request->get();
$searchSession = 'acalbums::search';
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['car_id'] = isset($search['car_id']) ? (int)$search['car_id'] : '';
$CarModel = new AcCar();
if (empty($search['car_id'])) {
$search['car_id'] = isset($get['car_id']) ? (int)$get['car_id'] : 0;
}
if (!empty($search['car_id'])) {
$where[] = ['=','car_id',$search['car_id']];
$car = $CarModel->findOne($search['car_id']);
$search['car_title'] = isset($car->title) ? $car->title : '';
}
$search['phone'] = isset($search['phone']) ? trim($search['phone']) : '';
if (!empty($search['phone'])) {
$where[] = ['or',['LIKE','phone1_1',$search['phone']],['LIKE','phone1_2',$search['phone']],['LIKE','phone2_1',$search['phone']],['LIKE','phone2_2',$search['phone']]];
}
$deleted = 0;
if (isset($_GET['deleted'])) {
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
$status = Yii::$app->params['AlbumStatus'];
$orders = [];
foreach ($res as $s) {
$s = $s->toArray();
$orders[$s['id']] = $s;
}
return $this->render('list', [
'orders' => $orders,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
//验新车
public function actionNewcar()
{
return $this->render('../layouts/dev');
$status = Yii::$app->params['AlbumStatus'];
$AcAlbum = new AcAlbums();
$AcAlbum->status_code = 0;
$detail = $AcAlbum->toArray();
return $this->render('modify', ['status'=>$status,'detail'=>$detail]);
}
/*编辑相册*/
public function actionEdit()
{
return $this->render('../layouts/dev');
$pid = Yii::$app->session->get('pid');
$status = Yii::$app->params['OrderStatus'];
$post = Yii::$app->request->post();
$id = Yii::$app->request->get('id');
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($id);
$detail = $order->toArray();
$detail['thumbs'] = json_decode($detail['thumbs']);
$model = new AcStore();
$store = $model->findOne($detail['store_id']);
if ($store) {
$detail['store_title'] = $store->title;
}
$model = new AcEmployee();
$employee = $model->findOne($detail['employee_id']);
if ($employee) {
$detail['employee_title'] = $employee->name;
}
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
$model = new AcCar();
$car = $model->findOne($detail['car_id']);
if ($car) {
$detail['car_owner_id'] = $car->owner_id;
$detail['car_brand_id'] = $car->brand_id;
$detail['car_series_id'] = $car->series_id;
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
$detail['car_number'] = $detail['car_number'] ? $detail['car_number'] : $car->num_frame;
}
$model = new User();
$user = $model->findOne($detail['from_mid']);
$model = new AcUserExt();
$exts = [];
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach ($_exts as $ext) {
$ext = $ext->toArray();
if (isset($users[$s['id']])) {
if ($ext['mobile']==$user->mobile) {
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
if ($owner) {
$_owner = User::findOne($detail['car_owner_id']);
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
if ($brand) {
$detail['car_title'] = $brand->title;
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series= $AcCarSeries->findOne($detail['car_series_id']);
if ($series) {
$detail['car_title'] .= $series->title;
}
$op = Yii::$app->request->get('op');
$tpl = 'modify';
if ($op=='print') {
$tpl = 'print';
$sn = '00000000000'; //11位
$sn = substr($sn, 0, 11-strlen($id));
$sn .=$id;
$detail['sn'] = $sn;
}
return $this->render(
$tpl,
[
'status'=>$status,
'detail'=>$detail,
'store'=>$store,
'employee'=>$employee,
'id'=>$id
]
);
}
/*相册详情*/
public function actionDetail()
{
$pid = Yii::$app->session->get('pid');
$status = Yii::$app->params['OrderStatus'];
$post = Yii::$app->request->post();
$id = Yii::$app->request->get('id');
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($id);
$detail = $order->toArray();
$detail['thumbs'] = json_decode($detail['thumbs']);
$model = new AcStore();
$store = $model->findOne($detail['store_id']);
if ($store) {
$detail['store_title'] = $store->title;
}
$model = new AcEmployee();
$employee = $model->findOne($detail['employee_id']);
if ($employee) {
$detail['employee_title'] = $employee->name;
}
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
$model = new AcCar();
$car = $model->findOne($detail['car_id']);
if ($car) {
$detail['car_owner_id'] = $car->owner_id;
$detail['car_brand_id'] = $car->brand_id;
$detail['car_series_id'] = $car->series_id;
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
$detail['car_number'] = $detail['car_number'] ? $detail['car_number'] : $car->num_frame;
}
$model = new User();
$user = $model->findOne($detail['from_mid']);
$model = new AcUserExt();
$exts = [];
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach ($_exts as $ext) {
$ext = $ext->toArray();
if (isset($users[$s['id']])) {
if ($ext['mobile']==$user->mobile) {
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
if ($owner) {
$_owner = User::findOne($detail['car_owner_id']);
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
if ($brand) {
$detail['car_title'] = $brand->title;
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series= $AcCarSeries->findOne($detail['car_series_id']);
if ($series) {
$detail['car_title'] .= $series->title;
}
$sn = '00000000000'; //11位
$sn = substr($sn, 0, 11-strlen($id));
$sn .=$id;
$detail['sn'] = $sn;
return $this->render(
'detail',
[
'status'=>$status,
'detail'=>$detail,
'store'=>$store,
'employee'=>$employee,
'id'=>$id
]
);
}
//站点验车
public function actionOrder()
{
return $this->render('../layouts/dev');
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
$AcOrder = new AcOrder();
if ($id) {
$order = $AcOrder->findOne($id);
if ($order->create_by != Yii::$app->user->identity->id) {
//不允许修改非本人操作的表单
$return['msg'] = '您不是该运单的制单人,不允许进行修改!';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
//格式化数据 为空的项则不修改
//目标键=》POST键
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city','signer'=>'signer','sender_name'=>'sender_name','sender_idcard'=>'sender_idcard','sender_mobiles'=>'sender_mobiles','receiver_name'=>'receiver_name','receiver_idcard'=>'receiver_idcard','receiver_mobiles'=>'receiver_mobiles','aim_address'=>'aim_address','thumb_f'=>'thumb_f','thumb_b'=>'thumb_b','thumb_l'=>'thumb_l','thumb_r'=>'thumb_r','car_extra'=>'car_extra','bind'=>'bind','driving_lisence'=>'driving_lisence'];
foreach ($cols as $col=>$key) {
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = trim($post[$key]);
}
// $data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['car_id'=>'car_id','employee_id'=>'employee_id','car_value'=>'car_value','fee_insurance'=>'fee_insurance','fee_truck'=>'fee_truck','fee_deliver'=>'fee_deliver','fee_pickup'=>'fee_pickup','fee_urgent'=>'fee_urgent','fee_extra'=>'fee_extra','fee_total'=>'fee_total','pay_send'=>'pay_send','pay_receive'=>'pay_receive','is_checked'=>'is_checked','no_driving_lisence'=>'no_driving_lisence','start_km'=>'start_km','not_insurance'=>'not_insurance'];
foreach ($cols as $col=>$key) {
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = (int)$post[$key];
}
// $data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
//图片组处理
$cols = ['thumbs'=>'thumbs'];
foreach ($cols as $col=>$key) {
if (isset($post[$key]) && !empty($post[$key])) {
$imgs = $post[$key]; //数组格式
$imgs = array_unique($imgs);
$imgs = json_encode($imgs);
$data[$col] = $imgs;
}
}
$cols = ['remark'=>'editor'];
foreach ($cols as $col=>$key) {
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = htmlspecialchars($post[$key]);
}
// $data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$sign_date = isset($post['sign_date']) ? strtotime($post['sign_date']) : '';
if (!$id) {
$data['create_by'] = Yii::$app->user->identity->id;
$data['sign_date'] = $sign_date ? $sign_date : time();
}
//部分规则校验
$has_err = false;
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
if (!$id) {
$data['status_code'] = 1;
}
/*不投保的保额不超过20W保费为0*/
if ($data['not_insurance']) {
if ($data['fee_insurance']) {
$data['fee_insurance']=0;
\Yii::$app->getSession()->setFlash('warning', '勾选了不投保已强制修改保费为0');
}
if ($data['car_value']>Yii::$app->params['DefaultCarInsuranceValueMax']) {
$has_err = true;
$data['car_value'] = Yii::$app->params['DefaultCarInsuranceValueMax'];
\Yii::$app->getSession()->setFlash('danger', '勾选了不投保,默认最高赠送的运输险保额不超过'.Yii::$app->params['DefaultCarInsuranceValueMax'].'万元,已自动强制校正');
}
}
$fee_total = $data['fee_truck']+$data['fee_insurance']+$data['fee_deliver']+$data['fee_pickup']+$data['fee_urgent']+$data['fee_extra'];
$fee_pay = $data['pay_send']+$data['pay_receive'];
if (!$data['fee_truck']) {
$has_err = true;
\Yii::$app->getSession()->setFlash('danger', '请注意,运费未正确填写!');
}
if (!$data['pay_send']&&!$data['pay_receive']) {
$has_err = true;
\Yii::$app->getSession()->setFlash('danger', '请注意,到收运费及起运地预收运费均未填写!');
}
if ($fee_total !=$data['fee_total']) {
$has_err = true;
\Yii::$app->getSession()->setFlash('danger', '请注意,所填运费、保费、提车费、送车费、额外费用、加急费等各项费用汇总的值与所填写的总费用不一致,请检查并更新');
}
if ($fee_pay !=$data['fee_total']) {
$has_err = true;
\Yii::$app->getSession()->setFlash('danger', '请注意,所填起运地预付运费、到收运费的汇总值与所填写的总费用不一致,请检查并更新');
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
$model = new AcEmployee();
$employee = $model->findOne($data['employee_id']);
if ($employee) {
$data['store_id'] = $employee->store_id;
}
//保存资料
if ($id) {
unset($data['create_at']);
$res = $AcOrder->updateAll($data, ['id'=>$id]);
} else {
foreach ($data as $key=>$val) {
$AcOrder->$key = $val;
}
$res = $AcOrder->save();
$id = $AcOrder->attributes['id']; //获取插入后id
}
if ($res) {
if ($has_err) {
\Yii::$app->getSession()->setFlash('success', '订单保存成功,但有价格数据录入错误,请根据情况检查更新!');
} else {
\Yii::$app->getSession()->setFlash('success', '订单保存成功!');
}
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '订单保存失败!');
return $this->goBack();
}
}
}

View File

@ -1,604 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:29:34+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:29:34+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCar;
use addons\models\AcCarOwner;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use common\models\Member as User;
use addons\models\AcUserExt;
class CarController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
//车辆列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$AcCar = new AcCar();
$where = $where2 = [];
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'cars::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
// }elseif($session->get($searchSession)){
// $search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if (!empty($search['title'])) {
$where2[] = 'or';
$where2[] = ['LIKE','num_left',$search['title']];
$where2[] = ['LIKE','num_frame',$search['title']];
}
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
if (!empty($search['brand_id'])) {
$where['brand_id'] = $search['brand_id'];
}
$where['deleted'] = 0;
$data = $AcCar->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
$oids = $mids = $bids = $sids = [];
if ($res) {
foreach ($res as $r) {
$oids[] = $r->owner_id;
$mids[] = $r->mid;
$bids[] = $r->brand_id;
$sids[] = $r->series_id;
}
}
$status = Yii::$app->params['CommonStatus'];
$AcCarOwner = new AcCarOwner();
$where = [];
$where['pid'] = $pid;
$_owners = $AcCarOwner->find()->where($where)->andwhere(['in','id',$oids])->all();
$owners = [];
foreach ($_owners as $s) {
$owners[$s->id] = $s->toArray();
}
$User = new User();
$where = [];
$_users = $User->find()->where($where)->andwhere(['in','id',$mids])->all();
$users = [];
foreach ($_users as $s) {
$users[$s->id] = $s->toArray();
}
$AcUserExt = new AcUserExt();
$userExts = $AcUserExt->find()->where(['pid' => $pid,'deleted'=>0])->andWhere(['in','mid',$mids])->all();
$exts = [];
if ($userExts) {
foreach ($userExts as $v) {
$exts[$v->mid][$v->key] = $v->value;
}
if ($exts) {
foreach ($exts as $i=>$ext) {
$_owner = $users[$i] ? $users[$i] : [];
if ($ext['title']) {
$_owner['owner_title'] = $ext['title'];
}
if ($ext['nickname']) {
$_owner['owner_title'] = $ext['nickname'];
}
if ($ext['realname']) {
$_owner['owner_title'] = $ext['realname'];
}
$users[$i]['username'] = $_owner['owner_title'].'【'.$users[$s->id]['mobile'].'】';
}
}
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series = [];
$_series = $AcCarSeries->find()->where($where)->andwhere(['in','id',$sids])->all();
if ($_series) {
foreach ($_series as $r) {
$series[$r->id] = $r->toArray();
}
}
$AcCarBrand = new AcCarBrand();
$where = [];
$_brands = $AcCarBrand->find()->where($where)->andwhere(['in','id',$bids])->all();
if ($_brands) {
foreach ($_brands as $r) {
$brands[$r->id] = $r->toArray();
}
}
$cars = [];
if ($res) {
foreach ($res as $r) {
$car = $r->toArray();
$t = '';
if (isset($series[$r->series_id]['title'])) {
$t .= $brands[$r->brand_id]['title'];
}
$t .= '-';
if (isset($series[$r->series_id]['title'])) {
$t .= $series[$r->series_id]['title'];
}
$car['title2'] = $t;
$car['numbers'] = $car['num_p'].$car['num_area'].$car['num_left'];
$car['numbers'] = $car['numbers'] ? $car['numbers'] : $car['num_frame'];
$cars[$r->id] = $car;
}
}
return $this->render('list', [
'cars'=>$cars,
'pager' => $pages,
'owners'=>$owners,
'users'=>$users,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$AcCar = new AcCar();
$where = $where2 = [];
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'cars::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
// }elseif($session->get($searchSession)){
// $search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if (!empty($search['title'])) {
$where2[] = 'or';
$where2[] = ['LIKE','num_left',$search['title']];
$where2[] = ['LIKE','num_frame',$search['title']];
}
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
if (!empty($search['brand_id'])) {
$where['brand_id'] = $search['brand_id'];
}
$where['deleted'] = 0;
$data = $AcCar->find()->where($where);
if ($search['title']) {
$data = $data->andWhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby(' id DESC')->all();
$oids = $mids = $bids = $sids = [];
if ($res) {
foreach ($res as $r) {
$oids[] = $r->owner_id;
$mids[] = $r->mid;
$bids[] = $r->brand_id;
$sids[] = $r->series_id;
}
}
$status = Yii::$app->params['CommonStatus'];
$AcCarOwner = new AcCarOwner();
$where = [];
$where['pid'] = $pid;
$_owners = $AcCarOwner->find()->where($where)->andwhere(['in','id',$oids])->all();
$owners = [];
foreach ($_owners as $s) {
$owners[$s->id] = $s->toArray();
}
$User = new User();
$where = [];
$_users = $User->find()->where($where)->andwhere(['in','id',$mids])->all();
$users = [];
foreach ($_users as $s) {
$users[$s->id] = $s->toArray();
}
$AcUserExt = new AcUserExt();
$userExts = $AcUserExt->find()->where(['pid' => $pid,'deleted'=>0])->andWhere(['in','mid',$mids])->all();
$exts = [];
if ($userExts) {
foreach ($userExts as $v) {
$exts[$v->mid][$v->key] = $v->value;
}
foreach ($exts as $i=>$ext) {
$_owner = $users[$i] ? $users[$i] : [];
if ($ext['title']) {
$_owner['owner_title'] = $ext['title'];
}
if ($ext['nickname']) {
$_owner['owner_title'] = $ext['nickname'];
}
if ($ext['realname']) {
$_owner['owner_title'] = $ext['realname'];
}
$users[$i]['username'] = $_owner['owner_title'].'【'.$users[$i]['mobile'].'】';
}
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series = [];
$_series = $AcCarSeries->find()->where($where)->andwhere(['in','id',$sids])->all();
if ($_series) {
foreach ($_series as $r) {
$series[$r->id] = $r->toArray();
}
}
$AcCarBrand = new AcCarBrand();
$where = [];
$_brands = $AcCarBrand->find()->where($where)->andwhere(['in','id',$bids])->all();
if ($_brands) {
foreach ($_brands as $r) {
$brands[$r->id] = $r->toArray();
}
}
$cars = [];
if ($res) {
foreach ($res as $r) {
$car = $r->toArray();
$t = '';
if (isset($series[$r->series_id]['title'])) {
$t .= $brands[$r->brand_id]['title'];
}
$t .= '-';
if (isset($series[$r->series_id]['title'])) {
$t .= $series[$r->series_id]['title'];
}
$car['title2'] = $t;
$car['numbers'] = $car['num_p'].$car['num_area'].$car['num_left'];
$car['numbers'] = $car['numbers'] ? $car['numbers'] : $car['num_frame'];
$cars[$r->id] = $car;
}
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truck';
return $this->render('select', [
'cars'=>$cars,
'pager' => $pages,
'owners'=>$owners,
'users'=>$users,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
$status = Yii::$app->params['CommonStatus'];
$AcCar = new AcCar();
$AcCar->status_code = 0;
return $this->render('modify', ['status'=>$status,'detail'=>$AcCar]);
}
//编辑客车资料
public function actionEdit()
{
$model = new AcCar();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
}
$pid = Yii::$app->session->get('pid');
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->find()->where(['id' => $res['owner_id']])->one();
if ($owner) {
$mid = $owner->mid;
$User = new User();
$user = $User->find()->where(['id' => $mid])->one();
if ($user) {
$res['owner_title'] = $user->username.'【'.$user->mobile.'】';
}
$AcUserExt = new AcUserExt();
$userExt = $AcUserExt->find()->where(['pid' => $pid,'mid' => $res['mid'],'deleted'=>0])->all();
$exts = [];
if ($userExt) {
foreach ($userExt as $v) {
$exts[$v->key] = $v->value;
}
if ($exts['title']) {
$res['owner_title'] = $exts['title'];
}
if ($exts['nickname']) {
$res['owner_title'] = $exts['nickname'];
}
if ($exts['realname']) {
$res['owner_title'] = $exts['realname'];
}
$res['owner_title'] = $res['owner_title'].'【'.$user->mobile.'】';
}
}
$AcCarSeries = new AcCarSeries();
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
if ($series) {
$res['series_title'] = $series->title;
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
if ($brand) {
$res['brand_title'] = $brand->title;
}
$status = Yii::$app->params['CommonStatus'];
return $this->render('modify', ['status'=>$status,'detail'=>$res]);
}
//复制客车资料后新建
public function actionCopy()
{
$model = new AcCar();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
}
$pid = Yii::$app->session->get('pid');
$AcCarSeries = new AcCarSeries();
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
if ($series) {
$res['series_title'] = $series->title;
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
if ($brand) {
$res['brand_title'] = $brand->title;
}
$status = Yii::$app->params['CommonStatus'];
$res['id'] = 0;
$res['num_p'] = $res['num_area'] = $res['num_left'] = $res['num_frame'] = '';
return $this->render('modify', ['status'=>$status,'detail'=>$res]);
}
//浏览客车详情
public function actionDetail()
{
$model = new AcCar();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
}
$pid = Yii::$app->session->get('pid');
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->find()->where(['id' => $res['owner_id']])->one();
$User = new User();
$user = $User->find()->where(['id' => $res['mid']])->one();
if ($user) {
$res['owner_title'] = $user->username.'【'.$user->mobile.'】';
}
$AcUserExt = new AcUserExt();
$userExt = $AcUserExt->find()->where(['pid' => $pid,'mid' => $res['mid'],'deleted'=>0])->all();
$exts = [];
if ($userExt) {
foreach ($userExt as $v) {
$exts[$v->key] = $v->value;
}
if ($exts['title']) {
$res['owner_title'] = $exts['title'];
}
if ($exts['nickname']) {
$res['owner_title'] = $exts['nickname'];
}
if ($exts['realname']) {
$res['owner_title'] = $exts['realname'];
}
$res['owner_title'] = $res['owner_title'].'【'.$user->mobile.'】';
}
$AcCarSeries = new AcCarSeries();
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
if ($series) {
$res['series_title'] = $series->title;
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
if ($brand) {
$res['brand_title'] = $brand->title;
}
$status = Yii::$app->params['CommonStatus'];
return $this->render('detail', ['status'=>$status,'detail'=>$res]);
}
//保存车辆资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['title'=>'title','num_frame'=>'num_frame','num_p'=>'num_p','num_area'=>'num_area','num_left'=>'num_left'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询车牌号是否在库
$hasCar = false;
if (!$data['num_frame']) {
$hasCar = AcCar::find()->where(['num_p'=>$data['num_p'],'num_area'=>$data['num_area'],'num_left'=>$data['num_left']])->one();
}
if ($hasCar) {
if ($id && $id!=$hasCar->id) {
\Yii::$app->getSession()->setFlash('danger', '保存失败,该车牌号已在库!');
return $this->goBack();
} else {
$id = $hasCar->id;
}
}
$cols = ['brand_id'=>'brand_id','series_id'=>'series_id','owner_id'=>'owner_id','status_code'=>'status_code','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['remark'=>'editor'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
// $data['status_code'] = 1;
$data['pid'] = $pid;
//填补mid参数
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->findOne($data['owner_id']);
if ($owner) {
$data['mid'] = $owner->mid;
}
//保存车辆资料
$AcCar = new AcCar();
foreach ($data as $key=>$val) {
$AcCar->$key = $val;
}
if ($id) {
$AcCar->id = $id;
unset($data['create_at']);
$res = $AcCar->updateAll($data, ['id'=>$id]);
} else {
$res = $AcCar->save();
$id = $AcCar->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '车辆资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '车辆资料保存失败!');
return $this->goBack();
}
}
//删除车辆
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcCar();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('car/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '车辆删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '车辆删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcCar();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
// $return['status_code'] = 0;
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '车辆数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
switch ($get['do']) {
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '车辆隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '车辆隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '车辆显示记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'primary'];
} else {
$return['msg'] = '车辆显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,266 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:28:54+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:29:12+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCarBrand;
class CarbrandController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
//车品牌列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$model = new AcCarBrand();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','title',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$brands=[];
foreach ($res as $s) {
$s = $s->toArray();
$brands[$s['id']] = $s;
}
$status = Yii::$app->params['CommonStatus'];
return $this->render('list', [
'brands' => $brands,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
//车品牌列表
public function actionSelect()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$model = new AcCarBrand();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','title',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$brands=[];
foreach ($res as $s) {
$s = $s->toArray();
$brands[$s['id']] = $s;
}
$status = Yii::$app->params['CommonStatus'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'car';
return $this->render('select', [
'brands' => $brands,
'pager' => $pages,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
//新增车品牌
public function actionNew()
{
global $_HI,$_FM;
$status = Yii::$app->params['CommonStatus'];
$AcCarBrand = new AcCarBrand();
$AcCarBrand->status_code = 0;
return $this->render('modify', ['status'=>$status,'detail'=>$AcCarBrand->toArray()]);
}
//更新车品牌
public function actionEdit()
{
global $_HI,$_FM;
$model = new AcCarBrand();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
} else {
$res = [];
}
$status = Yii::$app->params['CommonStatus'];
return $this->render('modify', [
'detail'=>$res,
'status'=>$status,
'id'=>$id,
]);
}
//保存车品牌资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
$data = [];
$data['title'] = trim($post['title']);
//目标键=》POST键
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//格式化资料
$AcCarBrand = new AcCarBrand();
foreach ($data as $key=>$val) {
$AcCarBrand->$key = $val;
}
//资料入库
if ($id) {
$AcCarBrand->id = $id;
unset($data['create_at']);
$res = $AcCarBrand->updateAll($data, ['id'=>$id]);
} else {
$res = $AcCarBrand->save();
$id = $AcCarBrand->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '车主资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '车主资料保存失败!');
return $this->goBack();
}
}
//删除用户
public function actionDelete($id)
{
global $_HI,$_FM;
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcCarBrand();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('carbrand/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcCarBrand();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status_code'] = 0;
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '品牌数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
switch ($get['do']) {
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '品牌隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
} else {
$return['msg'] = '品牌隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '品牌显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '品牌显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,673 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:29:55+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:29:55+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCar;
use addons\models\AcCarOwner;
use addons\models\AcStore;
use addons\models\AcEmployee;
use common\models\Member as User;
use addons\models\AcUserExt;
use common\models\CSms;
use common\models\CVcode;
use vendor\aliyun\dysms\Sms;
class CarownerController extends Common
{
//主界面
public function actionIndex()
{
global $_HI,$_FM;
return $this->render('../layouts/dev', []);
}
//车主用户列表
public function actionList()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$model = new AcCarOwner();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
// $data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
$status = Yii::$app->params['CommonStatus'];
$gender = Yii::$app->params['gender'];
$model = new AcStore();
$where = [];
$where['pid'] = $pid;
$_stores = $model->find()->where($where)->all();
$stores = [];
foreach ($_stores as $s) {
$stores[$s->id] = $s->toArray();
}
$eids = $mids = [];
foreach ($res as $r) {
$eids[$r['employee_id']] = $r['employee_id'];
$mids[$r['mid']] = $r['mid'];
}
$model = new AcEmployee();
$employees = [];
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
foreach ($_employees as $s) {
$employees[$s->id] = $s->toArray();
}
$model = new User();
$users = [];
$_users = $model->find()->where(['in','id',$mids])->all();
foreach ($_users as $s) {
$s = $s->toArray();
$users[$s['id']] = $s;
}
$model = new AcUserExt();
$exts = [];
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach ($_exts as $ext) {
$ext = $ext->toArray();
if (isset($users[$ext['mid']])) {
if ($ext['mobile']==$users[$ext['mid']]['mobile']) {
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$owners = [];
foreach ($res as $s) {
$s = $s->toArray();
if (isset($exts[$s['mid']])) {
foreach ($exts[$s['mid']] as $col=>$val) {
$s[$col] = $val;
}
}
$owners[$s['id']] = $s;
}
return $this->render('list', [
'owners' => $owners,
'pager' => $pages,
'employees'=>$employees,
'stores'=>$stores,
'exts'=>$exts,
'users'=>$users,
'status'=>$status,
'gender'=>$gender,
'search'=>$search
]);
}
//车主用户选择
public function actionSelect()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$model = new AcCarOwner();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
// $data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
$status = Yii::$app->params['CommonStatus'];
$gender = Yii::$app->params['gender'];
$model = new AcStore();
$where = [];
$where['pid'] = $pid;
$_stores = $model->find()->where($where)->all();
$stores = [];
foreach ($_stores as $s) {
$stores[$s->id] = $s->toArray();
}
$eids = $mids = [];
foreach ($res as $r) {
$eids[$r['employee_id']] = $r['employee_id'];
$mids[$r['mid']] = $r['mid'];
}
$model = new AcEmployee();
$employees = [];
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
foreach ($_employees as $s) {
$employees[$s->id] = $s->toArray();
}
$model = new User();
$users = [];
$_users = $model->find()->where(['in','id',$mids])->all();
foreach ($_users as $s) {
$s = $s->toArray();
$users[$s['id']] = $s;
}
$model = new AcUserExt();
$exts = [];
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach ($_exts as $ext) {
$ext = $ext->toArray();
if (isset($users[$ext['mid']])) {
if ($ext['mobile']==$users[$ext['mid']]['mobile']) {
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$owners = [];
foreach ($res as $s) {
$s = $s->toArray();
if (isset($exts[$s['mid']])) {
foreach ($exts[$s['mid']] as $col=>$val) {
$s[$col] = $val;
}
}
$owners[$s['id']] = $s;
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'carowner';
return $this->render('select', [
'owners' => $owners,
'pager' => $pages,
'employees'=>$employees,
'stores'=>$stores,
'exts'=>$exts,
'users'=>$users,
'status'=>$status,
'gender'=>$gender,
'search'=>$search,
'callback'=>$callback
]);
}
//新增车主
public function actionNew()
{
global $_HI,$_FM;
$levels = Yii::$app->params['customerLevels'];
return $this->render('modify', ['levels'=>$levels]);
}
//更新车主
public function actionEdit()
{
global $_HI,$_FM;
$levels = Yii::$app->params['customerLevels'];
$model = new AcCarOwner();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
$res['last_send'] = $res['last_send'] ? date('Y-m-d', $res['last_send']) : '';
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d', $res['last_contact']) : '';
} else {
$res = [];
}
//查询对应的系统用户
$userModel = new User();
$user = User::find()->where(['id'=>$res['mid']])->one();
$res['mobile'] = '';
if ($user) {
$res['mobile'] = $user->mobile;
}
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
if ($store) {
$res['store_title'] = $store->title;
}
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
if ($employee) {
$res['employee_title'] = $employee->name;
}
$exts = AcUserExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
if ($exts) {
foreach ($exts as $ext) {
$res[$ext['key']] = $ext['value'];
}
}
// memory_get_usage();//查看当前内存,字节
return $this->render('modify', [
'detail'=>$res,
'levels'=>$levels,
'id'=>$id,
]);
}
//保存车主资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
if (!$post['mobile']) {
\Yii::$app->getSession()->setFlash('warning', '请输入主手机号码!');
$url = Url::toRoute(['carowner/edit','id'=>$id]);
return $this->redirect(['modify','id'=>$id]);
}
$mobile = $post['mobile'];
//查询对应的系统用户
$userModel = new User();
$user = User::find()->where(['mobile'=>$mobile])->one();
if (!$user) {
$pwd = isset($post['password']) ? trim($post['password']) : Yii::$app->params['defaultUserPassword'];
$username = isset($post['realname']) ? trim($post['realname']) : (isset($post['nickname']) ? trim($post['nickname']) : $mobile);
$userModel->mobile = $mobile;
$userModel->username = $username;
$userModel->email = $mobile.'@hiluker.com';
$userModel->setPassword($pwd);
$userModel->generateAuthKey();
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
$userModel->created_at = time();
$userModel->status = 1;
$userModel->save();
$user_id = $userModel->attributes['id']; //获取插入后id
} else {
$user_id = $user->id;
}
//格式化数据
$data = [];
//目标键=》POST键
$cols = ['gender'=>'gender','total_fee'=>'total_fee','level'=>'level','score'=>'score','store_id'=>'store','employee_id'=>'employee','status_code'=>'status_code','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['last_send'=>'last_send','last_contact'=>'last_contact'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? strtotime($post[$key]) : 0;
}
$cols = ['remark'=>'editor'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
$data['mid'] = $user_id;
//格式化车主资料
$AcCarOwner = new AcCarOwner();
foreach ($data as $key=>$val) {
$AcCarOwner->$key = $val;
}
//查询该车主是否在库
$carOwner = AcCarOwner::find()->where(['pid'=>$data['pid'],'mid'=>$data['mid']])->one();
if ($carOwner) {
$id = $carOwner->id;
}
//车主资料入库
if ($id) {
$AcCarOwner->id = $id;
unset($data['create_at']);
$res = $AcCarOwner->updateAll($data, ['id'=>$id]);
} else {
$res = $AcCarOwner->save();
$id = $AcCarOwner->attributes['id']; //获取插入后id
}
//保存扩展资料
$AcUserExt = new AcUserExt();
//批量硬删及软删
// $AcUserExt->updateAll(['deleted'=>1],['deleted'=>0,'pid'=>$pid,'mid'=>$user_id]);
$AcUserExt->deleteAll(['deleted'=>9,'pid'=>$pid,'mid'=>$user_id]); //硬删,变更历史8次的
$AcUserExt->updateAllCounters(['deleted'=>1], ['pid'=>$pid,'mid'=>$user_id]); //更新已有数据
$datas = [];
$data = [];
$cols = ['realname'=>'realname','nickname'=>'nickname','title'=>'title','password'=>'password','mobiles'=>'mobiles','thumb'=>'thumb','province'=>'province','idcard'=>'idcard'];
foreach ($cols as $col=>$key) {
// $data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
$data['pid'] = $pid;
$data['mid'] = $user_id;
$data['key'] = $col;
$data['mobile'] = $mobile;
$data['value'] = isset($post[$key]) ? trim($post[$key]) : '';
$datas[] = $data;
}
//批量插入
$model = clone $AcUserExt;
foreach ($datas as $attributes) {
$model->isNewRecord = true;
$model->setAttributes($attributes, false);
$model->save() && $model->id=0;
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '车主资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '车主资料保存失败!');
return $this->goBack();
}
// $return = [];
// if($res){
// $return['msg'] = '车主信息保存成功';
// $return['errorcode'] = 200;
// $return['url'] = Url::toRoute(['carowner/edit','id'=>$id]);
// $return['buttons'] = [
// ['title'=>'好的,我知道了','class'=>'primary','url'=>$return['url']]
// ];
// }else{
// $return['msg'] = '车主信息保存失败';
// $return['errorcode'] = 0;
// $return['url'] = Url::toRoute(['carowner/new',$post]);
// $return['buttons'] = [
// ['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
// ];
// }
// $classes = ['0'=>'warning','200'=>'success'];
// $return['content'] = $return['msg'];
// $return['class'] = $classes[$return['errorcode']];
// Yii::$app->request->setBodyParams($return);
// return Yii::$app->runAction('index/msg');
}
//删除用户
public function actionDelete($id)
{
global $_HI,$_FM;
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcCarOwner();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('carowner/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcCarOwner();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status_code'] = 0;
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '车主数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
switch ($get['do']) {
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '车主隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
} else {
$return['msg'] = '车主隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '车主显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '车主显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
//短信营销
public function actionMsg()
{
global $_HI,$_FM;
$levels = Yii::$app->params['customerLevels'];
$model = new AcCarOwner();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
$res['last_send'] = $res['last_send'] ? date('Y-m-d', $res['last_send']) : '';
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d', $res['last_contact']) : '';
} else {
$res = [];
}
//查询对应的系统用户
$userModel = new User();
$user = User::find()->where(['id'=>$res['mid']])->one();
$res['mobile'] = '';
if ($user) {
$res['mobile'] = $user->mobile;
}
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
if ($store) {
$res['store_title'] = $store->title;
}
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
if ($store) {
$res['employee_title'] = $employee->name;
}
$exts = AcUserExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
if ($exts) {
foreach ($exts as $ext) {
$res[$ext['key']] = $ext['value'];
}
}
$op = Yii::$app->request->get('op');
$opp = Yii::$app->request->get('opp');
if (!$op) {
return $this->render('msg', [
'detail'=>$res,
'levels'=>$levels,
'id'=>$id,
]);
} elseif ($op=='send') {
$option = [];
$config = [];
$config['accessKeyId'] = Yii::$app->params['aliDySms']['accessKeyId'];
$config['accessKeySecret'] = Yii::$app->params['aliDySms']['accessKeySecret'];
$config['sign'] = Yii::$app->params['aliDySms']['sign'];
$sms = new Sms($option, $config);
$phone = $res['mobile'];
$content=[];
switch ($opp) {
case 'vcode': //发送验证码
$code = mt_rand(1000, 9999);
$content['code'] = $code;
$tmpl = Yii::$app->params['aliDySms']['tmpl']['vcode'];
//验证码入库
$vcodeModel = new CVcode();
$vcode = [];
$vcode['code'] = $code;
$vcode['mobile'] = $phone;
$vcode['create_at'] = time();
foreach ($vcode as $key=>$val) {
$vcodeModel->$key = $val;
}
$vcodeModel->save();
break;
case 'birthday': //发送生日祝福
$realname = isset($res['realname']) ? $res['realname'] : 'VIP';
$content['name'] = $realname;
$content['company'] = Yii::$app->request->post('company');
$content['company'] = $content['company'] ? $content['company'] : '安诚托车';
$tmpl = Yii::$app->params['aliDySms']['tmpl']['acBirthday'];
break;
}
$result = $sms->send($phone, $tmpl, $content);
//保存发送记录
$smsModel = new CSms();
$smsdata = [];
$sid = Yii::$app->session->get('sid');
$smsdata['sid'] = (int)$sid;
$smsdata['pid'] = $pid;
$smsdata['uid'] = Yii::$app->user->identity->id;
$smsdata['mobile'] = $phone;
$smsdata['content'] = json_encode($content, JSON_UNESCAPED_UNICODE);
$smsdata['create_at'] = time();
foreach ($smsdata as $key=>$val) {
$smsModel->$key = $val;
}
$smsModel->save();
$return = [];
$msg = '';
if (!$result) {
$msg .= "".$phone."】发送失败,接口提示:".$sms->errors."\r\n";
$return['errorcode'] = 0;
} elseif (is_array($result) && $result['Code'] !='OK') {
$msg .= "".$phone."】发送失败,接口提示:".$result['Message']."\r\n";
$return['errorcode'] = 0;
} else {
$msg .= "".$phone."】发送成功"."\r\n";
$return['errorcode'] = 0;
}
$return['msg'] = $msg;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
//信息摘要
public function actionInfo()
{
global $_HI,$_FM;
$levels = Yii::$app->params['customerLevels'];
$model = new AcCarOwner();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
$res['last_send'] = $res['last_send'] ? date('Y-m-d', $res['last_send']) : '';
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d', $res['last_contact']) : '';
} else {
$res = [];
}
//查询对应的系统用户
$userModel = new User();
$user = User::find()->where(['id'=>$res['mid']])->one();
$res['mobile'] = '';
if ($user) {
$res['mobile'] = $user->mobile;
}
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
if ($store) {
$res['store_title'] = $store->title;
}
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
if ($store) {
$res['employee_title'] = $employee->name;
}
$exts = AcUserExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
if ($exts) {
foreach ($exts as $ext) {
$res[$ext['key']] = $ext['value'];
}
}
return $this->render('info', [
'detail'=>$res,
'levels'=>$levels,
'id'=>$id,
]);
}
}

View File

@ -1,339 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:30:22+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:30:22+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
class CarseriesController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
//车型列表
public function actionList()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$model = new AcCarSeries();
$where = $where2 = [];
$where2[]='and';
$where2[] = ['in','pid',[0,$pid]];
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'carseries::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','title',$search['title']];
}
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
if (!empty($search['brand_id'])) {
$where['brand_id'] = $search['brand_id'];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
$status = Yii::$app->params['CommonStatus'];
$series = $bids = [];
foreach ($res as $r) {
$r = $r->toArray();
$series[$r['id']] = $r;
$bids[] = $r['brand_id'];
}
$AcCarBrand = new AcCarBrand();
$brands = [];
$_brands = $AcCarBrand->find()->where(['in','id',$bids])->indexBy('id')->all();
foreach ($_brands as $s) {
$brands[$s->id] = $s->toArray();
}
return $this->render('list', [
'series' => $series,
'pager' => $pages,
'brands'=>$brands,
'status'=>$status,
'search'=>$search
]);
}
//车型列表
public function actionSelect()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$model = new AcCarSeries();
$where = $where2 = [];
$where2[]='and';
$where2[] = ['in','pid',[0,$pid]];
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'carseries::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','title',$search['title']];
}
// $search['brand'] = isset($search['brand']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
if (!empty($search['brand_id'])) {
$where['brand_id'] = $search['brand_id'];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
$status = Yii::$app->params['CommonStatus'];
$series = $bids = [];
foreach ($res as $r) {
$r = $r->toArray();
$series[$r['id']] = $r;
$bids[$r['brand_id']] = $r['brand_id'];
}
$AcCarBrand = new AcCarBrand();
$brands = [];
$_brands = $AcCarBrand->find()->where(['in','id',$bids])->indexBy('id')->all();
foreach ($_brands as $s) {
$brands[$s->id] = $s->toArray();
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'car';
return $this->render('select', [
'series' => $series,
'pager' => $pages,
'brands'=>$brands,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
//新增车型
public function actionNew()
{
global $_HI,$_FM;
$status = Yii::$app->params['CommonStatus'];
$AcCarSeries = new AcCarSeries();
$AcCarSeries->status_code = 0;
return $this->render('modify', ['status'=>$status,'detail'=>$AcCarSeries->toArray()]);
}
//更新车型
public function actionEdit()
{
global $_HI,$_FM;
$status = Yii::$app->params['CommonStatus'];
$model = new AcCarSeries();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
$parmas = [];
if ($res) {
$res = $res->toArray();
$parmas = json_decode($res['params'], true);
} else {
$res = [];
}
//查询对应的品牌
$brand = AcCarBrand::find()->where(['id' => $res['brand_id']])->one();
if ($brand) {
$res['brand_title'] = $brand->title;
}
return $this->render('modify', [
'detail'=>$res,
'params'=>$parmas,
'status'=>$status,
'id'=>$id,
]);
}
//保存车型资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
$data = [];
$data['title'] = trim($post['title']);
//目标键=》POST键
$cols = ['brand_id'=>'brand_id','status_code'=>'status_code','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$params = $post['p'];
$cols = ['height','length','width','kg','seat'];
foreach ($cols as $col) {
$params[$col] = isset($params[$col]) ? (int)$params[$col] : 0;
}
$data['params'] = json_encode($params, JSON_UNESCAPED_UNICODE);
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//格式化车型资料
$AcCarSeries = new AcCarSeries();
foreach ($data as $key=>$val) {
$AcCarSeries->$key = $val;
}
//车型资料入库
if ($id) {
$AcCarSeries->id = $id;
unset($data['create_at']);
$res = $AcCarSeries->updateAll($data, ['id'=>$id]);
} else {
$res = $AcCarSeries->save();
$id = $AcCarSeries->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '车型资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '车型资料保存失败!');
return $this->goBack();
}
}
//删除车型
public function actionDelete($id)
{
global $_HI,$_FM;
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcCarSeries();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('carowner/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcCarSeries();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status_code'] = 0;
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '车型数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
switch ($get['do']) {
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '车型隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
} else {
$return['msg'] = '车型隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '车型显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '车型显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,39 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:30:47+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:30:47+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
// use backend\models\Citys;
class CityController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
public function actionSelect()
{
$citys = Yii::$app->params['citys'];
$pager = new Pagination(['totalCount' =>count($citys), 'pageSize' => '100']);
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'city';
$search=[];
return $this->render('select', [
'citys'=>$citys,
'pager' => $pager,
'search'=>$search,
'callback'=>$callback
]);
}
}

View File

@ -1,86 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-04-15 20:22:03
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2024-07-08T15:48:08+08:00
# @Copyright: www.hiluker.cn
//管理员用户入口
namespace backend\controllers;
use Yii;
use common\models\Member as User;
use addons\models\AcUserExt;
use addons\models\AcStore;
use addons\models\AcEmployee;
use yii\web\Controller;
class Common extends Controller
{
protected $pid = 0;
protected $user_id = 0;
protected $site_id = 0;
protected $store_id = 0;
protected $employee_id = 0;
protected $user_info;
protected $postdata = []; //重新整理一下客户端传输的数据
protected $imgHttp = true; //图片附件地址生成http(s) //false:不生成http网址 true:仅生成http网址 https:生成https网址
protected $page = 1; //当前数据分页
protected $pageSize = 10; //默认数据分页大小
public $enableCsrfValidation = false;
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
//判断请求内容类型 content-type,支持 json请求
$postdata = Yii::$app->request->post();
$headers = Yii::$app->request->headers;
$contentType = $headers->get('content-type');
if ($contentType=="application/json") {
$postdata = json_decode(file_get_contents('php://input'), true);
}
$this->postdata = $postdata;
$session = Yii::$app->session;
if (isset($postdata['pid'])) {
if ((int)$postdata['pid']>0) {
$this->pid = (int)$postdata['pid'];
$session->set('pid', $this->pid);
} else {
$session->set('pid', 0);
}
} else {
$session->set('pid', 0);
}
$this->site_id = Yii::$app->params['siteId'];
if (isset($postdata['user_id']) && (int)$postdata['user_id']>0) {
$this->user_id = (int)$postdata['user_id'];
}
$userModel = new User();
if ($this->user_id) {
$res = $userModel->findOne($this->user_id);
$this->user_info = $res;
}
if (isset($postdata['employee_id']) && (int)$postdata['employee_id']>0) {
$this->employee_id = (int)$postdata['employee_id'];
}
$page = isset($postdata['page']) ? (int)$postdata['page'] : 1;
$this->page = $page<=0 ? 1 : $page;
$pageSize = isset($postdata['psize']) ? (int)$postdata['psize'] : 10;
$this->pageSize = $pageSize<=0 ? 10 : $pageSize;
}
public function result($msg, $data=null, $code=0)
{
$return = [];
$return['code'] = $code;
$return['msg'] = $msg;
if ($data) {
$return['data'] = $data;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
}

View File

@ -1,278 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:35:33+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:35:33+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcContact;
use common\models\Member as User;
use common\models\UserExt;
class ContactController extends Common
{
public function actionIndex()
{
return $this->render('index');
}
//通讯录列表
public function actionList()
{
$model = new AcContact();
$where = $where2 = [];
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'contact::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if (!empty($search['title'])) {
$where2[]='or';
$where2[] = ['LIKE','name',$search['title']];
$where2[] = ['LIKE','mobile',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['CommonStatus'];
return $this->render('list', [
'contactors'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$model = new AcContact();
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$where = $where2 = [];
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'contact::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if (!empty($search['title'])) {
$where2[]='or';
$where2[] = ['LIKE','name',$search['title']];
$where2[] = ['LIKE','mobile',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['CommonStatus'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'contactor';
return $this->render('select', [
'contactors'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
return $this->render('modify', []);
}
//编辑通讯录资料
public function actionEdit()
{
$model = new AcContact();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
}
return $this->render('modify', ['detail'=>$res]);
}
//保存通讯录资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['company'=>'company','name'=>'name','mobile'=>'mobile','idcard'=>'idcard'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询通讯录手机号是否在库
$hasContactor = AcContact::find()->where(['mobile'=>$data['mobile']])->one();
if ($hasContactor) {
if ($id && $id==$hasContactor->id) {
} else {
$id = $hasContactor->id;
\Yii::$app->getSession()->setFlash('danger', '保存失败,该手机号对应的通讯录已在库,系统自动现在为您调出该通讯录资料!');
return $this->redirect(['edit','id'=>$id]);
}
}
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//保存通讯录资料
$AcContact = new AcContact();
foreach ($data as $key=>$val) {
$AcContact->$key = $val;
}
if ($id) {
$AcContact->id = $id;
unset($data['create_at']);
$res = $AcContact->updateAll($data, ['id'=>$id]);
} else {
$res = $AcContact->save();
$id = $AcContact->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '通讯录信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '通讯录信息保存失败!');
return $this->goBack();
}
}
//删除
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcContact();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('contact/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '通讯录删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '通讯录删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcContact();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '通讯录数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
switch ($get['do']) {
case 'out':
$data['status'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '通讯录隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
} else {
$return['msg'] = '通讯录隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'in':
$data['status'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '通讯录显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '通讯录显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,268 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:35:09+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:35:09+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcDriver;
use common\models\Member as User;
use common\models\UserExt;
class DriverController extends Common
{
public function actionIndex()
{
return $this->render('index');
}
//司机列表
public function actionList()
{
$model = new AcDriver();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['DriverStatus'];
return $this->render('list', [
'drivers'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$model = new AcDriver();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['DriverStatus'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'driver';
return $this->render('select', [
'drivers'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
return $this->render('modify', []);
}
//编辑司机资料
public function actionEdit()
{
$model = new AcDriver();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
}
return $this->render('modify', ['detail'=>$res]);
}
//保存司机资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['name'=>'name','mobile'=>'mobile','idcard'=>'idcard'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询司机手机号是否在库
$hasDriver = AcDriver::find()->where(['mobile'=>$data['mobile']])->one();
if ($hasDriver) {
if ($id && $id==$hasDriver->id) {
} else {
$id = $hasDriver->id;
\Yii::$app->getSession()->setFlash('danger', '保存失败,该手机号对应的司机已在库,系统自动现在为您调出该司机资料!');
return $this->redirect(['edit','id'=>$id]);
}
}
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//保存司机资料
$AcDriver = new AcDriver();
foreach ($data as $key=>$val) {
$AcDriver->$key = $val;
}
if ($id) {
$AcDriver->id = $id;
unset($data['create_at']);
$res = $AcDriver->updateAll($data, ['id'=>$id]);
} else {
$res = $AcDriver->save();
$id = $AcDriver->attributes['id']; //获取插入后id
}
//查询司机对应的系统用户
$userModel = new User();
$user = $userModel->find()->where(['mobile'=>$data['mobile']])->one();
if (empty($user)) {
$userModel->username = !$data['name'] ? $data['mobile'] : $data['name'];
$userModel->mobile = $data['mobile'];
$userModel->email = $data['mobile'].'@hiluker.com';
$userModel->setPassword(Yii::$app->params['defaultUserPassword']);
$userModel->generateAuthKey();
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
$userModel->created_at = time();
$userModel->status = 1;
$userModel->save();
$user_id = $userModel->attributes['id']; //获取插入后id
}
\Yii::$app->getSession()->setFlash('info', '已成功注册该用户!');
if ($res) {
\Yii::$app->getSession()->setFlash('success', '司机信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '司机信息保存失败!');
return $this->goBack();
}
}
//删除员工
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcDriver();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('driver/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '司机删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '司机删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcDriver();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '司机数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
switch ($get['do']) {
case 'out':
$data['status'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '司机离职标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
} else {
$return['msg'] = '司机离职标记失败';
$return['errorcode'] = 0;
}
break;
case 'in':
$data['status'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '司机在职标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '司机在职标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,295 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:34:47+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:34:47+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcEmployee;
use addons\models\AcStore;
use common\models\Member as User;
use addons\models\AcUserExt;
class EmployeeController extends Common
{
public function actionIndex()
{
return $this->render('index');
}
//用户列表
public function actionList()
{
$model = new AcEmployee();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['EmployeeStatus'];
$gender = Yii::$app->params['gender'];
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_stores = $model->find()->where($where)->all();
$stores = [];
foreach ($_stores as $s) {
$stores[$s->id] = $s->toArray();
}
return $this->render('list', [
'employees'=>$res,
'pager' => $pages,
'stores'=>$stores,
'status'=>$status,
'gender'=>$gender,
'search'=>$search
]);
}
public function actionSelect()
{
$model = new AcEmployee();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['EmployeeStatus'];
$gender = Yii::$app->params['gender'];
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_stores = $model->find()->where($where)->all();
$stores = [];
foreach ($_stores as $s) {
$stores[$s->id] = $s->toArray();
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'employee';
return $this->render('select', [
'employees'=>$res,
'pager' => $pages,
'stores'=>$stores,
'status'=>$status,
'gender'=>$gender,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
return $this->render('modify', []);
}
//编辑员工资料
public function actionEdit()
{
$model = new AcEmployee();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
}
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
if ($store) {
$res['store_title'] = $store->title;
}
return $this->render('modify', ['detail'=>$res]);
}
//保存员工资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['name'=>'name','mobile'=>'mobile'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['gender'=>'gender','status'=>'status','store_id'=>'store','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['remark'=>'editor'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['status_code'] = 1;
$data['pid'] = $pid;
//保存员工资料
$AcEmployee = new AcEmployee();
foreach ($data as $key=>$val) {
$AcEmployee->$key = $val;
}
//查询员工手机号是否在库
$employee = AcEmployee::find()->where(['mobile'=>$data['mobile']])->one();
if ($employee) {
$id = $employee->id;
}
if ($id) {
$AcEmployee->id = $id;
unset($data['create_at']);
$res = $AcEmployee->updateAll($data, ['id'=>$id]);
} else {
$res = $AcEmployee->save();
$id = $AcEmployee->attributes['id']; //获取插入后id
}
//查询员工对应的系统用户
$userModel = new User();
$user = User::find()->where(['mobile'=>$data['mobile']])->one();
if (empty($user)) {
$userModel->username = $data['mobile'];
$userModel->mobile = $data['mobile'];
$userModel->email = $data['mobile'].'@hiluker.com';
$userModel->setPassword(Yii::$app->params['defaultUserPassword']);
$userModel->generateAuthKey();
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
$userModel->created_at = time();
$userModel->status = 1;
$userModel->save();
$user_id = $userModel->attributes['id']; //获取插入后id
}
\Yii::$app->getSession()->setFlash('info', '已成功注册该用户!');
if ($res) {
\Yii::$app->getSession()->setFlash('success', '员工信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '员工信息保存失败!');
return $this->goBack();
}
}
//删除员工
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcEmployee();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('employee/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '员工删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '员工删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcEmployee();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '员工数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
switch ($get['do']) {
case 'out':
$data['status'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '员工离职标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
} else {
$return['msg'] = '员工离职标记失败';
$return['errorcode'] = 0;
}
break;
case 'in':
$data['status'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '员工在职标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '员工在职标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,76 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:34:19+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:34:19+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
class ErrorController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
public function actionReport()
{
$request = Yii::$app->request;
$get = $request->get();
$url = Urldecode($get['url']);
$code = 0;
if ($request->isPost) {
$code = getMillisecond().'_'.rand(0, 999);
$filename = $code.'.php';
$post = $request->post();
$code = $post['code']!=0 ? $post['code'] : $code;
$post['time'] = time();
fm_load()->fm_func('error');
fmFunc_error_write($filename, $post);
$msg = [];
$msg['title'] = '报错提交通知';
$msg['content'] = '感谢反馈,工程师将尽快处理!您本次的反馈工单号为<code>'.$code.'</code>';
$msg['class'] = 'success';
$btn = [];
$btn['title'] = '返回';
// $btn['url'] = Url::current();
$btn['url'] = $url;
$btn['class'] = 'primary';
$msg['buttons'][] = $btn;
$btn = [];
$btn['title'] = '查看工单';
$btn['url'] = Url::toRoute(['error/order','code'=>$code]);
$btn['class'] = 'warning';
$msg['buttons'][] = $btn;
$btn = [];
$btn['title'] = '回到首页';
$btn['url'] = Url::home();
$btn['class'] = 'info';
$msg['buttons'][] = $btn;
return $this->render('../layouts/msg', $msg);
}
return $this->render('report', ['url'=>$url]);
}
public function actionOrder()
{
$request = Yii::$app->request;
$get = $request->get();
$code = Urldecode($get['code']);
$filename = $code.'.php';
fm_load()->fm_func('error');
$data = [];
$file = fmFunc_error_get($code);
include $file;
return $this->render('report', ['code'=>$code,'data'=>$data,'url'=>$data['url']]);
}
}

View File

@ -1,32 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:33:38+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:33:38+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcFeeOrder;
use addons\models\AcFeeDriver;
use addons\models\AcOrder;
use addons\models\AcOrderPre;
use addons\models\AcOrderStatus;
use addons\models\AcStore;
use addons\models\AcEmployee;
use addons\models\AcPlat;
use common\models\CVcode;
class FeeController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('@app/views/layouts/dev', []);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,127 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-04-15 20:22:03
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2024-07-06T09:26:30+08:00
# @Copyright: www.hiluker.cn
//管理员用户入口
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use common\models\Member as User;
use addons\models\AcUserExt;
use addons\models\AcStore;
use addons\models\AcEmployee;
use backend\controllers\Common;
class GmController extends Common
{
public function beforeAction($action)
{
if (!$this->pid) {
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
}
return parent::beforeAction($action);
}
public function actionIndex()
{
$this->result('您正使用CMTS系统本接口为内部系统接口禁止非法链接使用', ['total'=>0,'data'=>[],'page'=>1], 200);
}
public function actionLogin()
{
$pid = $this->pid;
$post = $this->postdata;
$search = isset($post['search']) ? $post['search'] : null;
$username = isset($search['username']) ? $search['username'] : null;
$username = isset($post['username']) ? $post['username'] : $username;
$passwd = isset($search['passwd']) ? $search['passwd'] : null;
$passwd = isset($post['passwd']) ? $post['passwd'] : $passwd;
$return = [];
if (!$username && !passwd) {
$this->result('登陆参数错误!', null, 400);
}
if (!$username) {
$this->result('请输入您的账号!', null, 400);
}
if (!$passwd) {
$this->result('请输入您的密码!', null, 400);
}
$username = trim(htmlspecialchars_decode($username));
$passwd = trim(htmlspecialchars_decode($passwd));
if (!$username) {
$this->result('输入错误,请检查您的账号!', null, 400);
}
if (!$passwd) {
$this->result('输入有误,请检查您的密码!', null, 400);
}
$model = new User();
$user = $model->findOne(['mobile' => $username]);
if (!$user) {
$this->result('查无此人!', null, 404);
}
if ($user->status != User::STATUS_ACTIVE) {
$this->result('账户异常,禁止登陆!', null, 403);
}
//安全校验,登陆密码
$isPwdRight = $user->validatePassword($passwd);
if (!$isPwdRight) {
$this->result('密码错误,禁止登陆!', null, 400);
}
//校验结束
// 使用指定用户名获取用户身份实例
$identity = $user;
// 登录用户有效期30d
$duration = 3600 * 24 * 30;
$_login = Yii::$app->user->login($identity, $duration);
if (!$_login) {
$this->result('登陆失败!', null, 400);
}
//登陆成功,返回用户信息
$_user = ['id'=>$user->id,'username'=>$user->username,'mobile'=>$user->mobile,'email'=>$user->email,'avatar'=>Url::to($user->avatar)];
//查询关联网点信息(以登陆手机号为依据)
$AcEmployeeModel = new AcEmployee();
$employee = $AcEmployeeModel->findOne(['mobile'=>$user->mobile]);
if (!$employee) {
$this->result('未找到对应工号,请联系管理员!', null, 404);
}
if ($employee->deleted) {
$this->result('工号已清除,禁止登陆!', null, 403);
}
if (!$employee->status) {
$this->result('工号禁用,禁止登陆!', null, 403);
}
$_user['employee_id'] = $employee->id;
$AcStoreModel = new AcStore();
$store = $AcStoreModel->findOne($employee->store_id);
$_store = [];
$citys = Yii::$app->params['citys'];
if ($store && !$store->deleted) {
$_store= [
'id' => $store->id,
'title' => $store->title,
'city' => isset($citys[$store->city]) ? $citys[$store->city]['name'] : '',
'addr' => $store->addr,
'longt' => $store->longt,
'lat' => $store->lat,
'status' => $store->status_code
];
}
$_user['store'] = $_store;
$this->result('登陆成功!', ['user'=>$_user], 200);
}
}

View File

@ -1,378 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:32:02+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:32:02+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcTruckOnline;
use addons\models\AcTruckCars;
use addons\models\AcStore;
use addons\models\AcCar;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcOrder;
use addons\models\AcGps;
use addons\models\AcGpsRoute;
use addons\models\AcTruckRoute;
class GpsController extends Common
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
$session = Yii::$app->session;
if (isset($_GET['pid']) && (int)$_GET['pid']>0) {
$session->set('pid', (int)$_GET['pid']);
}
$pid = $session->get('pid');
if (!$pid) {
return Yii::$app->response->redirect(['index/index']);
}
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
if (!$online_id) {
$online_id = $session->get('online_id');
} else {
$session->set('online_id', $online_id);
}
if (!$online_id) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '请先选择好要查看的出车大板';
$return['errorcode'] = 0;
// $return['url'] = Url::toRoute(['truckol/index',$post]);
// $return['buttons'] = [
// ['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
// ];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truckol = $session->get('truckOnline');
$AcTruckOnline = new AcTruckOnline();
$res = true;
if (!$truckol) {
$res = $AcTruckOnline->findOne($online_id);
if ($res) {
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$session->set('truckOnline', $truckol);
}
}
if ($online_id != $truckol['id']) {
$res = $AcTruckOnline->findOne($online_id);
if ($res) {
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$session->set('truckOnline', $truckol);
}
}
if (!$res) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '请先选择好要查看的出车大板';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/index',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
}
//主界面
public function actionIndex()
{
return $this->render('index', []);
}
//所有板车位置记录列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute = new AcTruckRoute();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
if ($online_id) {
$where[] = ['=','online_id',$online_id];
}
$where[] = ['=','deleted',0];
$data = $AcTruckRoute->find()->where($where)->orderby('orderby ASC,id DESC');
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$truck_ids = [];
foreach ($res as $r) {
$truck_ids[] = $r->truck_id;
}
$AcTruck = new AcTruck();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$truck_ids];
$where[] = ['=','deleted',0];
$trucks = $AcTruck->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['CommonStatus'];
return $this->render('list', [
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'trucks'=>$trucks,
'online_id'=>$online_id,
'truckol'=>$truckol
]);
}
public function actionNew()
{
$status = Yii::$app->params['CommonStatus'];
$AcTruckRoute = [];
$AcTruckRoute['status_code'] = 0;
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute['truck_id'] = $truckol['truck_id'];
$AcTruckRoute['truck_num'] = $truckol['truck_num'];
return $this->render('modify', ['status'=>$status,'detail'=>$AcTruckRoute,'online_id'=>$online_id,'truckol'=>$truckol]);
}
//编辑板车位置信息
public function actionEdit()
{
$id = Yii::$app->request->get('id'); //记录ID
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute = new AcTruckRoute();
$route = $AcTruckRoute->findOne($id);
if (!$route) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '位置记录数据获取异常,请重新选择获取';
$return['errorcode'] = 0;
$return['url'] = '';
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$route = $route->toArray();
$route['truck_id'] = $truckol['truck_id'];
$route['online_id'] = $online_id;
$route['truck_num'] = $truckol['truck_num'];
$status = Yii::$app->params['CommonStatus'];
return $this->render('modify', ['status'=>$status,'detail'=>$route,'online_id'=>$online_id,'truckol'=>$truckol]);
}
//保存位置记录信息
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
$online_id = Yii::$app->session->get('online_id');
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$data = [];
$data['truck_id'] = $truckol['truck_id'];
$data['online_id'] = $online_id;
//格式化数据
//目标键=》POST键
$cols = ['longt'=>'lng','lat'=>'lat','addr'=>'addr'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['orderby'=>'orderby','status_code'=>'status_code'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$_time = time();
$key = 'update_at';
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
if (!$id) {
$data['create_at'] = $_time;
}
$data['pid'] = $pid;
//保存位置资料
$AcTruckRoute = new AcTruckRoute();
foreach ($data as $key=>$val) {
$AcTruckRoute->$key = $val;
}
if ($id) {
$res = $AcTruckRoute->updateAll($data, ['id'=>$id]);
} else {
$res = $AcTruckRoute->save();
$id = $AcTruckRoute->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//删除记录
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$return = [];
$model = new AcTruckRoute();
$route = $model->findOne($id);
if (!$route) {
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($route->pid !=$pid) {
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($route->deleted !=0) {
$return['msg'] = '数据已被删除过,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$route->deleted = 1;
$res = $route->save();
$return['url'] = '';
$return['timeout'] = 1; //n秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '位置记录删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '位置记录删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$return = [];
$model = new AcTruckRoute();
$route = $model->findOne($id);
if (!$route) {
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($route->pid !=$pid) {
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($route->deleted !=0) {
$return['msg'] = '数据已被删除,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$return['timeout'] = 1; //n秒后自动跳转
$res = true;
switch ($get['do']) {
case 'show':
if ($route->status_code!=1) {
$route->status_code = 1;
$res = $route->save();
}
if ($res) {
$return['msg'] = '记录显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
} else {
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
case 'hide':
if ($route->status_code!=0) {
$route->status_code = 0;
$res = $route->save();
}
if ($res) {
$return['msg'] = '记录隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
} else {
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,101 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-10T01:13:34+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-13T11:51:07+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\web\UploadedFile;
use common\models\CAttachment;
use backend\controllers\Common;
class ImageController extends Common
{
public function beforeAction($action)
{
if (!$this->pid) {
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
}
return parent::beforeAction($action);
}
public function actionIndex()
{
$apis = [
'list'=>'图片列表',
];
$this->result('您正使用CMTS系统订单管理接口', $apis, 200);
}
public function actionList()
{
$siteId = Yii::$app->params['siteId'];
$session = Yii::$app->session;
$pid = $this->pid;
$model = new CAttachment();
$search = $where = [];
$where[] = 'and';
$where[] = ['=','status_code',1];
$where[] = ['=','type',0];
$where[] = ['=','siteid',$siteId];
$where[] = ['=','pid',$pid];
$post = $this->postdata;
if (isset($post['search'])) {
$search = $post['search'];
$session->set('images::search', $search);
} elseif ($session->get('images::search')) {
$search = $session->get('images::search');
}
if ($search) {
if ($search['create_m']) {
$start = strtotime($search['create_m']);
$s = date("Y-m-d H:i:s", $start);
$ldm = strtotime("last day of ".$s);
$m = date("Y-m-d", $ldm)." 23:59:59";
$end = strtotime($m);
$where[] = ['between','create_at',$start,$end];
} elseif (!empty($search['create_after']) && !empty($search['create_before'])) {
$start = strtotime($search['create_after']);
$end = strtotime($search['create_before']);
$where[] = ['between','create_at',$start,$end];
} elseif (!empty($search['create_after'])) {
$start = strtotime($search['create_after']);
$where[] = ['>=','create_at',$start];
} elseif (!empty($search['create_before'])) {
$end = strtotime($search['create_before']);
$where[] = ['<=','create_at',$end];
}
if ($search['title']) {
$where[] = ['LIKE','title',$search['title']];
}
}
//分页
$orderby = ['id' => SORT_DESC];
$Attachment = new Attachment();
$list = $Attachment->getData($model, $where, $orderby);
$pager = $Attachment->getPagination();
//附件网址前缀
$src = Url::base(true)."/../../upload"; //在网站根目录下使用upload/pics目录;适合使用yii框架主目录入口而非绑定子域名的情形
if ($_SERVER['DOCUMENT_ROOT'].'/upload' != Yii::getAlias("@upload")) {
// $src = Url::toRoute(['attach/index','img'=>'']); //换用网络加载转换的方式-反应慢
$src = Yii::$app->params['attachSrc'].Yii::$app->params['attachDir'];
}
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'thumb';
$data = [
'list'=>$list,
'pager' => $pager,
'src'=>$src,
'callback'=>$callback
];
$this->result('', $data, 200);
}
}

View File

@ -1,160 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-13T09:20:03+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-13T10:25:41+08:00
# @Copyright: www.hiluker.cn
//主入口页
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use addons\models\AcCar;
use addons\models\AcCarOwner;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcStore;
use addons\models\AcEmployee;
use addons\models\AcOrder;
use addons\models\AcOrderPre;
use addons\models\AcOrderStatus;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcPlat;
use common\models\CVcode;
use addons\models\AcContact;
use common\models\Member as User;
use addons\models\AcUserExt;
class IndexController extends Common
{
public function beforeAction($action)
{
if (!$this->pid) {
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
}
return parent::beforeAction($action);
}
public function actionIndex()
{
$apis = [
'h5data'=>'拉取APP首页数据',
];
$this->result('您正使用CMTS系统接口', $apis, 200);
}
public function actionH5data()
{
$session = Yii::$app->session;
$pid = $this->pid;
$model = new AcOrder();
$search = $where = $orwhere = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$deleted = 0;
$where[]=['=','deleted',$deleted]; //排除已删除运单
$status_code = -1;
$where[]=['<>','status_code',$status_code]; //排除已取消运单
$start = date('Y-m-d 00:00:00'); //今日0点
// $start = date('2020-08-29 00:00:00'); //测试时段
$start = strtotime($start);
$end = date('Y-m-d H:i:s'); //当前时间点
// $end = date('2021-09-04 00:00:00'); //测试时段
$end = strtotime($end);
//今日运单
$_where = $where;
$_where[]=['=','is_turnover',0]; //排除交车单
$_where[] = ['between','sign_date',$start,$end];
$data = $model->find()->where($_where);
$order_today_count = $data->count();
//今日交车
$_where = $where;
$_where[]=['=','is_turnover',1]; //交车单
$_where[] = ['between','sign_date',$start,$end];
$data = $model->find()->where($_where);
$jiaoche_today_count = $data->count();
//今日录单
$_where = $where;
$_where[] = ['between','create_at',$start,$end];
$data = $model->find()->where($_where);
$order_today_create = $data->count();
//昨日
$_end = $start;
$_start = date('Y-m-d 00:00:00', strtotime("-1 day"));
$_start = strtotime($_start);
//昨日运单
$_where = $where;
$_where[]=['=','is_turnover',0]; //排除交车单
$_where[] = ['between','sign_date',$_start,$_end];
$data = $model->find()->where($_where);
$order_yesterday_count = $data->count();
//昨日交车
$_where = $where;
$_where[]=['=','is_turnover',1]; //交车单
$_where[] = ['between','sign_date',$_start,$_end];
$data = $model->find()->where($_where);
$jiaoche_yesterday_count = $data->count();
//昨日录单
$_where = $where;
$_where[] = ['between','create_at',$_start,$_end];
$data = $model->find()->where($_where);
$order_yesterday_create = $data->count();
//本月起始时间点
$_start = date('Y-m-01 00:00:00');
$ldm = strtotime("last day of ".$_start);
$m = date("Y-m-d", $ldm)." 23:59:59";
$_start = strtotime($_start);
$_end = strtotime($m);
//本月运单
$_where = $where;
$_where[]=['=','is_turnover',0]; //排除交车单
$_where[] = ['between','sign_date',$_start,$_end];
$data = $model->find()->where($_where);
$order_month_count = $data->count();
//本月交车
$_where = $where;
$_where[]=['=','is_turnover',1];
$_where[] = ['between','sign_date',$_start,$_end];
$data = $model->find()->where($_where);
$jiaoche_month_count = $data->count();
//累计运单
$_where = $where;
$_where[]=['=','is_turnover',0]; //排除交车单
$data = $model->find()->where($_where);
$order_all_count = $data->count();
//累计交车
$_where = $where;
$_where[]=['=','is_turnover',1];
$data = $model->find()->where($_where);
$jiaoche_all_count = $data->count();
$return = [];
$return['code'] = 200;
$return['msg'] = '首页数据下载!';
$return['data']= [
'orderToday'=>$order_today_count,
'orderYesterday'=>$order_yesterday_count,
'orderMonth'=>$order_month_count,
'orderTotal'=>$order_all_count,
'jiaocheToday'=>$jiaoche_today_count,
'jiaocheYesterday'=>$jiaoche_yesterday_count,
'jiaocheMonth'=>$jiaoche_month_count,
'jiaocheTotal'=>$jiaoche_all_count,
'notice'=>0
];
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
}

View File

@ -1,634 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-04-25T01:57:06+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:36:42+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use addons\models\AcCar;
use addons\models\AcCarOwner;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcStore;
use addons\models\AcEmployee;
use addons\models\AcOrder;
use addons\models\AcOrderPre;
use addons\models\AcOrderStatus;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcPlat;
use common\models\CVcode;
use addons\models\AcContact;
use common\models\Member as User;
use addons\models\AcUserExt;
use common\models\Fans;
class JiaocheController extends Common
{
public function beforeAction($action)
{
$session = Yii::$app->session;
$pid = $session->get('pid');
$pid = 1;
if (!$pid) {
$return = [];
$return['code'] = 0;
$return['msg'] = '您正使用本系统内部接口,禁止非法链接使用!';
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
return parent::beforeAction($action);
}
public function actionIndex()
{
$return = [];
$return['code'] = 200;
$return['msg'] = '您正使用CMTS系统本接口为内部系统接口禁止非法链接使用';
$return['data']= ['total'=>0,'data'=>[],'page'=>1];
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
//订单列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$pid = 1;
$session = Yii::$app->session;
$return = [];
$model = new AcOrder();
$where = $orwhere = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = Yii::$app->request->post();
$search = isset($post['search']) ? $post['search'] : [];
$CarModel = new AcCar();
if (isset($search['carno']) && !empty($search['carno'])) {
$search['carno'] = trim($search['carno']);
$cars = $CarModel->find()->where(['LIKE','num_left',$search['carno']])->limit(5)->offset(0)->all(); //最多仅显示可匹配车牌号的前5个
if (empty($cars)) {
$return['code'] = 400;
$return['msg'] = '未查询到相关车辆';
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
} else {
$car_ids = [];
foreach ($cars as $car) {
$car_ids[] = $car->id;
}
$where[] = ['IN','car_id',$car_ids];
}
}
if (isset($search['city']) && !empty($search['city'])) {
$search['city'] = trim($search['city']);
$where[] = ['LIKE','start_city',$search['city']];
}
if (isset($search['phone']) && !empty($search['phone'])) {
$search['phone'] = trim($search['phone']);
$orwhere = ['or',['LIKE','sender_mobiles',$search['phone']],['LIKE','receiver_mobiles',$search['phone']]];
}
$deleted = 0;
$where[]=['=','deleted',$deleted];
$where[]=['=','is_turnover',1]; //交车单
$data = $model->find()->where($where)->andwhere($orwhere);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '10']);
$_orderby = 'sign_date DESC,id DESC';
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
$status = Yii::$app->params['OrderStatus'];
$cids = $sids = $eids = $mids = [];
if ($res) {
foreach ($res as $r) {
$cids[$r->car_id] = $r->car_id;
$sids[$r->store_id] = $r->store_id;
$eids[$r->employee_id] = $r->employee_id;
$mids[$r->from_mid] = $r->from_mid;
}
}
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_stores = $model->find()->where(['in','id',$sids])->all();
$stores = [];
foreach ($_stores as $s) {
$stores[$s->id] = $s->toArray();
}
$model = new AcEmployee();
$employees = [];
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
foreach ($_employees as $s) {
$employees[$s->id] = $s->toArray();
}
$model = new User();
$users = [];
$_users = $model->find()->where(['in','id',$mids])->all();
foreach ($_users as $s) {
$s = $s->toArray();
$users[$s['id']] = $s;
}
$model = new AcCar();
$cars = [];
$_cars = $model->find()->where(['in','id',$cids])->indexBy('id')->all();
$bids = $sids =[];
foreach ($_cars as $s) {
$bids[] = $s->brand_id;
$sids[] = $s->series_id;
$cars[$s->id] = $s->toArray();
}
if ($cars) {
foreach ($cars as &$car) {
$car['title2'] = '';
if (isset($brands[$car['brand_id']])) {
$car['title2'] .= $brands[$car['brand_id']]['title'];
}
if (isset($series[$car['series_id']])) {
$car['title2'] .= $series[$car['series_id']]['title'];
}
$car['number2'] = $car['num_frame'];
if ($car['num_p']) {
$car['number2'] = $car['num_p'];
}
if ($car['num_area']) {
$car['number2'] .= $car['num_area'];
}
if ($car['num_left']) {
$car['number2'] .= $car['num_left'];
}
}
}
$orders = [];
$unsets = ['pid','commission','commission_left','fee_truck','create_at','create_by','deleted','income','expense','fee_deliver','fee_extra','fee_insurance','fee_pickup','fee_urgent','from_bid','from_mid','is_commission','is_cwqr','is_holdon','is_over','pay_receive_pids','pay_send_pids','pre_id','remark','car_extra','thumb_b','thumb_f','thumb_l','thumb_r','thumbs','driving_lisence','videos'];
foreach ($res as $s) {
$car = $cars[$s->car_id];
$s = $s->toArray();
if (isset($exts[$s['from_mid']])) {
foreach ($exts[$s['from_mid']] as $col=>$val) {
$s[$col] = $val;
}
}
foreach ($unsets as $us) {
unset($s[$us]);
}
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
$wk = date('w', $s['sign_date']);
$s['signdate'] = date('Y-m-d ', $s['sign_date']) . '星期'.$weekdays[$wk];
$s['from_province'] = Yii::$app->params['regionAreas'][$s['start_province']];
$s['to_province'] = Yii::$app->params['regionAreas'][$s['aim_province']];
$s['car_number']= $car['number2'];
$s['car_title'] = $car['title'];
$s['status'] = $status[$s['status_code']];
$orders[] = $s;
}
$return = [];
$return['code'] = 200;
$return['msg'] = '订单查询成功!';
$return['data']= ['total'=>$data->count(),
'data'=>[
'orders' => $orders,
'employees'=>$employees,
'stores'=>$stores,
'users'=>$users
],
'page'=>1];
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
public function actionDetail()
{
$pid = Yii::$app->session->get('pid');
$status = Yii::$app->params['OrderStatus'];
$post = Yii::$app->request->post();
$return = [];
$id = isset($post['oid']) ? $post['oid'] : 0;
if ($id<=0) {
$return['code'] = 200;
$return['msg'] = '查询参数错误!';
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($id);
$detail = $order->toArray();
$detail['thumbs'] = json_decode($detail['thumbs']);
$model = new AcStore();
$store = $model->findOne($detail['store_id']);
if ($store) {
$detail['store_title'] = $store->title;
}
$model = new AcEmployee();
$employee = $model->findOne($detail['employee_id']);
if ($employee) {
$detail['employee_title'] = $employee->name;
}
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
$model = new AcCar();
$car = $model->findOne($detail['car_id']);
if ($car) {
$detail['car_owner_id'] = $car->owner_id;
$detail['car_brand_id'] = $car->brand_id;
$detail['car_series_id'] = $car->series_id;
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
$detail['car_number'] = $detail['car_number'] ? $detail['car_number'] : $car->num_frame;
}
$model = new User();
$user = $model->findOne($detail['from_mid']);
$model = new AcUserExt();
$exts = [];
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach ($_exts as $ext) {
$ext = $ext->toArray();
if (isset($users[$s['id']])) {
if ($ext['mobile']==$user->mobile) {
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
if ($owner) {
$_owner = User::findOne($detail['car_owner_id']);
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
if ($brand) {
$detail['car_title'] = $brand->title;
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series= $AcCarSeries->findOne($detail['car_series_id']);
if ($series) {
$detail['car_title'] .= $series->title;
}
$sn = '00000000000'; //11位
$sn = substr($sn, 0, 11-strlen($id));
$sn .=$id;
$detail['sn'] = $sn;
$detail['signdate'] = date('Y-m-d 星期w', $detail['sign_date']);
$detail['from_province'] = Yii::$app->params['regionAreas'][$detail['start_province']];
$detail['to_province'] = Yii::$app->params['regionAreas'][$detail['aim_province']];
$detail['remark'] = htmlspecialchars_decode($detail['remark']);
// $src = 'http://'.$_SERVER["HTTP_HOST"].'/upload';
// $detail['thumb_b'] = $src.$detail['thumb_b'];
$unsets = ['commission','commission_left','fee_truck','create_at','create_by','deleted','income','expense','fee_deliver','fee_extra','fee_insurance','fee_pickup','fee_urgent','from_bid','from_mid','is_commission','is_cwqr','is_holdon','is_over','pay_receive_pids','pay_send_pids','pre_id'];
foreach ($unsets as $us) {
unset($detail[$us]);
}
$return['code'] = 200;
$return['msg'] = '订单查询成功!';
$return['data']= $detail;
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
public function actionCreate()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$pid = (int)$post['pid'];
//格式化数据 为空的项则不修改
//目标键=》POST键
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city','aim_address'=>'aim_address',
'signer'=>'signer','bind'=>'bind','wtdw'=>"wtdw",
'sender_name'=>'sender_name','sender_idcard'=>'sender_idcard','sender_mobiles'=>'sender_mobiles',
'receiver_name'=>'receiver_name','receiver_idcard'=>'receiver_idcard','receiver_mobiles'=>'receiver_mobiles',
'car_extra'=>'car_extra'];
foreach ($cols as $col=>$key) {
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = trim($post[$key]);
}
}
//'car_id'=>'car_id','employee_id'=>'employee_id',
//'weituo'=>'weituo'
$cols = ['car_value'=>'car_value','fee_insurance'=>'fee_insurance','fee_truck'=>'fee_truck','fee_deliver'=>'fee_deliver','fee_pickup'=>'fee_pickup','fee_urgent'=>'fee_urgent','fee_extra'=>'fee_extra','fee_total'=>'fee_total','pay_send'=>'pay_send','pay_receive'=>'pay_receive','not_insurance'=>'not_insurance',];
foreach ($cols as $col=>$key) {
$data[$col] = 0;
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = (int)$post[$key];
}
}
$cols = ['remark'=>'remark'];
foreach ($cols as $col=>$key) {
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = htmlspecialchars($post[$key]);
}
}
$data['remark'] = isset($data['remark']) ? isset($data['remark']) : '';
/*@sign_date: 1649952000000*/
$sign_date = isset($post['sign_date']) ? strtotime($post['sign_date']/1000) : '';
$data['sign_date'] = $sign_date ? $sign_date : time();
$mid = isset($post['mid']) ? (int)$post['mid'] : 11 ; //11是方孟
$data['create_by'] = $mid;
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
$data['is_turnover'] = 1; //交车补单
$data['status_code'] = 1; //订单处于创建待审核状态
//部分规则校验
$fee_total = $data['fee_truck']+$data['fee_insurance']+$data['fee_deliver']+$data['fee_pickup']+$data['fee_urgent']+$data['fee_extra'];
$fee_pay = $data['pay_send']+$data['pay_receive'];
if (!$data['fee_truck']) {
$return = [];
$return['code'] = 100;
$return['msg'] = '请注意,运费未正确填写!';
$return['data']= [];
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
if ($fee_total !=$data['fee_total']) {
$return = [];
$return['code'] = 100;
$return['msg'] = '所填各项费用汇总的值与所填写的总费用不一致!';
$return['data']= [];
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
if ($fee_pay !=$data['fee_total']) {
$return = [];
$return['code'] = 100;
$return['msg'] = '所填现付与到收费用汇总的值与所填写的总费用不一致!';
$return['data']= [];
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
$data['employee_id'] = isset($post['employee_id']) ? (int)$post['employee_id'] : 0;
$data['store_id'] = 0;
$model = new AcEmployee();
$employee = $model->findOne($data['employee_id']);
if ($employee) {
$data['store_id'] = $employee->store_id;
}
//校验生成部分补充数据
//生成现付说明
$payments = [
'wechat'=>'微信',
'alipay'=>'支付宝',
'cash'=>'现金',
'bankcard'=>'银行卡',
'bankunion'=>'银联',
'others'=>'其他'
];
if ($post['pay_send']) {
$txt = $post['payto'].'收款'.$post['pay_send'].'元('.$payments[$post['payment']].'';
$data['remark'] .= ' ; '.$txt;
}
//生成车辆信息
$carModel = new AcCar();
$where = [];
if ($post['isTempCarno']) {
$post['carno_left'] .='临';
}
if (empty($post['carno_frame'])) {
$where['num_p'] = $post['carno_p'];
$where['num_area'] = $post['carno_area'];
$where['num_left'] = $post['carno_left'];
}
if (!empty($post['carno_frame'])) {
$where['num_frame'] = $post['carno_frame'];
}
$car = $carModel->find()->where($where)->one();
if (empty($car)) {
$carModel->pid = $pid;
$carModel->num_frame = $post['carno_frame'];
$carModel->num_p = $post['carno_p'];
$carModel->num_area = $post['carno_area'];
$carModel->num_left = $post['carno_left'];
$carModel->title = $post['carno_title'];
$carModel->status_code = 1;
$carModel->create_at = time();
$carModel->update_at = time();
$carModel->save();
$car_id = $carModel->attributes['id'];
} else {
$car_id = $car->id;
}
$data['car_id'] = $car_id;
//查询联系人信息是否在库
$sender_mobiles = isset($data['sender_mobiles']) ? $data['sender_mobiles'] : null;
$receiver_mobiles = isset($data['receiver_mobiles']) ? $data['receiver_mobiles'] : null;
if ($sender_mobiles) {
//项目分支自有数据表
$contactModel = new AcContact();
$contactor = $contactModel->find()->where(['mobile'=>$data['sender_mobiles'],'pid'=>$pid])->one();
if (empty($contactor)) {
$contactModel->name = isset($data['sender_name']) ? $data['sender_name'] : '客户';
$contactModel->mobile = $data['sender_mobiles'];
$contactModel->pid = $pid;
$contactModel->idcard = isset($data['sender_idcard']) ? $data['sender_idcard'] : '';
$contactModel->create_at = time();
$contactModel->status_code = 1;
$contactModel->save();
} else {
$_contactDatas = [];
$_contactDatas['name'] = isset($data['sender_name']) ? $data['sender_name'] : $contactModel->name;
$_contactDatas['idcard'] = isset($data['idcard']) ? $data['idcard'] : $contactModel->idcard;
if ($_contactDatas['name']==$contactModel->name && $_contactDatas['idcard'] ==$contactModel->idcard) {
//无须做任何变化
} else {
$_contactDatas['update_at'] = time();
$contactModel->updateAll($_contactDatas, ['id'=>$contactModel->id]);
}
}
//框架核心数据表Fans
$userModel = new Fans();
$user = $userModel->findByUsername($sender_mobiles);
if (empty($user)) {
$userModel->mobile = $sender_mobiles;
$userModel->email = $sender_mobiles.'@hiluker.com';
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
$userModel->generateAuthKey();
$userModel->created_at = time();
$userModel->from = 'ctms';
$userModel->save();
}
}
if ($receiver_mobiles && $receiver_mobiles != $sender_mobiles) {
//项目分支自有数据表
$contactModel2 = new AcContact();
$contactor2 = $contactModel2->find()->where(['mobile'=>$data['receiver_mobiles'],'pid'=>$pid])->one();
if (empty($contactor2)) {
$contactModel2->name = isset($data['receiver_name']) ? $data['receiver_name'] : '客户';
$contactModel2->mobile = $data['receiver_mobiles'];
$contactModel2->pid = $pid;
$contactModel2->idcard = isset($data['receiver_idcard']) ? $data['receiver_idcard'] : '';
$contactModel2->create_at = time();
$contactModel2->status_code = 1;
$contactModel2->save();
} else {
$_contactDatas = [];
$_contactDatas['name'] = isset($data['receiver_name']) ? $data['receiver_name'] : $contactModel2->name;
$_contactDatas['idcard'] = isset($data['idcard']) ? $data['idcard'] : $contactModel2->idcard;
if ($_contactDatas['name']==$contactModel2->name && $_contactDatas['idcard'] ==$contactModel2->idcard) {
//无须做任何变化
} else {
$_contactDatas['update_at'] = time();
$contactModel2->updateAll($_contactDatas, ['id'=>$contactModel2->id]);
}
}
//框架核心数据表Fans
$userModel = new Fans();
$user = $userModel->findByUsername($receiver_mobiles);
if (empty($user)) {
$userModel->mobile = $receiver_mobiles;
$userModel->email = $receiver_mobiles.'@hiluker.com';
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
$userModel->generateAuthKey();
$userModel->created_at = time();
$userModel->from = 'ctms';
$userModel->save();
}
}
//保存资料
$AcOrder = new AcOrder();
foreach ($data as $key=>$val) {
$AcOrder->$key = $val;
}
$res = $AcOrder->save();
$id = $AcOrder->attributes['id']; //获取插入后id
if ($res) {
$return = [];
$return['code'] = 200;
$return['msg'] = '订单保存成功!';
$return['data']= ['id'=>$id];
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
} else {
$return = [];
$return['code'] = 100;
$return['msg'] = '订单保存失败!';
$return['data']= [];
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
}
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcOrder();
$res = $model->findOne($id);
$return = [];
$return['timeout'] = 1; //几秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if (!$res) {
$return['msg'] = '订单数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
} else {
$order = $res;
if ($order->deleted>0) {
$return['msg'] = '订单已被删除了,无法操作';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
switch ($get['do']) {
case 'cancel':
if ($order->is_cwqr>0) {
$return['msg'] = '订单已入账,请先联系财务销账后再取消';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($order->status_code>1) {
$return['msg'] = '订单已进入运输后流程,无法操作取消';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($order->status_code==-1) {
$return['msg'] = '订单已经是被取消状态';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = -1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '订单取消成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'btn-info'];
} else {
$return['msg'] = '订单取消失败';
$return['errorcode'] = 0;
}
break;
case 'truckcar':
if ($order->status_code==-1) {
$return['msg'] = '订单已被取消,不能承运';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($order->status_code!=1) {
$return['msg'] = '订单当前非初始状态(协议签订),不可作承运处理';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = 5;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '订单已转为待承运状态';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '订单标记失败,请稍后再试';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,156 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:35:53+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2024-07-09T16:01:52+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use backend\models\AuthItem;
use backend\models\Menu;
use backend\models\PasswordForm;
use yii\data\Pagination;
use common\models\Member as User;
use common\models\UserExt;
use backend\models\AuthAssignment;
use backend\components\Tree;
class MemberController extends Common
{
public function actionIndex()
{
return $this->render('index');
}
//用户列表
public function actionList()
{
$username = Yii::$app->user->identity->username;
if (Yii::$app->request->post()) {
if ($_POST['username']!='') {
$username = $_POST['username'];
$data = User::find()->where(['username'=>$username]);
} elseif ($_POST['mobile']!='') {
$mobile = $_POST['mobile'];
$data = User::find()->where(['mobile'=>$mobile]);
} else {
$data = User::find();
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$user = $data->joinWith('usergroup')->offset($pages->offset)->limit($pages->limit)->all();
return $this->render('list', [
'user'=>$user,
'pages' => $pages
]);
} else {
$data = User::find();
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$user = $data->joinWith('usergroup')->offset($pages->offset)->limit($pages->limit)->all();
}
return $this->render('list', [
'user'=>$user,
'pages' => $pages
]);
}
//新增用户
public function actionCreate()
{
$model = new User();
if ($model->load(Yii::$app->request->post())) {
$post = Yii::$app->request->post();
$model->username = $post['User']['username'];
$model->mobile = $post['User']['mobile'];
$model->email = $post['User']['email'];
$user = User::find()->where(['username'=>$model->username])->all();
if (!empty($user)) {
\Yii::$app->getSession()->setFlash('error', '用户名已存在!');
return $this->redirect(['create']);
}
$user = User::find()->where(['mobile'=>$model->mobile])->all();
if (!empty($user)) {
\Yii::$app->getSession()->setFlash('error', '该手机号已使用!');
return $this->redirect(['create']);
}
$user = User::find()->where(['email'=>$model->email])->all();
if (!empty($user)) {
\Yii::$app->getSession()->setFlash('error', '邮箱重复!');
return $this->redirect(['create']);
}
$model->email = $post['User']['email'];
$model->avatar = $post['User']['avatar'];
$model->mobile = $post['User']['mobile'];
$model->setPassword($post['User']['auth_key']);
$model->generateAuthKey();
$model->created_at = time();
$model->save();
$user_id = $model->attributes['id']; //获取插入后id
return $this->redirect(['list']);
} else {
return $this->render('create', [
'model' => $model,
'params' => Yii::$app->params
]);
}
}
//更新用户
public function actionUpdate()
{
$item_name = Yii::$app->request->get('item_name');
$id = Yii::$app->request->get('id');
$model = User::find()->joinWith('usergroup')->where(['id' => $id])->one();
$model1 = $this->findModel($id);
if ($model1->load(Yii::$app->request->post())) {
$post = Yii::$app->request->post();
//更新密码
if (!empty($post['User']['auth_key_new'])) {
$model1->setPassword($post['User']['auth_key_new']);
$model1->generateAuthKey();
} else {
$model1->auth_key = $post['User']['auth_key'];
}
$model1->avatar = $post['User']['avatar'];
$model1->mobile = $post['User']['mobile'];
$model1->save($post);
return $this->redirect(['user/list']);
}
return $this->render('update', [
'model' => $model,
]);
}
//删除用户
public function actionDelete($id)
{
$connection=Yii::$app->db;
$transaction=$connection->beginTransaction();
try {
$connection->createCommand()->delete("c_user", "id = '$id'")->execute();
$transaction->commit();
} catch (Exception $ex) {
$transaction->rollBack();
}
return $this->redirect(['list']);
}
protected function findModel($id)
{
if (($model = User::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -1,70 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-13T09:20:03+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-21T09:28:23+08:00
# @Copyright: www.hiluker.cn
//主入口页
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use vendor\huawei\obsclient\Hwobs;
use vendor\huawei\obsclient\TemporarySignature;
use vendor\huawei\obsclient\PostObject;
class ObsController extends Common
{
public function actionIndex()
{
$apis = [
'getkey'=>'获取访问Key',
];
$this->result('您正使用CMTS系统-华为云OBS接口', $apis, 200);
}
private function getconf()
{
return [
'id'=> 'ee124c5102064b83bccd2fdda53261cc', //账号ID
'ak'=> '1DYBXUNEPNCIEEQOGGAE',
'sk'=> '0VBI2xPlDB0NtqqVJv3hSFC8DY52G8OYPYNhncGK',
'area'=>'cn-south-1', //华南广州
'endpoint'=>'obs.cn-south-1.myhuaweicloud.com',
'bucketName'=>'hilu-ctms',
];
}
public function actionGetkey()
{
$params = $this->getconf();
$obs = new Hwobs($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
}
public function actionGeturl()
{
$params = $this->getconf();
$obs = new TemporarySignature($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
$res = $obs->UploadUrl($params['bucketName']);
// $res = $obs->getCors($params['bucketName']);
var_dump($res);
// $this->result('获取上传网址成功!', $res, 200);
}
public function actionGetform()
{
$params = $this->getconf();
$obs = new PostObject($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
$obs->init('obs');
$res = $obs->claimPost('hilu-ctms', 'file.jpg');
$url = 'https://'.$params['bucketName'].".".$params['endpoint'];
$res['up_url'] = $url;
$this->result('获取OBS上传准备信息', $res, 200);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,302 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-04-24T20:28:47+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-21T22:11:58+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use addons\models\AcCar;
use addons\models\AcCarOwner;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcStore;
use addons\models\AcEmployee;
use addons\models\AcOrder;
use addons\models\AcOrderPre;
use addons\models\AcOrderStatus;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcPlat;
use common\models\CVcode;
use addons\models\AcContact;
use common\models\Member as User;
use addons\models\AcUserExt;
use common\models\Fans;
class OrdercheckController extends Common
{
public function beforeAction($action)
{
if (!$this->pid) {
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
}
return parent::beforeAction($action);
}
public function actionIndex()
{
$apis = [
'basic'=>'基础验车', //启运网点
'online'=>'中转验车',
'arrive'=>'到站验车', //目的地网点
];
$this->result('您正使用CMTS系统运单验车管理接口', $apis, 200);
}
public function actionBasic()
{
$pid = $this->pid;
$status = Yii::$app->params['OrderStatus'];
$post = $this->postdata;
$id = isset($post['oid']) ? $post['oid'] : 0;
if ($id<=0) {
$this->result('查询参数错误!');
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($id);
if (!$order) {
$this->result('该运单数据不存在!');
}
if (!isset($post['checks'])) {
$this->result('验车参数错误!');
}
$checks = $post['checks']; //需要更新的验车信息
//判断执行权限 S
if (!$this->user_info) {
$this->result('无有效用户登陆信息,无权操作!');
}
if (!$this->employee_id) {
$this->result('未表明员工工号身份!');
}
//判断执行权限 E
$hasChange = 0; //是否有需要更新的数据
$op = isset($post['op']) ? $post['op'] : '';
$isOss = true; //是否启用OSS服务
switch ($op) {
case 'data':
$hasChange = 1;
$checker = isset($checks['checker']) ? trim($checks['checker']) : '';
$order->checker = $checker ? $checker : $this->user_info->username;
$start_km = isset($checks['start_km']) ? (int) $checks['start_km'] : 0;
$order->start_km = $start_km;
$is_driving_lisence = isset($checks['is_driving_lisence']) ? (int)$checks['is_driving_lisence'] : 0;
$order->no_driving_lisence = $is_driving_lisence==1 ? 1 : 0;
$car_extra = isset($checks['car_extra']) ? trim($checks['car_extra']) : '';
$order->car_extra = $car_extra;
break;
case 'driving_lisence':
$k = 'driving_lisence';
if (isset($checks[$k]) && $checks[$k]) {
if (!$isOss) {
$file = Yii::getAlias('@upload-src').$checks[$k];
if (file_exists($file)) {
$hasChange = 1;
$order->$k = $checks[$k];
}
} else {
$hasChange = 1;
$order->$k = $checks[$k];
}
}
break;
case 'thumb_f':
$k = 'thumb_f';
if (isset($checks[$k]) && $checks[$k]) {
if (!$isOss) {
$file = Yii::getAlias('@upload-src').$checks[$k];
if (file_exists($file)) {
$hasChange = 1;
$order->$k = $checks[$k];
}
} else {
$hasChange = 1;
$order->$k = $checks[$k];
}
}
break;
case 'thumb_b':
$k = 'thumb_b';
if (isset($checks[$k]) && $checks[$k]) {
$file = Yii::getAlias('@upload-src').$checks[$k];
if (file_exists($file)) {
$hasChange = 1;
$order->$k = $checks[$k];
}
}
break;
case 'thumb_l':
$k = 'thumb_l';
if (isset($checks[$k]) && $checks[$k]) {
if (!$isOss) {
$file = Yii::getAlias('@upload-src').$checks[$k];
if (file_exists($file)) {
$hasChange = 1;
$order->$k = $checks[$k];
}
} else {
$hasChange = 1;
$order->$k = $checks[$k];
}
}
break;
case 'thumb_r':
$k = 'thumb_r';
if (isset($checks[$k]) && $checks[$k]) {
if (!$isOss) {
$file = Yii::getAlias('@upload-src').$checks[$k];
if (file_exists($file)) {
$hasChange = 1;
$order->$k = $checks[$k];
}
} else {
$hasChange = 1;
$order->$k = $checks[$k];
}
}
break;
case 'thumbs':
$k = 'thumbs';
if (isset($checks[$k]) && $checks[$k]) {
$hasChange = 1;
$thumbs = json_encode($checks[$k]);
$order->$k = $thumbs;
}
break;
case 'all':
$keys = ['driving_lisence','thumb_f','thumb_b','thumb_l','thumb_r'];
foreach ($keys as $k) {
if (isset($checks[$k]) && $checks[$k]) {
if (!$isOss) {
$file = Yii::getAlias('@upload-src').$checks[$k];
if (file_exists($file)) {
$hasChange = 1;
$order->$k = $checks[$k];
}
} else {
$hasChange = 1;
$order->$k = $checks[$k];
}
}
}
$k = 'thumbs';
if (isset($checks[$k]) && $checks[$k]) {
$hasChange = 1;
$thumbs = json_encode($checks[$k]);
$order->$k = $thumbs;
}
$checker = isset($checks['checker']) ? trim($checks['checker']) : '';
$order->checker = $checker ? $checker : $this->user_info->username;
$start_km = isset($checks['start_km']) ? (int) $checks['start_km'] : 0;
$order->start_km = $start_km;
$is_driving_lisence = isset($checks['is_driving_lisence']) ? (int)$checks['is_driving_lisence'] : 0;
$order->no_driving_lisence = $is_driving_lisence==1 ? 1 : 0;
$car_extra = isset($checks['car_extra']) ? trim($checks['car_extra']) : '';
$order->car_extra = $car_extra;
if ($hasChange) {
$order->is_checked = 1;
}
break;
}
if ($hasChange) {
$res = $order->save();
$this->result('操作完成!', null, 200);
} else {
$this->result('没有要更新的数据!', null, 200);
}
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcOrder();
$res = $model->findOne($id);
$return = [];
$return['timeout'] = 1; //几秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if (!$res) {
$return['msg'] = '订单数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
} else {
$order = $res;
if ($order->deleted>0) {
$return['msg'] = '订单已被删除了,无法操作';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
switch ($get['do']) {
case 'cancel':
if ($order->is_cwqr>0) {
$return['msg'] = '订单已入账,请先联系财务销账后再取消';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($order->status_code>1) {
$return['msg'] = '订单已进入运输后流程,无法操作取消';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($order->status_code==-1) {
$return['msg'] = '订单已经是被取消状态';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = -1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '订单取消成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'btn-info'];
} else {
$return['msg'] = '订单取消失败';
$return['errorcode'] = 0;
}
break;
case 'truckcar':
if ($order->status_code==-1) {
$return['msg'] = '订单已被取消,不能承运';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($order->status_code!=1) {
$return['msg'] = '订单当前非初始状态(协议签订),不可作承运处理';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = 5;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '订单已转为待承运状态';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '订单标记失败,请稍后再试';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,248 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:39:14+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:39:14+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcPlat;
class PlatController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
public function actionList()
{
$model = new AcPlat();
$search = $where = [];
$where[] = 'and';
if (isset($_POST['title']) && $_POST['title']!='') {
$search['title'] = $_POST['title'];
$where[] = ['LIKE','title',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $model->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '5']);
$res = $data->orderby('orderby DESC')->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['CommonStatus'];
$plats = [];
foreach ($res as $r) {
$plats[$r->id] = $r->toArray();
}
return $this->render('list', [
'plats'=>$plats,
'pager' => $pages,
'search'=>$search,
'status'=>$status
]);
}
public function actionNew()
{
return $this->render('modify', []);
}
public function actionEdit()
{
$model = new AcPlat();
$id = Yii::$app->request->get('id');
$res = $model->findOne($id);
if ($res) {
$res = $res->toArray();
}
return $this->render('modify', ['detail'=>$res]);
}
public function actionSave()
{
$post = Yii::$app->request->post();
$data = [];
$id = $post['id'];
//目标键=》POST键
$cols = ['title'=>'title','thumb'=>'thumb'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['orderby'=>'orderby','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['update_at'] = time();
$data['create_at'] = $data['update_at'];
$model = new AcPlat();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
if ($id) {
$model->id = $id;
$res = $model->updateAll($data, ['id'=>$id]);
} else {
$res = $model->save();
$id = $model->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '平台保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '平台保存失败!');
return $this->goBack();
}
}
public function actionExt()
{
$session = Yii::$app->session;
if (isset($_GET['pid']) && (int)$_GET['pid']>0) {
$session->set('pid', (int)$_GET['pid']);
}
$pid = $session->get('pid');
if (!$pid) {
$url = Url::toRoute(['index/index','pid'=>0]);
header('location:'.$url);
exit;
}
$model = new AcPlat();
$res = $model->findOne($pid);
$detail = [];
if ($res) {
$detail = json_decode($res->remark, true);
}
return $this->render('ext', ['detail'=>$detail]);
}
public function actionExtsave()
{
$user_id=Yii::$app->user->identity->getId();
if ($user_id !=1) {
\Yii::$app->getSession()->setFlash('warning', '修改失败,平台配置仅支持超级管理员修改!');
return $this->redirect(['plat/ext']);
}
$post = Yii::$app->request->post();
$session = Yii::$app->session;
$pid = $session->get('pid');
$data = [];
//目标键=》POST键
$cols = ['cw_phone'=>'cw_phone'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$remark = json_encode($data, JSON_UNESCAPED_UNICODE);
$model = new AcPlat();
$model->remark = $remark;
$res = $model->updateAll(['remark'=>$remark], ['id'=>$pid]);
if ($res) {
\Yii::$app->getSession()->setFlash('success', '参数保存成功!');
} else {
\Yii::$app->getSession()->setFlash('warning', '参数保存失败!');
}
return $this->redirect(['plat/ext']);
}
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcPlat();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('plat/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '平台删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '平台删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcPlat();
$res = $model->findOne($id);
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '平台数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return));
}
switch ($get['do']) {
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '平台隐藏成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
} else {
$return['msg'] = '平台隐藏失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '平台显示成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '平台显示失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return));
}
}

View File

@ -1,270 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:38:52+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:38:52+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\helpers\Url;
use vendor\aliyun\dysms\Sms;
use common\models\CSms;
use common\models\CVcode;
use addons\models\AcPlat;
class SmsController extends Common
{
public function actionIndex()
{
global $_HI;
global $_FM;
$_HI['action'] = 'index';
/*自定义常量*/
/*默认配置*/
$_HI['accessKeyId'] = 'LTAIQrJFtHfqsyOt'; // AccessKeyId
$_HI['accessKeySecret'] = 'tvGieI3vNI7Si3imauCB4rJ3OX4AR8'; // AccessKeySecret
$_HI['sign'] = '嗨路客';
$_HI['tmpl'] = 'SMS_116695055';
$_HI['reportQueueName'] = 'Alicom-Queue-31737903-SmsReport'; //状态报告接收
$_HI['UpQueueName'] = 'Alicom-Queue-31737903-SmsUp'; //上行消息接收
return $this->render('index');
}
public function actionGsend()
{
global $_HI;
global $_FM;
$session = Yii::$app->session;
$session->set('sms::success', 0);
$session->set('sms::msg', '');
$session->set('sms::guests', []);
/*自定义常量*/
/*默认配置*/
$_HI['accessKeyId'] = Yii::$app->params['aliDySms']['accessKeyId']; // AccessKeyId
$_HI['accessKeySecret'] = Yii::$app->params['aliDySms']['accessKeySecret']; // AccessKeySecret
$_HI['sign'] = Yii::$app->params['aliDySms']['sign'];
$_HI['tmpl'] = Yii::$app->params['aliDySms']['tmpl']['acGongxue'];
$_HI['reportQueueName'] = Yii::$app->params['aliDySms']['reportQueueName']; //状态报告接收
$_HI['UpQueueName'] = Yii::$app->params['aliDySms']['UpQueueName']; //上行消息接收
return $this->render('gsend');
}
public function actionSend()
{
global $_HI;
global $_FM;
global $START_TIME;
$session = Yii::$app->session;
//数据取出方法
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
$params = Yii::$app->params;
$config = array();
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : $params['aliDySms']['accessKeyId'];
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : $params['aliDySms']['accessKeySecret'];
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : $params['aliDySms']['sign'];
if ($config) {
$session->set('sms::config', $config);
} else {
$config = $session->get('sms::config');
}
$option = array();
$sms = new Sms($option, $config);
$address = isset($dataPost['address']) ? $dataPost['address'] : '';
if ($address) {
$session->set('sms::address', $address);
} else {
$address = $session->get('sms::address');
}
$tmpl = isset($dataPost['tmpl']) ? $dataPost['tmpl'] : '';
if ($tmpl) {
$session->set('sms::tmpl', $tmpl);
} else {
$tmpl = $session->get('sms::tmpl');
}
$_guests = isset($dataPost['guests']) ? $dataPost['guests'] : '';
if (!$_guests) {
$guests = $session->get('sms::guests');
} else {
$_guests = explode("\r\n", $_guests);
$guests = array();
foreach ($_guests as $c) {
$_c = explode(',', $c);
if (count($_c)>1) {
$k = trim($_c[1]);
$v = trim($_c[0]);
$guests[$k] = $v;
}
}
unset($_c);
unset($k);
unset($v);
$guests = array_unique($guests);
}
if (!$guests) {
$i = (int)$session->get('sms::success');
$session->set('sms::success', 0);
$msg = $session->get('sms::msg');
$session->set('sms::msg', '');
\Yii::$app->getSession()->setFlash('info', '群发完成,共成功发送'.$i.'条;详情:'.$msg);
return $this->render('gsend');
}
$results = array();
$msg = "";
$content = [];
$content['address'] = $address;
$i = 0;
$j = 50;
foreach ($guests as $p=>$username) {
$j--;
$content['name'] = !empty($username) ? $username.'安诚托车' : '安诚捷顺运车';
$result = $sms->send($p, $tmpl, $content);
$results[$p] = $result;
if (!$result) {
$msg .= "".$p."】发送失败,接口提示:".$sms->errors."\r\n";
} elseif ($result->Code !='OK') {
$msg .= "".$p."】发送失败,接口提示:".$result->Message."\r\n";
} else {
$i++;
$msg .= "".$p."】发送成功"."\r\n";
}
unset($guests[$p]);
if ($j==0) {
break;
}
}
$session->set('sms::guests', $guests);
$i += (int)$session->get('sms::success');
$session->set('sms::success', $i);
$msg .= $session->get('sms::msg');
$session->set('sms::msg', $msg);
\Yii::$app->getSession()->setFlash('info', '群发完成,共成功发送'.$i.'条;详情:'.$msg);
return $this->render('ajax');
}
//发送验证码
public function actionVcode()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$plat = AcPlat::findOne($pid);
$platExt = json_decode($plat->remark, true);
//数据取出方法
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
$params = Yii::$app->params;
$config = array();
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : $params['aliDySms']['accessKeyId'];
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : $params['aliDySms']['accessKeySecret'];
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : $params['aliDySms']['sign'];
$option = array();
$sms = new Sms($option, $config);
$op = Yii::$app->request->get('op');
$content=[];
switch ($op) {
case 'caiwu':
$phone = $platExt['cw_phone'];
$codetype = 'caiwu';
if (!$phone) {
$return = [];
$return['errorcode'] = 1;
$return['msg'] = '还没有配置财务手机号,请联系站长管理员进行设置';
exit(json_encode($return));
}
$vcodeModel = new CVcode();
//查询上次发送记录
$_time = time();
$where=[];
$where['mobile'] = $phone;
$where['deleted'] = 0;
$where['type'] = $codetype;
$res = $vcodeModel->find()->where($where)->one();
if ($res) {
if (($_time-$res->create_at)<7200) {
$code = $res->code;
$return = [];
$return['errorcode'] = 2;
$return['msg'] = '上次发送的验证码仍然可用;请注意查看财务手机';
exit(json_encode($return));
} else {
$res->deleted = 1;
$res->save();
}
}
$code = mt_rand(1000, 9999);
$content['code'] = $code;
$tmpl = Yii::$app->params['aliDySms']['tmpl']['cwVcode'];
//验证码入库
$vcode = [];
$vcode['code'] = $code;
$vcode['type'] = $codetype;
$vcode['mobile'] = $phone;
$vcode['create_at'] = time();
foreach ($vcode as $key=>$val) {
$vcodeModel->$key = $val;
}
break;
default:
$mobile = Yii::$app->request->post('mobile');
break;
}
$result = $sms->send($phone, $tmpl, $content);
//保存发送记录
$smsModel = new CSms();
$smsdata = [];
$sid = Yii::$app->params['siteId'];
$smsdata['sid'] = (int)$sid;
$smsdata['pid'] = $pid;
$smsdata['uid'] = Yii::$app->user->identity->id;
$smsdata['mobile'] = $phone;
$smsdata['content'] = json_encode($content, JSON_UNESCAPED_UNICODE);
$smsdata['create_at'] = time();
foreach ($smsdata as $key=>$val) {
$smsModel->$key = $val;
}
$smsModel->save();
$return = [];
$msg = '';
if (!$result) {
$msg .= "发送失败,接口提示:".$sms->errors."\r\n";
$return['errorcode'] = 3;
} elseif (is_array($result) && $result['Code'] !='OK') {
$msg .= "发送失败,接口提示:".$result['Message']."\r\n";
$return['errorcode'] = 4;
} else {
$vcodeModel->save();
$msg .= "发送成功"."\r\n";
$return['errorcode'] = 0;
}
$return['msg'] = $msg;
exit(json_encode($return));
}
}

View File

@ -1,95 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-16T16:31:49+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2024-06-29T15:44:54+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcStore;
class StoreController extends Common
{
//主界面
public function actionIndex()
{
$apis = [
'list'=>'网点清单',
'detail'=>'网点详情'
];
$this->result('您正使用CMTS系统网点管理接口', $apis, 200);
}
public function actionList()
{
$pid = $this->pid;
$model = new AcStore();
$where = [];
$where['pid'] = $pid;
$citys = Yii::$app->params['citys'];
$post = $this->postdata;
$where['deleted'] = 0;
$where['status_code'] = 1;
$data = $model->find()->where($where);
$page = $this->page;
$pageSize = $this->pageSize;
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
$pages->setPage($page-1, true); //设置分页的当前页面值
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
if (!$res) {
$this->result('没有符合条件的结果');
}
$stores = [];
foreach ($res as $k=>$v) {
$stores[$v->id] = $v->toArray();
}
$return = [];
$return['data'] = [
'stores'=>$stores,
'citys'=>$citys,
];
$return['total'] = $data->count();
$return['page'] = $this->page;
$this->result('网点列表', $return, 200);
}
public function actionSelect()
{
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$citys = Yii::$app->params['citys'];
$post = Yii::$app->request->post();
$where['deleted'] = 0;
$where['status_code'] = 1;
$data = $model->find()->where($where);
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2 = ['LIKE','title',$search['title']];
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = ['0'=>'隐藏','1'=>'正常'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'store';
return $this->render('select', [
'stores'=>$res,
'pager' => $pages,
'citys'=>$citys,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
}

View File

@ -1,422 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:38:08+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:38:08+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
class TruckController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
//板车列表
public function actionList()
{
$AcTruck = new AcTruck();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','num_left',$search['title']];
}
$where['deleted'] = 0;
$data = $AcTruck->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['TruckStatus'];
$AcDriver = new AcDriver();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_drivers = $AcDriver->find()->where($where)->all();
$drivers = [];
foreach ($_drivers as $s) {
$drivers[$s->id] = $s->toArray();
}
return $this->render('list', [
'trucks'=>$res,
'pager' => $pages,
'drivers'=>$drivers,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$AcTruck = new AcTruck();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where2[] = ['LIKE','num_left',$search['title']];
}
$where['deleted'] = 0;
$data = $AcTruck->find()->where($where);
if ($search['title']) {
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['TruckStatus'];
$AcDriver = new AcDriver();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_drivers = $AcDriver->find()->where($where)->all();
$drivers = [];
foreach ($_drivers as $s) {
$drivers[$s->id] = $s->toArray();
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truck';
return $this->render('select', [
'trucks'=>$res,
'pager' => $pages,
'drivers'=>$drivers,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
$status = Yii::$app->params['TruckStatus'];
$AcTruck = new AcTruck();
$AcTruck->status_code = 0;
return $this->render('modify', ['status'=>$status,'detail'=>$AcTruck]);
}
//编辑板车资料
public function actionEdit()
{
$model = new AcTruck();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $res['driver_id']])->one();
if ($driver) {
$res['driver_title'] = $driver->name;
}
$driver2 = $AcDriver->find()->where(['id' => $res['driver2_id']])->one();
if ($driver2) {
$res['driver2_title'] = $driver2->name;
}
$status = Yii::$app->params['TruckStatus'];
return $this->render('modify', ['status'=>$status,'detail'=>$res]);
}
//保存板车资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['num_p'=>'num_p','num_area'=>'num_area','num_left'=>'num_left'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询车牌号是否在库
$hasTruck = AcTruck::find()->where(['num_p'=>$data['num_p'],'num_area'=>$data['num_area'],'num_left'=>$data['num_left']])->one();
if ($hasTruck) {
if ($id && $id!=$hasTruck->id) {
\Yii::$app->getSession()->setFlash('danger', '保存失败,该车牌号已在库!');
return $this->goBack();
} else {
$id = $hasTruck->id;
}
}
$cols = ['driver_id'=>'driver','driver2_id'=>'driver2','status_code'=>'status_code','max_cars'=>'max_cars','deleted'=>'deleted'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['remark'=>'editor'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
// $data['status_code'] = 1;
$data['pid'] = $pid;
//保存板车资料
$AcTruck = new AcTruck();
foreach ($data as $key=>$val) {
$AcTruck->$key = $val;
}
if ($id) {
$AcTruck->id = $id;
unset($data['create_at']);
$res = $AcTruck->updateAll($data, ['id'=>$id]);
} else {
$res = $AcTruck->save();
$id = $AcTruck->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '板车资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '板车资料保存失败!');
return $this->goBack();
}
}
//删除板车
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcTruck();
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('truck/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '板车删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '板车删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcTruck();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['ajax'] = 1;
if ($res) {
$res = $res->toArray();
} else {
$return['msg'] = '板车数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
switch ($get['do']) {
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '板车停用标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
} else {
$return['msg'] = '板车停用标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '板车入库记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'primary'];
} else {
$return['msg'] = '板车入库标记失败';
$return['errorcode'] = 0;
}
break;
case 'lock':
$data['status_code'] = 99;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '板车锁定标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'danger'];
} else {
$return['msg'] = '板车锁定标记失败';
$return['errorcode'] = 0;
}
break;
case 'repair':
$data['status_code'] = 2;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '板车检修标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'warning'];
} else {
$return['msg'] = '板车检修标记失败';
$return['errorcode'] = 0;
}
break;
case 'reset':
$data['status_code'] = 2;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '板车保养标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
} else {
$return['msg'] = '板车保养标记失败';
$return['errorcode'] = 0;
}
break;
case 'working':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '板车恢复正常,标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
} else {
$return['msg'] = '板车恢复标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
//发车
public function actionFache()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($id);
if (!$truck) {
$return['msg'] = '板车数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($truck->status_code==4) {
$return = [];
// $return['url'] = Url::toRoute('truckol/modify');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
$return['msg'] = '当前板车已在装车中,发车操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
} elseif ($truck->status_code==5) {
$return = [];
// $return['url'] = Url::toRoute('truckol/modify');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
$return['msg'] = '当前板车已在运输途中,发车操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
} elseif ($truck->status_code!=1) {
$return['msg'] = '当前板车状态不允许发车,请先确认板车已归为正常状态';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['status_code'] = 4;
foreach ($data as $key=>$val) {
$AcTruck->$key = $val;
}
$res = $AcTruck->updateAll($data, $where);
$return = [];
// $return['url'] = Url::toRoute('truckol/modify');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '发车成功,请进行下一步操作';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '发车操作失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
//浏览板车资料
public function actionDetail()
{
$model = new AcTruck();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if ($res) {
$res = $res->toArray();
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $res['driver_id']])->one();
if ($driver) {
$res['driver_title'] = $driver->name;
$res['driver_mobile'] = $driver->mobile;
}
$driver2 = $AcDriver->find()->where(['id' => $res['driver2_id']])->one();
if ($driver2) {
$res['driver2_title'] = $driver2->name;
$res['driver2_mobile'] = $driver2->mobile;
}
$status = Yii::$app->params['TruckStatus'];
return $this->render('detail', ['status'=>$status,'detail'=>$res]);
}
}

View File

@ -1,561 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:38:28+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:38:28+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcTruckOnline;
use addons\models\AcTruckCars;
use addons\models\AcStore;
use addons\models\AcCar;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcOrder;
use addons\models\AcGps;
use addons\models\AcGpsRoute;
class TruckcarController extends Common
{
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
//所有装车记录列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
$AcTruckCars = new AcTruckCars();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$search = isset($post['search']) ? $post['search'] : [];
$search['start_city'] = isset($search['start_city']) ? trim(htmlspecialchars_decode($search['start_city'])) : '';
if (!empty($search['start_city'])) {
$where[] = ['LIKE','from_city',$search['start_city']];
}
$search['aim_city'] = isset($search['aim_city']) ? trim(htmlspecialchars_decode($search['aim_city'])) : '';
if (!empty($search['aim_city'])) {
$where[] = ['LIKE','to_city',$search['aim_city']];
}
$search['car_id'] = isset($search['car_id']) ? (int)$search['car_id'] : 0;
$CarModel = new AcCar();
if (!empty($search['car_id'])) {
$where[] = ['=','car_id',$search['car_id']];
$car = $CarModel->findOne($search['car_id']);
$search['car_title'] = isset($car->title) ? $car->title : '';
}
$search['status_code'] = isset($search['status_code']) ? $search['status_code'] : 'all';
if ($search['status_code']!='all') {
$where[] = ['=','status_code',(int)$search['status_code']];
}
//按月份筛选
$search['start_m'] = isset($search['start_m']) ? $search['start_m'] : '';
if (!empty($search['start_m'])) {
$start = strtotime($search['start_m']);
$s = date("Y-m-d H:i:s", $start);
$ldm = strtotime("last day of ".$s);
$m = date("Y-m-d", $ldm)." 23:59:59";
$end = strtotime($m);
$where[] = ['between','from_time',$start,$end];
}
$where[] = ['=','deleted',0];
$data = $AcTruckCars->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('status_code ASC,id DESC')->all();
$car_ids = [];
foreach ($res as $r) {
$car_ids[] = $r->car_id;
}
$AcCar = new AcCar();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$car_ids];
$where[] = ['=','deleted',0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['TruckCarsStatus'];
return $this->render('list', [
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'cars'=>$cars,
'search'=>$search
]);
}
public function actionNew()
{
$status = Yii::$app->params['TruckCarsStatus'];
$AcTruckCars = [];
$AcTruckCars['status_code'] = 0;
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
$AcTruckCars['online_id'] = $online_id;
$order_id = Yii::$app->request->get('order_id'); //待承运订单ID
$AcTruckCars['order_id'] = $order_id;
$car_id = Yii::$app->request->get('car_id'); //待装客车ID
$AcTruckCars['car_id'] = $car_id;
return $this->render('create', ['status'=>$status,'detail'=>$AcTruckCars]);
}
//编辑客车上板信息
public function actionEdit()
{
$id = Yii::$app->request->get('id'); //承运单ID
$truck_id = $online_id = $store_id = $store2_id = 0;
$truckCar = $truckol = [];
$AcTruckCars = new AcTruckCars();
$res = $AcTruckCars->findOne($id);
if ($res) {
$truckCar = $res->toArray();
$online_id = $res->online_id;
$store2_id = $res->to_store;
$store_id = $res->from_store;
$order_id = $res->order_id;
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$AcTruckOnline = new AcTruckOnline();
$res = $AcTruckOnline->findOne($online_id);
if ($res) {
$truck_id = $res->truck_id;
$truckol = $res->toArray();
}
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if (!$truck) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truck/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truckCar['truck_id'] = $truck_id;
$truckCar['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
$truckCar['truck_num'] = $truckCar['truck_title'] ? $truckCar['truck_title'] : $truckol['truck_num'];
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckCar['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckCar['endstore_title'] = $store2->title;
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
$truckCar['driver_title'] = $truckCar['driver_mobile'] = '';
if ($driver) {
$truckCar['driver_title'] = $driver->name;
$truckCar['driver_mobile'] = $driver->mobile;
}
$truckCar['from_time'] = !empty($truckCar['from_time']) ? $truckCar['from_time'] : $truckol['from_date'];
$truckCar['to_time'] = !empty($truckCar['to_time']) ? $truckCar['to_time'] : $truckol['end_date'];
$from_city = $order->start_city;
$truckCar['from_city'] = !empty($truckCar['from_city']) ? $truckCar['from_city'] : $from_city;
$truckCar['from_city'] = $truckCar['from_city'] ? $truckCar['from_city'] : $truckol['from_city'];
$end_city = $order->aim_city;
$truckCar['to_city'] = !empty($truckCar['to_city']) ? $truckCar['to_city'] : $end_city;
$truckCar['to_city'] = $truckCar['to_city'] ? $truckCar['to_city'] : $truckol['end_city'];
$truckCar['driver_name'] = isset($truckCar['driver_name']) ? $truckCar['driver_name'] : $truckol['driver_name'];
$truckCar['driver_mobiles'] = isset($truckCar['driver_mobiles']) ? $truckCar['driver_mobiles'] : $truckol['driver_mobiles'];
$status = Yii::$app->params['TruckCarsStatus'];
return $this->render('modify', ['status'=>$status,'detail'=>$truckCar]);
}
//保存客车上板信息(直接指派方式)
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['from_city'=>'from_city','to_city'=>'to_city'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['online_id'=>'online_id','from_store'=>'from_store','to_store'=>'to_store'];
if (isset($_GET['debug'])&&($_GET['debug']==1)) {
$cols['status_code'] = 'status_code';
}
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
/*出车计划判断*/
$online_id = $data['online_id'];
if (!$online_id) {
$return['msg'] = '未关联板车出车计划信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
if (!$truckol) {
$return['msg'] = '未找到指定板车出车计划,保存失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$_time = time();
$key = 'to_time';
if (isset($post[$key]) && $post[$key]!="") {
$data[$key] = strtotime($post[$key]);
}
$key = 'from_time';
if (isset($post[$key]) && $post[$key]!="") {
$data[$key] = strtotime($post[$key]);
}
if (!$id) {
$data['create_at'] = $_time;
}
$data['update_at'] = $_time;
$data['pid'] = $pid;
//保存上板信息
$AcTruckCars = new AcTruckCars();
foreach ($data as $key=>$val) {
$AcTruckCars->$key = $val;
}
if ($id) {
$res = $AcTruckCars->updateAll($data, ['id'=>$id]);
} else {
$res = $AcTruckCars->save();
$id = $AcTruckCars->attributes['id']; //获取插入后id
}
if ($res) {
//修改对应运单状态
$_code = 0;
if (isset($data['status_code'])) {
if ($data['status_code'] == 1) {
$_code = 2;
} elseif ($data['status_code'] == 99) {
$_code = 3;
}
}
if ($_code) {
$order_id = isset($post['order_id']) ? (int)$post['order_id'] : 0;
if (!$order_id) {
$car = $AcTruckCars->findOne($id);
$order_id = $car->order_id;
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$order->update_at = $_time;
$order->status_code = $_code;
$order->save();
}
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//保存客车上板信息(板车出车界面车辆管理方式)
public function actionSave2()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['from_city'=>'from_city','to_city'=>'to_city'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['online_id'=>'online_id','from_store'=>'from_store','to_store'=>'to_store','order_id'=>'order_id','car_id'=>'car_id'];
if (isset($_GET['debug'])&&($_GET['debug']==1)) {
$cols['status_code'] = 'status_code';
}
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
/*出车计划判断*/
$online_id = $data['online_id'];
if (!$online_id) {
$return['msg'] = '未关联板车出车计划信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
if (!$truckol) {
$return['msg'] = '未找到指定板车出车计划,保存失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$_time = time();
$key = 'to_time';
if (isset($post[$key]) && $post[$key]!="") {
$data[$key] = strtotime($post[$key]);
}
$key = 'from_time';
if (isset($post[$key]) && $post[$key]!="") {
$data[$key] = strtotime($post[$key]);
}
if (!$id) {
$data['create_at'] = $_time;
}
$data['update_at'] = $_time;
$data['pid'] = $pid;
//保存上板信息
$AcTruckCars = new AcTruckCars();
foreach ($data as $key=>$val) {
$AcTruckCars->$key = $val;
}
if ($id) {
$res = $AcTruckCars->updateAll($data, ['id'=>$id]);
} else {
$res = $AcTruckCars->save();
$id = $AcTruckCars->attributes['id']; //获取插入后id
}
if ($res) {
//修改对应运单状态
$_code = 0;
if (isset($data['status_code'])) {
if ($data['status_code'] == 1) {
$_code = 2;
} elseif ($data['status_code'] == 99) {
$_code = 3;
}
}
if ($_code) {
$order_id = isset($post['order_id']) ? (int)$post['order_id'] : 0;
if (!$order_id) {
$car = $AcTruckCars->findOne($id);
$order_id = $car->order_id;
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$order->update_at = $_time;
$order->status_code = $_code;
$order->save();
}
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//删除板车
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$data = $return = [];
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcTruckCars();
$car = $model->findOne($id);
if (!$car) {
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($car->pid !=$pid) {
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($car->deleted !=0) {
$return['msg'] = '数据已被删除过,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
foreach ($data as $key=>$val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, ['id'=>$id]);
$return['url'] = Url::toRoute('truckcar/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '上板记录删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '上板记录删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$data = $return = [];
$_time = time();
$data['update_at'] = $_time;
$model = new AcTruckCars();
$car = $model->findOne($id);
if (!$car) {
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($car->pid !=$pid) {
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($car->deleted !=0) {
$return['msg'] = '数据已被删除,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$online_id = $car->online_id;
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
$order_id = $car->order_id;
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$return['timeout'] = 1; //n秒后自动跳转
$where = ['id'=>$id];
switch ($get['do']) {
case 'intruck':
if ($car->status_code !=0) {
$return['msg'] = '当前运单并非待承运状态,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = 1;
$data['from_time'] = $_time;
$res = $model->updateAll($data, $where);
if ($res) {
//增加板车一辆装车统计
$truckol->update_at = $_time;
$truckol->updateCounters(['cars'=>1]);
$truckol->save();
//修改对应订单的状态
$order->update_at = $_time;
$order->status_code = 2;
$order->save();
$return['msg'] = '客车上板标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
} else {
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
case 'arrive':
if ($car->status_code ==0) {
$return['msg'] = '当前任务尚待承运,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = 99;
$data['to_time'] = $_time;
$res = $model->updateAll($data, $where);
if ($res) {
//修改对应订单的状态
$order->update_at = $_time;
$order->status_code = 3;
$order->save();
$return['msg'] = '客车运达标记记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'primary'];
} else {
$return['msg'] = '客车运达标记失败';
$return['errorcode'] = 0;
}
break;
case 'fix':
$data['status_code'] = 80;
if ($car->status_code != 1) {
$return['msg'] = '当前运单并非运输中状态,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '客车运达标记记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'primary'];
} else {
$return['msg'] = '客车运达标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

View File

@ -1,923 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:37:46+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:37:46+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcTruckOnline;
use addons\models\AcTruckCars;
use addons\models\AcStore;
use addons\models\AcCar;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcOrder;
use addons\models\AcEmployee;
use addons\models\AcGps;
use addons\models\AcGpsRoute;
class TruckolController extends Common
{
//出车单
public function actionIndex()
{
$AcTruckOnline = new AcTruckOnline();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$where[] = ['>','status_code',0];
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','num_left',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $AcTruckOnline->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '10']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
$status = Yii::$app->params['TruckOnlineStatus'];
$stores = [];
$AcStore = new AcStore();
if ($res) {
$store_ids = [];
foreach ($res as $r) {
$store_ids[$r->from_store] = $r->from_store;
$store_ids[$r->end_store] = $r->end_store;
}
array_unique($store_ids);
$_stores = $AcStore->find()->where(['IN','id',$store_ids])->all();
if ($_stores) {
foreach ($_stores as $r) {
$stores[$r->id] = $r->toArray();
}
}
}
return $this->render('index', [
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'stores'=>$stores,
'search'=>$search
]);
}
//在线板车列表(标记了发车状态——装车中的)
public function actionList()
{
$AcTruck = new AcTruck();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$where[] = ['=','status_code',4];
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','num_left',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $AcTruck->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['TruckStatus'];
$AcDriver = new AcDriver();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_drivers = $AcDriver->find()->where($where)->all();
$drivers = [];
foreach ($_drivers as $s) {
$drivers[$s->id] = $s->toArray();
}
return $this->render('list', [
'trucks'=>$res,
'pager' => $pages,
'drivers'=>$drivers,
'status'=>$status,
'search'=>$search
]);
}
//选择可装车的板车
public function actionSelect()
{
$AcTruck = new AcTruck();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$where[] = ['=','status_code',4];
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','num_left',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $AcTruck->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['TruckStatus'];
$AcDriver = new AcDriver();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_drivers = $AcDriver->find()->where($where)->all();
$drivers = [];
foreach ($_drivers as $s) {
$drivers[$s->id] = $s->toArray();
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truckol';
return $this->render('select', [
'trucks'=>$res,
'pager' => $pages,
'drivers'=>$drivers,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionSelect2()
{
$AcTruckOnline = new AcTruckOnline();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$where[] = ['>','status_code',0];
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','num_left',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $AcTruckOnline->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '10']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
$status = Yii::$app->params['TruckOnlineStatus'];
$stores = [];
$AcStore = new AcStore();
if ($res) {
$store_ids = [];
foreach ($res as $r) {
$store_ids[$r->from_store] = $r->from_store;
$store_ids[$r->end_store] = $r->end_store;
}
array_unique($store_ids);
$_stores = $AcStore->find()->where(['IN','id',$store_ids])->all();
if ($_stores) {
foreach ($_stores as $r) {
$stores[$r->id] = $r->toArray();
}
}
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truckol';
return $this->render('select2', [
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'stores'=>$stores,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
$status = Yii::$app->params['TruckOnlineStatus'];
$AcTruckOnline = [];
$AcTruckOnline['status_code'] = 0;
return $this->render('edit', ['status'=>$status,'detail'=>$AcTruckOnline]);
}
//编辑板车装车计划资料
public function actionEdit()
{
// $id = Yii::$app->request->get('id'); //装车任务ID
$id = 0;
$truck_id = Yii::$app->request->get('truck_id'); //板车ID
$store_id = $store2_id = 0;
$pid = Yii::$app->session->get('pid');
$AcTruckOnline = new AcTruckOnline();
$AcTruck = new AcTruck();
$truckol = [];
$truck = $AcTruck->findOne($truck_id);
if (!$truck) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truck/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
if (!$id) {
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','truck_id',$truck_id];
$where[] = ['<','status_code',99];
$where[] = ['=','deleted',0];
$res = $AcTruckOnline->find()->where($where)->orderby('id ASC')->one();
if ($res) {
$id = $res->id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
}
}
$truckol['truck_id'] = $truck_id;
$truckol['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
$truckol['truck_num'] = $truckol['truck_title'] ? $truckol['truck_title'] : $truckol['truck_num'];
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
$truckol['driver_title'] = $truckol['driver_mobile'] = '';
if ($driver) {
$truckol['driver_title'] = $driver->name;
$truckol['driver_mobile'] = $driver->mobile;
}
$truckol['driver_name'] = isset($truckol['driver_name']) ? $truckol['driver_name'] : $truckol['driver_title'];
$truckol['driver_mobiles'] = isset($truckol['driver_mobiles']) ? $truckol['driver_mobiles'] : $truckol['driver_mobile'];
$status = Yii::$app->params['TruckOnlineStatus'];
return $this->render('edit', ['status'=>$status,'detail'=>$truckol]);
}
//更新板车装车任务资料
public function actionModify()
{
$id = Yii::$app->request->get('id'); //装车任务ID
// $truck_id = Yii::$app->request->get('truck_id'); //板车ID
$truck_id = 0;
$store_id = $store2_id = 0;
$pid = Yii::$app->session->get('pid');
$AcTruckOnline = new AcTruckOnline();
$AcTruck = new AcTruck();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if ($res) {
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
}
$truck = $AcTruck->findOne($truck_id);
if (!$truck) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truck/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truckol['truck_id'] = $truck_id;
$truckol['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
$truckol['truck_num'] = $truckol['truck_title'] ? $truckol['truck_title'] : $truckol['truck_num'];
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
$truckol['driver_title'] = $truckol['driver_mobile'] = '';
if ($driver) {
$truckol['driver_title'] = $driver->name;
$truckol['driver_mobile'] = $driver->mobile;
}
$truckol['driver_name'] = isset($truckol['driver_name']) ? $truckol['driver_name'] : $truckol['driver_title'];
$truckol['driver_mobiles'] = isset($truckol['driver_mobiles']) ? $truckol['driver_mobiles'] : $truckol['driver_mobile'];
$status = Yii::$app->params['TruckOnlineStatus'];
return $this->render('modify', ['status'=>$status,'detail'=>$truckol]);
}
//保存装车基础资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['driver_name'=>'driver_name','driver_mobiles'=>'driver_mobiles','driver_idcard'=>'driver_idcard','truck_num'=>'truck_num','end_city'=>'end_city','from_city'=>'from_city'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['truck_id'=>'truck_id','from_store'=>'from_store','end_store'=>'end_store'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$key = 'status_code';
if (isset($post[$key])) {
$data[$key] = (int)$post[$key];
}
/*板车规则判断
*一辆板车只能有一条可用装车任务表单
**/
$truck_id = $data['truck_id'];
if (!$truck_id) {
$return['msg'] = '未指定板车信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if (!$truck) {
$return['msg'] = '未找到指定板车,保存失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$AcTruckOnline = new AcTruckOnline();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','truck_id',$truck_id];
$where[] = ['<','status_code',99];
$where[] = ['=','deleted',0];
$truckol = $AcTruckOnline->find()->where($where)->orderby('id ASC')->one();
if ($truckol) {
if ($id != $truckol->id) {
$return['msg'] = '该板车已有未完成的托运任务,不允许重复指派';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$_time = time();
$key = 'from_date';
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
$key = 'end_date';
if (isset($post[$key])) {
$data[$key] = strtotime($post[$key]);
}
if (!$id) {
$data['create_at'] = $_time;
}
$data['update_at'] = $_time;
;
$data['pid'] = $pid;
//保存板车资料
$AcTruckOnline = new AcTruckOnline();
foreach ($data as $key=>$val) {
$AcTruckOnline->$key = $val;
}
if ($id) {
$res = $AcTruckOnline->updateAll($data, ['id'=>$id]);
} else {
$res = $AcTruckOnline->save();
$id = $AcTruckOnline->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['modify','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//随车车辆管理
public function actionCars()
{
$pid = Yii::$app->session->get('pid');
$id = Yii::$app->request->get('id'); //装车任务ID
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if (!$res) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$online_id = $id;
$AcTruckCars = new AcTruckCars();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','online_id',$online_id];
$where[] = ['=','deleted',0];
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
$carids = $orderids = [];
if ($truckcars) {
foreach ($truckcars as $t) {
$carids[] = $t->car_id;
$orderids[] = $t->order_id;
}
}
$AcCar = new AcCar();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$carids];
$where[] = ['=','deleted',0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['TruckCarsStatus'];
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
return $this->render('cars', [
'status'=>$status,
'truckOnLineStatus'=>$truckOnLineStatus,
'truckol'=>$truckol,
'cars'=>$cars,
'truckcars'=>$truckcars
]);
}
//保存装车随车资料
public function actionCarssave()
{
$post = Yii::$app->request->post();
$online_id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['car_id','order_id'];
foreach ($cols as $key) {
if (!isset($post[$key])) {
$return['msg'] = '未传入的运单或车辆信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
$car_ids = $post['car_id'];
if (!is_array($car_ids)) {
$return['msg'] = '传入的车辆数据不正确,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$order_ids = $post['order_id'];
if (!is_array($order_ids)) {
$return['msg'] = '传入的运单数据不正确,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if (count($car_ids) != count($order_ids)) {
$return['msg'] = '传入的车辆数据与运单数据不匹配,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
/*筛除已在运输中的运单及车辆数据 TBD*/
$AcTruckCars = new AcTruckCars();
$cars = [];
$_time = time();
foreach ($car_ids as $k=>$car_id) {
$car = [];
$car['pid'] = $pid;
$car['online_id'] = $online_id;
$car['car_id'] = $car_id;
$car['order_id'] = $order_ids[$k];
$car['create_at'] = $_time;
$car['update_at'] = $_time;
$cars[] = $car;
$model = clone $AcTruckCars;
foreach ($car as $key=>$val) {
$model->$key = $val;
}
$model->save();
}
$return['msg'] = '操作完成,请刷新页面并检查数据';
$return['errorcode'] = 200;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
//板车出发
public function actionChufa()
{
$id = Yii::$app->request->get('id'); //装车任务ID
$return = [];
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if (!$res) {
$post = Yii::$app->request->post();
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($res->status_code!=0) {
$return['msg'] = '关联出车任务非“待出发”状态,操作失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$truck_id = $res->truck_id;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if (!$truck) {
$return['msg'] = '关联板车数据获取异常,操作失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
/*更新数据*/
$_time = time();
$data = [];
$data['update_at'] = $_time;
$data['status_code'] = 1;
$res = $AcTruckOnline->updateAll($data, ['id'=>$id]);
$data = [];
$data['update_at'] = $_time;
$data['status_code'] = 5;
$AcTruck->updateAll($data, ['id'=>$truck_id]);
if ($res) {
$return['msg'] = '出车任务出发标记操作成功';
$return['errorcode'] = 200;
} else {
$return['msg'] = '出发标记操作失败';
$return['errorcode'] = 100;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
//板车到达
public function actionArrive()
{
$id = Yii::$app->request->get('id'); //装车任务ID
$return = [];
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if (!$res) {
$post = Yii::$app->request->post();
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($res->status_code!=1) {
$return['msg'] = '关联出车任务非“进行中”(在途)状态,操作失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$truck_id = $res->truck_id;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if (!$truck) {
$return['msg'] = '关联板车数据获取异常,操作失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
/*更新数据*/
$_time = time();
$data = [];
$data['update_at'] = $_time;
$data['status_code'] = 99;
$res = $AcTruckOnline->updateAll($data, ['id'=>$id]);
$data = [];
$data['update_at'] = $_time;
$data['status_code'] = 0;
$AcTruck->updateAll($data, ['id'=>$truck_id]);
if ($res) {
$return['msg'] = '出车任务运达标记操作成功';
$return['errorcode'] = 200;
} else {
$return['msg'] = '运达标记操作失败';
$return['errorcode'] = 100;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
//删除板车装车任务
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcTruck();
$res = $model->updateAll($data, $where);
$return = [];
$return['url'] = Url::toRoute('truckol/index');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '板车装车任务删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '板车装车任务删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
//打印出车单
public function actionPrint()
{
$pid = Yii::$app->session->get('pid');
$id = Yii::$app->request->get('id'); //装车任务ID
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if (!$res) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$online_id = $id;
$AcTruckCars = new AcTruckCars();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','online_id',$online_id];
$where[] = ['=','deleted',0];
$where[] = ['>','status_code',0];
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
$carids = $orderids = [];
if ($truckcars) {
foreach ($truckcars as $t) {
$carids[] = $t->car_id;
$orderids[] = $t->order_id;
}
}
$counts = [];
$AcCar = new AcCar();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$carids];
$where[] = ['=','deleted',0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$AcOrder = new AcOrder();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$orderids];
$where[] = ['=','deleted',0];
$orders = $AcOrder->find()->where($where)->indexby('id')->all();
$employee_ids = [];
$count['fee_total'] = $count['pay_receive'] = 0;
foreach ($orders as $v) {
$employee_ids[] = $v->employee_id;
$count['fee_total'] += $v->fee_total;
$count['pay_receive'] += $v->pay_receive;
}
$AcEmployee = new AcEmployee();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$employee_ids];
$where[] = ['=','deleted',0];
$employees = $AcEmployee->find()->where($where)->indexby('id')->all();
$count['cars'] = count($truckcars);
$status = Yii::$app->params['TruckCarsStatus'];
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
return $this->render('print', [
'status'=>$status,
'truckOnLineStatus'=>$truckOnLineStatus,
'truckol'=>$truckol,
'cars'=>$cars,
'orders'=>$orders,
'employees'=>$employees,
'truckcars'=>$truckcars,
'count'=>$count
]);
}
//浏览详情
public function actionDetail()
{
$pid = Yii::$app->session->get('pid');
$id = Yii::$app->request->get('id'); //装车任务ID
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if (!$res) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$online_id = $id;
$AcTruckCars = new AcTruckCars();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','online_id',$online_id];
$where[] = ['=','deleted',0];
$where[] = ['>','status_code',1];
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
$carids = $orderids = [];
if ($truckcars) {
foreach ($truckcars as $t) {
$carids[] = $t->car_id;
$orderids[] = $t->order_id;
}
}
$counts = [];
$AcCar = new AcCar();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$carids];
$where[] = ['=','deleted',0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$AcOrder = new AcOrder();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$orderids];
$where[] = ['=','deleted',0];
$orders = $AcOrder->find()->where($where)->indexby('id')->all();
$employee_ids = [];
$count['fee_total'] = $count['pay_receive'] = 0;
foreach ($orders as $v) {
$employee_ids[] = $v->employee_id;
$count['fee_total'] += $v->fee_total;
$count['pay_receive'] += $v->pay_receive;
}
$AcEmployee = new AcEmployee();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$employee_ids];
$where[] = ['=','deleted',0];
$employees = $AcEmployee->find()->where($where)->indexby('id')->all();
$count['cars'] = count($truckcars);
$status = Yii::$app->params['TruckCarsStatus'];
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
return $this->render('detail', [
'status'=>$status,
'truckOnLineStatus'=>$truckOnLineStatus,
'truckol'=>$truckol,
'cars'=>$cars,
'orders'=>$orders,
'employees'=>$employees,
'truckcars'=>$truckcars,
'count'=>$count
]);
}
}

View File

@ -1,378 +0,0 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:37:26+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-22T07:37:26+08:00
# @Copyright: www.hiluker.cn
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcTruckOnline;
use addons\models\AcTruckCars;
use addons\models\AcStore;
use addons\models\AcCar;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcOrder;
use addons\models\AcGps;
use addons\models\AcGpsRoute;
use addons\models\AcTruckRoute;
class TruckrouteController extends Common
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
$session = Yii::$app->session;
if (isset($_GET['pid']) && (int)$_GET['pid']>0) {
$session->set('pid', (int)$_GET['pid']);
}
$pid = $session->get('pid');
if (!$pid) {
return Yii::$app->response->redirect(['index/index']);
}
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
if (!$online_id) {
$online_id = $session->get('online_id');
} else {
$session->set('online_id', $online_id);
}
if (!$online_id) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '请先选择好要查看的出车大板';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/index',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truckol = $session->get('truckOnline');
$AcTruckOnline = new AcTruckOnline();
$res = true;
if (!$truckol) {
$res = $AcTruckOnline->findOne($online_id);
if ($res) {
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$session->set('truckOnline', $truckol);
}
}
if ($online_id != $truckol['id']) {
$res = $AcTruckOnline->findOne($online_id);
if ($res) {
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckol['endstore_title'] = $store2->title;
}
$session->set('truckOnline', $truckol);
}
}
if (!$res) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '请先选择好要查看的出车大板';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/index',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
}
//所有板车位置记录列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute = new AcTruckRoute();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
if ($online_id) {
$where[] = ['=','online_id',$online_id];
}
$where[] = ['=','deleted',0];
$data = $AcTruckRoute->find()->where($where)->orderby('orderby ASC,id DESC');
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$truck_ids = [];
foreach ($res as $r) {
$truck_ids[] = $r->truck_id;
}
$AcTruck = new AcTruck();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$truck_ids];
$where[] = ['=','deleted',0];
$trucks = $AcTruck->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['CommonStatus'];
return $this->render('list', [
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'trucks'=>$trucks,
'online_id'=>$online_id,
'truckol'=>$truckol
]);
}
public function actionNew()
{
$status = Yii::$app->params['CommonStatus'];
$AcTruckRoute = [];
$AcTruckRoute['status_code'] = 0;
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute['truck_id'] = $truckol['truck_id'];
$AcTruckRoute['truck_num'] = $truckol['truck_num'];
return $this->render('modify', ['status'=>$status,'detail'=>$AcTruckRoute,'online_id'=>$online_id,'truckol'=>$truckol]);
}
//编辑板车位置信息
public function actionEdit()
{
$id = Yii::$app->request->get('id'); //记录ID
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute = new AcTruckRoute();
$route = $AcTruckRoute->findOne($id);
if (!$route) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '位置记录数据获取异常,请重新选择获取';
$return['errorcode'] = 0;
$return['url'] = '';
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$route = $route->toArray();
$route['truck_id'] = $truckol['truck_id'];
$route['online_id'] = $online_id;
$route['truck_num'] = $truckol['truck_num'];
$status = Yii::$app->params['CommonStatus'];
return $this->render('modify', ['status'=>$status,'detail'=>$route,'online_id'=>$online_id,'truckol'=>$truckol]);
}
//保存位置记录信息
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
$online_id = Yii::$app->session->get('online_id');
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$data = [];
$data['truck_id'] = $truckol['truck_id'];
$data['online_id'] = $online_id;
//格式化数据
//目标键=》POST键
$cols = ['longt'=>'lng','lat'=>'lat','addr'=>'addr'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['orderby'=>'orderby','status_code'=>'status_code'];
foreach ($cols as $col=>$key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$_time = time();
$key = 'update_at';
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
if (!$id) {
$data['create_at'] = $_time;
}
$data['pid'] = $pid;
//保存位置资料
$AcTruckRoute = new AcTruckRoute();
foreach ($data as $key=>$val) {
$AcTruckRoute->$key = $val;
}
if ($id) {
$res = $AcTruckRoute->updateAll($data, ['id'=>$id]);
} else {
$res = $AcTruckRoute->save();
$id = $AcTruckRoute->attributes['id']; //获取插入后id
}
if ($res) {
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//删除记录
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$return = [];
$model = new AcTruckRoute();
$route = $model->findOne($id);
if (!$route) {
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($route->pid !=$pid) {
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($route->deleted !=0) {
$return['msg'] = '数据已被删除过,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$route->deleted = 1;
$res = $route->save();
$return['url'] = '';
$return['timeout'] = 1; //n秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '位置记录删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '位置记录删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$return = [];
$model = new AcTruckRoute();
$route = $model->findOne($id);
if (!$route) {
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($route->pid !=$pid) {
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($route->deleted !=0) {
$return['msg'] = '数据已被删除,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$return['timeout'] = 1; //n秒后自动跳转
$res = true;
switch ($get['do']) {
case 'show':
if ($route->status_code!=1) {
$route->status_code = 1;
$res = $route->save();
}
if ($res) {
$return['msg'] = '记录显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
} else {
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
case 'hide':
if ($route->status_code!=0) {
$route->status_code = 0;
$res = $route->save();
}
if ($res) {
$return['msg'] = '记录隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
} else {
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}

Some files were not shown because too many files have changed in this diff Show More