Initial commit,修正
This commit is contained in:
Executable
+1
@@ -0,0 +1 @@
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<title>404</title>
|
||||
<style>
|
||||
body{
|
||||
background-color:#444;
|
||||
font-size:14px;
|
||||
}
|
||||
h3{
|
||||
font-size:60px;
|
||||
color:#eee;
|
||||
text-align:center;
|
||||
padding-top:30px;
|
||||
font-weight:normal;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>404,您请求的文件不存在!</h3>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace backend\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
/**
|
||||
* Main backend application asset bundle.
|
||||
*/
|
||||
class AppAsset extends AssetBundle
|
||||
{
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
'css/site.css',
|
||||
'css/login.min.css',
|
||||
];
|
||||
public $js = [
|
||||
'js/hplus.min.js',
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* User: Administrator
|
||||
* Date: 2016-7-5
|
||||
* Time: 16:10
|
||||
* Description:
|
||||
*/
|
||||
|
||||
namespace backend\components;
|
||||
|
||||
|
||||
use Yii;
|
||||
use yii\rbac\Rule;
|
||||
|
||||
|
||||
class ArticleRule extends Rule
|
||||
{
|
||||
public $name = 'article';
|
||||
public function execute($user, $item, $params)
|
||||
{
|
||||
// 这里先设置为false,逻辑上后面再完善
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Executable
+89
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-08 00:25:51
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-02-08T09:46:43+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\components;
|
||||
|
||||
use Yii;
|
||||
use common\models\CLog;
|
||||
use common\models\User;
|
||||
use common\models\Member;
|
||||
use common\models\Fans;
|
||||
use common\models\CAttachment;
|
||||
use common\models\CSms;
|
||||
use common\models\CVcode;
|
||||
|
||||
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 addons\models\AcContact;
|
||||
|
||||
class Helper {
|
||||
|
||||
//历史访客数
|
||||
public static function getHistoryVisNum(){
|
||||
$res = CLog::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//最近一个月访问量
|
||||
public static function getMonthHistoryVisNum(){
|
||||
$LastMonth = strtotime("-1 month");
|
||||
$res = CLog::find()->where(['>','create_time',$LastMonth])->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//API接口站用户总数
|
||||
public static function getApierCount(){
|
||||
$res = User::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//会员数据总数
|
||||
public static function getMemberCount(){
|
||||
$res = Member::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//粉丝数据总数
|
||||
public static function getFansCount(){
|
||||
$res = Fans::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//短信统计
|
||||
public static function getSmsStat(){
|
||||
$sms = CSms::find()->count();
|
||||
$mobile = CSms::find()->groupBy('mobile')->count();
|
||||
return ['sms'=>$sms,'mobile'=>$mobile];
|
||||
}
|
||||
|
||||
//附件统计
|
||||
public static function getAttachStat(){
|
||||
$num = CAttachment::find()->count();
|
||||
$size = CAttachment::find()->sum('filesize');
|
||||
return ['num'=>$num, 'size'=>$size];
|
||||
}
|
||||
|
||||
//今日运单
|
||||
public static function getOrderToday(){
|
||||
$num = CAttachment::find()->count();
|
||||
$size = CAttachment::find()->sum('filesize');
|
||||
return ['num'=>$num, 'size'=>$size];
|
||||
}
|
||||
}
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
main-local.php
|
||||
params-local.php
|
||||
test-local.php
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
Yii::setAlias('@backend', dirname(__DIR__));
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
# @Author: fm453
|
||||
# @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
|
||||
|
||||
$params = array_merge(
|
||||
require(__DIR__ . '/../../common/config/params.php'),
|
||||
require(__DIR__ . '/../../addons-'.HI_APP.'/config/citys.php'),
|
||||
require(__DIR__ . '/../../addons-'.HI_APP.'/config/params-car.php'),
|
||||
require(__DIR__ . '/../../addons-'.HI_APP.'/config/params-letter.php'),
|
||||
require(__DIR__ . '/../../addons-'.HI_APP.'/config/params-area.php'),
|
||||
require(__DIR__ . '/../../addons-'.HI_APP.'/config/params.php'),
|
||||
// require(__DIR__ . '/../../addons-'.HI_APP.'/config/version.php'),
|
||||
require(__DIR__ . '/params.php')
|
||||
);
|
||||
|
||||
$config = [
|
||||
'id' => 'api-ctms-backend',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'controllerNamespace' => 'backend\controllers',
|
||||
'defaultRoute' => 'index', //默认路由
|
||||
'bootstrap' => ['log'],
|
||||
'modules' => [
|
||||
// "admin" => [
|
||||
// "class" => 'mdm\admin\Module',
|
||||
// ],
|
||||
],
|
||||
'aliases' => [
|
||||
"@mdm/admin" => "@vendor/mdmsoft/yii2-admin",
|
||||
],
|
||||
// 'as access' => [
|
||||
// //加了才会自动验证是否有权限
|
||||
// 'class' => 'mdm\admin\components\AccessControl',
|
||||
// 'allowActions' => [
|
||||
// //允许访问的action
|
||||
// //controller/action
|
||||
// '*'
|
||||
// ]
|
||||
// ],
|
||||
'language' => 'zh-CN', //目标语言
|
||||
//组件
|
||||
'components' => [
|
||||
'request' => [
|
||||
'csrfParam' => '_csrf-backend',
|
||||
'cookieValidationKey' => 'CU5iSYmIp6kbjKKuh541KsA_oaYvTuNh',
|
||||
],
|
||||
// //身份认证类
|
||||
'user' => [
|
||||
'identityClass' => 'common\models\Adminer',
|
||||
'enableAutoLogin' => true,
|
||||
'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
|
||||
],
|
||||
'session' => [
|
||||
'name' => 'advanced-ctms-api',
|
||||
],
|
||||
//Rbac权限控制
|
||||
'authManager' => [
|
||||
'class' => 'yii\rbac\DbManager',
|
||||
],
|
||||
'log' => [
|
||||
'traceLevel' => YII_DEBUG ? 3 : 0,
|
||||
'targets' => [
|
||||
[
|
||||
'class' => 'yii\log\FileTarget',
|
||||
'levels' => ['error', 'warning'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'errorHandler' => [
|
||||
'errorAction' => 'site/error',
|
||||
],
|
||||
|
||||
'urlManager' => [
|
||||
'enablePrettyUrl' => true,
|
||||
'showScriptName' => true,
|
||||
'suffix' => '.453', //后缀
|
||||
'rules' => [
|
||||
],
|
||||
],
|
||||
],
|
||||
'params' => $params,
|
||||
];
|
||||
|
||||
return $config;
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客科技(www.hiluker.cn) <Fm453>
|
||||
# @Date: 1970-01-01T08:00:00+08:00
|
||||
# @Email: fm453@hiluker.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-09T17:30:39+08:00
|
||||
|
||||
return [
|
||||
|
||||
];
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => 'app-backend-tests',
|
||||
'components' => [
|
||||
'assetManager' => [
|
||||
'basePath' => __DIR__ . '/../web/assets',
|
||||
],
|
||||
],
|
||||
];
|
||||
Executable
+415
@@ -0,0 +1,415 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+604
@@ -0,0 +1,604 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+266
@@ -0,0 +1,266 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+673
@@ -0,0 +1,673 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Executable
+339
@@ -0,0 +1,339 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
<?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
|
||||
]);
|
||||
}
|
||||
}
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+278
@@ -0,0 +1,278 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+268
@@ -0,0 +1,268 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+295
@@ -0,0 +1,295 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
<?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']]);
|
||||
}
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
<?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', []);
|
||||
}
|
||||
}
|
||||
Executable
+1182
File diff suppressed because it is too large
Load Diff
Executable
+1393
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,127 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Executable
+378
@@ -0,0 +1,378 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Executable
+160
@@ -0,0 +1,160 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+634
@@ -0,0 +1,634 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+156
@@ -0,0 +1,156 @@
|
||||
<?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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Executable
+1381
File diff suppressed because it is too large
Load Diff
+302
@@ -0,0 +1,302 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+1593
File diff suppressed because it is too large
Load Diff
Executable
+248
@@ -0,0 +1,248 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+270
@@ -0,0 +1,270 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
<?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
|
||||
]);
|
||||
}
|
||||
}
|
||||
Executable
+422
@@ -0,0 +1,422 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
Executable
+561
@@ -0,0 +1,561 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+923
@@ -0,0 +1,923 @@
|
||||
<?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
|
||||
]);
|
||||
}
|
||||
}
|
||||
+378
@@ -0,0 +1,378 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Executable
+379
@@ -0,0 +1,379 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-10T01:13:34+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-14T21:12:32+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 UploadController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'image'=>'上传图片(单传)',
|
||||
];
|
||||
$this->result('您正使用CMTS系统文件上传接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionImage()
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$model = new CAttachment();
|
||||
$file = UploadedFile::getInstanceByName('file');
|
||||
//{error: 0
|
||||
// name: "e8.png"
|
||||
// size: 5362
|
||||
// tempName: "/Applications/XAMPP/xamppfiles/temp/phpG8vgnV"
|
||||
// type: "image/png"}
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
$title = isset($file->name) ? $file->name : md5(TIMESTAMP.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
//POST数据处理
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
$model = new CAttachment();
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$this->result('上传成功', ['id'=>$id,'path'=>$model->route], 200);
|
||||
}
|
||||
|
||||
public function actionImages()
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$model = new CAttachment();
|
||||
$files = UploadedFile::getInstancesByName('files');
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
//POST数据处理
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
|
||||
$attachModel = new CAttachment();
|
||||
$ids = $paths = $datas = [];
|
||||
foreach ($files as $file) {
|
||||
$tkey = microtime();
|
||||
$title = isset($file->name) ? $file->name : md5($tkey.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
$model = clone $attachModel;
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$ids[$id] = $id;
|
||||
$paths[$id] = $model->route;
|
||||
}
|
||||
|
||||
$this->result('上传成功', ['ids'=>$ids,'paths'=>$paths], 200);
|
||||
}
|
||||
|
||||
public function save_image()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$model = new CAttachment();
|
||||
$files = UploadedFile::getInstanceByName('files');
|
||||
//{error: 0
|
||||
// name: "e8.png"
|
||||
// size: 5362
|
||||
// tempName: "/Applications/XAMPP/xamppfiles/temp/phpG8vgnV"
|
||||
// type: "image/png"}
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
$title = isset($file->name) ? $file->name : md5(TIMESTAMP.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
//POST数据处理
|
||||
$post = Yii::$app->request->post();
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
$model = new CAttachment();
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$this->result('上传成功', ['id'=>$id,'path'=>$model->route], 200);
|
||||
}
|
||||
}
|
||||
|
||||
/*多图上传时的数据示例
|
||||
array(7) {
|
||||
[0]=>
|
||||
object(yii\web\UploadedFile)#60 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpJvR1FV"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[1]=>
|
||||
object(yii\web\UploadedFile)#62 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpzIuYVB"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[2]=>
|
||||
object(yii\web\UploadedFile)#63 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpUHXR4W"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[3]=>
|
||||
object(yii\web\UploadedFile)#64 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpEa5Q93"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[4]=>
|
||||
object(yii\web\UploadedFile)#65 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpEDfHIr"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[5]=>
|
||||
object(yii\web\UploadedFile)#66 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpiLqBVZ"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[6]=>
|
||||
object(yii\web\UploadedFile)#67 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/php5rqzIk"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
Executable
+126
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-15 20:22:03
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-06T09:36:33+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端普通用户入口
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use common\models\User;
|
||||
use addons\models\AcUserExt;
|
||||
use backend\controllers\Common;
|
||||
|
||||
class UserController 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)];
|
||||
//查询关联用户的在当前系统中的扩展信息
|
||||
$AcUserExt = new AcUserExt();
|
||||
//TODO
|
||||
$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);
|
||||
}
|
||||
}
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:37:06+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-10-23T11:51:39+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcWeituoren;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
|
||||
class WeituorenController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
// $this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'搜索委托单位清单',
|
||||
'detail'=>'委托单位详情'
|
||||
];
|
||||
$this->result('您正使用CMTS系统委托单位管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcWeituoren();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : null;
|
||||
if (!$search) {
|
||||
$search = [];
|
||||
}
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','company',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->asArray()->where($where); //asArray() 放在find后,可让查询结果以数组形式呈现
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'orderby DESC,id ASC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
if (!$res) {
|
||||
$this->result('没有符合条件的结果');
|
||||
}
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '委托单位查询成功!';
|
||||
$return['data']= ['total'=>$data->count(),
|
||||
'data'=>[
|
||||
'weituoren' => $res
|
||||
],
|
||||
'page'=>$this->page];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcWeituoren();
|
||||
$weituo = $model->findOne($id);
|
||||
$detail = $weituo->toArray();
|
||||
|
||||
$this->result('查询成功!', $detail, 200);
|
||||
}
|
||||
}
|
||||
+415
@@ -0,0 +1,415 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+604
@@ -0,0 +1,604 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+673
@@ -0,0 +1,673 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
+339
@@ -0,0 +1,339 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?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
|
||||
]);
|
||||
}
|
||||
}
|
||||
Executable
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-15 20:22:03
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-08T16:02:30+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端用户入口
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
use common\models\Fans; //‘from’字段为ctms的数据
|
||||
use addons\models\AcFansExt;
|
||||
|
||||
class Common extends Controller
|
||||
{
|
||||
protected $pid = 0;
|
||||
protected $user_id = 0;
|
||||
protected $site_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;
|
||||
protected $timetamp = '';
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->timetamp = time();
|
||||
//判断请求内容类型 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);
|
||||
}
|
||||
} elseif (isset($_GET['pid'])) {
|
||||
if ((int)$_GET['pid']>0) {
|
||||
$this->pid = $_GET['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['uid']) && (int)$postdata['uid']>0) {
|
||||
$this->user_id = (int)$postdata['uid'];
|
||||
}
|
||||
if ($this->user_id) {
|
||||
$userModel = new Fans();
|
||||
$res = $userModel->findOne($this->user_id);
|
||||
if(!$res){
|
||||
$this->user_id = 0;
|
||||
}else{
|
||||
$this->user_info = $res;
|
||||
}
|
||||
//TBD 后期需加上更多登陆验证逻辑
|
||||
}
|
||||
|
||||
$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));
|
||||
}
|
||||
|
||||
public function fansToken($user=[], $refresh=false, $expire = null){
|
||||
//生成token(用户数据,是否强制更新,过期时间 // TBD 具体方法有待优化
|
||||
$expire = $expire ? $expire : '+1 day';
|
||||
$token = Yii::$app->session->get('fansToken');
|
||||
$tokenExpired = Yii::$app->session->get('fansTokenExpired');
|
||||
if(!$token || $refresh){
|
||||
$tokenExpired = strtotime($expire)*1000;
|
||||
$token = md5('username='.$user['username'].'&mobile='.$user['mobile'].'&time='.$tokenExpired);
|
||||
Yii::$app->session->set('fansToken',$token);
|
||||
Yii::$app->session->set('fansTokenExpired',$tokenExpired);
|
||||
}
|
||||
$user['token'] = $token;
|
||||
$user['tokenExpired'] = $tokenExpired;
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
+278
@@ -0,0 +1,278 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+268
@@ -0,0 +1,268 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
<?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']]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-15 20:22:03
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-12T15:46:59+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端普通用户入口
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use common\models\Fans; //‘from’字段为ctms的数据
|
||||
use addons\models\AcFansExt;
|
||||
use common\models\CSms;
|
||||
use common\models\CVcode;
|
||||
|
||||
class FansController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'login'=>'账号密码登陆',
|
||||
'loginSms'=>'手机验证码登陆',
|
||||
'detail'=>'个人资料',
|
||||
'register'=>'用户注册',
|
||||
'auth'=>'授权登陆'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统用户管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionLogin()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$username = $post['username'] ?? null;
|
||||
$passwd = $post['passwd'] ?? null;
|
||||
|
||||
$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 Fans();
|
||||
$from = Yii::$app->params['fansFrom']; //指定fans数据的from字段指定ctms,表示该项目的专有数据
|
||||
$condition = '(`mobile` = :username OR `email` = :username) AND `from` = :from';
|
||||
$args = [':username' => $username, ':from' => $from];
|
||||
$user = $model->find()->where($condition,$args)->one();
|
||||
if (!$user) {
|
||||
$this->result('查无此人!', null, 404);
|
||||
}
|
||||
|
||||
if ($user->status != Fans::STATUS_ACTIVE) {
|
||||
$this->result('账户异常,禁止登陆!', null, 403);
|
||||
}
|
||||
//安全校验,登陆密码
|
||||
$isPwdRight = $user->validatePassword($passwd);
|
||||
|
||||
if (!$isPwdRight) {
|
||||
$this->result('密码错误,禁止登陆!', null, 400);
|
||||
}
|
||||
//校验结束
|
||||
|
||||
$_user = $this->fansLogin($user,true);
|
||||
$this->result('登陆成功!', ['user'=>$_user], 200);
|
||||
}
|
||||
|
||||
public function actionLoginSms()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$mobile = $post['mobile'] ?? null;
|
||||
$vcode = $post['vcode'] ?? null;
|
||||
|
||||
$return = [];
|
||||
if (!$mobile && !$vcode) {
|
||||
$this->result('登陆参数错误!', null, 400);
|
||||
}
|
||||
if (!$mobile) {
|
||||
$this->result('请输入您的手机号!', null, 400);
|
||||
}
|
||||
if (!$vcode) {
|
||||
$this->result('请输入手机验证码!', null, 400);
|
||||
}
|
||||
$mobile = trim(htmlspecialchars_decode($mobile));
|
||||
//验证手机号
|
||||
$isPhone = preg_match('/^1\d{10}$/', $mobile) ? true : false;
|
||||
if(!$isPhone){
|
||||
$this->result('手机号不正确,请检查');
|
||||
}
|
||||
$vcode = trim(htmlspecialchars_decode($vcode));
|
||||
//验证手机验证码
|
||||
$vcodeModel = new CVcode();
|
||||
$where=[];
|
||||
$where['mobile'] = $mobile;
|
||||
$where['deleted'] = 0;
|
||||
$where['code'] = $vcode;
|
||||
$where['type'] = 'login';
|
||||
$res = $vcodeModel->find()->where($where)->one();
|
||||
if(!$res){
|
||||
$this->result('验证码校验失败');
|
||||
}
|
||||
if (($this->timetamp-$res->create_at)>300) {
|
||||
// 超时5分钟
|
||||
$this->result('验证码已失效,请重新获取');
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$from = Yii::$app->params['fansFrom']; //指定fans数据的from字段指定ctms,表示该项目的专有数据
|
||||
$condition = '`mobile` = :username AND `from` = :from';
|
||||
$args = [':username' => $mobile, ':from' => $from];
|
||||
$user = $model->find()->where($condition,$args)->one();
|
||||
$hasExt = true;
|
||||
if (!$user) {
|
||||
$hasExt = false;
|
||||
$userModel = clone $model;
|
||||
$user = $this->fansAdd(['mobile'=>$mobile,'from'=>$from],$userModel);
|
||||
}elseif ($user->status != Fans::STATUS_ACTIVE) {
|
||||
$this->result('账户异常,禁止登陆!', null, 403);
|
||||
}
|
||||
//校验结束
|
||||
$_user = $this->fansLogin($user,$hasExt);
|
||||
$this->result('登陆成功!', ['user'=>$_user], 200);
|
||||
}
|
||||
|
||||
public function actionAuth()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
$openplat = $post['from'] ?? 'uni-app'; //归属的开放平台,默认标记为了uni-app
|
||||
$mobile = isset($post['mobile']) ? trim(htmlspecialchars_decode($post['mobile'])) : '';
|
||||
$openid = isset($post['openid']) ? trim(htmlspecialchars_decode($post['openid'])) : '';
|
||||
|
||||
$return = [];
|
||||
if (!$mobile) {
|
||||
$this->result('未提供授权手机号!');
|
||||
}
|
||||
if (!$openid) {
|
||||
$this->result('未提供授权用户身份ID!');
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$userModel = clone $model;
|
||||
$from = Yii::$app->params['fansFrom']; //指定fans数据的from字段指定ctms,表示该项目的专有数据
|
||||
$user = $model->findOne(['mobile' => $mobile,'from' =>$from]);
|
||||
//扩展用户信息
|
||||
$AcFansExt = new AcFansExt();
|
||||
$Ext = clone $AcFansExt; //用于更新openid
|
||||
$Ext2 = clone $AcFansExt; //用于更新来源归属的开放平台openplat
|
||||
|
||||
$hasExt = true;
|
||||
if (!$user) {
|
||||
$hasExt = false;
|
||||
//自动注册一个新用户
|
||||
$user = $this->fansAdd(['mobile'=>$mobile,'from'=>$from],$userModel);
|
||||
|
||||
// 添加扩展信息
|
||||
$Ext->pid = $this->pid;
|
||||
$Ext->mid = $user->id;
|
||||
$Ext->mobile = $mobile;
|
||||
$Ext->key = 'openid';
|
||||
$Ext->value = $openid;
|
||||
$Ext->deleted = 0;
|
||||
$Ext->save();
|
||||
|
||||
$Ext2->pid = $this->pid;
|
||||
$Ext2->mid = $user->id;
|
||||
$Ext2->mobile = $mobile;
|
||||
$Ext2->key = 'openplat';
|
||||
$Ext2->value = $openplat;
|
||||
$Ext2->deleted = 0;
|
||||
$Ext2->save();
|
||||
}else{
|
||||
//所有该用户已设置过的openid值添加一次被删除标记
|
||||
$condition = '`mid` = :mid AND `mobile` = :mobile AND `pid` = :pid AND `deleted` = :deleted AND `key` = :key AND `value` != :value';
|
||||
$args = [':mid' => $user->id,':mobile' => $user->mobile,':pid'=>$pid,':deleted'=>0,':value'=>$openid,':key'=>'openid'];
|
||||
$AcFansExt->updateAllCounters(
|
||||
['deleted'=>1],$condition,$args
|
||||
);
|
||||
|
||||
$condition = '`mid` = :mid AND `mobile` = :mobile AND `pid` = :pid AND `key` = :key AND `value` = :value';
|
||||
|
||||
$args = [':mid' => $user->id,':mobile' => $user->mobile,':pid'=>$pid,':key'=>'openid',':value'=>$openid];
|
||||
$userExt = $Ext->find()->where($condition,$args)->one();
|
||||
if($userExt){
|
||||
$userExt->deleted = 0;
|
||||
$userExt->save();
|
||||
}else{
|
||||
$Ext->pid = $this->pid;
|
||||
$Ext->mid = $user->id;
|
||||
$Ext->mobile = $mobile;
|
||||
$Ext->key = 'openid';
|
||||
$Ext->value = $openid;
|
||||
$Ext->deleted = 0;
|
||||
$Ext->save();
|
||||
}
|
||||
|
||||
$args = [':mid' => $user->id,':mobile' => $user->mobile,':pid'=>$pid,':key'=>'openplat',':value'=>$openplat];
|
||||
$userExt2 = $Ext2->find()->where($condition,$args)->one();
|
||||
if($userExt2){
|
||||
$userExt2->deleted = 0;
|
||||
$userExt2->save();
|
||||
}else{
|
||||
$Ext2->pid = $this->pid;
|
||||
$Ext2->mid = $user->id;
|
||||
$Ext2->mobile = $mobile;
|
||||
$Ext2->key = 'openplat';
|
||||
$Ext2->value = $openplat;
|
||||
$Ext2->deleted = 0;
|
||||
$Ext2->save();
|
||||
}
|
||||
}
|
||||
|
||||
// 登陆用户
|
||||
$_user = $this->fansLogin($user,$hasExt);
|
||||
$this->result('登陆成功!', ['user'=>$_user], 200);
|
||||
}
|
||||
|
||||
public function actionRegister()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$mobile = isset($post['mobile']) ? trim(htmlspecialchars_decode($post['mobile'])) : '';
|
||||
$vcode = isset($post['vcode']) ? trim(htmlspecialchars_decode($post['vcode'])) : '';
|
||||
$password = isset($post['passwd']) ? trim(htmlspecialchars_decode($post['passwd'])) : '';
|
||||
$username = isset($post['username']) ? trim(htmlspecialchars_decode($post['username'])) : '';
|
||||
$email = isset($post['email']) ? trim(htmlspecialchars_decode($post['email'])) : '';
|
||||
|
||||
$return = [];
|
||||
if (!$mobile) {
|
||||
$this->result('未填写手机号!');
|
||||
}
|
||||
if (!$vcode) {
|
||||
$this->result('未填写手机验证码!');
|
||||
}
|
||||
//验证短信码
|
||||
|
||||
$model = new Fans();
|
||||
$userModel = clone $model;
|
||||
$from = Yii::$app->params['fansFrom']; //指定fans数据的from字段指定ctms,表示该项目的专有数据
|
||||
|
||||
$user = $model->findOne(['mobile' => $mobile,'from' =>$from]);
|
||||
//扩展用户信息
|
||||
$AcFansExt = new AcFansExt();
|
||||
$Ext = clone $AcFansExt;
|
||||
|
||||
if (!$user) {
|
||||
//自动注册一个新用户
|
||||
$userModel->mobile = $mobile;
|
||||
$userModel->email = $mobile.'@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = $from;
|
||||
$userModel->save();
|
||||
$user = $userModel;
|
||||
}
|
||||
|
||||
$_user = $this->fansLogin($user,true);
|
||||
$this->result('登陆成功!', ['user'=>$_user], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个新用户
|
||||
* @param $data 用户数据
|
||||
* @return void
|
||||
*/
|
||||
private function fansAdd($data,$userModel){
|
||||
$mobile = $data['mobile'];
|
||||
$from = $data['from'] ?? Yii::$app->params['fansFrom'];
|
||||
$userModel->mobile = $mobile;
|
||||
$userModel->email = $mobile.'@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = $from;
|
||||
$userModel->save();
|
||||
return $userModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user 用户实例
|
||||
* @param $hasExt 有否扩展
|
||||
* @return void
|
||||
*/
|
||||
private function fansLogin($user,$hasExt = false){
|
||||
// 使用指定用户名获取用户身份实例
|
||||
$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->mobile,'mobile'=>$user->mobile];
|
||||
if($hasExt){
|
||||
//查询关联用户的在当前系统中的扩展信息
|
||||
$AcUserExt = new AcFansExt();
|
||||
$exts = $AcUserExt->find()->where(['mid' => $user->id,'mobile' => $user->mobile,'pid'=>$this->pid,'deleted'=>0])->all();
|
||||
if ($exts) {
|
||||
foreach ($exts as $ext) {
|
||||
$_user[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
//生成token(用户数据,是否强制更新,过期时间
|
||||
$isLong = $this->postdata['isLong'] || false;
|
||||
$expire = $isLong ? '+1 Month' : false;
|
||||
$_user = $this->fansToken($_user,$refresh = true, $expire);
|
||||
return $_user;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?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', []);
|
||||
}
|
||||
}
|
||||
+1182
File diff suppressed because it is too large
Load Diff
+1393
File diff suppressed because it is too large
Load Diff
+378
@@ -0,0 +1,378 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-13T09:20:03+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-09T00:58:05+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
|
||||
//主入口页
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
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 actionAdsSplash()
|
||||
{
|
||||
$ads = [
|
||||
// "http://public.hiluker.com/ctms/client/app-kp/kp01.jpg",
|
||||
"http://public.hiluker.com/ctms/client/app-kp/kp03.jpg",
|
||||
];
|
||||
$this->result('开屏广告!', $ads, 200);
|
||||
}
|
||||
|
||||
public function actionAdsBanner()
|
||||
{
|
||||
$ads = [
|
||||
'0'=>[
|
||||
"image"=>'http://public.hiluker.com/ctms/client/app-banner/banner01.jpg',
|
||||
"link"=>'/pages/uni-starter/ucenter/ucenter'
|
||||
],
|
||||
'1'=>[
|
||||
"image"=>'http://public.hiluker.com/ctms/client/app-banner/banner03.jpg',
|
||||
"link"=>'http://ctms.hiluker.cn'
|
||||
],
|
||||
'2'=>[
|
||||
"image"=>'http://public.hiluker.com/ctms/client/app-banner/banner02.jpg',
|
||||
"link"=>''
|
||||
]
|
||||
];
|
||||
$this->result('BANNER广告!', $ads, 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));
|
||||
}
|
||||
}
|
||||
+634
@@ -0,0 +1,634 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNews;
|
||||
use addons\models\AcNewsCat;
|
||||
use Yii;use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class NewsController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'文章清单',
|
||||
'detail'=>'文章详情'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统文章内容管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search(['is_show'=>1]);
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
'total'=>$data->count(),
|
||||
'news' => $list,
|
||||
'page'=>$this->page
|
||||
];
|
||||
$this->result('内容查询成功!',$return,200);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = $post['id'] ?? 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcNews();
|
||||
$detail = $model->findOne($id);
|
||||
$s = $this->formatDetail($detail->toArray());
|
||||
$this->result('查询成功!', $s, 200);
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$id = $post['id'] ?? 0;
|
||||
if ($id<=0) {
|
||||
$this->result('未指定内容!');
|
||||
}
|
||||
$model = new AcNews();
|
||||
$detail = $model->findOne($id);
|
||||
if (!$detail) {
|
||||
$this->result('指定的内容不存在!');
|
||||
}
|
||||
if ($detail->deleted) {
|
||||
$this->result('指定的内容已被删除!');
|
||||
}
|
||||
$op = $post['op'] ?? '';
|
||||
if(!$op){
|
||||
$this->result('无有效指令!');
|
||||
}
|
||||
switch ($op) {
|
||||
case 'read':
|
||||
$detail->reading += 1;
|
||||
break;
|
||||
case 'no_read':
|
||||
$detail->reading -= 1;
|
||||
$detail->reading = $detail->reading<0 ? 0 : $detail->reading;
|
||||
break;
|
||||
case 'like':
|
||||
$detail->liked += 1;
|
||||
break;
|
||||
case 'no_like':
|
||||
$detail->liked -= 1;
|
||||
$detail->liked = $detail->liked<0 ? 0 : $detail->liked;
|
||||
break;
|
||||
case 'view':
|
||||
$detail->viewed += 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$detail->save();
|
||||
$data = $this->formatDetail($detail->toArray());
|
||||
$this->result('已执行', $data, 200);
|
||||
}
|
||||
|
||||
private function search($ops=[])
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$model = new AcNews();
|
||||
$where = '`pid` = :pid';
|
||||
$params = [':pid'=>$pid];
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
// 优先处理$ops传参,并同时删除$search中相应元素
|
||||
if($ops){
|
||||
foreach ($ops as $key => $value) {
|
||||
$where .= ' AND `'.$key.'` = :'.$key;
|
||||
$params[':'.$key] = $value;
|
||||
if(isset($search[$key])){
|
||||
unset($search[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search['title'])) {
|
||||
$search['title'] = trim($search['title']);
|
||||
$where .= ' AND `title` like :title';
|
||||
$params[':title'] = '%'.$search['title'].'%';
|
||||
}
|
||||
if (!empty($search['cid'])) {
|
||||
$search['cid'] = intval($search['cid']);
|
||||
$where .= ' AND `cid` = :cid';
|
||||
$params[':cid'] = $search['cid'];
|
||||
}
|
||||
|
||||
if(!isset($params[':deleted'])){
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' AND `deleted` = :deleted';
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where,$params);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'orderby DESC,update_at DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
return ['res'=>$res,'data'=>$data];
|
||||
}
|
||||
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted'];
|
||||
$list = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期'.$weekdays[$wk];
|
||||
|
||||
$s['content'] = $s['content'] ? htmlspecialchars_decode($s['content']) : '';
|
||||
|
||||
$list[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s=[])
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted','is_show'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期'.$weekdays[$wk];
|
||||
$s['content'] = htmlspecialchars_decode($s['content']);
|
||||
|
||||
// 'src="/upload/pics/'
|
||||
$upload_url = 'https://dacms.hiluker.cn';
|
||||
$s['content'] = str_replace('src="/upload/pics/', 'src="'.$upload_url.'/upload/pics/', $s['content']);
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNewsCat;use yii\data\Pagination;
|
||||
|
||||
class NewscatController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'分类清单'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统内容分类管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search(['is_show'=>1]);
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
}
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
'cats' => $list
|
||||
];
|
||||
$this->result('通知查询成功!',$return,200);
|
||||
}
|
||||
|
||||
private function search($ops=[])
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$model = new AcNewsCat();
|
||||
$where = 'pid = :pid';
|
||||
$params = [':pid'=>$pid];
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
// 优先处理$ops传参,并同时删除$search中相应元素
|
||||
if($ops){
|
||||
foreach ($ops as $key => $value) {
|
||||
$where .= ' & '.$key.' = :'.$key;
|
||||
$params[':'.$key] = $value;
|
||||
if(isset($search[$key])){
|
||||
unset($search[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($search['title'])) {
|
||||
$search['title'] = trim($search['title']);
|
||||
$where .= ' & title like :title';
|
||||
$params[':title'] = $search['title'];
|
||||
}
|
||||
|
||||
if(!isset($params[':deleted'])){
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' & deleted = :deleted';
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
$pageSize = 10;
|
||||
$data = $model->find()->where($where,$params);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'orderby DESC,update_at DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
return ['res'=>$res,'data'=>$data];
|
||||
}
|
||||
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted','update_at'];
|
||||
$list = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$list[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s=[])
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted','is_show'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期'.$weekdays[$wk];
|
||||
$s['des'] = htmlspecialchars_decode($s['des']);
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNotice;use yii\data\Pagination;
|
||||
|
||||
class NoticeController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'通知清单',
|
||||
'detail'=>'通知详情'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统通知管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
// $s = $this->search(['is_show'=>1]);
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
'total'=>$data->count(),
|
||||
'notices' => $list,
|
||||
'page'=>$this->page
|
||||
];
|
||||
$this->result('通知查询成功!',$return,200);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcNotice();
|
||||
$detail = $model->findOne($id);
|
||||
$s = $this->formatDetail($detail->toArray());
|
||||
$this->result('查询成功!', $s, 200);
|
||||
}
|
||||
|
||||
private function search($ops=[])
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$model = new AcNotice();
|
||||
$where = 'pid = :pid';
|
||||
$params = [':pid'=>$pid];
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
// 优先处理$ops传参,并同时删除$search中相应元素
|
||||
if($ops){
|
||||
foreach ($ops as $key => $value) {
|
||||
$where .= ' & '.$key.' = :'.$key;
|
||||
$params[':'.$key] = $value;
|
||||
if(isset($search[$key])){
|
||||
unset($search[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($search['title']) && !empty($search['title'])) {
|
||||
$search['title'] = trim($search['title']);
|
||||
$where .= ' & title like :title';
|
||||
$params[':title'] = $search['title'];
|
||||
}
|
||||
|
||||
if(!isset($params[':deleted'])){
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' & deleted = :deleted';
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where,$params);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'update_at DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
return ['res'=>$res,'data'=>$data];
|
||||
}
|
||||
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted'];
|
||||
$list = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期'.$weekdays[$wk];
|
||||
$list[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s=[])
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted','is_show'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $s['update_at']);
|
||||
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期'.$weekdays[$wk];
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
+707
@@ -0,0 +1,707 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-13T14:23:16+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use backend\controllers\client\v1\Common;
|
||||
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;
|
||||
use addons\models\AcFansExt;
|
||||
|
||||
class OrderController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
// $this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'搜索运单',
|
||||
'detail'=>'运单详情',
|
||||
'create'=>'创建运单'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统订单管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$this->showOrder($res, $data);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$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);
|
||||
$detail = $order->toArray();
|
||||
$detail['thumbs'] = $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;
|
||||
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $detail['sign_date']);
|
||||
$detail['signdate'] = date('Y-m-d 星期'.$weekdays[$wk], $detail['sign_date']);
|
||||
$detail['from_province'] = isset($detail['start_province']) ? Yii::$app->params['regionAreas'][$detail['start_province']] : '';
|
||||
$detail['to_province'] = isset($detail['aim_province']) ? Yii::$app->params['regionAreas'][$detail['aim_province']] : '';
|
||||
$detail['remark'] = $detail['remark'] || '';
|
||||
$detail['remark'] = trim($detail['remark']) ? htmlspecialchars_decode(trim($detail['remark'])) : '';
|
||||
|
||||
$imgDir = Yii::getAlias('@upload');
|
||||
$imgKeys = ['driving_lisence','thumb_f','thumb_b','thumb_l','thumb_r'];
|
||||
foreach ($imgKeys as $k) {
|
||||
$detail[$k] = $detail[$k] ? $detail[$k] : '/pics/nopic.jpg';
|
||||
$url_pre = substr($detail[$k], 0, 4);
|
||||
if ($url_pre =='/pic') {
|
||||
$detail[$k.'_url'] = Url::to('@upload'.$detail[$k], $this->imgHttp);
|
||||
} elseif ($url_pre =='http') {
|
||||
$detail[$k.'_url'] = $detail[$k];
|
||||
}
|
||||
}
|
||||
|
||||
if ($detail['thumbs']) {
|
||||
$thumbs = $detail['thumbs'];
|
||||
$thumbs_url = [];
|
||||
foreach ($thumbs as $k=>$v) {
|
||||
$url_pre = substr($v, 0, 4);
|
||||
if ($url_pre =='/pic') {
|
||||
$v_url = Url::to('@upload'.$v, $this->imgHttp);
|
||||
} elseif ($url_pre =='http') {
|
||||
$v_url = $v;
|
||||
}
|
||||
$thumbs_url[] = ['src'=>$v,'url'=>$v_url];
|
||||
}
|
||||
$detail['thumbs_url'] = $thumbs_url;
|
||||
}
|
||||
|
||||
$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]);
|
||||
}
|
||||
|
||||
$this->result('订单查询成功!', $detail, 200);
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$pid = $this->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',
|
||||
$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','weituo'=>'weituo'];
|
||||
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']) ? $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['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
//部分规则校验
|
||||
$hasError = 0;
|
||||
$msg = '';
|
||||
$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']) {
|
||||
$hasError += 1;
|
||||
$msg .= '请注意,运费未正确填写!';
|
||||
}
|
||||
|
||||
if ($fee_total !=$data['fee_total']) {
|
||||
$hasError += 1;
|
||||
$msg .= '所填各项费用汇总的值与所填写的总费用不一致!';
|
||||
}
|
||||
if ($fee_pay !=$data['fee_total']) {
|
||||
$hasError += 1;
|
||||
$msg .= '所填现付与到收费用汇总的值与所填写的总费用不一致!';
|
||||
}
|
||||
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
$data['employee_id'] = isset($post['employee_id']) ? (int)$post['employee_id'] : 1; //1是宫雪
|
||||
$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']].')';
|
||||
if ($data['remark']) {
|
||||
$data['remark'] .= ' ; '.$txt;
|
||||
} else {
|
||||
$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'];
|
||||
}
|
||||
$post['carno_frame'] = isset($post['carno_frame']) ? $post['carno_frame'] : '';
|
||||
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->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'] = '订单保存成功!'.$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));
|
||||
}
|
||||
}
|
||||
|
||||
//订单列表
|
||||
private function search()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcOrder();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$search['phone'] = $this->user_info->mobile;
|
||||
$orwhere = ['or',['LIKE','sender_mobiles',$search['phone']],['LIKE','receiver_mobiles',$search['phone']]];
|
||||
|
||||
//车牌号使用完整精准搜索(皖A88888)
|
||||
$CarModel = new AcCar();
|
||||
if (isset($search['carno']) && !empty($search['carno'])) {
|
||||
$search['carno'] = trim($search['carno']);
|
||||
$sql = 'CONCAT(num_p,num_area,num_left) = :carno or num_frame LIKE :carno';
|
||||
$cars = $CarModel->find()->where($sql,[':carno'=>$search['carno']])->limit(5)->offset(0)->all();
|
||||
|
||||
//最多仅显示可匹配车牌号的前5个
|
||||
if (empty($cars)) {
|
||||
$return['code'] = 400;
|
||||
$return['msg'] = '未查询到相关车辆';
|
||||
return ['res'=>false,'data'=>$return];
|
||||
} 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','aim_city',$search['city']];
|
||||
}
|
||||
|
||||
$search['employee'] = isset($search['employee']) ? (int)$search['employee'] : '';
|
||||
$EmployeeModel = new AcEmployee();
|
||||
if (!empty($search['employee'])) {
|
||||
$where[] = ['=','employee_id',$search['employee']];
|
||||
$employee = $EmployeeModel->findOne($search['employee']);
|
||||
$search['employee_title'] = isset($employee->name) ? $employee->name : '';
|
||||
}
|
||||
$search['store_id'] = isset($search['store_id']) ? (int)$search['store_id'] : '';
|
||||
if (empty($search['sotre_id'])) {
|
||||
$search['store_id'] = isset($get['store_id']) ? (int)$get['store_id'] : 0;
|
||||
}
|
||||
$StoreModel = new AcStore();
|
||||
if (!empty($search['store_id'])) {
|
||||
$where[] = ['=','store_id',$search['store_id']];
|
||||
$store = $StoreModel->findOne($search['store_id']);
|
||||
$search['store_title'] = isset($store->title) ? $store->title : '';
|
||||
}
|
||||
|
||||
$search['start_province'] = isset($search['start_province']) ? trim($search['start_province']) : '';
|
||||
if (!empty($search['start_province'])) {
|
||||
$where[] = ['=','start_province',$search['start_province']];
|
||||
}
|
||||
$search['start_city'] = isset($search['start_city']) ? trim($search['start_city']) : '';
|
||||
if (!empty($search['start_city'])) {
|
||||
$where[] = ['LIKE','start_city',$search['start_city']];
|
||||
}
|
||||
$search['aim_province'] = isset($search['aim_province']) ? trim($search['aim_province']) : '';
|
||||
if (!empty($search['aim_province'])) {
|
||||
$where[] = ['=','aim_province',$search['aim_province']];
|
||||
}
|
||||
$search['aim_city'] = isset($search['aim_city']) ? trim($search['aim_city']) : '';
|
||||
if (!empty($search['aim_city'])) {
|
||||
$where[] = ['LIKE','aim_city',$search['aim_city']];
|
||||
}
|
||||
$search['signer'] = isset($search['signer']) ? trim($search['signer']) : '';
|
||||
$search['wtdw'] = isset($search['wtdw']) ? trim($search['wtdw']) : '';
|
||||
$search['weituo'] = isset($search['weituo']) ? (int)$search['weituo'] : 0;
|
||||
if ($search['weituo']) {
|
||||
$where[] = ['=','weituo',$search['weituo']];
|
||||
} elseif (!empty($search['wtdw'])) {
|
||||
$where[] = ['LIKE','wtdw',$search['wtdw']];
|
||||
} elseif (!empty($search['signer'])) {
|
||||
$where[] = ['LIKE','signer',$search['signer']];
|
||||
}
|
||||
|
||||
$search['sender_name'] = isset($search['sender_name']) ? trim($search['sender_name']) : '';
|
||||
if (!empty($search['sender_name'])) {
|
||||
$where[] = ['LIKE','sender_name',$search['sender_name']];
|
||||
}
|
||||
$search['receiver_name'] = isset($search['receiver_name']) ? trim($search['receiver_name']) : '';
|
||||
if (!empty($search['receiver_name'])) {
|
||||
$where[] = ['LIKE','receiver_name',$search['receiver_name']];
|
||||
}
|
||||
$search['bind'] = isset($search['bind']) ? trim($search['bind']) : '';
|
||||
if (!empty($search['bind'])) {
|
||||
$where[] = ['LIKE','bind',$search['bind']];
|
||||
}
|
||||
if (isset($search['status_code']) && $search['status_code'] !='all') {
|
||||
$search['status_code'] = (int)$search['status_code'];
|
||||
$where[] = ['=','status_code',$search['status_code']];
|
||||
} else {
|
||||
unset($search['status_code']);
|
||||
}
|
||||
|
||||
if (isset($search['is_holdon'])) {
|
||||
$search['is_holdon'] = (int)$search['is_holdon'];
|
||||
$where[] = ['=','is_holdon',$search['is_holdon']];
|
||||
}
|
||||
if (isset($search['is_over'])) {
|
||||
$search['is_over'] = (int)$search['is_over'];
|
||||
$where[] = ['=','is_over',$search['is_over']];
|
||||
}
|
||||
if (isset($search['is_commission'])) {
|
||||
$search['is_commission'] = (int)$search['is_commission'];
|
||||
$where[] = ['=','is_commission',$search['is_commission']];
|
||||
}
|
||||
$search['is_cwqr'] = isset($search['is_cwqr']) ? $search['is_cwqr'] : '';
|
||||
if ($search['is_cwqr']=='') {
|
||||
$search['is_cwqr'] = isset($get['is_cwqr']) ? $get['is_cwqr'] : '';
|
||||
}
|
||||
if ($search['is_cwqr'] !='') {
|
||||
$search['is_cwqr'] = (int)$get['is_cwqr'];
|
||||
$where[] = ['=','is_cwqr',$search['is_cwqr']];
|
||||
}
|
||||
|
||||
//签约时间筛选
|
||||
$search['sign_m'] = isset($search['sign_m']) ? $search['sign_m'] : '';
|
||||
$search['sign_after'] = isset($search['sign_after']) ? $search['sign_after'] : '';
|
||||
$search['sign_before'] = isset($search['sign_before']) ? $search['sign_before'] : '';
|
||||
//按月份筛选
|
||||
if (!empty($search['sign_m'])) {
|
||||
$start = strtotime($search['sign_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','sign_date',$start,$end];
|
||||
}
|
||||
//按指定时段筛选
|
||||
elseif (!empty($search['sign_after']) && !empty($search['sign_before'])) {
|
||||
$start = strtotime($search['sign_after']);
|
||||
$end = strtotime($search['sign_before']);
|
||||
$where[] = ['between','sign_date',$start,$end];
|
||||
}
|
||||
//按指定时间临界点筛选(以不早于为优先筛选条件)
|
||||
elseif (!empty($search['sign_after'])) {
|
||||
$start = strtotime($search['sign_after']);
|
||||
$where[] = ['>=','sign_date',$start];
|
||||
} elseif (!empty($search['sign_before'])) {
|
||||
$end = strtotime($search['sign_before']);
|
||||
$where[] = ['<=','sign_date',$end];
|
||||
}
|
||||
|
||||
//带序列号搜索(TBD:后期考虑改为精准唯一搜索)
|
||||
if(isset($search['sn']) && $search['sn'] != 'undefined' && $search['sn']){
|
||||
$where[] = ['LIKE','sn',$search['sn']];
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
$where[]=['=','deleted',$deleted];
|
||||
$where[]=['=','is_turnover',0]; //排除交车单
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where)->andwhere($orwhere);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'sign_date DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
|
||||
return ['res'=>$res,'data'=>$data];
|
||||
}
|
||||
|
||||
/*
|
||||
订单数据显示格式化
|
||||
*/
|
||||
private function showOrder($orderRes, $data)
|
||||
{
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
|
||||
$cids = $sids = $eids = $mids = [];
|
||||
if ($orderRes) {
|
||||
foreach ($orderRes 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();
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$model = new AcCarBrand();
|
||||
$brands = $model->find()->where(['in','id',$bids])->indexBy('id')->all();
|
||||
$model = new AcCarSeries();
|
||||
$series = $model->find()->where(['in','id',$sids])->indexBy('id')->all();
|
||||
|
||||
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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($car);
|
||||
|
||||
$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 ($orderRes as $s) {
|
||||
$car = [];
|
||||
if($s->car_id) $car = $cars[$s->car_id];
|
||||
$s = $s->toArray();
|
||||
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'] = $s['start_province'] ? Yii::$app->params['regionAreas'][$s['start_province']] : '';
|
||||
$s['to_province'] = $s['aim_province'] ? Yii::$app->params['regionAreas'][$s['aim_province']] : '';
|
||||
$s['car_number']= isset($car['number2']) ? $car['number2'] : '';
|
||||
$s['car_title'] = isset($car['title']) ? $car['title'] : '';
|
||||
$s['car_title'] = $s['car_title'] ? $s['car_title'] : (isset($car['title2']) ? $car['title2'] : '');
|
||||
$s['status'] = $status[$s['status_code']];
|
||||
$orders[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单查询成功!';
|
||||
$return['data']= [
|
||||
'total'=>$data->count(),
|
||||
'orders' => $orders,
|
||||
'employees'=>$employees,
|
||||
'stores'=>$stores,
|
||||
'users'=>$users,
|
||||
'page'=>$this->page
|
||||
];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
<?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\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
use addons\models\AcOrder;
|
||||
|
||||
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->user_id !== $order->from_mid) {
|
||||
// $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('操作完成!', $order->toArray(), 200);
|
||||
} else {
|
||||
$this->result('没有要更新的数据!', null, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
+418
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-24T20:28:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-07-13T14:23:16+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrderPre;
|
||||
use addons\models\AcStore;
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class OrderpreController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'搜索询单',
|
||||
'detail'=>'询单详情',
|
||||
'create'=>'创建询单'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统询价单管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$this->showOrder($res, $data);
|
||||
}
|
||||
|
||||
private function search()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcOrderPre();
|
||||
$where = $orwhere = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$where[] = ['=','from_uid',$this->user_id];
|
||||
$search['phone'] = $this->user_info->mobile;
|
||||
$where[] = ['=','from_mobile',$search['phone']];
|
||||
|
||||
if (isset($search['carno']) && !empty($search['carno'])) {
|
||||
$search['carno'] = trim($search['carno']);
|
||||
$where[] = ['LIKE','car_no',$search['carno']];
|
||||
}
|
||||
if (isset($search['phone']) && !empty($search['phone'])) {
|
||||
$search['phone'] = trim($search['phone']);
|
||||
$where[] = ['=','from_mobile',$search['phone']];
|
||||
}
|
||||
|
||||
if (isset($search['city']) && !empty($search['city'])) {
|
||||
$search['city'] = trim($search['city']);
|
||||
$where[] = ['LIKE','aim_city',$search['city']];
|
||||
}
|
||||
|
||||
$search['employee'] = isset($search['employee']) ? (int)$search['employee'] : '';
|
||||
$EmployeeModel = new AcEmployee();
|
||||
if (!empty($search['employee'])) {
|
||||
$where[] = ['=','employee_id',$search['employee']];
|
||||
$employee = $EmployeeModel->findOne($search['employee']);
|
||||
$search['employee_title'] = isset($employee->name) ? $employee->name : '';
|
||||
}
|
||||
$search['store_id'] = isset($search['store_id']) ? (int)$search['store_id'] : '';
|
||||
if (empty($search['sotre_id'])) {
|
||||
$search['store_id'] = isset($get['store_id']) ? (int)$get['store_id'] : 0;
|
||||
}
|
||||
$StoreModel = new AcStore();
|
||||
if (!empty($search['store_id'])) {
|
||||
$where[] = ['=','store_id',$search['store_id']];
|
||||
$store = $StoreModel->findOne($search['store_id']);
|
||||
$search['store_title'] = isset($store->title) ? $store->title : '';
|
||||
}
|
||||
|
||||
$search['start_province'] = isset($search['start_province']) ? trim($search['start_province']) : '';
|
||||
if (!empty($search['start_province'])) {
|
||||
$where[] = ['=','start_province',$search['start_province']];
|
||||
}
|
||||
$search['start_city'] = isset($search['start_city']) ? trim($search['start_city']) : '';
|
||||
if (!empty($search['start_city'])) {
|
||||
$where[] = ['LIKE','start_city',$search['start_city']];
|
||||
}
|
||||
$search['aim_province'] = isset($search['aim_province']) ? trim($search['aim_province']) : '';
|
||||
if (!empty($search['aim_province'])) {
|
||||
$where[] = ['=','aim_province',$search['aim_province']];
|
||||
}
|
||||
$search['aim_city'] = isset($search['aim_city']) ? trim($search['aim_city']) : '';
|
||||
if (!empty($search['aim_city'])) {
|
||||
$where[] = ['LIKE','aim_city',$search['aim_city']];
|
||||
}
|
||||
|
||||
$search['bind'] = isset($search['bind']) ? trim($search['bind']) : '';
|
||||
if (!empty($search['bind'])) {
|
||||
$where[] = ['LIKE','bind',$search['bind']];
|
||||
}
|
||||
if (isset($search['status_code']) && $search['status_code'] !='all') {
|
||||
$search['status_code'] = (int)$search['status_code'];
|
||||
$where[] = ['=','status_code',$search['status_code']];
|
||||
} else {
|
||||
unset($search['status_code']);
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
$where[]=['=','deleted',$deleted];
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where)->andwhere($orwhere);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'update_at DESC,id DESC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
return ['res'=>$res,'data'=>$data];
|
||||
}
|
||||
|
||||
private function showOrder($orderRes, $data)
|
||||
{
|
||||
$status = Yii::$app->params['OrderPreStatus'];
|
||||
|
||||
$cids = $sids = $eids = $mids = [];
|
||||
if ($orderRes) {
|
||||
foreach ($orderRes as $r) {
|
||||
$sids[$r->store_id] = $r->store_id;
|
||||
$eids[$r->employee_id] = $r->employee_id;
|
||||
}
|
||||
}
|
||||
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
|
||||
$model = new AcStore();
|
||||
$_stores = $model->find()->where(['in','id',$sids])->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach ($_employees as $s) {
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$orders = [];
|
||||
$unsets = ['pid','create_at','deleted','from_mid','car'];
|
||||
|
||||
foreach ($orderRes as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$s['price'] = !empty($s['price']) ? $s['price'] : '尚未报价';
|
||||
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $s['date']);
|
||||
$s['date_plan'] = date('Y-m-d ', $s['date']) . '星期'.$weekdays[$wk];
|
||||
|
||||
$s['from_province'] = isset($s['start_province']) ? Yii::$app->params['regionAreas'][$s['start_province']] : '';
|
||||
$s['to_province'] = isset($s['aim_province']) ? Yii::$app->params['regionAreas'][$s['aim_province']] : '';
|
||||
|
||||
$s['status'] = $status[$s['status_code']];
|
||||
$orders[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单查询成功!';
|
||||
$return['data']= [
|
||||
'total'=>$data->count(),
|
||||
'orders' => $orders,
|
||||
'employees'=>$employees,
|
||||
'stores'=>$stores,
|
||||
'page'=>$this->page
|
||||
];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
$order = $AcOrderPre->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
|
||||
if($detail['store_id']){
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
}
|
||||
|
||||
if($detail['employee_id']){
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($detail['employee_id']);
|
||||
if ($employee) {
|
||||
$detail['employee_title'] = $employee->name;
|
||||
}
|
||||
}
|
||||
|
||||
$sn = '00000000000'; //11位
|
||||
$sn = substr($sn, 0, 11-strlen($id));
|
||||
$sn .=$id;
|
||||
$detail['sn'] = $detail['sn'] ? $detail['sn'] : $sn;
|
||||
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $detail['date']);
|
||||
$detail['date_plan'] = date('Y-m-d 星期'.$weekdays[$wk], $detail['date']);
|
||||
$detail['remark'] = !empty($detail['remark']) ? htmlspecialchars_decode($detail['remark']) : '';
|
||||
$detail['car'] = !empty($detail['car']) ? htmlspecialchars_decode($detail['car']) : '';
|
||||
|
||||
$unsets = ['create_at','deleted','from_mid'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($detail[$us]);
|
||||
}
|
||||
$this->result('查询成功!', $detail, 200);
|
||||
}
|
||||
|
||||
public function actionCancel()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id<=0) {
|
||||
$this->result('未指定订单!');
|
||||
}
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
$order = $AcOrderPre->findOne($id);
|
||||
if($order->from_uid != $this->user_id){
|
||||
$this->result('非本人订单,不允许操作!');
|
||||
}
|
||||
if($order->status_code <= 0 || $order->status_code >= 99 ){
|
||||
$this->result('订单已取消或已经完成,不允许操作!');
|
||||
}
|
||||
$order->status_code = -1;
|
||||
$order->save();
|
||||
$this->result('已取消!', $order->toArray(), 200);
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
{
|
||||
/**
|
||||
* 创建咨询单
|
||||
* @mid [int] 平台租户身份
|
||||
* @uid [int] 前端用户身份
|
||||
*/
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$pid = $this->pid;
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
$data['from_uid'] = $this->user_id;
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city',
|
||||
'car_title'=>'car_title','car_no'=>'car_no','price'=>'price',
|
||||
'bind'=>'bind','receptionist'=>"receptionist",
|
||||
'from_name'=>'from_name','from_mobile'=>'from_mobile',
|
||||
];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['car_value'=>'car_value','from_gender'=>'from_gender'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = 0;
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = (int)$post[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['remark'=>'remark','car'=>'car'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = htmlspecialchars($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/*@date: 1649952000000*/
|
||||
$data['date'] = isset($post['plan_date']) ? $post['plan_date']/1000 : strtotime('+7 day');
|
||||
// 计划时间,默认7天后
|
||||
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 0 ;
|
||||
$data['from_mid'] = $mid;
|
||||
|
||||
$data['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
$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'] = isset($post['store_id']) ? (int)$post['store_id'] : 0;
|
||||
|
||||
//保存资料
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcOrderPre->$key = $val;
|
||||
}
|
||||
|
||||
$res = $AcOrderPre->save();
|
||||
$id = $AcOrderPre->attributes['id']; //获取插入后id
|
||||
|
||||
if ($res) {
|
||||
$this->result('询单保存成功!',['id'=>$id],200);
|
||||
} else {
|
||||
$this->result('询单保存失败!',[],100);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
订单数据显示格式化
|
||||
*/
|
||||
|
||||
public function actionEdit()
|
||||
{
|
||||
/**
|
||||
* 更新咨询单
|
||||
* @mid [int] 平台租户身份
|
||||
* @uid [int] 前端用户身份
|
||||
*/
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$id = isset($post['id']) ? (int)$post['id'] : 0;
|
||||
if(!$id){
|
||||
$this->result('未指定询价单!');
|
||||
}
|
||||
$model = new AcOrderPre();
|
||||
$detail = $model->findOne($id);
|
||||
if(!$detail){
|
||||
$this->result('询价单信息不存在!');
|
||||
}
|
||||
if($detail->pid != $this->pid){
|
||||
$this->result('非法操作!');
|
||||
}
|
||||
if($detail->from_uid != $this->user_id){
|
||||
$this->result('非法操作,请检查订单归属!');
|
||||
}
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city',
|
||||
'car_title'=>'car_title','car_no'=>'car_no',
|
||||
'from_name'=>'from_name','from_mobile'=>'from_mobile',
|
||||
];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$detail->$col = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['car_value'=>'car_value','from_gender'=>'from_gender'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$detail->$col = (int)$post[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['remark'=>'remark'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$detail->$col = htmlspecialchars($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$detail->date = isset($post['plan_date']) ? $post['plan_date']/1000 : $detail->date;
|
||||
|
||||
$detail->status_code = 1; //标记订单处于创建待审核状态
|
||||
$detail->update_at = time();
|
||||
|
||||
//保存资料
|
||||
$res = $detail->save();
|
||||
|
||||
if ($res) {
|
||||
$this->result('询单保存成功!',['id'=>$id],200);
|
||||
} else {
|
||||
$this->result('询单保存失败!',[],100);
|
||||
}
|
||||
}
|
||||
}
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+362
@@ -0,0 +1,362 @@
|
||||
<?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\client\v1;
|
||||
|
||||
use Yii;
|
||||
use vendor\aliyun\dysms\Sms;
|
||||
use common\models\CSms;
|
||||
use common\models\CVcode;
|
||||
use addons\models\AcPlat;
|
||||
|
||||
class SmsController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'vcode'=>'获取短信验证码'
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统短信管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionSend()
|
||||
{
|
||||
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', '');
|
||||
$this->result('群发完成,共成功发送'.$i.'条;详情:'.$msg);
|
||||
}
|
||||
|
||||
$results = [];
|
||||
$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."】发送成功";
|
||||
}
|
||||
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);
|
||||
$this->result('群发完成,共成功发送'.$i.'条;详情:'.$msg);
|
||||
}
|
||||
|
||||
//发送验证码
|
||||
public function actionVcode()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$plat = AcPlat::findOne($pid);
|
||||
$platExt = json_decode($plat->remark, true);
|
||||
|
||||
//数据取出方法
|
||||
$dataPost = $this->postdata; //YII应用内的真实或模拟POST数据
|
||||
$phone = $dataPost['phone'] ?? 0;
|
||||
//验证手机号
|
||||
$isPhone = false;
|
||||
if($phone){
|
||||
$isPhone = preg_match('/^1\d{10}$/', $phone) ? true : false;
|
||||
}
|
||||
if(!$isPhone){
|
||||
$this->result('手机号不正确,请确认');
|
||||
}
|
||||
// 手机号掩码
|
||||
$phoneMask = substr($phone, 0, 3) . str_repeat('*', strlen($phone) - 7) . substr($phone, -4);
|
||||
|
||||
$params = Yii::$app->params;
|
||||
$codetype = $dataPost['scence'] ?? 'vcode'; //验证码使用场景
|
||||
|
||||
$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);
|
||||
$_time = time();
|
||||
$vcodeModel = new CVcode();
|
||||
//查询上次发送记录
|
||||
$where=[];
|
||||
$where['mobile'] = $phone;
|
||||
$where['deleted'] = 0;
|
||||
$where['type'] = $codetype;
|
||||
$res = $vcodeModel->find()->where($where)->one();
|
||||
if ($res) {
|
||||
if (($_time-$res->create_at)<300) {
|
||||
//设置5分钟内,验证码仍然可用
|
||||
$code = $res->code;
|
||||
$msg = '上次发送的验证码仍然可用;请注意查看手机 '.$phoneMask;
|
||||
$data = ['errorcode'=>2];
|
||||
if(YII_DEBUG){
|
||||
$data['code'] = $code;
|
||||
}
|
||||
$this->result($msg, $data, 200);
|
||||
} else {
|
||||
$res->deleted = 1;
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
$content=[];
|
||||
$code = mt_rand(1000, 9999);
|
||||
$content['code'] = $code;
|
||||
|
||||
//验证码准备入库
|
||||
$vcode = [];
|
||||
$vcode['code'] = $code;
|
||||
$vcode['type'] = $codetype;
|
||||
$vcode['mobile'] = $phone;
|
||||
$vcode['create_at'] = $_time;
|
||||
foreach ($vcode as $key=>$val) {
|
||||
$vcodeModel->$key = $val;
|
||||
}
|
||||
$tmpls = $params['aliDySms']['tmpl'];
|
||||
switch ($codetype) {
|
||||
case 'reg':
|
||||
$tmpl = $tmpls['regVerify'];
|
||||
break;
|
||||
case 'login':
|
||||
$tmpl = $tmpls['loginVcode'];
|
||||
break;
|
||||
case 'info':
|
||||
$tmpl = $tmpls['infoChange'];
|
||||
break;
|
||||
case 'passwd':
|
||||
$tmpl = $tmpls['passwdChange'];
|
||||
break;
|
||||
case 'vcode':
|
||||
default:
|
||||
$tmpl = $tmpls['vcode'];
|
||||
break;
|
||||
}
|
||||
|
||||
// 发送前控制
|
||||
$host = yii::$app->request->hostName;
|
||||
$debug = $params['aliDySms']['debug'] ?? false;
|
||||
$domains = $params['aliDySms']['domains'] ?? [];
|
||||
$sendable = false;
|
||||
if(in_array($host,$domains) || $debug){
|
||||
$sendable = true;
|
||||
}
|
||||
$result = true;
|
||||
if($sendable){
|
||||
$result = $sms->send($phone, $tmpl, $content);
|
||||
}
|
||||
|
||||
//保存发送记录
|
||||
$smsModel = new CSms();
|
||||
$smsdata = [];
|
||||
$sid = $params['siteId'];
|
||||
$smsdata['sid'] = (int)$sid;
|
||||
$smsdata['pid'] = $pid;
|
||||
$smsdata['uid'] = 0;
|
||||
$smsdata['mid'] = $this->user_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();
|
||||
|
||||
$errorcode = 0;
|
||||
$msg = '';
|
||||
if (!$result) {
|
||||
$msg .= "发送失败,接口提示:".$sms->errors;
|
||||
$errorcode = 3;
|
||||
} elseif (is_array($result) && $result['Code'] !='OK') {
|
||||
$msg .= "发送失败,接口提示:".$result['Message'];
|
||||
$errorcode = 4;
|
||||
} else {
|
||||
$vcodeModel->save();
|
||||
$msg .= "发送成功";
|
||||
}
|
||||
$data = ['errorcode'=>$errorcode];
|
||||
if(!$debug || YII_DEBUG){
|
||||
$data['data'] = $content;
|
||||
}
|
||||
$this->result($msg, $data, 200);
|
||||
}
|
||||
|
||||
//发送给财务
|
||||
public function actionCaiwu()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$plat = AcPlat::findOne($pid);
|
||||
$platExt = json_decode($plat->remark, true);
|
||||
|
||||
$phone = $platExt['cw_phone'];
|
||||
if (!$phone) {
|
||||
$this->result('还没有配置财务手机号,请联系站长管理员进行设置!', ['errorcode'=>1], 200);
|
||||
}
|
||||
|
||||
$vcodeModel = new CVcode();
|
||||
$codetype = 'caiwu';
|
||||
//查询上次发送记录
|
||||
$_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) {
|
||||
//设置2小时内,验证码仍然可用
|
||||
$code = $res->code;
|
||||
$this->result('上次发送的验证码仍然可用;请注意查看财务手机!', ['errorcode'=>2], 200);
|
||||
} else {
|
||||
$res->deleted = 1;
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
//数据取出方法
|
||||
$dataPost = $this->postdata; //YII应用内的真实或模拟POST数据
|
||||
$params = Yii::$app->params;
|
||||
|
||||
$content = [];
|
||||
$code = mt_rand(1000, 9999);
|
||||
$content['code'] = $code;
|
||||
$tmpl = $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;
|
||||
}
|
||||
|
||||
$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);
|
||||
$result = $sms->send($phone, $tmpl, $content); //编排发送短信
|
||||
//保存发送记录
|
||||
$smsModel = new CSms();
|
||||
$smsdata = [];
|
||||
$sid = $params['siteId'];
|
||||
$smsdata['sid'] = (int)$sid;
|
||||
$smsdata['pid'] = $pid;
|
||||
$smsdata['uid'] = 0;
|
||||
$smsdata['mid'] = $this->user_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();
|
||||
|
||||
$errorcode = 0;
|
||||
$msg = '';
|
||||
if (!$result) {
|
||||
$msg .= "发送失败,接口提示:".$sms->errors;
|
||||
$errorcode = 3;
|
||||
} elseif (is_array($result) && $result['Code'] !='OK') {
|
||||
$msg .= "发送失败,接口提示:".$result['Message'];
|
||||
$errorcode = 4;
|
||||
} else {
|
||||
$vcodeModel->save();
|
||||
$msg .= "发送成功";
|
||||
}
|
||||
$this->result($msg, ['errorcode'=>$errorcode], 200);
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
<?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
|
||||
]);
|
||||
}
|
||||
}
|
||||
+422
@@ -0,0 +1,422 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
+561
@@ -0,0 +1,561 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+923
@@ -0,0 +1,923 @@
|
||||
<?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
|
||||
]);
|
||||
}
|
||||
}
|
||||
+378
@@ -0,0 +1,378 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
+379
@@ -0,0 +1,379 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-10T01:13:34+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-14T21:12:32+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 UploadController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'image'=>'上传图片(单传)',
|
||||
];
|
||||
$this->result('您正使用CMTS系统文件上传接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionImage()
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$model = new CAttachment();
|
||||
$file = UploadedFile::getInstanceByName('file');
|
||||
//{error: 0
|
||||
// name: "e8.png"
|
||||
// size: 5362
|
||||
// tempName: "/Applications/XAMPP/xamppfiles/temp/phpG8vgnV"
|
||||
// type: "image/png"}
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
$title = isset($file->name) ? $file->name : md5(TIMESTAMP.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
//POST数据处理
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
$model = new CAttachment();
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$this->result('上传成功', ['id'=>$id,'path'=>$model->route], 200);
|
||||
}
|
||||
|
||||
public function actionImages()
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$model = new CAttachment();
|
||||
$files = UploadedFile::getInstancesByName('files');
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
//POST数据处理
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
|
||||
$attachModel = new CAttachment();
|
||||
$ids = $paths = $datas = [];
|
||||
foreach ($files as $file) {
|
||||
$tkey = microtime();
|
||||
$title = isset($file->name) ? $file->name : md5($tkey.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
$model = clone $attachModel;
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$ids[$id] = $id;
|
||||
$paths[$id] = $model->route;
|
||||
}
|
||||
|
||||
$this->result('上传成功', ['ids'=>$ids,'paths'=>$paths], 200);
|
||||
}
|
||||
|
||||
public function save_image()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$model = new CAttachment();
|
||||
$files = UploadedFile::getInstanceByName('files');
|
||||
//{error: 0
|
||||
// name: "e8.png"
|
||||
// size: 5362
|
||||
// tempName: "/Applications/XAMPP/xamppfiles/temp/phpG8vgnV"
|
||||
// type: "image/png"}
|
||||
// 构建目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$siteId = $this->site_id;
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = $this->pid;
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
$title = isset($file->name) ? $file->name : md5(TIMESTAMP.rand(1, 99)).'.jpg'; //文件原名
|
||||
//取后缀名
|
||||
$_filetype = explode('/', $file->type);
|
||||
$suffix = strtolower($_filetype[1]);
|
||||
//重新命名以便转存
|
||||
$newName = date('dHis', TIMESTAMP).'_'.md5($title);
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
|
||||
$res = $file->saveAs($newFile, true);
|
||||
|
||||
//文件入库
|
||||
//POST数据处理
|
||||
$post = Yii::$app->request->post();
|
||||
$member_id = 0;
|
||||
if (isset($post['mid']) && (int)$post['mid']>0) {
|
||||
$member_id = (int)$post['mid'];
|
||||
}
|
||||
$options = '';
|
||||
if (isset($post['options'])) {
|
||||
$options = json_encode($options, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||
}
|
||||
$model = new CAttachment();
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $this->pid;
|
||||
$model->uid = $this->user_id;
|
||||
$model->mid = $member_id;
|
||||
$model->type = 0; //附件类型,0图片1视频2音频3表格4文档5PPT888证书999其他
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $file->size;
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$this->result('上传成功', ['id'=>$id,'path'=>$model->route], 200);
|
||||
}
|
||||
}
|
||||
|
||||
/*多图上传时的数据示例
|
||||
array(7) {
|
||||
[0]=>
|
||||
object(yii\web\UploadedFile)#60 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpJvR1FV"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[1]=>
|
||||
object(yii\web\UploadedFile)#62 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpzIuYVB"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[2]=>
|
||||
object(yii\web\UploadedFile)#63 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpUHXR4W"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[3]=>
|
||||
object(yii\web\UploadedFile)#64 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpEa5Q93"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[4]=>
|
||||
object(yii\web\UploadedFile)#65 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpEDfHIr"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[5]=>
|
||||
object(yii\web\UploadedFile)#66 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/phpiLqBVZ"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[6]=>
|
||||
object(yii\web\UploadedFile)#67 (6) {
|
||||
["name"]=>
|
||||
string(18) "file-1652511550195"
|
||||
["tempName"]=>
|
||||
string(45) "/Applications/XAMPP/xamppfiles/temp/php5rqzIk"
|
||||
["type"]=>
|
||||
string(9) "text/html"
|
||||
["size"]=>
|
||||
int(425)
|
||||
["error"]=>
|
||||
int(0)
|
||||
["_tempResource":"yii\web\UploadedFile":private]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:37:06+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-10-23T11:51:39+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcWeituoren;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
|
||||
class WeituorenController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
// $this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'搜索委托单位清单',
|
||||
'detail'=>'委托单位详情'
|
||||
];
|
||||
$this->result('您正使用CMTS系统委托单位管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcWeituoren();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : null;
|
||||
if (!$search) {
|
||||
$search = [];
|
||||
}
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','company',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->asArray()->where($where); //asArray() 放在find后,可让查询结果以数组形式呈现
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'orderby DESC,id ASC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
if (!$res) {
|
||||
$this->result('没有符合条件的结果');
|
||||
}
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '委托单位查询成功!';
|
||||
$return['data']= ['total'=>$data->count(),
|
||||
'data'=>[
|
||||
'weituoren' => $res
|
||||
],
|
||||
'page'=>$this->page];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcWeituoren();
|
||||
$weituo = $model->findOne($id);
|
||||
$detail = $weituo->toArray();
|
||||
|
||||
$this->result('查询成功!', $detail, 200);
|
||||
}
|
||||
}
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>恭喜,站点创建成功!</title>
|
||||
<style>
|
||||
.container {
|
||||
width: 60%;
|
||||
margin: 10% auto 0;
|
||||
background-color: #f0f0f0;
|
||||
padding: 2% 5%;
|
||||
border-radius: 10px
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
ul li {
|
||||
line-height: 2.3
|
||||
}
|
||||
|
||||
a {
|
||||
color: #20a53a
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>恭喜, 站点创建成功!</h1>
|
||||
<h3>这是默认index.html,本页面由系统自动生成</h3>
|
||||
<ul>
|
||||
<li>本页面在FTP根目录下的index.html</li>
|
||||
<li>您可以修改、删除或覆盖本页面</li>
|
||||
<li>FTP相关信息,请到“面板系统后台 > FTP” 查看</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
@Author: 嗨噜客(三亚) <fm453>
|
||||
@Date: 2024-07-06T09:30:10+08:00
|
||||
@Email: 393213759@qq.com
|
||||
@Last modified by: fm453
|
||||
@Last modified time: 2024-07-06T09:30:10+08:00
|
||||
@Copyright: www.hiluker.cn
|
||||
|
||||
轿车托运物流管理系统后台API
|
||||
Executable
+73539
File diff suppressed because it is too large
Load Diff
Executable
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__.'/../../');
|
||||
|
||||
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php');
|
||||
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
|
||||
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
|
||||
require_once(__DIR__ . '/../config/bootstrap.php');
|
||||
Executable
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
return [
|
||||
[
|
||||
'username' => 'erau',
|
||||
'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
|
||||
// password_0
|
||||
'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
|
||||
'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
|
||||
'created_at' => '1392559490',
|
||||
'updated_at' => '1392559490',
|
||||
'email' => 'sfriesen@jenkins.info',
|
||||
],
|
||||
];
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
_generated
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace backend\tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class FunctionalTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\FunctionalTesterActions;
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace backend\tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class UnitTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\UnitTesterActions;
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
class_name: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Yii2
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace backend\tests\functional;
|
||||
|
||||
use \backend\tests\FunctionalTester;
|
||||
use common\fixtures\User as UserFixture;
|
||||
|
||||
/**
|
||||
* Class LoginCest
|
||||
*/
|
||||
class LoginCest
|
||||
{
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
$I->haveFixtures([
|
||||
'user' => [
|
||||
'class' => UserFixture::className(),
|
||||
'dataFile' => codecept_data_dir() . 'login_data.php'
|
||||
]
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param FunctionalTester $I
|
||||
*/
|
||||
public function loginUser(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnPage('/site/login');
|
||||
$I->fillField('Username', 'erau');
|
||||
$I->fillField('Password', 'password_0');
|
||||
$I->click('login-button');
|
||||
|
||||
$I->see('Logout (erau)', 'form button[type=submit]');
|
||||
$I->dontSeeLink('Login');
|
||||
$I->dontSeeLink('Signup');
|
||||
}
|
||||
}
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Here you can initialize variables via \Codeception\Util\Fixtures class
|
||||
* to store data in global array and use it in Cests.
|
||||
*
|
||||
* ```php
|
||||
* // Here _bootstrap.php
|
||||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
|
||||
* ```
|
||||
*
|
||||
* In Cests
|
||||
*
|
||||
* ```php
|
||||
* \Codeception\Util\Fixtures::get('user1');
|
||||
* ```
|
||||
*/
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
class_name: UnitTester
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Here you can initialize variables via \Codeception\Util\Fixtures class
|
||||
* to store data in global array and use it in Tests.
|
||||
*
|
||||
* ```php
|
||||
* // Here _bootstrap.php
|
||||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
|
||||
* ```
|
||||
*
|
||||
* In Tests
|
||||
*
|
||||
* ```php
|
||||
* \Codeception\Util\Fixtures::get('user1');
|
||||
* ```
|
||||
*/
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
<div class="site-error">
|
||||
<div style="margin-top: 100px;text-align: center;">
|
||||
<h1>温馨提示</h1><br>
|
||||
</div>
|
||||
<h4 style="margin: 10px auto;text-align: center;background-color: #1ab394; color: #ffffff;width: 500px;height: 50px;line-height: 50px;border-radius: 5px;"><i class="fa fa-spinner fa-spin"></i> 功能尚未开放,敬请稍候……</h4>
|
||||
|
||||
</div>
|
||||
Executable
+202
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $content string */
|
||||
|
||||
use backend\assets\AppAsset;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
use yii\bootstrap\Nav;
|
||||
use yii\bootstrap\NavBar;
|
||||
use yii\widgets\Breadcrumbs;
|
||||
use common\widgets\Alert;
|
||||
|
||||
// AppAsset::register($this);
|
||||
$keywords = '';
|
||||
$description = '';
|
||||
$routes = ['data']; //自添加的controllers列表集,用于为新添加的控制器在渲染视图时自动加入HTML代码段,以便兼容h+的后台模板
|
||||
?>
|
||||
<?php $this->beginPage() ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= Yii::$app->language ?>">
|
||||
<head>
|
||||
<meta charset="<?= Yii::$app->charset ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<?= Html::csrfMetaTags() ?>
|
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="Cache-Control" content="no-siteapp" />
|
||||
<meta name="keywords" content="<?php echo $keywords ?>">
|
||||
<meta name="description" content="<?php echo $description ?>">
|
||||
<!--[if lt IE 9]>
|
||||
<meta http-equiv="refresh" content="0;ie.html" />
|
||||
<![endif]-->
|
||||
<link rel="shortcut icon" href="<?=Url::to('@web/favicon.ico');?>">
|
||||
|
||||
<?=Html::cssFile('@web/css/bootstrap.min.css')?>
|
||||
<?=Html::cssFile('@web/css/font-awesome.css')?>
|
||||
<?=Html::cssFile('@web/css/animate.min.css')?>
|
||||
<?=Html::cssFile('@web/css/site.css')?>
|
||||
<?=Html::cssFile('@web/css/style.min.css')?>
|
||||
|
||||
<?=Html::jsFile('@web/js/jquery.min.js?v=2.1.4')?>
|
||||
<?=Html::jsFile('@web/js/bootstrap.min.js?v=3.3.6')?>
|
||||
|
||||
<?=Html::jsFile('@web/js/plugins/layer/layer.js')?>
|
||||
<?=Html::jsFile('@web/js/admin.js')?>
|
||||
|
||||
<?=Html::cssFile('@web/css/plugins/iCheck/custom.css')?>
|
||||
<?=Html::cssFile('@web/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css')?>
|
||||
<?php $this->head() ?>
|
||||
</head>
|
||||
<body class="fixed-sidebar full-height-layout gray-bg animated">
|
||||
<?php $this->beginBody() ?>
|
||||
<?php if((Yii::$app->controller->module->defaultRoute!="site") ||(Yii::$app->controller->module->defaultRoute=="site" && Yii::$app->controller->module->requestedRoute!=""
|
||||
&& Yii::$app->controller->module->requestedRoute!="site/login")):?>
|
||||
<nav class="breadcrumb fix_top hidden-sm hidden-xs" id="_HiQuickMenu" style="background-color:#ccc;width: 55px;padding-top: 15px;padding-left: 10px;position:fixed;top:40%;right:15px;z-index:9999;">
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-primary radius goback" style="line-height:1.6em;margin-top:3px" href="javascript:history.go(-1);" title="后退">
|
||||
<span class="fa fa-reply"></span>
|
||||
</a>
|
||||
<br>
|
||||
<a class="btn btn-primary radius refresh" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新">
|
||||
<span class="fa fa-refresh"></span>
|
||||
</a>
|
||||
<br>
|
||||
<a class="btn btn-warning radius" style="line-height:1.6em;margin-top:3px" href="<?php echo url::toRoute(['error/report','url'=>urlDecode(Url::current())]);?>" title="报错反馈">
|
||||
<span class="fa fa-at"></span>
|
||||
</a>
|
||||
<br>
|
||||
<button class="btn btn-danger radius lockscreen" style="line-height:1.6em;margin-top:3px" title="锁屏">
|
||||
<span class="fa fa-expeditedssl"></span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
<?php endif;?>
|
||||
<?php if(in_array(Yii::$app->controller->module->id,$routes)): ?>
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
<?php endif;?>
|
||||
<?= Alert::widget() ?>
|
||||
<?= $content ?>
|
||||
<?php if(in_array(Yii::$app->controller->module->id,$routes)): ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
|
||||
<?php $this->endBody() ?>
|
||||
<style>
|
||||
.modal-backdrop.in {
|
||||
opacity: .7;
|
||||
}
|
||||
</style>
|
||||
<div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true" data-keyboard='false' data-backdrop="static" style="z-index:9999;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content animated bounceInRight">
|
||||
<div class="modal-header">
|
||||
<i class="fa fa-laptop modal-icon"></i>
|
||||
<h4 class="modal-title">屏幕解锁</h4>
|
||||
<small class="font-bold"><?php echo date('Y-m-d H:i:s');?></small>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p id="_LockScreenTips"></p>
|
||||
<form class="form-horizontal m-t" id="commentForm" novalidate="novalidate">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">口令:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="_ScreenLockCode" name="code" type="password" class="form-control" required="" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4 col-sm-offset-3">
|
||||
<button type="button" class="btn btn-white unlockscreen">验证</button>
|
||||
<button type="reset" class="btn btn-warning">再等等</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer" style="text-align: center;">
|
||||
<button type="button" class="hidden btn btn-primary closelockscreen" data-dismiss="modal">现在点我,立即解锁</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
//锁屏
|
||||
$(function(){
|
||||
var modalId = 'myModal';
|
||||
sessionStorage.unLockScreen =true;
|
||||
$('.lockscreen').bind('click',function(){
|
||||
layer.confirm('您确认要锁屏吗?', {
|
||||
btn: ['确认','算了'], //按钮
|
||||
shade: true //是否显示遮罩
|
||||
}, function(index){
|
||||
layer.close(index);
|
||||
layer.prompt(
|
||||
{
|
||||
title: '输入解锁屏幕时要用的口令(仅数字与字母)后按确认,即可锁屏',
|
||||
formType: 0 //prompt风格,支持0-2
|
||||
},
|
||||
function(value,index,elem){
|
||||
layer.close(index);
|
||||
var code1 = value;
|
||||
sessionStorage.unLockScreen =false;
|
||||
sessionStorage.LockScreenCode = code1;
|
||||
var msg = '锁屏完成,您的口令是:'+ code1 + ' ;如果您不小心忘记锁屏密码,请重新登陆;如果您有可能未保存的页面数据,可通过浏览器的网页开发调试工具,清除会话缓存中的锁屏键;如果您不会操作,可联系微信客服<?php echo Yii::$app->params["developerWx"];?>获取付费协助';
|
||||
var msg2 = '锁屏完成;如果您不小心忘记锁屏密码,请重新登陆;如果您有可能未保存的页面数据,可通过浏览器的网页开发调试工具,清除会话缓存中的锁屏键;如果您不会操作,可联系微信客服<?php echo Yii::$app->params["developerWx"];?>获取付费协助';
|
||||
$('#_LockScreenTips').html(msg2);
|
||||
$('#'+modalId).modal('show');
|
||||
}
|
||||
);
|
||||
}, function(){
|
||||
layer.msg('您取消了锁屏操作', {shift: 6});
|
||||
});
|
||||
|
||||
$('#'+modalId).on('hide.bs.modal',
|
||||
function() {
|
||||
$('.closelockscreen').addClass('hidden').hide();
|
||||
layer.msg('好的,您已成功解锁');
|
||||
});
|
||||
});
|
||||
|
||||
$('.unlockscreen').bind('click',function(){
|
||||
var code = $('#_ScreenLockCode').val();
|
||||
var LockScreenCode = sessionStorage.LockScreenCode;
|
||||
if(code == LockScreenCode){
|
||||
sessionStorage.unLockScreen =true;
|
||||
$('.closelockscreen').removeClass('hidden').show();
|
||||
}else{
|
||||
layer.msg('口令错误,请重新输入');
|
||||
}
|
||||
});
|
||||
|
||||
if(!sessionStorage.unLockScreen){
|
||||
if(sessionStorage.LockScreenCode){
|
||||
$('#'+modalId).modal('show');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<script>
|
||||
var HOME_URL = '<?php echo Url::home();?>'; //定义首页位置,用于content.min.js中快速跳转首页按钮
|
||||
</script>
|
||||
<!-- 以下js必须放在页尾,顺序不可更换 -->
|
||||
<?=Html::jsFile('@web/js/bootstrap.min.js?v=3.3.6')?>
|
||||
<?=Html::jsFile('@web/js/plugins/layer/layer.js')?>
|
||||
<?=Html::jsFile('@web/js/content.min.js')?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php $this->endPage() ?>
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
$this->title = isset($title) ? $title : '提示';
|
||||
$content = isset($content) ? $content : '';
|
||||
$class = isset($class) ? $class : 'info';
|
||||
$class = in_array($class,['danger','warning','success','info']) ? $class : 'info';
|
||||
$buttons = isset($buttons) ? $buttons : [['title'=>'好的,我知道了','class'=>'primary','url'=>false]];
|
||||
|
||||
?>
|
||||
<div class="site-index" style="text-align: center;width:80%;margin-left:10%;">
|
||||
<div style="margin-top: 100px;">
|
||||
<h1><?=Html::encode($this->title) ?></h1><br>
|
||||
</div>
|
||||
<div class="alert alert-<?php echo $class;?> fade in" role="alert">
|
||||
<?php echo $content; ?>
|
||||
</div>
|
||||
<?php foreach($buttons as $btn){?>
|
||||
<a <?php if($btn['url']){?> href="<?php echo $btn['url'];?>" <?php }?> class="btn btn-<?php if($btn['class']){echo $btn['class'];}else{echo 'primary';}?>"><?php if($btn['title']){echo $btn['title'];}else{echo '点击按钮';}?></a>
|
||||
<?php }?>
|
||||
</div>
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
Options +FollowSymLinks
|
||||
IndexIgnore /
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . index.php
|
||||
@@ -0,0 +1 @@
|
||||
MTWO07hqoQjRePhb5wX98mGDKL5YfstR
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user