优化ctms-api语法、修复已知BUG;
主要修复ctms-api、dacms对PHP新版本的支持问题
This commit is contained in:
@@ -1,415 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:27:54+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:27:54+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcAlbums;
|
||||
use addons\models\AcAlbumPics;
|
||||
use addons\models\AcAlbumVersion;
|
||||
|
||||
class AlbumsController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
//相册列表
|
||||
public function actionList()
|
||||
{
|
||||
return $this->render('../layouts/dev');
|
||||
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$session = Yii::$app->session;
|
||||
$model = new AcAlbums();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$post = Yii::$app->request->post();
|
||||
$get = Yii::$app->request->get();
|
||||
|
||||
$searchSession = 'acalbums::search';
|
||||
if (isset($post['search'])) {
|
||||
$search = $post['search'];
|
||||
$session->set($searchSession, $search);
|
||||
} elseif ($session->get($searchSession)) {
|
||||
$search = $session->get($searchSession);
|
||||
}
|
||||
|
||||
$search['car_id'] = isset($search['car_id']) ? (int)$search['car_id'] : '';
|
||||
$CarModel = new AcCar();
|
||||
if (empty($search['car_id'])) {
|
||||
$search['car_id'] = isset($get['car_id']) ? (int)$get['car_id'] : 0;
|
||||
}
|
||||
if (!empty($search['car_id'])) {
|
||||
$where[] = ['=','car_id',$search['car_id']];
|
||||
$car = $CarModel->findOne($search['car_id']);
|
||||
$search['car_title'] = isset($car->title) ? $car->title : '';
|
||||
}
|
||||
|
||||
$search['phone'] = isset($search['phone']) ? trim($search['phone']) : '';
|
||||
if (!empty($search['phone'])) {
|
||||
$where[] = ['or',['LIKE','phone1_1',$search['phone']],['LIKE','phone1_2',$search['phone']],['LIKE','phone2_1',$search['phone']],['LIKE','phone2_2',$search['phone']]];
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
if (isset($_GET['deleted'])) {
|
||||
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
|
||||
}
|
||||
$where[]=['=','deleted',$deleted];
|
||||
|
||||
$data = $model->find()->where($where);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
|
||||
$status = Yii::$app->params['AlbumStatus'];
|
||||
|
||||
$orders = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
$orders[$s['id']] = $s;
|
||||
}
|
||||
|
||||
return $this->render('list', [
|
||||
'orders' => $orders,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
//验新车
|
||||
public function actionNewcar()
|
||||
{
|
||||
return $this->render('../layouts/dev');
|
||||
$status = Yii::$app->params['AlbumStatus'];
|
||||
$AcAlbum = new AcAlbums();
|
||||
$AcAlbum->status_code = 0;
|
||||
$detail = $AcAlbum->toArray();
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$detail]);
|
||||
}
|
||||
|
||||
/*编辑相册*/
|
||||
public function actionEdit()
|
||||
{
|
||||
return $this->render('../layouts/dev');
|
||||
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = Yii::$app->request->post();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
$detail['thumbs'] = json_decode($detail['thumbs']);
|
||||
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($detail['employee_id']);
|
||||
if ($employee) {
|
||||
$detail['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
|
||||
$model = new AcCar();
|
||||
$car = $model->findOne($detail['car_id']);
|
||||
if ($car) {
|
||||
$detail['car_owner_id'] = $car->owner_id;
|
||||
$detail['car_brand_id'] = $car->brand_id;
|
||||
$detail['car_series_id'] = $car->series_id;
|
||||
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
|
||||
$detail['car_number'] = $detail['car_number'] ? $detail['car_number'] : $car->num_frame;
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$user = $model->findOne($detail['from_mid']);
|
||||
|
||||
$model = new AcUserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach ($_exts as $ext) {
|
||||
$ext = $ext->toArray();
|
||||
if (isset($users[$s['id']])) {
|
||||
if ($ext['mobile']==$user->mobile) {
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
|
||||
if ($owner) {
|
||||
$_owner = User::findOne($detail['car_owner_id']);
|
||||
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
|
||||
if ($brand) {
|
||||
$detail['car_title'] = $brand->title;
|
||||
}
|
||||
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$where = [];
|
||||
$series= $AcCarSeries->findOne($detail['car_series_id']);
|
||||
if ($series) {
|
||||
$detail['car_title'] .= $series->title;
|
||||
}
|
||||
|
||||
$op = Yii::$app->request->get('op');
|
||||
$tpl = 'modify';
|
||||
if ($op=='print') {
|
||||
$tpl = 'print';
|
||||
$sn = '00000000000'; //11位
|
||||
$sn = substr($sn, 0, 11-strlen($id));
|
||||
$sn .=$id;
|
||||
$detail['sn'] = $sn;
|
||||
}
|
||||
return $this->render(
|
||||
$tpl,
|
||||
[
|
||||
'status'=>$status,
|
||||
'detail'=>$detail,
|
||||
'store'=>$store,
|
||||
'employee'=>$employee,
|
||||
'id'=>$id
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/*相册详情*/
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = Yii::$app->request->post();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
$detail['thumbs'] = json_decode($detail['thumbs']);
|
||||
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($detail['employee_id']);
|
||||
if ($employee) {
|
||||
$detail['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
|
||||
$model = new AcCar();
|
||||
$car = $model->findOne($detail['car_id']);
|
||||
if ($car) {
|
||||
$detail['car_owner_id'] = $car->owner_id;
|
||||
$detail['car_brand_id'] = $car->brand_id;
|
||||
$detail['car_series_id'] = $car->series_id;
|
||||
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
|
||||
$detail['car_number'] = $detail['car_number'] ? $detail['car_number'] : $car->num_frame;
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$user = $model->findOne($detail['from_mid']);
|
||||
|
||||
$model = new AcUserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach ($_exts as $ext) {
|
||||
$ext = $ext->toArray();
|
||||
if (isset($users[$s['id']])) {
|
||||
if ($ext['mobile']==$user->mobile) {
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
|
||||
if ($owner) {
|
||||
$_owner = User::findOne($detail['car_owner_id']);
|
||||
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
|
||||
if ($brand) {
|
||||
$detail['car_title'] = $brand->title;
|
||||
}
|
||||
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$where = [];
|
||||
$series= $AcCarSeries->findOne($detail['car_series_id']);
|
||||
if ($series) {
|
||||
$detail['car_title'] .= $series->title;
|
||||
}
|
||||
|
||||
$sn = '00000000000'; //11位
|
||||
$sn = substr($sn, 0, 11-strlen($id));
|
||||
$sn .=$id;
|
||||
$detail['sn'] = $sn;
|
||||
return $this->render(
|
||||
'detail',
|
||||
[
|
||||
'status'=>$status,
|
||||
'detail'=>$detail,
|
||||
'store'=>$store,
|
||||
'employee'=>$employee,
|
||||
'id'=>$id
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
//站点验车
|
||||
public function actionOrder()
|
||||
{
|
||||
return $this->render('../layouts/dev');
|
||||
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
$AcOrder = new AcOrder();
|
||||
if ($id) {
|
||||
$order = $AcOrder->findOne($id);
|
||||
if ($order->create_by != Yii::$app->user->identity->id) {
|
||||
//不允许修改非本人操作的表单
|
||||
$return['msg'] = '您不是该运单的制单人,不允许进行修改!';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
//格式化数据 为空的项则不修改
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city','signer'=>'signer','sender_name'=>'sender_name','sender_idcard'=>'sender_idcard','sender_mobiles'=>'sender_mobiles','receiver_name'=>'receiver_name','receiver_idcard'=>'receiver_idcard','receiver_mobiles'=>'receiver_mobiles','aim_address'=>'aim_address','thumb_f'=>'thumb_f','thumb_b'=>'thumb_b','thumb_l'=>'thumb_l','thumb_r'=>'thumb_r','car_extra'=>'car_extra','bind'=>'bind','driving_lisence'=>'driving_lisence'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = trim($post[$key]);
|
||||
}
|
||||
// $data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
|
||||
$cols = ['car_id'=>'car_id','employee_id'=>'employee_id','car_value'=>'car_value','fee_insurance'=>'fee_insurance','fee_truck'=>'fee_truck','fee_deliver'=>'fee_deliver','fee_pickup'=>'fee_pickup','fee_urgent'=>'fee_urgent','fee_extra'=>'fee_extra','fee_total'=>'fee_total','pay_send'=>'pay_send','pay_receive'=>'pay_receive','is_checked'=>'is_checked','no_driving_lisence'=>'no_driving_lisence','start_km'=>'start_km','not_insurance'=>'not_insurance'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = (int)$post[$key];
|
||||
}
|
||||
// $data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
//图片组处理
|
||||
$cols = ['thumbs'=>'thumbs'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && !empty($post[$key])) {
|
||||
$imgs = $post[$key]; //数组格式
|
||||
$imgs = array_unique($imgs);
|
||||
$imgs = json_encode($imgs);
|
||||
$data[$col] = $imgs;
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = htmlspecialchars($post[$key]);
|
||||
}
|
||||
// $data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
|
||||
}
|
||||
|
||||
$sign_date = isset($post['sign_date']) ? strtotime($post['sign_date']) : '';
|
||||
if (!$id) {
|
||||
$data['create_by'] = Yii::$app->user->identity->id;
|
||||
$data['sign_date'] = $sign_date ? $sign_date : time();
|
||||
}
|
||||
//部分规则校验
|
||||
$has_err = false;
|
||||
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
|
||||
if (!$id) {
|
||||
$data['status_code'] = 1;
|
||||
}
|
||||
/*不投保的,保额不超过20W,保费为0*/
|
||||
if ($data['not_insurance']) {
|
||||
if ($data['fee_insurance']) {
|
||||
$data['fee_insurance']=0;
|
||||
\Yii::$app->getSession()->setFlash('warning', '勾选了不投保,已强制修改保费为0!');
|
||||
}
|
||||
if ($data['car_value']>Yii::$app->params['DefaultCarInsuranceValueMax']) {
|
||||
$has_err = true;
|
||||
$data['car_value'] = Yii::$app->params['DefaultCarInsuranceValueMax'];
|
||||
\Yii::$app->getSession()->setFlash('danger', '勾选了不投保,默认最高赠送的运输险保额不超过'.Yii::$app->params['DefaultCarInsuranceValueMax'].'万元,已自动强制校正');
|
||||
}
|
||||
}
|
||||
$fee_total = $data['fee_truck']+$data['fee_insurance']+$data['fee_deliver']+$data['fee_pickup']+$data['fee_urgent']+$data['fee_extra'];
|
||||
$fee_pay = $data['pay_send']+$data['pay_receive'];
|
||||
if (!$data['fee_truck']) {
|
||||
$has_err = true;
|
||||
\Yii::$app->getSession()->setFlash('danger', '请注意,运费未正确填写!');
|
||||
}
|
||||
if (!$data['pay_send']&&!$data['pay_receive']) {
|
||||
$has_err = true;
|
||||
\Yii::$app->getSession()->setFlash('danger', '请注意,到收运费及起运地预收运费均未填写!');
|
||||
}
|
||||
if ($fee_total !=$data['fee_total']) {
|
||||
$has_err = true;
|
||||
\Yii::$app->getSession()->setFlash('danger', '请注意,所填运费、保费、提车费、送车费、额外费用、加急费等各项费用汇总的值与所填写的总费用不一致,请检查并更新');
|
||||
}
|
||||
if ($fee_pay !=$data['fee_total']) {
|
||||
$has_err = true;
|
||||
\Yii::$app->getSession()->setFlash('danger', '请注意,所填起运地预付运费、到收运费的汇总值与所填写的总费用不一致,请检查并更新');
|
||||
}
|
||||
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($data['employee_id']);
|
||||
if ($employee) {
|
||||
$data['store_id'] = $employee->store_id;
|
||||
}
|
||||
|
||||
//保存资料
|
||||
if ($id) {
|
||||
unset($data['create_at']);
|
||||
$res = $AcOrder->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcOrder->$key = $val;
|
||||
}
|
||||
$res = $AcOrder->save();
|
||||
$id = $AcOrder->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
if ($has_err) {
|
||||
\Yii::$app->getSession()->setFlash('success', '订单保存成功,但有价格数据录入错误,请根据情况检查更新!');
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('success', '订单保存成功!');
|
||||
}
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '订单保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,604 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:29:34+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:29:34+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarOwner;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
|
||||
class CarController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
//车辆列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$session = Yii::$app->session;
|
||||
$AcCar = new AcCar();
|
||||
$where = $where2 = [];
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$searchSession = 'cars::search';
|
||||
if (isset($_GET['reset']) && $_GET['reset']==1) {
|
||||
$post['search'] = [];
|
||||
}
|
||||
if (isset($post['search'])) {
|
||||
$search = $post['search'];
|
||||
$session->set($searchSession, $search);
|
||||
// }elseif($session->get($searchSession)){
|
||||
// $search = $session->get($searchSession);
|
||||
}
|
||||
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = 'or';
|
||||
$where2[] = ['LIKE','num_left',$search['title']];
|
||||
$where2[] = ['LIKE','num_frame',$search['title']];
|
||||
}
|
||||
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
|
||||
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
|
||||
if (!empty($search['brand_id'])) {
|
||||
$where['brand_id'] = $search['brand_id'];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $AcCar->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
|
||||
|
||||
$oids = $mids = $bids = $sids = [];
|
||||
if ($res) {
|
||||
foreach ($res as $r) {
|
||||
$oids[] = $r->owner_id;
|
||||
$mids[] = $r->mid;
|
||||
$bids[] = $r->brand_id;
|
||||
$sids[] = $r->series_id;
|
||||
}
|
||||
}
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$where = [];
|
||||
$where['pid'] = $pid;
|
||||
$_owners = $AcCarOwner->find()->where($where)->andwhere(['in','id',$oids])->all();
|
||||
$owners = [];
|
||||
foreach ($_owners as $s) {
|
||||
$owners[$s->id] = $s->toArray();
|
||||
}
|
||||
$User = new User();
|
||||
$where = [];
|
||||
$_users = $User->find()->where($where)->andwhere(['in','id',$mids])->all();
|
||||
$users = [];
|
||||
foreach ($_users as $s) {
|
||||
$users[$s->id] = $s->toArray();
|
||||
}
|
||||
$AcUserExt = new AcUserExt();
|
||||
$userExts = $AcUserExt->find()->where(['pid' => $pid,'deleted'=>0])->andWhere(['in','mid',$mids])->all();
|
||||
$exts = [];
|
||||
if ($userExts) {
|
||||
foreach ($userExts as $v) {
|
||||
$exts[$v->mid][$v->key] = $v->value;
|
||||
}
|
||||
if ($exts) {
|
||||
foreach ($exts as $i=>$ext) {
|
||||
$_owner = $users[$i] ? $users[$i] : [];
|
||||
if ($ext['title']) {
|
||||
$_owner['owner_title'] = $ext['title'];
|
||||
}
|
||||
if ($ext['nickname']) {
|
||||
$_owner['owner_title'] = $ext['nickname'];
|
||||
}
|
||||
if ($ext['realname']) {
|
||||
$_owner['owner_title'] = $ext['realname'];
|
||||
}
|
||||
$users[$i]['username'] = $_owner['owner_title'].'【'.$users[$s->id]['mobile'].'】';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$where = [];
|
||||
$series = [];
|
||||
$_series = $AcCarSeries->find()->where($where)->andwhere(['in','id',$sids])->all();
|
||||
if ($_series) {
|
||||
foreach ($_series as $r) {
|
||||
$series[$r->id] = $r->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$where = [];
|
||||
$_brands = $AcCarBrand->find()->where($where)->andwhere(['in','id',$bids])->all();
|
||||
if ($_brands) {
|
||||
foreach ($_brands as $r) {
|
||||
$brands[$r->id] = $r->toArray();
|
||||
}
|
||||
}
|
||||
$cars = [];
|
||||
if ($res) {
|
||||
foreach ($res as $r) {
|
||||
$car = $r->toArray();
|
||||
$t = '';
|
||||
if (isset($series[$r->series_id]['title'])) {
|
||||
$t .= $brands[$r->brand_id]['title'];
|
||||
}
|
||||
$t .= '-';
|
||||
if (isset($series[$r->series_id]['title'])) {
|
||||
$t .= $series[$r->series_id]['title'];
|
||||
}
|
||||
$car['title2'] = $t;
|
||||
$car['numbers'] = $car['num_p'].$car['num_area'].$car['num_left'];
|
||||
$car['numbers'] = $car['numbers'] ? $car['numbers'] : $car['num_frame'];
|
||||
$cars[$r->id] = $car;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('list', [
|
||||
'cars'=>$cars,
|
||||
'pager' => $pages,
|
||||
'owners'=>$owners,
|
||||
'users'=>$users,
|
||||
'status'=>$status,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$session = Yii::$app->session;
|
||||
$AcCar = new AcCar();
|
||||
$where = $where2 = [];
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$searchSession = 'cars::search';
|
||||
if (isset($_GET['reset']) && $_GET['reset']==1) {
|
||||
$post['search'] = [];
|
||||
}
|
||||
if (isset($post['search'])) {
|
||||
$search = $post['search'];
|
||||
$session->set($searchSession, $search);
|
||||
// }elseif($session->get($searchSession)){
|
||||
// $search = $session->get($searchSession);
|
||||
}
|
||||
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = 'or';
|
||||
$where2[] = ['LIKE','num_left',$search['title']];
|
||||
$where2[] = ['LIKE','num_frame',$search['title']];
|
||||
}
|
||||
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
|
||||
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
|
||||
if (!empty($search['brand_id'])) {
|
||||
$where['brand_id'] = $search['brand_id'];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $AcCar->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andWhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby(' id DESC')->all();
|
||||
|
||||
$oids = $mids = $bids = $sids = [];
|
||||
if ($res) {
|
||||
foreach ($res as $r) {
|
||||
$oids[] = $r->owner_id;
|
||||
$mids[] = $r->mid;
|
||||
$bids[] = $r->brand_id;
|
||||
$sids[] = $r->series_id;
|
||||
}
|
||||
}
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$where = [];
|
||||
$where['pid'] = $pid;
|
||||
$_owners = $AcCarOwner->find()->where($where)->andwhere(['in','id',$oids])->all();
|
||||
$owners = [];
|
||||
foreach ($_owners as $s) {
|
||||
$owners[$s->id] = $s->toArray();
|
||||
}
|
||||
$User = new User();
|
||||
$where = [];
|
||||
$_users = $User->find()->where($where)->andwhere(['in','id',$mids])->all();
|
||||
$users = [];
|
||||
foreach ($_users as $s) {
|
||||
$users[$s->id] = $s->toArray();
|
||||
}
|
||||
$AcUserExt = new AcUserExt();
|
||||
$userExts = $AcUserExt->find()->where(['pid' => $pid,'deleted'=>0])->andWhere(['in','mid',$mids])->all();
|
||||
$exts = [];
|
||||
if ($userExts) {
|
||||
foreach ($userExts as $v) {
|
||||
$exts[$v->mid][$v->key] = $v->value;
|
||||
}
|
||||
foreach ($exts as $i=>$ext) {
|
||||
$_owner = $users[$i] ? $users[$i] : [];
|
||||
if ($ext['title']) {
|
||||
$_owner['owner_title'] = $ext['title'];
|
||||
}
|
||||
if ($ext['nickname']) {
|
||||
$_owner['owner_title'] = $ext['nickname'];
|
||||
}
|
||||
if ($ext['realname']) {
|
||||
$_owner['owner_title'] = $ext['realname'];
|
||||
}
|
||||
$users[$i]['username'] = $_owner['owner_title'].'【'.$users[$i]['mobile'].'】';
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$where = [];
|
||||
$series = [];
|
||||
$_series = $AcCarSeries->find()->where($where)->andwhere(['in','id',$sids])->all();
|
||||
if ($_series) {
|
||||
foreach ($_series as $r) {
|
||||
$series[$r->id] = $r->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$where = [];
|
||||
$_brands = $AcCarBrand->find()->where($where)->andwhere(['in','id',$bids])->all();
|
||||
if ($_brands) {
|
||||
foreach ($_brands as $r) {
|
||||
$brands[$r->id] = $r->toArray();
|
||||
}
|
||||
}
|
||||
$cars = [];
|
||||
if ($res) {
|
||||
foreach ($res as $r) {
|
||||
$car = $r->toArray();
|
||||
$t = '';
|
||||
if (isset($series[$r->series_id]['title'])) {
|
||||
$t .= $brands[$r->brand_id]['title'];
|
||||
}
|
||||
$t .= '-';
|
||||
if (isset($series[$r->series_id]['title'])) {
|
||||
$t .= $series[$r->series_id]['title'];
|
||||
}
|
||||
$car['title2'] = $t;
|
||||
$car['numbers'] = $car['num_p'].$car['num_area'].$car['num_left'];
|
||||
$car['numbers'] = $car['numbers'] ? $car['numbers'] : $car['num_frame'];
|
||||
$cars[$r->id] = $car;
|
||||
}
|
||||
}
|
||||
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truck';
|
||||
return $this->render('select', [
|
||||
'cars'=>$cars,
|
||||
'pager' => $pages,
|
||||
'owners'=>$owners,
|
||||
'users'=>$users,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$AcCar = new AcCar();
|
||||
$AcCar->status_code = 0;
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$AcCar]);
|
||||
}
|
||||
|
||||
//编辑客车资料
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new AcCar();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$owner = $AcCarOwner->find()->where(['id' => $res['owner_id']])->one();
|
||||
if ($owner) {
|
||||
$mid = $owner->mid;
|
||||
$User = new User();
|
||||
$user = $User->find()->where(['id' => $mid])->one();
|
||||
if ($user) {
|
||||
$res['owner_title'] = $user->username.'【'.$user->mobile.'】';
|
||||
}
|
||||
$AcUserExt = new AcUserExt();
|
||||
$userExt = $AcUserExt->find()->where(['pid' => $pid,'mid' => $res['mid'],'deleted'=>0])->all();
|
||||
$exts = [];
|
||||
if ($userExt) {
|
||||
foreach ($userExt as $v) {
|
||||
$exts[$v->key] = $v->value;
|
||||
}
|
||||
if ($exts['title']) {
|
||||
$res['owner_title'] = $exts['title'];
|
||||
}
|
||||
if ($exts['nickname']) {
|
||||
$res['owner_title'] = $exts['nickname'];
|
||||
}
|
||||
if ($exts['realname']) {
|
||||
$res['owner_title'] = $exts['realname'];
|
||||
}
|
||||
$res['owner_title'] = $res['owner_title'].'【'.$user->mobile.'】';
|
||||
}
|
||||
}
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
|
||||
if ($series) {
|
||||
$res['series_title'] = $series->title;
|
||||
}
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
|
||||
if ($brand) {
|
||||
$res['brand_title'] = $brand->title;
|
||||
}
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$res]);
|
||||
}
|
||||
|
||||
//复制客车资料后新建
|
||||
public function actionCopy()
|
||||
{
|
||||
$model = new AcCar();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
|
||||
if ($series) {
|
||||
$res['series_title'] = $series->title;
|
||||
}
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
|
||||
if ($brand) {
|
||||
$res['brand_title'] = $brand->title;
|
||||
}
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$res['id'] = 0;
|
||||
$res['num_p'] = $res['num_area'] = $res['num_left'] = $res['num_frame'] = '';
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$res]);
|
||||
}
|
||||
|
||||
//浏览客车详情
|
||||
public function actionDetail()
|
||||
{
|
||||
$model = new AcCar();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$owner = $AcCarOwner->find()->where(['id' => $res['owner_id']])->one();
|
||||
$User = new User();
|
||||
$user = $User->find()->where(['id' => $res['mid']])->one();
|
||||
if ($user) {
|
||||
$res['owner_title'] = $user->username.'【'.$user->mobile.'】';
|
||||
}
|
||||
$AcUserExt = new AcUserExt();
|
||||
$userExt = $AcUserExt->find()->where(['pid' => $pid,'mid' => $res['mid'],'deleted'=>0])->all();
|
||||
$exts = [];
|
||||
if ($userExt) {
|
||||
foreach ($userExt as $v) {
|
||||
$exts[$v->key] = $v->value;
|
||||
}
|
||||
if ($exts['title']) {
|
||||
$res['owner_title'] = $exts['title'];
|
||||
}
|
||||
if ($exts['nickname']) {
|
||||
$res['owner_title'] = $exts['nickname'];
|
||||
}
|
||||
if ($exts['realname']) {
|
||||
$res['owner_title'] = $exts['realname'];
|
||||
}
|
||||
$res['owner_title'] = $res['owner_title'].'【'.$user->mobile.'】';
|
||||
}
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
|
||||
if ($series) {
|
||||
$res['series_title'] = $series->title;
|
||||
}
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
|
||||
if ($brand) {
|
||||
$res['brand_title'] = $brand->title;
|
||||
}
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
return $this->render('detail', ['status'=>$status,'detail'=>$res]);
|
||||
}
|
||||
|
||||
//保存车辆资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['title'=>'title','num_frame'=>'num_frame','num_p'=>'num_p','num_area'=>'num_area','num_left'=>'num_left'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
//查询车牌号是否在库
|
||||
$hasCar = false;
|
||||
if (!$data['num_frame']) {
|
||||
$hasCar = AcCar::find()->where(['num_p'=>$data['num_p'],'num_area'=>$data['num_area'],'num_left'=>$data['num_left']])->one();
|
||||
}
|
||||
|
||||
if ($hasCar) {
|
||||
if ($id && $id!=$hasCar->id) {
|
||||
\Yii::$app->getSession()->setFlash('danger', '保存失败,该车牌号已在库!');
|
||||
return $this->goBack();
|
||||
} else {
|
||||
$id = $hasCar->id;
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['brand_id'=>'brand_id','series_id'=>'series_id','owner_id'=>'owner_id','status_code'=>'status_code','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
// $data['status_code'] = 1;
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//填补mid参数
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$owner = $AcCarOwner->findOne($data['owner_id']);
|
||||
if ($owner) {
|
||||
$data['mid'] = $owner->mid;
|
||||
}
|
||||
|
||||
//保存车辆资料
|
||||
$AcCar = new AcCar();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcCar->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$AcCar->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcCar->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcCar->save();
|
||||
$id = $AcCar->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '车辆资料保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '车辆资料保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除车辆
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcCar();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('car/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '车辆删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '车辆删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcCar();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
// $return['status_code'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '车辆数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '车辆隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '车辆隐藏标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '车辆显示记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'primary'];
|
||||
} else {
|
||||
$return['msg'] = '车辆显示标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:28:54+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:29:12+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcCarBrand;
|
||||
|
||||
class CarbrandController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
//车品牌列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$model = new AcCarBrand();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','title',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$brands=[];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
$brands[$s['id']] = $s;
|
||||
}
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
|
||||
return $this->render('list', [
|
||||
'brands' => $brands,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
//车品牌列表
|
||||
public function actionSelect()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$model = new AcCarBrand();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','title',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$brands=[];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
$brands[$s['id']] = $s;
|
||||
}
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'car';
|
||||
return $this->render('select', [
|
||||
'brands' => $brands,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
//新增车品牌
|
||||
public function actionNew()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$AcCarBrand->status_code = 0;
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$AcCarBrand->toArray()]);
|
||||
}
|
||||
|
||||
//更新车品牌
|
||||
public function actionEdit()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$model = new AcCarBrand();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$res = [];
|
||||
}
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
return $this->render('modify', [
|
||||
'detail'=>$res,
|
||||
'status'=>$status,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
|
||||
//保存车品牌资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
//格式化数据
|
||||
$data = [];
|
||||
$data['title'] = trim($post['title']);
|
||||
//目标键=》POST键
|
||||
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//格式化资料
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcCarBrand->$key = $val;
|
||||
}
|
||||
|
||||
//资料入库
|
||||
if ($id) {
|
||||
$AcCarBrand->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcCarBrand->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcCarBrand->save();
|
||||
$id = $AcCarBrand->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '车主资料保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '车主资料保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除用户
|
||||
public function actionDelete($id)
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcCarBrand();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('carbrand/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcCarBrand();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status_code'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '品牌数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '品牌隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
} else {
|
||||
$return['msg'] = '品牌隐藏标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '品牌显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '品牌显示标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,673 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:29:55+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:29:55+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarOwner;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcEmployee;
|
||||
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
|
||||
use common\models\CSms;
|
||||
use common\models\CVcode;
|
||||
|
||||
use vendor\aliyun\dysms\Sms;
|
||||
|
||||
class CarownerController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
//车主用户列表
|
||||
public function actionList()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$model = new AcCarOwner();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
// $data = $data->andwhere($where2);
|
||||
}
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$gender = Yii::$app->params['gender'];
|
||||
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = $pid;
|
||||
$_stores = $model->find()->where($where)->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$eids = $mids = [];
|
||||
foreach ($res as $r) {
|
||||
$eids[$r['employee_id']] = $r['employee_id'];
|
||||
$mids[$r['mid']] = $r['mid'];
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach ($_employees as $s) {
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['in','id',$mids])->all();
|
||||
foreach ($_users as $s) {
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$model = new AcUserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach ($_exts as $ext) {
|
||||
$ext = $ext->toArray();
|
||||
if (isset($users[$ext['mid']])) {
|
||||
if ($ext['mobile']==$users[$ext['mid']]['mobile']) {
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$owners = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
if (isset($exts[$s['mid']])) {
|
||||
foreach ($exts[$s['mid']] as $col=>$val) {
|
||||
$s[$col] = $val;
|
||||
}
|
||||
}
|
||||
$owners[$s['id']] = $s;
|
||||
}
|
||||
|
||||
return $this->render('list', [
|
||||
'owners' => $owners,
|
||||
'pager' => $pages,
|
||||
'employees'=>$employees,
|
||||
'stores'=>$stores,
|
||||
'exts'=>$exts,
|
||||
'users'=>$users,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
//车主用户选择
|
||||
public function actionSelect()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$model = new AcCarOwner();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
// $data = $data->andwhere($where2);
|
||||
}
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$gender = Yii::$app->params['gender'];
|
||||
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = $pid;
|
||||
$_stores = $model->find()->where($where)->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$eids = $mids = [];
|
||||
foreach ($res as $r) {
|
||||
$eids[$r['employee_id']] = $r['employee_id'];
|
||||
$mids[$r['mid']] = $r['mid'];
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach ($_employees as $s) {
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['in','id',$mids])->all();
|
||||
foreach ($_users as $s) {
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$model = new AcUserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach ($_exts as $ext) {
|
||||
$ext = $ext->toArray();
|
||||
if (isset($users[$ext['mid']])) {
|
||||
if ($ext['mobile']==$users[$ext['mid']]['mobile']) {
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$owners = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
if (isset($exts[$s['mid']])) {
|
||||
foreach ($exts[$s['mid']] as $col=>$val) {
|
||||
$s[$col] = $val;
|
||||
}
|
||||
}
|
||||
$owners[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'carowner';
|
||||
return $this->render('select', [
|
||||
'owners' => $owners,
|
||||
'pager' => $pages,
|
||||
'employees'=>$employees,
|
||||
'stores'=>$stores,
|
||||
'exts'=>$exts,
|
||||
'users'=>$users,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
//新增车主
|
||||
public function actionNew()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$levels = Yii::$app->params['customerLevels'];
|
||||
return $this->render('modify', ['levels'=>$levels]);
|
||||
}
|
||||
|
||||
//更新车主
|
||||
public function actionEdit()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$levels = Yii::$app->params['customerLevels'];
|
||||
$model = new AcCarOwner();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
$res['last_send'] = $res['last_send'] ? date('Y-m-d', $res['last_send']) : '';
|
||||
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d', $res['last_contact']) : '';
|
||||
} else {
|
||||
$res = [];
|
||||
}
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['id'=>$res['mid']])->one();
|
||||
$res['mobile'] = '';
|
||||
if ($user) {
|
||||
$res['mobile'] = $user->mobile;
|
||||
}
|
||||
|
||||
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
|
||||
if ($store) {
|
||||
$res['store_title'] = $store->title;
|
||||
}
|
||||
|
||||
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
|
||||
if ($employee) {
|
||||
$res['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$exts = AcUserExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
|
||||
if ($exts) {
|
||||
foreach ($exts as $ext) {
|
||||
$res[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
|
||||
// memory_get_usage();//查看当前内存,字节
|
||||
|
||||
return $this->render('modify', [
|
||||
'detail'=>$res,
|
||||
'levels'=>$levels,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
|
||||
//保存车主资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
if (!$post['mobile']) {
|
||||
\Yii::$app->getSession()->setFlash('warning', '请输入主手机号码!');
|
||||
$url = Url::toRoute(['carowner/edit','id'=>$id]);
|
||||
return $this->redirect(['modify','id'=>$id]);
|
||||
}
|
||||
|
||||
$mobile = $post['mobile'];
|
||||
//查询对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['mobile'=>$mobile])->one();
|
||||
if (!$user) {
|
||||
$pwd = isset($post['password']) ? trim($post['password']) : Yii::$app->params['defaultUserPassword'];
|
||||
$username = isset($post['realname']) ? trim($post['realname']) : (isset($post['nickname']) ? trim($post['nickname']) : $mobile);
|
||||
$userModel->mobile = $mobile;
|
||||
$userModel->username = $username;
|
||||
$userModel->email = $mobile.'@hiluker.com';
|
||||
$userModel->setPassword($pwd);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
|
||||
$userModel->created_at = time();
|
||||
$userModel->status = 1;
|
||||
$userModel->save();
|
||||
$user_id = $userModel->attributes['id']; //获取插入后id
|
||||
} else {
|
||||
$user_id = $user->id;
|
||||
}
|
||||
|
||||
//格式化数据
|
||||
$data = [];
|
||||
//目标键=》POST键
|
||||
$cols = ['gender'=>'gender','total_fee'=>'total_fee','level'=>'level','score'=>'score','store_id'=>'store','employee_id'=>'employee','status_code'=>'status_code','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$cols = ['last_send'=>'last_send','last_contact'=>'last_contact'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? strtotime($post[$key]) : 0;
|
||||
}
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
$data['mid'] = $user_id;
|
||||
|
||||
//格式化车主资料
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcCarOwner->$key = $val;
|
||||
}
|
||||
|
||||
//查询该车主是否在库
|
||||
$carOwner = AcCarOwner::find()->where(['pid'=>$data['pid'],'mid'=>$data['mid']])->one();
|
||||
if ($carOwner) {
|
||||
$id = $carOwner->id;
|
||||
}
|
||||
|
||||
//车主资料入库
|
||||
if ($id) {
|
||||
$AcCarOwner->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcCarOwner->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcCarOwner->save();
|
||||
$id = $AcCarOwner->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
//保存扩展资料
|
||||
$AcUserExt = new AcUserExt();
|
||||
//批量硬删及软删
|
||||
// $AcUserExt->updateAll(['deleted'=>1],['deleted'=>0,'pid'=>$pid,'mid'=>$user_id]);
|
||||
$AcUserExt->deleteAll(['deleted'=>9,'pid'=>$pid,'mid'=>$user_id]); //硬删,变更历史8次的
|
||||
$AcUserExt->updateAllCounters(['deleted'=>1], ['pid'=>$pid,'mid'=>$user_id]); //更新已有数据
|
||||
|
||||
$datas = [];
|
||||
$data = [];
|
||||
$cols = ['realname'=>'realname','nickname'=>'nickname','title'=>'title','password'=>'password','mobiles'=>'mobiles','thumb'=>'thumb','province'=>'province','idcard'=>'idcard'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
// $data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
$data['pid'] = $pid;
|
||||
$data['mid'] = $user_id;
|
||||
$data['key'] = $col;
|
||||
$data['mobile'] = $mobile;
|
||||
$data['value'] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
$datas[] = $data;
|
||||
}
|
||||
//批量插入
|
||||
$model = clone $AcUserExt;
|
||||
foreach ($datas as $attributes) {
|
||||
$model->isNewRecord = true;
|
||||
$model->setAttributes($attributes, false);
|
||||
$model->save() && $model->id=0;
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '车主资料保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '车主资料保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
|
||||
// $return = [];
|
||||
// if($res){
|
||||
// $return['msg'] = '车主信息保存成功';
|
||||
// $return['errorcode'] = 200;
|
||||
// $return['url'] = Url::toRoute(['carowner/edit','id'=>$id]);
|
||||
// $return['buttons'] = [
|
||||
// ['title'=>'好的,我知道了','class'=>'primary','url'=>$return['url']]
|
||||
// ];
|
||||
// }else{
|
||||
// $return['msg'] = '车主信息保存失败';
|
||||
// $return['errorcode'] = 0;
|
||||
// $return['url'] = Url::toRoute(['carowner/new',$post]);
|
||||
// $return['buttons'] = [
|
||||
// ['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
// ];
|
||||
// }
|
||||
|
||||
// $classes = ['0'=>'warning','200'=>'success'];
|
||||
// $return['content'] = $return['msg'];
|
||||
// $return['class'] = $classes[$return['errorcode']];
|
||||
|
||||
// Yii::$app->request->setBodyParams($return);
|
||||
// return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
|
||||
//删除用户
|
||||
public function actionDelete($id)
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcCarOwner();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('carowner/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcCarOwner();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status_code'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '车主数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '车主隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
} else {
|
||||
$return['msg'] = '车主隐藏标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '车主显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '车主显示标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
//短信营销
|
||||
public function actionMsg()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$levels = Yii::$app->params['customerLevels'];
|
||||
$model = new AcCarOwner();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
$res['last_send'] = $res['last_send'] ? date('Y-m-d', $res['last_send']) : '';
|
||||
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d', $res['last_contact']) : '';
|
||||
} else {
|
||||
$res = [];
|
||||
}
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['id'=>$res['mid']])->one();
|
||||
$res['mobile'] = '';
|
||||
if ($user) {
|
||||
$res['mobile'] = $user->mobile;
|
||||
}
|
||||
|
||||
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
|
||||
if ($store) {
|
||||
$res['store_title'] = $store->title;
|
||||
}
|
||||
|
||||
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
|
||||
if ($store) {
|
||||
$res['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$exts = AcUserExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
|
||||
if ($exts) {
|
||||
foreach ($exts as $ext) {
|
||||
$res[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
|
||||
$op = Yii::$app->request->get('op');
|
||||
$opp = Yii::$app->request->get('opp');
|
||||
if (!$op) {
|
||||
return $this->render('msg', [
|
||||
'detail'=>$res,
|
||||
'levels'=>$levels,
|
||||
'id'=>$id,
|
||||
]);
|
||||
} elseif ($op=='send') {
|
||||
$option = [];
|
||||
$config = [];
|
||||
$config['accessKeyId'] = Yii::$app->params['aliDySms']['accessKeyId'];
|
||||
$config['accessKeySecret'] = Yii::$app->params['aliDySms']['accessKeySecret'];
|
||||
$config['sign'] = Yii::$app->params['aliDySms']['sign'];
|
||||
$sms = new Sms($option, $config);
|
||||
$phone = $res['mobile'];
|
||||
$content=[];
|
||||
switch ($opp) {
|
||||
case 'vcode': //发送验证码
|
||||
$code = mt_rand(1000, 9999);
|
||||
$content['code'] = $code;
|
||||
$tmpl = Yii::$app->params['aliDySms']['tmpl']['vcode'];
|
||||
//验证码入库
|
||||
$vcodeModel = new CVcode();
|
||||
$vcode = [];
|
||||
$vcode['code'] = $code;
|
||||
$vcode['mobile'] = $phone;
|
||||
$vcode['create_at'] = time();
|
||||
foreach ($vcode as $key=>$val) {
|
||||
$vcodeModel->$key = $val;
|
||||
}
|
||||
$vcodeModel->save();
|
||||
break;
|
||||
case 'birthday': //发送生日祝福
|
||||
$realname = isset($res['realname']) ? $res['realname'] : 'VIP';
|
||||
$content['name'] = $realname;
|
||||
$content['company'] = Yii::$app->request->post('company');
|
||||
$content['company'] = $content['company'] ? $content['company'] : '安诚托车';
|
||||
$tmpl = Yii::$app->params['aliDySms']['tmpl']['acBirthday'];
|
||||
break;
|
||||
}
|
||||
$result = $sms->send($phone, $tmpl, $content);
|
||||
//保存发送记录
|
||||
$smsModel = new CSms();
|
||||
$smsdata = [];
|
||||
$sid = Yii::$app->session->get('sid');
|
||||
$smsdata['sid'] = (int)$sid;
|
||||
$smsdata['pid'] = $pid;
|
||||
$smsdata['uid'] = Yii::$app->user->identity->id;
|
||||
$smsdata['mobile'] = $phone;
|
||||
$smsdata['content'] = json_encode($content, JSON_UNESCAPED_UNICODE);
|
||||
$smsdata['create_at'] = time();
|
||||
foreach ($smsdata as $key=>$val) {
|
||||
$smsModel->$key = $val;
|
||||
}
|
||||
$smsModel->save();
|
||||
|
||||
$return = [];
|
||||
$msg = '';
|
||||
if (!$result) {
|
||||
$msg .= "【".$phone."】发送失败,接口提示:".$sms->errors."\r\n";
|
||||
$return['errorcode'] = 0;
|
||||
} elseif (is_array($result) && $result['Code'] !='OK') {
|
||||
$msg .= "【".$phone."】发送失败,接口提示:".$result['Message']."\r\n";
|
||||
$return['errorcode'] = 0;
|
||||
} else {
|
||||
$msg .= "【".$phone."】发送成功"."\r\n";
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
$return['msg'] = $msg;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
||||
//信息摘要
|
||||
public function actionInfo()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$levels = Yii::$app->params['customerLevels'];
|
||||
$model = new AcCarOwner();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
$res['last_send'] = $res['last_send'] ? date('Y-m-d', $res['last_send']) : '';
|
||||
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d', $res['last_contact']) : '';
|
||||
} else {
|
||||
$res = [];
|
||||
}
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['id'=>$res['mid']])->one();
|
||||
$res['mobile'] = '';
|
||||
if ($user) {
|
||||
$res['mobile'] = $user->mobile;
|
||||
}
|
||||
|
||||
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
|
||||
if ($store) {
|
||||
$res['store_title'] = $store->title;
|
||||
}
|
||||
|
||||
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
|
||||
if ($store) {
|
||||
$res['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$exts = AcUserExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
|
||||
if ($exts) {
|
||||
foreach ($exts as $ext) {
|
||||
$res[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('info', [
|
||||
'detail'=>$res,
|
||||
'levels'=>$levels,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,339 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:30:22+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:30:22+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
|
||||
class CarseriesController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
//车型列表
|
||||
public function actionList()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$session = Yii::$app->session;
|
||||
$model = new AcCarSeries();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where2[] = ['in','pid',[0,$pid]];
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$searchSession = 'carseries::search';
|
||||
if (isset($_GET['reset']) && $_GET['reset']==1) {
|
||||
$post['search'] = [];
|
||||
}
|
||||
if (isset($post['search'])) {
|
||||
$search = $post['search'];
|
||||
$session->set($searchSession, $search);
|
||||
} elseif ($session->get($searchSession)) {
|
||||
$search = $session->get($searchSession);
|
||||
}
|
||||
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','title',$search['title']];
|
||||
}
|
||||
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
|
||||
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
|
||||
if (!empty($search['brand_id'])) {
|
||||
$where['brand_id'] = $search['brand_id'];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
|
||||
$series = $bids = [];
|
||||
foreach ($res as $r) {
|
||||
$r = $r->toArray();
|
||||
$series[$r['id']] = $r;
|
||||
$bids[] = $r['brand_id'];
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brands = [];
|
||||
$_brands = $AcCarBrand->find()->where(['in','id',$bids])->indexBy('id')->all();
|
||||
foreach ($_brands as $s) {
|
||||
$brands[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
return $this->render('list', [
|
||||
'series' => $series,
|
||||
'pager' => $pages,
|
||||
'brands'=>$brands,
|
||||
'status'=>$status,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
//车型列表
|
||||
public function actionSelect()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$session = Yii::$app->session;
|
||||
$model = new AcCarSeries();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where2[] = ['in','pid',[0,$pid]];
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$searchSession = 'carseries::search';
|
||||
if (isset($_GET['reset']) && $_GET['reset']==1) {
|
||||
$post['search'] = [];
|
||||
}
|
||||
if (isset($post['search'])) {
|
||||
$search = $post['search'];
|
||||
$session->set($searchSession, $search);
|
||||
} elseif ($session->get($searchSession)) {
|
||||
$search = $session->get($searchSession);
|
||||
}
|
||||
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','title',$search['title']];
|
||||
}
|
||||
// $search['brand'] = isset($search['brand']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
|
||||
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
|
||||
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
|
||||
if (!empty($search['brand_id'])) {
|
||||
$where['brand_id'] = $search['brand_id'];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
|
||||
$series = $bids = [];
|
||||
foreach ($res as $r) {
|
||||
$r = $r->toArray();
|
||||
$series[$r['id']] = $r;
|
||||
$bids[$r['brand_id']] = $r['brand_id'];
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brands = [];
|
||||
$_brands = $AcCarBrand->find()->where(['in','id',$bids])->indexBy('id')->all();
|
||||
foreach ($_brands as $s) {
|
||||
$brands[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'car';
|
||||
return $this->render('select', [
|
||||
'series' => $series,
|
||||
'pager' => $pages,
|
||||
'brands'=>$brands,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
//新增车型
|
||||
public function actionNew()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$AcCarSeries->status_code = 0;
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$AcCarSeries->toArray()]);
|
||||
}
|
||||
|
||||
//更新车型
|
||||
public function actionEdit()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$model = new AcCarSeries();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$parmas = [];
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
$parmas = json_decode($res['params'], true);
|
||||
} else {
|
||||
$res = [];
|
||||
}
|
||||
|
||||
//查询对应的品牌
|
||||
$brand = AcCarBrand::find()->where(['id' => $res['brand_id']])->one();
|
||||
if ($brand) {
|
||||
$res['brand_title'] = $brand->title;
|
||||
}
|
||||
|
||||
return $this->render('modify', [
|
||||
'detail'=>$res,
|
||||
'params'=>$parmas,
|
||||
'status'=>$status,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
|
||||
//保存车型资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
$data = [];
|
||||
$data['title'] = trim($post['title']);
|
||||
//目标键=》POST键
|
||||
$cols = ['brand_id'=>'brand_id','status_code'=>'status_code','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$params = $post['p'];
|
||||
$cols = ['height','length','width','kg','seat'];
|
||||
foreach ($cols as $col) {
|
||||
$params[$col] = isset($params[$col]) ? (int)$params[$col] : 0;
|
||||
}
|
||||
$data['params'] = json_encode($params, JSON_UNESCAPED_UNICODE);
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//格式化车型资料
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcCarSeries->$key = $val;
|
||||
}
|
||||
|
||||
//车型资料入库
|
||||
if ($id) {
|
||||
$AcCarSeries->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcCarSeries->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcCarSeries->save();
|
||||
$id = $AcCarSeries->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '车型资料保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '车型资料保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除车型
|
||||
public function actionDelete($id)
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcCarSeries();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('carowner/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcCarSeries();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status_code'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '车型数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '车型隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
} else {
|
||||
$return['msg'] = '车型隐藏标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '车型显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '车型显示标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:30:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:30:47+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
// use backend\models\Citys;
|
||||
|
||||
class CityController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$citys = Yii::$app->params['citys'];
|
||||
$pager = new Pagination(['totalCount' =>count($citys), 'pageSize' => '100']);
|
||||
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'city';
|
||||
$search=[];
|
||||
return $this->render('select', [
|
||||
'citys'=>$citys,
|
||||
'pager' => $pager,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
# @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
|
||||
# @Last modified time: 2024-08-09T09:02:06+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端用户入口
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
@@ -26,13 +26,12 @@ class Common extends Controller
|
||||
protected $page = 1; //当前数据分页
|
||||
protected $pageSize = 10; //默认数据分页大小
|
||||
public $enableCsrfValidation = false;
|
||||
protected $timetamp = '';
|
||||
protected $timestamp = TIMESTAMP;
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->timetamp = time();
|
||||
//判断请求内容类型 content-type,支持 json请求
|
||||
$postdata = Yii::$app->request->post();
|
||||
$headers = Yii::$app->request->headers;
|
||||
@@ -41,7 +40,7 @@ class Common extends Controller
|
||||
$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) {
|
||||
@@ -60,18 +59,18 @@ class Common extends Controller
|
||||
} 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){
|
||||
if (!$res) {
|
||||
$this->user_id = 0;
|
||||
}else{
|
||||
} else {
|
||||
$this->user_info = $res;
|
||||
}
|
||||
//TBD 后期需加上更多登陆验证逻辑
|
||||
@@ -93,19 +92,20 @@ class Common extends Controller
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function fansToken($user=[], $refresh=false, $expire = null){
|
||||
|
||||
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){
|
||||
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);
|
||||
Yii::$app->session->set('fansToken', $token);
|
||||
Yii::$app->session->set('fansTokenExpired', $tokenExpired);
|
||||
}
|
||||
$user['token'] = $token;
|
||||
$user['token'] = $token;
|
||||
$user['tokenExpired'] = $tokenExpired;
|
||||
return $user;
|
||||
}
|
||||
|
||||
@@ -1,278 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:35:33+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:35:33+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcContact;
|
||||
use common\models\Member as User;
|
||||
use common\models\UserExt;
|
||||
|
||||
class ContactController extends Common
|
||||
{
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
//通讯录列表
|
||||
public function actionList()
|
||||
{
|
||||
$model = new AcContact();
|
||||
$where = $where2 = [];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$session = Yii::$app->session;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$searchSession = 'contact::search';
|
||||
if (isset($_GET['reset']) && $_GET['reset']==1) {
|
||||
$post['search'] = [];
|
||||
}
|
||||
if (isset($post['search'])) {
|
||||
$search = $post['search'];
|
||||
$session->set($searchSession, $search);
|
||||
} elseif ($session->get($searchSession)) {
|
||||
$search = $session->get($searchSession);
|
||||
}
|
||||
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[]='or';
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
$where2[] = ['LIKE','mobile',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
|
||||
return $this->render('list', [
|
||||
'contactors'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new AcContact();
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$session = Yii::$app->session;
|
||||
$where = $where2 = [];
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$searchSession = 'contact::search';
|
||||
if (isset($_GET['reset']) && $_GET['reset']==1) {
|
||||
$post['search'] = [];
|
||||
}
|
||||
if (isset($post['search'])) {
|
||||
$search = $post['search'];
|
||||
$session->set($searchSession, $search);
|
||||
} elseif ($session->get($searchSession)) {
|
||||
$search = $session->get($searchSession);
|
||||
}
|
||||
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[]='or';
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
$where2[] = ['LIKE','mobile',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'contactor';
|
||||
return $this->render('select', [
|
||||
'contactors'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('modify', []);
|
||||
}
|
||||
|
||||
//编辑通讯录资料
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new AcContact();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
|
||||
return $this->render('modify', ['detail'=>$res]);
|
||||
}
|
||||
|
||||
//保存通讯录资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['company'=>'company','name'=>'name','mobile'=>'mobile','idcard'=>'idcard'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
//查询通讯录手机号是否在库
|
||||
$hasContactor = AcContact::find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if ($hasContactor) {
|
||||
if ($id && $id==$hasContactor->id) {
|
||||
} else {
|
||||
$id = $hasContactor->id;
|
||||
\Yii::$app->getSession()->setFlash('danger', '保存失败,该手机号对应的通讯录已在库,系统自动现在为您调出该通讯录资料!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
}
|
||||
}
|
||||
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存通讯录资料
|
||||
$AcContact = new AcContact();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcContact->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$AcContact->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcContact->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcContact->save();
|
||||
$id = $AcContact->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '通讯录信息保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '通讯录信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcContact();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('contact/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '通讯录删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '通讯录删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcContact();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '通讯录数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'out':
|
||||
$data['status'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '通讯录隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
} else {
|
||||
$return['msg'] = '通讯录隐藏标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'in':
|
||||
$data['status'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '通讯录显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '通讯录显示标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,268 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:35:09+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:35:09+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcDriver;
|
||||
use common\models\Member as User;
|
||||
use common\models\UserExt;
|
||||
|
||||
class DriverController extends Common
|
||||
{
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
//司机列表
|
||||
public function actionList()
|
||||
{
|
||||
$model = new AcDriver();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['DriverStatus'];
|
||||
|
||||
return $this->render('list', [
|
||||
'drivers'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new AcDriver();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['DriverStatus'];
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'driver';
|
||||
return $this->render('select', [
|
||||
'drivers'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('modify', []);
|
||||
}
|
||||
|
||||
//编辑司机资料
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new AcDriver();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
|
||||
return $this->render('modify', ['detail'=>$res]);
|
||||
}
|
||||
|
||||
//保存司机资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['name'=>'name','mobile'=>'mobile','idcard'=>'idcard'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
//查询司机手机号是否在库
|
||||
$hasDriver = AcDriver::find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if ($hasDriver) {
|
||||
if ($id && $id==$hasDriver->id) {
|
||||
} else {
|
||||
$id = $hasDriver->id;
|
||||
\Yii::$app->getSession()->setFlash('danger', '保存失败,该手机号对应的司机已在库,系统自动现在为您调出该司机资料!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
}
|
||||
}
|
||||
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存司机资料
|
||||
$AcDriver = new AcDriver();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcDriver->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$AcDriver->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcDriver->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcDriver->save();
|
||||
$id = $AcDriver->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
//查询司机对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = $userModel->find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if (empty($user)) {
|
||||
$userModel->username = !$data['name'] ? $data['mobile'] : $data['name'];
|
||||
$userModel->mobile = $data['mobile'];
|
||||
$userModel->email = $data['mobile'].'@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultUserPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
|
||||
$userModel->created_at = time();
|
||||
$userModel->status = 1;
|
||||
$userModel->save();
|
||||
$user_id = $userModel->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
\Yii::$app->getSession()->setFlash('info', '已成功注册该用户!');
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '司机信息保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '司机信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除员工
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcDriver();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('driver/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '司机删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '司机删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcDriver();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '司机数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'out':
|
||||
$data['status'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '司机离职标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
} else {
|
||||
$return['msg'] = '司机离职标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'in':
|
||||
$data['status'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '司机在职标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '司机在职标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,295 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:34:47+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:34:47+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcStore;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
|
||||
class EmployeeController extends Common
|
||||
{
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
//用户列表
|
||||
public function actionList()
|
||||
{
|
||||
$model = new AcEmployee();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['EmployeeStatus'];
|
||||
$gender = Yii::$app->params['gender'];
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_stores = $model->find()->where($where)->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
return $this->render('list', [
|
||||
'employees'=>$res,
|
||||
'pager' => $pages,
|
||||
'stores'=>$stores,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new AcEmployee();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['EmployeeStatus'];
|
||||
$gender = Yii::$app->params['gender'];
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_stores = $model->find()->where($where)->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'employee';
|
||||
return $this->render('select', [
|
||||
'employees'=>$res,
|
||||
'pager' => $pages,
|
||||
'stores'=>$stores,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('modify', []);
|
||||
}
|
||||
|
||||
//编辑员工资料
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new AcEmployee();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
|
||||
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
|
||||
if ($store) {
|
||||
$res['store_title'] = $store->title;
|
||||
}
|
||||
return $this->render('modify', ['detail'=>$res]);
|
||||
}
|
||||
|
||||
//保存员工资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['name'=>'name','mobile'=>'mobile'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
$cols = ['gender'=>'gender','status'=>'status','store_id'=>'store','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['status_code'] = 1;
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存员工资料
|
||||
$AcEmployee = new AcEmployee();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcEmployee->$key = $val;
|
||||
}
|
||||
|
||||
//查询员工手机号是否在库
|
||||
$employee = AcEmployee::find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if ($employee) {
|
||||
$id = $employee->id;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$AcEmployee->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcEmployee->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcEmployee->save();
|
||||
$id = $AcEmployee->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
//查询员工对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if (empty($user)) {
|
||||
$userModel->username = $data['mobile'];
|
||||
$userModel->mobile = $data['mobile'];
|
||||
$userModel->email = $data['mobile'].'@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultUserPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
|
||||
$userModel->created_at = time();
|
||||
$userModel->status = 1;
|
||||
$userModel->save();
|
||||
$user_id = $userModel->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
\Yii::$app->getSession()->setFlash('info', '已成功注册该用户!');
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '员工信息保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '员工信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除员工
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcEmployee();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('employee/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '员工删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '员工删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcEmployee();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '员工数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'out':
|
||||
$data['status'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '员工离职标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
} else {
|
||||
$return['msg'] = '员工离职标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'in':
|
||||
$data['status'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '员工在职标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '员工在职标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:34:19+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:34:19+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class ErrorController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
public function actionReport()
|
||||
{
|
||||
$request = Yii::$app->request;
|
||||
$get = $request->get();
|
||||
$url = Urldecode($get['url']);
|
||||
$code = 0;
|
||||
if ($request->isPost) {
|
||||
$code = getMillisecond().'_'.rand(0, 999);
|
||||
$filename = $code.'.php';
|
||||
$post = $request->post();
|
||||
$code = $post['code']!=0 ? $post['code'] : $code;
|
||||
$post['time'] = time();
|
||||
fm_load()->fm_func('error');
|
||||
fmFunc_error_write($filename, $post);
|
||||
|
||||
$msg = [];
|
||||
$msg['title'] = '报错提交通知';
|
||||
$msg['content'] = '感谢反馈,工程师将尽快处理!您本次的反馈工单号为<code>'.$code.'</code>';
|
||||
$msg['class'] = 'success';
|
||||
$btn = [];
|
||||
$btn['title'] = '返回';
|
||||
// $btn['url'] = Url::current();
|
||||
$btn['url'] = $url;
|
||||
$btn['class'] = 'primary';
|
||||
$msg['buttons'][] = $btn;
|
||||
$btn = [];
|
||||
$btn['title'] = '查看工单';
|
||||
$btn['url'] = Url::toRoute(['error/order','code'=>$code]);
|
||||
$btn['class'] = 'warning';
|
||||
$msg['buttons'][] = $btn;
|
||||
$btn = [];
|
||||
$btn['title'] = '回到首页';
|
||||
$btn['url'] = Url::home();
|
||||
$btn['class'] = 'info';
|
||||
$msg['buttons'][] = $btn;
|
||||
return $this->render('../layouts/msg', $msg);
|
||||
}
|
||||
return $this->render('report', ['url'=>$url]);
|
||||
}
|
||||
|
||||
public function actionOrder()
|
||||
{
|
||||
$request = Yii::$app->request;
|
||||
$get = $request->get();
|
||||
$code = Urldecode($get['code']);
|
||||
$filename = $code.'.php';
|
||||
fm_load()->fm_func('error');
|
||||
$data = [];
|
||||
$file = fmFunc_error_get($code);
|
||||
include $file;
|
||||
return $this->render('report', ['code'=>$code,'data'=>$data,'url'=>$data['url']]);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
# @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
|
||||
# @Last modified time: 2024-08-09T08:59:44+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
//前端普通用户入口
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use common\models\Fans; //‘from’字段为ctms的数据
|
||||
@@ -42,7 +42,7 @@ class FansController extends Common
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
|
||||
$username = $post['username'] ?? null;
|
||||
$passwd = $post['passwd'] ?? null;
|
||||
|
||||
@@ -68,8 +68,8 @@ class FansController extends Common
|
||||
$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();
|
||||
$args = [':username' => $username, ':from' => $from];
|
||||
$user = $model->find()->where($condition, $args)->one();
|
||||
if (!$user) {
|
||||
$this->result('查无此人!', null, 404);
|
||||
}
|
||||
@@ -81,11 +81,11 @@ class FansController extends Common
|
||||
$isPwdRight = $user->validatePassword($passwd);
|
||||
|
||||
if (!$isPwdRight) {
|
||||
$this->result('密码错误,禁止登陆!', null, 400);
|
||||
$this->result('密码错误,禁止登陆!', NULL, 400);
|
||||
}
|
||||
//校验结束
|
||||
|
||||
$_user = $this->fansLogin($user,true);
|
||||
|
||||
$_user = $this->fansLogin($user, TRUE);
|
||||
$this->result('登陆成功!', ['user'=>$_user], 200);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class FansController extends Common
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
|
||||
$mobile = $post['mobile'] ?? null;
|
||||
$vcode = $post['vcode'] ?? null;
|
||||
|
||||
@@ -108,43 +108,43 @@ class FansController extends Common
|
||||
$this->result('请输入手机验证码!', null, 400);
|
||||
}
|
||||
$mobile = trim(htmlspecialchars_decode($mobile));
|
||||
//验证手机号
|
||||
$isPhone = preg_match('/^1\d{10}$/', $mobile) ? true : false;
|
||||
if(!$isPhone){
|
||||
$this->result('手机号不正确,请检查');
|
||||
}
|
||||
//验证手机号
|
||||
$isPhone = preg_match('/^1\d{10}$/', $mobile) ? TRUE : FALSE;
|
||||
if (!$isPhone) {
|
||||
$this->result('手机号不正确,请检查');
|
||||
}
|
||||
$vcode = trim(htmlspecialchars_decode($vcode));
|
||||
//验证手机验证码
|
||||
//验证手机验证码
|
||||
$vcodeModel = new CVcode();
|
||||
$where=[];
|
||||
$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('验证码已失效,请重新获取');
|
||||
}
|
||||
$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;
|
||||
$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) {
|
||||
$hasExt = FALSE;
|
||||
$userModel = clone $model;
|
||||
$user = $this->fansAdd(['mobile' => $mobile, 'from' => $from], $userModel);
|
||||
} else if ($user->status != Fans::STATUS_ACTIVE) {
|
||||
$this->result('账户异常,禁止登陆!', null, 403);
|
||||
}
|
||||
//校验结束
|
||||
$_user = $this->fansLogin($user,$hasExt);
|
||||
$_user = $this->fansLogin($user, $hasExt);
|
||||
$this->result('登陆成功!', ['user'=>$_user], 200);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ class FansController extends Common
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
$openplat = $post['from'] ?? 'uni-app'; //归属的开放平台,默认标记为了uni-app
|
||||
$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'])) : '';
|
||||
|
||||
@@ -160,7 +160,7 @@ class FansController extends Common
|
||||
if (!$mobile) {
|
||||
$this->result('未提供授权手机号!');
|
||||
}
|
||||
if (!$openid) {
|
||||
if (!$openid) {
|
||||
$this->result('未提供授权用户身份ID!');
|
||||
}
|
||||
|
||||
@@ -171,13 +171,13 @@ class FansController extends Common
|
||||
//扩展用户信息
|
||||
$AcFansExt = new AcFansExt();
|
||||
$Ext = clone $AcFansExt; //用于更新openid
|
||||
$Ext2 = clone $AcFansExt; //用于更新来源归属的开放平台openplat
|
||||
|
||||
$hasExt = true;
|
||||
$Ext2 = clone $AcFansExt; //用于更新来源归属的开放平台openplat
|
||||
|
||||
$hasExt = TRUE;
|
||||
if (!$user) {
|
||||
$hasExt = false;
|
||||
$hasExt = FALSE;
|
||||
//自动注册一个新用户
|
||||
$user = $this->fansAdd(['mobile'=>$mobile,'from'=>$from],$userModel);
|
||||
$user = $this->fansAdd(['mobile' => $mobile, 'from' => $from], $userModel);
|
||||
|
||||
// 添加扩展信息
|
||||
$Ext->pid = $this->pid;
|
||||
@@ -187,30 +187,32 @@ class FansController extends Common
|
||||
$Ext->value = $openid;
|
||||
$Ext->deleted = 0;
|
||||
$Ext->save();
|
||||
|
||||
$Ext2->pid = $this->pid;
|
||||
|
||||
$Ext2->pid = $this->pid;
|
||||
$Ext2->mid = $user->id;
|
||||
$Ext2->mobile = $mobile;
|
||||
$Ext2->key = 'openplat';
|
||||
$Ext2->value = $openplat;
|
||||
$Ext2->deleted = 0;
|
||||
$Ext2->save();
|
||||
}else{
|
||||
} 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'];
|
||||
$args = [':mid' => $user->id, ':mobile' => $user->mobile, ':pid' => $pid, ':deleted' => 0, ':value' => $openid, ':key' => 'openid'];
|
||||
$AcFansExt->updateAllCounters(
|
||||
['deleted'=>1],$condition,$args
|
||||
['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){
|
||||
|
||||
$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{
|
||||
} else {
|
||||
$Ext->pid = $this->pid;
|
||||
$Ext->mid = $user->id;
|
||||
$Ext->mobile = $mobile;
|
||||
@@ -219,13 +221,13 @@ class FansController extends Common
|
||||
$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){
|
||||
|
||||
$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{
|
||||
} else {
|
||||
$Ext2->pid = $this->pid;
|
||||
$Ext2->mid = $user->id;
|
||||
$Ext2->mobile = $mobile;
|
||||
@@ -237,7 +239,7 @@ class FansController extends Common
|
||||
}
|
||||
|
||||
// 登陆用户
|
||||
$_user = $this->fansLogin($user,$hasExt);
|
||||
$_user = $this->fansLogin($user, $hasExt);
|
||||
$this->result('登陆成功!', ['user'=>$_user], 200);
|
||||
}
|
||||
|
||||
@@ -248,23 +250,23 @@ class FansController extends Common
|
||||
|
||||
$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 = [];
|
||||
$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) {
|
||||
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();
|
||||
@@ -281,8 +283,8 @@ class FansController extends Common
|
||||
$userModel->save();
|
||||
$user = $userModel;
|
||||
}
|
||||
|
||||
$_user = $this->fansLogin($user,true);
|
||||
|
||||
$_user = $this->fansLogin($user, TRUE);
|
||||
$this->result('登陆成功!', ['user'=>$_user], 200);
|
||||
}
|
||||
|
||||
@@ -291,7 +293,8 @@ class FansController extends Common
|
||||
* @param $data 用户数据
|
||||
* @return void
|
||||
*/
|
||||
private function fansAdd($data,$userModel){
|
||||
private function fansAdd($data, $userModel)
|
||||
{
|
||||
$mobile = $data['mobile'];
|
||||
$from = $data['from'] ?? Yii::$app->params['fansFrom'];
|
||||
$userModel->mobile = $mobile;
|
||||
@@ -309,7 +312,8 @@ class FansController extends Common
|
||||
* @param $hasExt 有否扩展
|
||||
* @return void
|
||||
*/
|
||||
private function fansLogin($user,$hasExt = false){
|
||||
private function fansLogin($user, $hasExt = FALSE)
|
||||
{
|
||||
// 使用指定用户名获取用户身份实例
|
||||
$identity = $user;
|
||||
// 登录用户,有效期30d
|
||||
@@ -320,20 +324,20 @@ class FansController extends Common
|
||||
}
|
||||
//登陆成功,返回用户信息
|
||||
$_user = ['id'=>$user->id,'username'=>$user->mobile,'mobile'=>$user->mobile];
|
||||
if($hasExt){
|
||||
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'];
|
||||
}
|
||||
}
|
||||
$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;
|
||||
$isLong = $this->postdata['isLong'] ?? FALSE;
|
||||
$expire = $isLong ? '+1 Month' : false;
|
||||
$_user = $this->fansToken($_user,$refresh = true, $expire);
|
||||
$_user = $this->fansToken($_user, $refresh = TRUE, $expire);
|
||||
return $_user;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:33:38+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:33:38+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcFeeOrder;
|
||||
use addons\models\AcFeeDriver;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcOrderPre;
|
||||
use addons\models\AcOrderStatus;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcPlat;
|
||||
use common\models\CVcode;
|
||||
|
||||
class FeeController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('@app/views/layouts/dev', []);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,378 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:32:02+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:32:02+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcTruckOnline;
|
||||
use addons\models\AcTruckCars;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcGps;
|
||||
use addons\models\AcGpsRoute;
|
||||
use addons\models\AcTruckRoute;
|
||||
|
||||
class GpsController extends Common
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
$session = Yii::$app->session;
|
||||
if (isset($_GET['pid']) && (int)$_GET['pid']>0) {
|
||||
$session->set('pid', (int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if (!$pid) {
|
||||
return Yii::$app->response->redirect(['index/index']);
|
||||
}
|
||||
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
|
||||
if (!$online_id) {
|
||||
$online_id = $session->get('online_id');
|
||||
} else {
|
||||
$session->set('online_id', $online_id);
|
||||
}
|
||||
if (!$online_id) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '请先选择好要查看的出车大板';
|
||||
$return['errorcode'] = 0;
|
||||
// $return['url'] = Url::toRoute(['truckol/index',$post]);
|
||||
// $return['buttons'] = [
|
||||
// ['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
// ];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
$truckol = $session->get('truckOnline');
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$res = true;
|
||||
if (!$truckol) {
|
||||
$res = $AcTruckOnline->findOne($online_id);
|
||||
if ($res) {
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
$session->set('truckOnline', $truckol);
|
||||
}
|
||||
}
|
||||
if ($online_id != $truckol['id']) {
|
||||
$res = $AcTruckOnline->findOne($online_id);
|
||||
if ($res) {
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
$session->set('truckOnline', $truckol);
|
||||
}
|
||||
}
|
||||
if (!$res) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '请先选择好要查看的出车大板';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truckol/index',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
}
|
||||
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index', []);
|
||||
}
|
||||
|
||||
//所有板车位置记录列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',Yii::$app->session->get('pid')];
|
||||
if ($online_id) {
|
||||
$where[] = ['=','online_id',$online_id];
|
||||
}
|
||||
$where[] = ['=','deleted',0];
|
||||
$data = $AcTruckRoute->find()->where($where)->orderby('orderby ASC,id DESC');
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
|
||||
$truck_ids = [];
|
||||
foreach ($res as $r) {
|
||||
$truck_ids[] = $r->truck_id;
|
||||
}
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$truck_ids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$trucks = $AcTruck->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
|
||||
return $this->render('list', [
|
||||
'list'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'trucks'=>$trucks,
|
||||
'online_id'=>$online_id,
|
||||
'truckol'=>$truckol
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$AcTruckRoute = [];
|
||||
$AcTruckRoute['status_code'] = 0;
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
|
||||
$AcTruckRoute['truck_id'] = $truckol['truck_id'];
|
||||
$AcTruckRoute['truck_num'] = $truckol['truck_num'];
|
||||
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$AcTruckRoute,'online_id'=>$online_id,'truckol'=>$truckol]);
|
||||
}
|
||||
|
||||
//编辑板车位置信息
|
||||
public function actionEdit()
|
||||
{
|
||||
$id = Yii::$app->request->get('id'); //记录ID
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
$route = $AcTruckRoute->findOne($id);
|
||||
if (!$route) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '位置记录数据获取异常,请重新选择获取';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = '';
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
$route = $route->toArray();
|
||||
$route['truck_id'] = $truckol['truck_id'];
|
||||
$route['online_id'] = $online_id;
|
||||
$route['truck_num'] = $truckol['truck_num'];
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$route,'online_id'=>$online_id,'truckol'=>$truckol]);
|
||||
}
|
||||
|
||||
//保存位置记录信息
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$online_id = Yii::$app->session->get('online_id');
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
$data = [];
|
||||
$data['truck_id'] = $truckol['truck_id'];
|
||||
$data['online_id'] = $online_id;
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['longt'=>'lng','lat'=>'lat','addr'=>'addr'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
|
||||
$cols = ['orderby'=>'orderby','status_code'=>'status_code'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
|
||||
$_time = time();
|
||||
$key = 'update_at';
|
||||
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
|
||||
|
||||
if (!$id) {
|
||||
$data['create_at'] = $_time;
|
||||
}
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存位置资料
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcTruckRoute->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$res = $AcTruckRoute->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcTruckRoute->save();
|
||||
$id = $AcTruckRoute->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除记录
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$return = [];
|
||||
|
||||
$model = new AcTruckRoute();
|
||||
$route = $model->findOne($id);
|
||||
if (!$route) {
|
||||
$return['msg'] = '数据不存在,删除失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->pid !=$pid) {
|
||||
$return['msg'] = '非本平台数据,不允许操作';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->deleted !=0) {
|
||||
$return['msg'] = '数据已被删除过,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$route->deleted = 1;
|
||||
$res = $route->save();
|
||||
|
||||
$return['url'] = '';
|
||||
$return['timeout'] = 1; //n秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '位置记录删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '位置记录删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$return = [];
|
||||
|
||||
$model = new AcTruckRoute();
|
||||
$route = $model->findOne($id);
|
||||
if (!$route) {
|
||||
$return['msg'] = '数据不存在,删除失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->pid !=$pid) {
|
||||
$return['msg'] = '非本平台数据,不允许操作';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
if ($route->deleted !=0) {
|
||||
$return['msg'] = '数据已被删除,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$return['timeout'] = 1; //n秒后自动跳转
|
||||
$res = true;
|
||||
switch ($get['do']) {
|
||||
case 'show':
|
||||
if ($route->status_code!=1) {
|
||||
$route->status_code = 1;
|
||||
$res = $route->save();
|
||||
}
|
||||
if ($res) {
|
||||
$return['msg'] = '记录显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'success'];
|
||||
} else {
|
||||
$return['msg'] = '客车上板标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'hide':
|
||||
if ($route->status_code!=0) {
|
||||
$route->status_code = 0;
|
||||
$res = $route->save();
|
||||
}
|
||||
if ($res) {
|
||||
$return['msg'] = '记录隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'success'];
|
||||
} else {
|
||||
$return['msg'] = '客车上板标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-10T01:13:34+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-13T11:51:07+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\web\UploadedFile;
|
||||
use common\models\CAttachment;
|
||||
use backend\controllers\Common;
|
||||
|
||||
class ImageController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'图片列表',
|
||||
];
|
||||
$this->result('您正使用CMTS系统订单管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
$siteId = Yii::$app->params['siteId'];
|
||||
$session = Yii::$app->session;
|
||||
$pid = $this->pid;
|
||||
$model = new CAttachment();
|
||||
$search = $where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','status_code',1];
|
||||
$where[] = ['=','type',0];
|
||||
$where[] = ['=','siteid',$siteId];
|
||||
$where[] = ['=','pid',$pid];
|
||||
$post = $this->postdata;
|
||||
|
||||
if (isset($post['search'])) {
|
||||
$search = $post['search'];
|
||||
$session->set('images::search', $search);
|
||||
} elseif ($session->get('images::search')) {
|
||||
$search = $session->get('images::search');
|
||||
}
|
||||
if ($search) {
|
||||
if ($search['create_m']) {
|
||||
$start = strtotime($search['create_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of ".$s);
|
||||
$m = date("Y-m-d", $ldm)." 23:59:59";
|
||||
$end = strtotime($m);
|
||||
$where[] = ['between','create_at',$start,$end];
|
||||
} elseif (!empty($search['create_after']) && !empty($search['create_before'])) {
|
||||
$start = strtotime($search['create_after']);
|
||||
$end = strtotime($search['create_before']);
|
||||
$where[] = ['between','create_at',$start,$end];
|
||||
} elseif (!empty($search['create_after'])) {
|
||||
$start = strtotime($search['create_after']);
|
||||
$where[] = ['>=','create_at',$start];
|
||||
} elseif (!empty($search['create_before'])) {
|
||||
$end = strtotime($search['create_before']);
|
||||
$where[] = ['<=','create_at',$end];
|
||||
}
|
||||
if ($search['title']) {
|
||||
$where[] = ['LIKE','title',$search['title']];
|
||||
}
|
||||
}
|
||||
//分页
|
||||
$orderby = ['id' => SORT_DESC];
|
||||
$Attachment = new Attachment();
|
||||
$list = $Attachment->getData($model, $where, $orderby);
|
||||
$pager = $Attachment->getPagination();
|
||||
|
||||
//附件网址前缀
|
||||
$src = Url::base(true)."/../../upload"; //在网站根目录下使用upload/pics目录;适合使用yii框架主目录入口而非绑定子域名的情形
|
||||
if ($_SERVER['DOCUMENT_ROOT'].'/upload' != Yii::getAlias("@upload")) {
|
||||
// $src = Url::toRoute(['attach/index','img'=>'']); //换用网络加载转换的方式-反应慢
|
||||
$src = Yii::$app->params['attachSrc'].Yii::$app->params['attachDir'];
|
||||
}
|
||||
|
||||
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'thumb';
|
||||
$data = [
|
||||
'list'=>$list,
|
||||
'pager' => $pager,
|
||||
'src'=>$src,
|
||||
'callback'=>$callback
|
||||
];
|
||||
$this->result('', $data, 200);
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,13 @@
|
||||
# @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
|
||||
# @Last modified time: 2024-08-09T08:59:48+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
|
||||
//主入口页
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
@@ -1,634 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-04-25T01:57:06+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:36:42+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarOwner;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcOrderPre;
|
||||
use addons\models\AcOrderStatus;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcPlat;
|
||||
use common\models\CVcode;
|
||||
use addons\models\AcContact;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
use common\models\Fans;
|
||||
|
||||
class JiaocheController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
$session = Yii::$app->session;
|
||||
$pid = $session->get('pid');
|
||||
$pid = 1;
|
||||
if (!$pid) {
|
||||
$return = [];
|
||||
$return['code'] = 0;
|
||||
$return['msg'] = '您正使用本系统内部接口,禁止非法链接使用!';
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '您正使用CMTS系统,本接口为内部系统接口,禁止非法链接使用!';
|
||||
$return['data']= ['total'=>0,'data'=>[],'page'=>1];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$pid = 1;
|
||||
$session = Yii::$app->session;
|
||||
$return = [];
|
||||
$model = new AcOrder();
|
||||
$where = $orwhere = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$post = Yii::$app->request->post();
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
|
||||
$CarModel = new AcCar();
|
||||
if (isset($search['carno']) && !empty($search['carno'])) {
|
||||
$search['carno'] = trim($search['carno']);
|
||||
$cars = $CarModel->find()->where(['LIKE','num_left',$search['carno']])->limit(5)->offset(0)->all(); //最多仅显示可匹配车牌号的前5个
|
||||
if (empty($cars)) {
|
||||
$return['code'] = 400;
|
||||
$return['msg'] = '未查询到相关车辆';
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
} else {
|
||||
$car_ids = [];
|
||||
foreach ($cars as $car) {
|
||||
$car_ids[] = $car->id;
|
||||
}
|
||||
$where[] = ['IN','car_id',$car_ids];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($search['city']) && !empty($search['city'])) {
|
||||
$search['city'] = trim($search['city']);
|
||||
$where[] = ['LIKE','start_city',$search['city']];
|
||||
}
|
||||
|
||||
if (isset($search['phone']) && !empty($search['phone'])) {
|
||||
$search['phone'] = trim($search['phone']);
|
||||
$orwhere = ['or',['LIKE','sender_mobiles',$search['phone']],['LIKE','receiver_mobiles',$search['phone']]];
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
$where[]=['=','deleted',$deleted];
|
||||
$where[]=['=','is_turnover',1]; //交车单
|
||||
|
||||
$data = $model->find()->where($where)->andwhere($orwhere);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '10']);
|
||||
|
||||
$_orderby = 'sign_date DESC,id DESC';
|
||||
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
|
||||
$cids = $sids = $eids = $mids = [];
|
||||
if ($res) {
|
||||
foreach ($res as $r) {
|
||||
$cids[$r->car_id] = $r->car_id;
|
||||
$sids[$r->store_id] = $r->store_id;
|
||||
$eids[$r->employee_id] = $r->employee_id;
|
||||
$mids[$r->from_mid] = $r->from_mid;
|
||||
}
|
||||
}
|
||||
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_stores = $model->find()->where(['in','id',$sids])->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
$stores[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach ($_employees as $s) {
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['in','id',$mids])->all();
|
||||
foreach ($_users as $s) {
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$model = new AcCar();
|
||||
$cars = [];
|
||||
$_cars = $model->find()->where(['in','id',$cids])->indexBy('id')->all();
|
||||
$bids = $sids =[];
|
||||
foreach ($_cars as $s) {
|
||||
$bids[] = $s->brand_id;
|
||||
$sids[] = $s->series_id;
|
||||
$cars[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
if ($cars) {
|
||||
foreach ($cars as &$car) {
|
||||
$car['title2'] = '';
|
||||
if (isset($brands[$car['brand_id']])) {
|
||||
$car['title2'] .= $brands[$car['brand_id']]['title'];
|
||||
}
|
||||
if (isset($series[$car['series_id']])) {
|
||||
$car['title2'] .= $series[$car['series_id']]['title'];
|
||||
}
|
||||
$car['number2'] = $car['num_frame'];
|
||||
if ($car['num_p']) {
|
||||
$car['number2'] = $car['num_p'];
|
||||
}
|
||||
if ($car['num_area']) {
|
||||
$car['number2'] .= $car['num_area'];
|
||||
}
|
||||
if ($car['num_left']) {
|
||||
$car['number2'] .= $car['num_left'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$orders = [];
|
||||
$unsets = ['pid','commission','commission_left','fee_truck','create_at','create_by','deleted','income','expense','fee_deliver','fee_extra','fee_insurance','fee_pickup','fee_urgent','from_bid','from_mid','is_commission','is_cwqr','is_holdon','is_over','pay_receive_pids','pay_send_pids','pre_id','remark','car_extra','thumb_b','thumb_f','thumb_l','thumb_r','thumbs','driving_lisence','videos'];
|
||||
|
||||
foreach ($res as $s) {
|
||||
$car = $cars[$s->car_id];
|
||||
$s = $s->toArray();
|
||||
if (isset($exts[$s['from_mid']])) {
|
||||
foreach ($exts[$s['from_mid']] as $col=>$val) {
|
||||
$s[$col] = $val;
|
||||
}
|
||||
}
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
|
||||
$wk = date('w', $s['sign_date']);
|
||||
$s['signdate'] = date('Y-m-d ', $s['sign_date']) . '星期'.$weekdays[$wk];
|
||||
$s['from_province'] = Yii::$app->params['regionAreas'][$s['start_province']];
|
||||
$s['to_province'] = Yii::$app->params['regionAreas'][$s['aim_province']];
|
||||
$s['car_number']= $car['number2'];
|
||||
$s['car_title'] = $car['title'];
|
||||
$s['status'] = $status[$s['status_code']];
|
||||
$orders[] = $s;
|
||||
}
|
||||
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单查询成功!';
|
||||
$return['data']= ['total'=>$data->count(),
|
||||
'data'=>[
|
||||
'orders' => $orders,
|
||||
'employees'=>$employees,
|
||||
'stores'=>$stores,
|
||||
'users'=>$users
|
||||
],
|
||||
'page'=>1];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
|
||||
$id = isset($post['oid']) ? $post['oid'] : 0;
|
||||
if ($id<=0) {
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '查询参数错误!';
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
$detail['thumbs'] = json_decode($detail['thumbs']);
|
||||
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($detail['employee_id']);
|
||||
if ($employee) {
|
||||
$detail['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
|
||||
$model = new AcCar();
|
||||
$car = $model->findOne($detail['car_id']);
|
||||
if ($car) {
|
||||
$detail['car_owner_id'] = $car->owner_id;
|
||||
$detail['car_brand_id'] = $car->brand_id;
|
||||
$detail['car_series_id'] = $car->series_id;
|
||||
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
|
||||
$detail['car_number'] = $detail['car_number'] ? $detail['car_number'] : $car->num_frame;
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$user = $model->findOne($detail['from_mid']);
|
||||
|
||||
$model = new AcUserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach ($_exts as $ext) {
|
||||
$ext = $ext->toArray();
|
||||
if (isset($users[$s['id']])) {
|
||||
if ($ext['mobile']==$user->mobile) {
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$AcCarOwner = new AcCarOwner();
|
||||
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
|
||||
if ($owner) {
|
||||
$_owner = User::findOne($detail['car_owner_id']);
|
||||
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
|
||||
}
|
||||
|
||||
$AcCarBrand = new AcCarBrand();
|
||||
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
|
||||
if ($brand) {
|
||||
$detail['car_title'] = $brand->title;
|
||||
}
|
||||
|
||||
$AcCarSeries = new AcCarSeries();
|
||||
$where = [];
|
||||
$series= $AcCarSeries->findOne($detail['car_series_id']);
|
||||
if ($series) {
|
||||
$detail['car_title'] .= $series->title;
|
||||
}
|
||||
|
||||
$sn = '00000000000'; //11位
|
||||
$sn = substr($sn, 0, 11-strlen($id));
|
||||
$sn .=$id;
|
||||
$detail['sn'] = $sn;
|
||||
|
||||
$detail['signdate'] = date('Y-m-d 星期w', $detail['sign_date']);
|
||||
$detail['from_province'] = Yii::$app->params['regionAreas'][$detail['start_province']];
|
||||
$detail['to_province'] = Yii::$app->params['regionAreas'][$detail['aim_province']];
|
||||
$detail['remark'] = htmlspecialchars_decode($detail['remark']);
|
||||
|
||||
// $src = 'http://'.$_SERVER["HTTP_HOST"].'/upload';
|
||||
// $detail['thumb_b'] = $src.$detail['thumb_b'];
|
||||
|
||||
$unsets = ['commission','commission_left','fee_truck','create_at','create_by','deleted','income','expense','fee_deliver','fee_extra','fee_insurance','fee_pickup','fee_urgent','from_bid','from_mid','is_commission','is_cwqr','is_holdon','is_over','pay_receive_pids','pay_send_pids','pre_id'];
|
||||
foreach ($unsets as $us) {
|
||||
unset($detail[$us]);
|
||||
}
|
||||
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单查询成功!';
|
||||
$return['data']= $detail;
|
||||
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$pid = (int)$post['pid'];
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
//目标键=》POST键
|
||||
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city','aim_address'=>'aim_address',
|
||||
'signer'=>'signer','bind'=>'bind','wtdw'=>"wtdw",
|
||||
'sender_name'=>'sender_name','sender_idcard'=>'sender_idcard','sender_mobiles'=>'sender_mobiles',
|
||||
'receiver_name'=>'receiver_name','receiver_idcard'=>'receiver_idcard','receiver_mobiles'=>'receiver_mobiles',
|
||||
'car_extra'=>'car_extra'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
//'car_id'=>'car_id','employee_id'=>'employee_id',
|
||||
//'weituo'=>'weituo'
|
||||
$cols = ['car_value'=>'car_value','fee_insurance'=>'fee_insurance','fee_truck'=>'fee_truck','fee_deliver'=>'fee_deliver','fee_pickup'=>'fee_pickup','fee_urgent'=>'fee_urgent','fee_extra'=>'fee_extra','fee_total'=>'fee_total','pay_send'=>'pay_send','pay_receive'=>'pay_receive','not_insurance'=>'not_insurance',];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = 0;
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = (int)$post[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['remark'=>'remark'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
if (isset($post[$key]) && $post[$key] !='') {
|
||||
$data[$col] = htmlspecialchars($post[$key]);
|
||||
}
|
||||
}
|
||||
$data['remark'] = isset($data['remark']) ? isset($data['remark']) : '';
|
||||
|
||||
/*@sign_date: 1649952000000*/
|
||||
$sign_date = isset($post['sign_date']) ? strtotime($post['sign_date']/1000) : '';
|
||||
$data['sign_date'] = $sign_date ? $sign_date : time();
|
||||
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 11 ; //11是方孟
|
||||
$data['create_by'] = $mid;
|
||||
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
|
||||
$data['is_turnover'] = 1; //交车补单
|
||||
$data['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
//部分规则校验
|
||||
$fee_total = $data['fee_truck']+$data['fee_insurance']+$data['fee_deliver']+$data['fee_pickup']+$data['fee_urgent']+$data['fee_extra'];
|
||||
$fee_pay = $data['pay_send']+$data['pay_receive'];
|
||||
if (!$data['fee_truck']) {
|
||||
$return = [];
|
||||
$return['code'] = 100;
|
||||
$return['msg'] = '请注意,运费未正确填写!';
|
||||
$return['data']= [];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
if ($fee_total !=$data['fee_total']) {
|
||||
$return = [];
|
||||
$return['code'] = 100;
|
||||
$return['msg'] = '所填各项费用汇总的值与所填写的总费用不一致!';
|
||||
$return['data']= [];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
if ($fee_pay !=$data['fee_total']) {
|
||||
$return = [];
|
||||
$return['code'] = 100;
|
||||
$return['msg'] = '所填现付与到收费用汇总的值与所填写的总费用不一致!';
|
||||
$return['data']= [];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
|
||||
$data['employee_id'] = isset($post['employee_id']) ? (int)$post['employee_id'] : 0;
|
||||
$data['store_id'] = 0;
|
||||
$model = new AcEmployee();
|
||||
$employee = $model->findOne($data['employee_id']);
|
||||
if ($employee) {
|
||||
$data['store_id'] = $employee->store_id;
|
||||
}
|
||||
|
||||
//校验生成部分补充数据
|
||||
//生成现付说明
|
||||
$payments = [
|
||||
'wechat'=>'微信',
|
||||
'alipay'=>'支付宝',
|
||||
'cash'=>'现金',
|
||||
'bankcard'=>'银行卡',
|
||||
'bankunion'=>'银联',
|
||||
'others'=>'其他'
|
||||
];
|
||||
if ($post['pay_send']) {
|
||||
$txt = $post['payto'].'收款'.$post['pay_send'].'元('.$payments[$post['payment']].')';
|
||||
$data['remark'] .= ' ; '.$txt;
|
||||
}
|
||||
//生成车辆信息
|
||||
$carModel = new AcCar();
|
||||
$where = [];
|
||||
if ($post['isTempCarno']) {
|
||||
$post['carno_left'] .='临';
|
||||
}
|
||||
if (empty($post['carno_frame'])) {
|
||||
$where['num_p'] = $post['carno_p'];
|
||||
$where['num_area'] = $post['carno_area'];
|
||||
$where['num_left'] = $post['carno_left'];
|
||||
}
|
||||
if (!empty($post['carno_frame'])) {
|
||||
$where['num_frame'] = $post['carno_frame'];
|
||||
}
|
||||
$car = $carModel->find()->where($where)->one();
|
||||
if (empty($car)) {
|
||||
$carModel->pid = $pid;
|
||||
$carModel->num_frame = $post['carno_frame'];
|
||||
$carModel->num_p = $post['carno_p'];
|
||||
$carModel->num_area = $post['carno_area'];
|
||||
$carModel->num_left = $post['carno_left'];
|
||||
$carModel->title = $post['carno_title'];
|
||||
$carModel->status_code = 1;
|
||||
$carModel->create_at = time();
|
||||
$carModel->update_at = time();
|
||||
$carModel->save();
|
||||
$car_id = $carModel->attributes['id'];
|
||||
} else {
|
||||
$car_id = $car->id;
|
||||
}
|
||||
$data['car_id'] = $car_id;
|
||||
|
||||
//查询联系人信息是否在库
|
||||
$sender_mobiles = isset($data['sender_mobiles']) ? $data['sender_mobiles'] : null;
|
||||
$receiver_mobiles = isset($data['receiver_mobiles']) ? $data['receiver_mobiles'] : null;
|
||||
if ($sender_mobiles) {
|
||||
//项目分支自有数据表
|
||||
$contactModel = new AcContact();
|
||||
$contactor = $contactModel->find()->where(['mobile'=>$data['sender_mobiles'],'pid'=>$pid])->one();
|
||||
if (empty($contactor)) {
|
||||
$contactModel->name = isset($data['sender_name']) ? $data['sender_name'] : '客户';
|
||||
$contactModel->mobile = $data['sender_mobiles'];
|
||||
$contactModel->pid = $pid;
|
||||
$contactModel->idcard = isset($data['sender_idcard']) ? $data['sender_idcard'] : '';
|
||||
$contactModel->create_at = time();
|
||||
$contactModel->status_code = 1;
|
||||
$contactModel->save();
|
||||
} else {
|
||||
$_contactDatas = [];
|
||||
$_contactDatas['name'] = isset($data['sender_name']) ? $data['sender_name'] : $contactModel->name;
|
||||
$_contactDatas['idcard'] = isset($data['idcard']) ? $data['idcard'] : $contactModel->idcard;
|
||||
if ($_contactDatas['name']==$contactModel->name && $_contactDatas['idcard'] ==$contactModel->idcard) {
|
||||
//无须做任何变化
|
||||
} else {
|
||||
$_contactDatas['update_at'] = time();
|
||||
$contactModel->updateAll($_contactDatas, ['id'=>$contactModel->id]);
|
||||
}
|
||||
}
|
||||
|
||||
//框架核心数据表Fans
|
||||
$userModel = new Fans();
|
||||
$user = $userModel->findByUsername($sender_mobiles);
|
||||
if (empty($user)) {
|
||||
$userModel->mobile = $sender_mobiles;
|
||||
$userModel->email = $sender_mobiles.'@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = 'ctms';
|
||||
$userModel->save();
|
||||
}
|
||||
}
|
||||
if ($receiver_mobiles && $receiver_mobiles != $sender_mobiles) {
|
||||
//项目分支自有数据表
|
||||
$contactModel2 = new AcContact();
|
||||
$contactor2 = $contactModel2->find()->where(['mobile'=>$data['receiver_mobiles'],'pid'=>$pid])->one();
|
||||
if (empty($contactor2)) {
|
||||
$contactModel2->name = isset($data['receiver_name']) ? $data['receiver_name'] : '客户';
|
||||
$contactModel2->mobile = $data['receiver_mobiles'];
|
||||
$contactModel2->pid = $pid;
|
||||
$contactModel2->idcard = isset($data['receiver_idcard']) ? $data['receiver_idcard'] : '';
|
||||
$contactModel2->create_at = time();
|
||||
$contactModel2->status_code = 1;
|
||||
$contactModel2->save();
|
||||
} else {
|
||||
$_contactDatas = [];
|
||||
$_contactDatas['name'] = isset($data['receiver_name']) ? $data['receiver_name'] : $contactModel2->name;
|
||||
$_contactDatas['idcard'] = isset($data['idcard']) ? $data['idcard'] : $contactModel2->idcard;
|
||||
if ($_contactDatas['name']==$contactModel2->name && $_contactDatas['idcard'] ==$contactModel2->idcard) {
|
||||
//无须做任何变化
|
||||
} else {
|
||||
$_contactDatas['update_at'] = time();
|
||||
$contactModel2->updateAll($_contactDatas, ['id'=>$contactModel2->id]);
|
||||
}
|
||||
}
|
||||
//框架核心数据表Fans
|
||||
$userModel = new Fans();
|
||||
$user = $userModel->findByUsername($receiver_mobiles);
|
||||
if (empty($user)) {
|
||||
$userModel->mobile = $receiver_mobiles;
|
||||
$userModel->email = $receiver_mobiles.'@hiluker.com';
|
||||
$userModel->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = 'ctms';
|
||||
$userModel->save();
|
||||
}
|
||||
}
|
||||
|
||||
//保存资料
|
||||
$AcOrder = new AcOrder();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcOrder->$key = $val;
|
||||
}
|
||||
|
||||
$res = $AcOrder->save();
|
||||
$id = $AcOrder->attributes['id']; //获取插入后id
|
||||
|
||||
if ($res) {
|
||||
$return = [];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '订单保存成功!';
|
||||
$return['data']= ['id'=>$id];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
} else {
|
||||
$return = [];
|
||||
$return['code'] = 100;
|
||||
$return['msg'] = '订单保存失败!';
|
||||
$return['data']= [];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcOrder();
|
||||
$res = $model->findOne($id);
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //几秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
|
||||
if (!$res) {
|
||||
$return['msg'] = '订单数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
} else {
|
||||
$order = $res;
|
||||
if ($order->deleted>0) {
|
||||
$return['msg'] = '订单已被删除了,无法操作';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'cancel':
|
||||
if ($order->is_cwqr>0) {
|
||||
$return['msg'] = '订单已入账,请先联系财务销账后再取消';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($order->status_code>1) {
|
||||
$return['msg'] = '订单已进入运输后流程,无法操作取消';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($order->status_code==-1) {
|
||||
$return['msg'] = '订单已经是被取消状态';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$data['status_code'] = -1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '订单取消成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'btn-info'];
|
||||
} else {
|
||||
$return['msg'] = '订单取消失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'truckcar':
|
||||
if ($order->status_code==-1) {
|
||||
$return['msg'] = '订单已被取消,不能承运';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($order->status_code!=1) {
|
||||
$return['msg'] = '订单当前非初始状态(协议签订),不可作承运处理';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$data['status_code'] = 5;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '订单已转为待承运状态';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '订单标记失败,请稍后再试';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-03T15:34:01+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:02+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNews;
|
||||
use addons\models\AcNewsCat;
|
||||
use Yii;use yii\data\Pagination;
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class NewsController extends Common
|
||||
@@ -12,7 +20,7 @@ class NewsController extends Common
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
@@ -29,20 +37,20 @@ class NewsController extends Common
|
||||
//订单列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search(['is_show'=>1]);
|
||||
$s = $this->search(['is_show' => 1]);
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
|
||||
$return = [
|
||||
'total'=>$data->count(),
|
||||
'news' => $list,
|
||||
'page'=>$this->page
|
||||
];
|
||||
$this->result('内容查询成功!',$return,200);
|
||||
$this->result('内容查询成功!', $return, 200);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
@@ -56,7 +64,7 @@ class NewsController extends Common
|
||||
}
|
||||
$model = new AcNews();
|
||||
$detail = $model->findOne($id);
|
||||
$s = $this->formatDetail($detail->toArray());
|
||||
$s = $this->formatDetail($detail->toArray());
|
||||
$this->result('查询成功!', $s, 200);
|
||||
}
|
||||
|
||||
@@ -69,39 +77,39 @@ class NewsController extends Common
|
||||
}
|
||||
$model = new AcNews();
|
||||
$detail = $model->findOne($id);
|
||||
if (!$detail) {
|
||||
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;
|
||||
}
|
||||
$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());
|
||||
$data = $this->formatDetail($detail->toArray());
|
||||
$this->result('已执行', $data, 200);
|
||||
}
|
||||
|
||||
@@ -113,36 +121,36 @@ class NewsController extends Common
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 优先处理$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'].'%';
|
||||
$params[':title'] = '%' . $search['title'] . '%';
|
||||
}
|
||||
if (!empty($search['cid'])) {
|
||||
if (!empty($search['cid'])) {
|
||||
$search['cid'] = intval($search['cid']);
|
||||
$where .= ' AND `cid` = :cid';
|
||||
$params[':cid'] = $search['cid'];
|
||||
$params[':cid'] = $search['cid'];
|
||||
}
|
||||
|
||||
if(!isset($params[':deleted'])){
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' AND `deleted` = :deleted';
|
||||
}
|
||||
|
||||
|
||||
if (!isset($params[':deleted'])) {
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' AND `deleted` = :deleted';
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where,$params);
|
||||
$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';
|
||||
@@ -153,43 +161,41 @@ class NewsController extends Common
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted'];
|
||||
$list = [];
|
||||
$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;
|
||||
|
||||
$s['content'] = $s['content'] ? htmlspecialchars_decode($s['content']) : '';
|
||||
|
||||
$list[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s=[])
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNewsCat;use yii\data\Pagination;
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-03T16:38:33+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T08:59:58+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNewsCat;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class NewscatController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
@@ -25,19 +33,19 @@ class NewscatController extends Common
|
||||
//列表
|
||||
public function actionList()
|
||||
{
|
||||
$s = $this->search(['is_show'=>1]);
|
||||
$s = $this->search(['is_show' => 1]);
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
|
||||
$return = [
|
||||
'cats' => $list
|
||||
];
|
||||
$this->result('通知查询成功!',$return,200);
|
||||
$this->result('通知查询成功!', $return, 200);
|
||||
}
|
||||
|
||||
|
||||
private function search($ops=[])
|
||||
{
|
||||
$pid = $this->pid;
|
||||
@@ -46,31 +54,31 @@ class NewscatController extends Common
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 优先处理$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'];
|
||||
$params[':title'] = $search['title'];
|
||||
}
|
||||
|
||||
if(!isset($params[':deleted'])){
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' & deleted = :deleted';
|
||||
}
|
||||
|
||||
|
||||
if (!isset($params[':deleted'])) {
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' & deleted = :deleted';
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
$pageSize = 10;
|
||||
$data = $model->find()->where($where,$params);
|
||||
$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';
|
||||
@@ -81,31 +89,29 @@ class NewscatController extends Common
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted','update_at'];
|
||||
$list = [];
|
||||
$list = [];
|
||||
foreach ($res as $s) {
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
}
|
||||
$list[] = $s;
|
||||
$list[] = $s;
|
||||
}
|
||||
unset($s);
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s=[])
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNotice;use yii\data\Pagination;
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2024-08-02T01:08:31+08:00
|
||||
# @Email: 1280880631@qq.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:00:06+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcNotice;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class NoticeController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
@@ -29,18 +37,18 @@ class NoticeController extends Common
|
||||
// $s = $this->search(['is_show'=>1]);
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$list = $this->formatList($res);
|
||||
|
||||
$return = [
|
||||
|
||||
$return = [
|
||||
'total'=>$data->count(),
|
||||
'notices' => $list,
|
||||
'page'=>$this->page
|
||||
];
|
||||
$this->result('通知查询成功!',$return,200);
|
||||
$this->result('通知查询成功!', $return, 200);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
@@ -54,7 +62,7 @@ class NoticeController extends Common
|
||||
}
|
||||
$model = new AcNotice();
|
||||
$detail = $model->findOne($id);
|
||||
$s = $this->formatDetail($detail->toArray());
|
||||
$s = $this->formatDetail($detail->toArray());
|
||||
$this->result('查询成功!', $s, 200);
|
||||
}
|
||||
|
||||
@@ -66,31 +74,31 @@ class NoticeController extends Common
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 优先处理$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'];
|
||||
$params[':title'] = $search['title'];
|
||||
}
|
||||
|
||||
if(!isset($params[':deleted'])){
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' & deleted = :deleted';
|
||||
}
|
||||
|
||||
|
||||
if (!isset($params[':deleted'])) {
|
||||
$params[':deleted'] = 0;
|
||||
$where .= ' & deleted = :deleted';
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$data = $model->find()->where($where,$params);
|
||||
$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';
|
||||
@@ -101,15 +109,14 @@ class NoticeController extends Common
|
||||
|
||||
private function formatList($res)
|
||||
{
|
||||
|
||||
$unsets = ['pid','create_at','deleted'];
|
||||
$list = [];
|
||||
$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];
|
||||
@@ -120,16 +127,15 @@ class NoticeController extends Common
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function formatDetail($s=[])
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-13T09:20:03+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-21T09:28:23+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
|
||||
//主入口页
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
|
||||
use vendor\huawei\obsclient\Hwobs;
|
||||
use vendor\huawei\obsclient\TemporarySignature;
|
||||
use vendor\huawei\obsclient\PostObject;
|
||||
|
||||
class ObsController extends Common
|
||||
{
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'getkey'=>'获取访问Key',
|
||||
];
|
||||
$this->result('您正使用CMTS系统-华为云OBS接口!', $apis, 200);
|
||||
}
|
||||
|
||||
private function getconf()
|
||||
{
|
||||
return [
|
||||
'id'=> 'ee124c5102064b83bccd2fdda53261cc', //账号ID
|
||||
'ak'=> '1DYBXUNEPNCIEEQOGGAE',
|
||||
'sk'=> '0VBI2xPlDB0NtqqVJv3hSFC8DY52G8OYPYNhncGK',
|
||||
'area'=>'cn-south-1', //华南广州
|
||||
'endpoint'=>'obs.cn-south-1.myhuaweicloud.com',
|
||||
'bucketName'=>'hilu-ctms',
|
||||
];
|
||||
}
|
||||
|
||||
public function actionGetkey()
|
||||
{
|
||||
$params = $this->getconf();
|
||||
$obs = new Hwobs($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
|
||||
}
|
||||
|
||||
public function actionGeturl()
|
||||
{
|
||||
$params = $this->getconf();
|
||||
$obs = new TemporarySignature($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
|
||||
$res = $obs->UploadUrl($params['bucketName']);
|
||||
// $res = $obs->getCors($params['bucketName']);
|
||||
var_dump($res);
|
||||
// $this->result('获取上传网址成功!', $res, 200);
|
||||
}
|
||||
|
||||
public function actionGetform()
|
||||
{
|
||||
$params = $this->getconf();
|
||||
$obs = new PostObject($ak=$params['ak'], $sk=$params['sk'], $endpoint=$params['endpoint'], $t1=30, $t2=10);
|
||||
$obs->init('obs');
|
||||
$res = $obs->claimPost('hilu-ctms', 'file.jpg');
|
||||
$url = 'https://'.$params['bucketName'].".".$params['endpoint'];
|
||||
$res['up_url'] = $url;
|
||||
$this->result('获取OBS上传准备信息!', $res, 200);
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,14 @@
|
||||
# @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
|
||||
# @Last modified time: 2024-08-09T09:00:15+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
namespace api\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;
|
||||
@@ -37,7 +36,7 @@ class OrderController extends Common
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
// $this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
@@ -57,8 +56,8 @@ class OrderController extends Common
|
||||
{
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$this->showOrder($res, $data);
|
||||
@@ -69,8 +68,8 @@ class OrderController extends Common
|
||||
$pid = $this->pid;
|
||||
$status = Yii::$app->params['OrderStatus'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['oid']) ? $post['oid'] : 0;
|
||||
|
||||
$id = $post['oid'] ?? 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
@@ -101,11 +100,11 @@ class OrderController extends Common
|
||||
$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();
|
||||
|
||||
$model = new Fans();
|
||||
$user = $model->findOne($detail['from_mid']);
|
||||
|
||||
$model = new AcUserExt();
|
||||
|
||||
$model = new AcFansExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach ($_exts as $ext) {
|
||||
@@ -184,8 +183,8 @@ class OrderController extends Common
|
||||
|
||||
$this->result('订单查询成功!', $detail, 200);
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
|
||||
public function actionCreate($contactModel2)
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
@@ -218,16 +217,22 @@ class OrderController extends Common
|
||||
$data[$col] = htmlspecialchars($post[$key]);
|
||||
}
|
||||
}
|
||||
$data['remark'] = isset($data['remark']) ? isset($data['remark']) : '';
|
||||
$data['remark'] = $data['remark'] ?? '';
|
||||
|
||||
/*@sign_date: 1649952000000*/
|
||||
$sign_date = isset($post['sign_date']) ? $post['sign_date']/1000 : '';
|
||||
$data['sign_date'] = $sign_date ? $sign_date : time();
|
||||
$data['sign_date'] = $sign_date ? $sign_date : TIMESTAMP;
|
||||
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 11 ; //11是方孟
|
||||
// 指派运单的创建人(平台管理员ID)
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 0; //11是方孟
|
||||
$data['create_by'] = $mid;
|
||||
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
|
||||
|
||||
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
|
||||
$data['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
//关联运单前台用户;fans表
|
||||
$fid = $this->user_id;
|
||||
$data['from_mid'] = $fid;
|
||||
|
||||
//部分规则校验
|
||||
$hasError = 0;
|
||||
@@ -289,7 +294,7 @@ class OrderController extends Common
|
||||
$where['num_area'] = $post['carno_area'];
|
||||
$where['num_left'] = $post['carno_left'];
|
||||
}
|
||||
$post['carno_frame'] = isset($post['carno_frame']) ? $post['carno_frame'] : '';
|
||||
$post['carno_frame'] = $post['carno_frame'] ?? '';
|
||||
if (!empty($post['carno_frame'])) {
|
||||
$where['num_frame'] = $post['carno_frame'];
|
||||
}
|
||||
@@ -301,10 +306,9 @@ class OrderController extends Common
|
||||
$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->create_at = TIMESTAMP;
|
||||
$carModel->update_at = TIMESTAMP;
|
||||
$carModel->save();
|
||||
$car_id = $carModel->attributes['id'];
|
||||
} else {
|
||||
@@ -313,79 +317,83 @@ class OrderController extends Common
|
||||
$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();
|
||||
//框架核心数据表Fans
|
||||
$userModel = new Fans();
|
||||
//项目分支自有数据表
|
||||
$contactModel = new AcContact();
|
||||
$sender_mobiles = $data['sender_mobiles'] ?? NULL;
|
||||
$receiver_mobiles = $data['receiver_mobiles'] ?? NULL;
|
||||
if ($sender_mobiles) {
|
||||
//项目分支自有数据表
|
||||
$_model = clone $contactModel;
|
||||
$contactor = $_model->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();
|
||||
$_model->name = $data['sender_name'] ?? '客户';
|
||||
$_model->mobile = $data['sender_mobiles'];
|
||||
$_model->pid = $pid;
|
||||
$_model->idcard = $data['sender_idcard'] ?? '';
|
||||
$_model->create_at = TIMESTAMP;
|
||||
$_model->status_code = 1;
|
||||
$_model->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) {
|
||||
$_contactDatas['name'] = $data['sender_name'] ?? $contactor->name;
|
||||
$_contactDatas['idcard'] = $data['idcard'] ?? $contactor->idcard;
|
||||
if ($_contactDatas['name'] == $contactor->name && $_contactDatas['idcard'] == $contactor->idcard) {
|
||||
//无须做任何变化
|
||||
} else {
|
||||
$_contactDatas['update_at'] = time();
|
||||
$contactModel->updateAll($_contactDatas, ['id'=>$contactModel->id]);
|
||||
$contactModel->updateAll($_contactDatas, ['id' => $contactor->id]);
|
||||
}
|
||||
}
|
||||
|
||||
//框架核心数据表Fans
|
||||
$userModel = new Fans();
|
||||
$user = $userModel->findByUsername($sender_mobiles);
|
||||
$_model = clone $userModel;
|
||||
$user = $_model->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();
|
||||
$_model->mobile = $sender_mobiles;
|
||||
$_model->email = $sender_mobiles . '@hiluker.com';
|
||||
$_model->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$_model->generateAuthKey();
|
||||
$_model->created_at = TIMESTAMP;
|
||||
$_model->from = Yii::$app->params['fansFrom'];;
|
||||
$_model->save();
|
||||
}
|
||||
}
|
||||
if ($receiver_mobiles && $receiver_mobiles != $sender_mobiles) {
|
||||
//项目分支自有数据表
|
||||
$contactModel2 = new AcContact();
|
||||
$contactor2 = $contactModel2->find()->where(['mobile'=>$data['receiver_mobiles'],'pid'=>$pid])->one();
|
||||
$_model = clone $contactModel;
|
||||
$contactor2 = $_model->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();
|
||||
$_model->name = $data['receiver_name'] ?? '客户';
|
||||
$_model->mobile = $data['receiver_mobiles'];
|
||||
$_model->pid = $pid;
|
||||
$_model->idcard = $data['receiver_idcard'] ?? '';
|
||||
$_model->create_at = TIMESTAMP;
|
||||
$_model->status_code = 1;
|
||||
$_model->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) {
|
||||
$_contactDatas['name'] = $data['receiver_name'] ?? $contactor2->name;
|
||||
$_contactDatas['idcard'] = $data['idcard'] ?? $contactor2->idcard;
|
||||
if ($_contactDatas['name'] == $contactor2->name && $_contactDatas['idcard'] == $contactor2->idcard) {
|
||||
//无须做任何变化
|
||||
} else {
|
||||
$_contactDatas['update_at'] = time();
|
||||
$contactModel2->updateAll($_contactDatas, ['id'=>$contactModel2->id]);
|
||||
$contactor2->updateAll($_contactDatas, ['id' => $contactor2->id]);
|
||||
}
|
||||
}
|
||||
//框架核心数据表Fans
|
||||
$userModel = new Fans();
|
||||
$user = $userModel->findByUsername($receiver_mobiles);
|
||||
$_model = clone $userModel;
|
||||
$user = $_model->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();
|
||||
$_model->mobile = $receiver_mobiles;
|
||||
$_model->email = $receiver_mobiles . '@hiluker.com';
|
||||
$_model->setPassword(Yii::$app->params['defaultFansPassword']);
|
||||
$_model->generateAuthKey();
|
||||
$_model->created_at = TIMESTAMP;
|
||||
$_model->from = Yii::$app->params['fansFrom'];;
|
||||
$_model->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,14 +411,13 @@ class OrderController extends Common
|
||||
$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));
|
||||
}
|
||||
$this->result($return['msg'], $return['data'], $return['code']);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
@@ -422,19 +429,19 @@ class OrderController extends Common
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
$search = $post['search'] ?? [];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$search['phone'] = $this->user_info->mobile;
|
||||
$orwhere = ['or',['LIKE','sender_mobiles',$search['phone']],['LIKE','receiver_mobiles',$search['phone']]];
|
||||
|
||||
$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();
|
||||
$cars = $CarModel->find()->where($sql, [':carno' => $search['carno']])->limit(5)->offset(0)->all();
|
||||
|
||||
//最多仅显示可匹配车牌号的前5个
|
||||
if (empty($cars)) {
|
||||
@@ -449,12 +456,12 @@ class OrderController extends Common
|
||||
$where[] = ['IN','car_id',$car_ids];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($search['city']) && !empty($search['city'])) {
|
||||
|
||||
if (!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'])) {
|
||||
@@ -463,7 +470,7 @@ class OrderController extends Common
|
||||
$search['employee_title'] = isset($employee->name) ? $employee->name : '';
|
||||
}
|
||||
$search['store_id'] = isset($search['store_id']) ? (int)$search['store_id'] : '';
|
||||
if (empty($search['sotre_id'])) {
|
||||
if (empty($search['store_id'])) {
|
||||
$search['store_id'] = isset($get['store_id']) ? (int)$get['store_id'] : 0;
|
||||
}
|
||||
$StoreModel = new AcStore();
|
||||
@@ -472,7 +479,7 @@ class OrderController extends Common
|
||||
$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']];
|
||||
@@ -531,12 +538,10 @@ class OrderController extends Common
|
||||
$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'] : '';
|
||||
}
|
||||
//运单是否通过了财务确认
|
||||
$search['is_cwqr'] = $search['is_cwqr'] ?? ($get['is_cwqr'] ?? '');
|
||||
if ($search['is_cwqr'] !='') {
|
||||
$search['is_cwqr'] = (int)$get['is_cwqr'];
|
||||
$search['is_cwqr'] = (int)$search['is_cwqr'];
|
||||
$where[] = ['=','is_cwqr',$search['is_cwqr']];
|
||||
}
|
||||
|
||||
@@ -567,9 +572,9 @@ class OrderController extends Common
|
||||
$end = strtotime($search['sign_before']);
|
||||
$where[] = ['<=','sign_date',$end];
|
||||
}
|
||||
|
||||
|
||||
//带序列号搜索(TBD:后期考虑改为精准唯一搜索)
|
||||
if(isset($search['sn']) && $search['sn'] != 'undefined' && $search['sn']){
|
||||
if (isset($search['sn']) && $search['sn'] != 'undefined' && $search['sn']) {
|
||||
$where[] = ['LIKE','sn',$search['sn']];
|
||||
}
|
||||
|
||||
@@ -607,7 +612,7 @@ class OrderController extends Common
|
||||
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['pid'] = $this->pid;
|
||||
$_stores = $model->find()->where(['in','id',$sids])->all();
|
||||
$stores = [];
|
||||
foreach ($_stores as $s) {
|
||||
@@ -620,8 +625,8 @@ class OrderController extends Common
|
||||
foreach ($_employees as $s) {
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
|
||||
$model = new Fans();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['in','id',$mids])->all();
|
||||
foreach ($_users as $s) {
|
||||
@@ -673,7 +678,9 @@ class OrderController extends Common
|
||||
|
||||
foreach ($orderRes as $s) {
|
||||
$car = [];
|
||||
if($s->car_id) $car = $cars[$s->car_id];
|
||||
if ($s->car_id) {
|
||||
$car = $cars[$s->car_id];
|
||||
}
|
||||
$s = $s->toArray();
|
||||
foreach ($unsets as $us) {
|
||||
unset($s[$us]);
|
||||
@@ -683,9 +690,9 @@ class OrderController extends Common
|
||||
$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['car_number'] = $car['number2'] ?? '';
|
||||
$s['car_title'] = $car['title'] ?? '';
|
||||
$s['car_title'] = $s['car_title'] ? $s['car_title'] : ($car['title2'] ?? '');
|
||||
$s['status'] = $status[$s['status_code']];
|
||||
$orders[] = $s;
|
||||
}
|
||||
@@ -702,6 +709,6 @@ class OrderController extends Common
|
||||
'users'=>$users,
|
||||
'page'=>$this->page
|
||||
];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
$this->result($return['msg'], $return['data'], $return['code']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
# @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
|
||||
# @Last modified time: 2024-08-09T09:00:10+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
@@ -184,7 +184,7 @@ class OrdercheckController extends Common
|
||||
$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) {
|
||||
if ($hasChange) {
|
||||
$order->is_checked = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
# @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
|
||||
# @Last modified time: 2024-08-09T09:00:19+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcOrderPre;
|
||||
@@ -20,7 +20,7 @@ class OrderpreController extends Common
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
@@ -40,8 +40,8 @@ class OrderpreController extends Common
|
||||
{
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if(!$res){
|
||||
$this->result('没有查询到相应的数据!',[],0);
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data = $s['data'];
|
||||
$this->showOrder($res, $data);
|
||||
@@ -55,14 +55,14 @@ class OrderpreController extends Common
|
||||
$where = $orwhere = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$where[] = ['=','from_uid',$this->user_id];
|
||||
//预置搜索条件,只允许查询与自己完全相关的订单
|
||||
$where[] = ['=', 'from_uid', $this->user_id];
|
||||
$search['phone'] = $this->user_info->mobile;
|
||||
$where[] = ['=','from_mobile',$search['phone']];
|
||||
|
||||
$where[] = ['=', 'from_mobile', $search['phone']];
|
||||
|
||||
if (isset($search['carno']) && !empty($search['carno'])) {
|
||||
$search['carno'] = trim($search['carno']);
|
||||
$where[] = ['LIKE','car_no',$search['carno']];
|
||||
@@ -94,7 +94,7 @@ class OrderpreController extends Common
|
||||
$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']];
|
||||
@@ -111,7 +111,7 @@ class OrderpreController extends Common
|
||||
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']];
|
||||
@@ -215,23 +215,23 @@ class OrderpreController extends Common
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
$order = $AcOrderPre->findOne($id);
|
||||
$detail = $order->toArray();
|
||||
|
||||
if($detail['store_id']){
|
||||
|
||||
if ($detail['store_id']) {
|
||||
$model = new AcStore();
|
||||
$store = $model->findOne($detail['store_id']);
|
||||
if ($store) {
|
||||
$detail['store_title'] = $store->title;
|
||||
}
|
||||
}
|
||||
|
||||
if($detail['employee_id']){
|
||||
|
||||
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;
|
||||
@@ -262,10 +262,10 @@ class OrderpreController extends Common
|
||||
}
|
||||
$AcOrderPre = new AcOrderPre();
|
||||
$order = $AcOrderPre->findOne($id);
|
||||
if($order->from_uid != $this->user_id){
|
||||
if ($order->from_uid != $this->user_id) {
|
||||
$this->result('非本人订单,不允许操作!');
|
||||
}
|
||||
if($order->status_code <= 0 || $order->status_code >= 99 ){
|
||||
if ($order->status_code <= 0 || $order->status_code >= 99) {
|
||||
$this->result('订单已取消或已经完成,不允许操作!');
|
||||
}
|
||||
$order->status_code = -1;
|
||||
@@ -297,7 +297,7 @@ class OrderpreController extends Common
|
||||
$data[$col] = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cols = ['car_value'=>'car_value','from_gender'=>'from_gender'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = 0;
|
||||
@@ -319,7 +319,7 @@ class OrderpreController extends Common
|
||||
|
||||
$mid = isset($post['mid']) ? (int)$post['mid'] : 0 ;
|
||||
$data['from_mid'] = $mid;
|
||||
|
||||
|
||||
$data['status_code'] = 1; //订单处于创建待审核状态
|
||||
|
||||
$data['create_at'] = time();
|
||||
@@ -328,7 +328,7 @@ class OrderpreController extends Common
|
||||
|
||||
$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) {
|
||||
@@ -339,9 +339,9 @@ class OrderpreController extends Common
|
||||
$id = $AcOrderPre->attributes['id']; //获取插入后id
|
||||
|
||||
if ($res) {
|
||||
$this->result('询单保存成功!',['id'=>$id],200);
|
||||
$this->result('询单保存成功!', ['id' => $id], 200);
|
||||
} else {
|
||||
$this->result('询单保存失败!',[],100);
|
||||
$this->result('询单保存失败!', [], 100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,24 +359,24 @@ class OrderpreController extends Common
|
||||
$get = Yii::$app->request->get();
|
||||
$post = $this->postdata;
|
||||
$id = isset($post['id']) ? (int)$post['id'] : 0;
|
||||
if(!$id){
|
||||
if (!$id) {
|
||||
$this->result('未指定询价单!');
|
||||
}
|
||||
$model = new AcOrderPre();
|
||||
$detail = $model->findOne($id);
|
||||
if(!$detail){
|
||||
if (!$detail) {
|
||||
$this->result('询价单信息不存在!');
|
||||
}
|
||||
if($detail->pid != $this->pid){
|
||||
if ($detail->pid != $this->pid) {
|
||||
$this->result('非法操作!');
|
||||
}
|
||||
if($detail->from_uid != $this->user_id){
|
||||
if ($detail->from_uid != $this->user_id) {
|
||||
$this->result('非法操作,请检查订单归属!');
|
||||
}
|
||||
|
||||
//格式化数据 为空的项则不修改
|
||||
|
||||
//目标键=》POST键
|
||||
|
||||
//目标键=》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',
|
||||
@@ -386,8 +386,8 @@ class OrderpreController extends Common
|
||||
$detail->$col = trim($post[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['car_value'=>'car_value','from_gender'=>'from_gender'];
|
||||
|
||||
$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];
|
||||
@@ -405,14 +405,14 @@ class OrderpreController extends Common
|
||||
|
||||
$detail->status_code = 1; //标记订单处于创建待审核状态
|
||||
$detail->update_at = time();
|
||||
|
||||
//保存资料
|
||||
|
||||
//保存资料
|
||||
$res = $detail->save();
|
||||
|
||||
if ($res) {
|
||||
$this->result('询单保存成功!',['id'=>$id],200);
|
||||
$this->result('询单保存成功!', ['id' => $id], 200);
|
||||
} else {
|
||||
$this->result('询单保存失败!',[],100);
|
||||
$this->result('询单保存失败!', [], 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:39:14+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:39:14+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcPlat;
|
||||
|
||||
class PlatController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
$model = new AcPlat();
|
||||
$search = $where = [];
|
||||
$where[] = 'and';
|
||||
if (isset($_POST['title']) && $_POST['title']!='') {
|
||||
$search['title'] = $_POST['title'];
|
||||
$where[] = ['LIKE','title',$search['title']];
|
||||
}
|
||||
$where[] = ['=','deleted',0];
|
||||
$data = $model->find()->where($where);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '5']);
|
||||
$res = $data->orderby('orderby DESC')->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$plats = [];
|
||||
foreach ($res as $r) {
|
||||
$plats[$r->id] = $r->toArray();
|
||||
}
|
||||
return $this->render('list', [
|
||||
'plats'=>$plats,
|
||||
'pager' => $pages,
|
||||
'search'=>$search,
|
||||
'status'=>$status
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('modify', []);
|
||||
}
|
||||
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new AcPlat();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->findOne($id);
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
return $this->render('modify', ['detail'=>$res]);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$data = [];
|
||||
$id = $post['id'];
|
||||
//目标键=》POST键
|
||||
$cols = ['title'=>'title','thumb'=>'thumb'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
$cols = ['orderby'=>'orderby','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$data['update_at'] = time();
|
||||
$data['create_at'] = $data['update_at'];
|
||||
|
||||
$model = new AcPlat();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
if ($id) {
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '平台保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '平台保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionExt()
|
||||
{
|
||||
$session = Yii::$app->session;
|
||||
if (isset($_GET['pid']) && (int)$_GET['pid']>0) {
|
||||
$session->set('pid', (int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if (!$pid) {
|
||||
$url = Url::toRoute(['index/index','pid'=>0]);
|
||||
header('location:'.$url);
|
||||
exit;
|
||||
}
|
||||
|
||||
$model = new AcPlat();
|
||||
$res = $model->findOne($pid);
|
||||
$detail = [];
|
||||
if ($res) {
|
||||
$detail = json_decode($res->remark, true);
|
||||
}
|
||||
return $this->render('ext', ['detail'=>$detail]);
|
||||
}
|
||||
|
||||
public function actionExtsave()
|
||||
{
|
||||
$user_id=Yii::$app->user->identity->getId();
|
||||
if ($user_id !=1) {
|
||||
\Yii::$app->getSession()->setFlash('warning', '修改失败,平台配置仅支持超级管理员修改!');
|
||||
return $this->redirect(['plat/ext']);
|
||||
}
|
||||
$post = Yii::$app->request->post();
|
||||
$session = Yii::$app->session;
|
||||
$pid = $session->get('pid');
|
||||
|
||||
$data = [];
|
||||
//目标键=》POST键
|
||||
$cols = ['cw_phone'=>'cw_phone'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
$remark = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$model = new AcPlat();
|
||||
$model->remark = $remark;
|
||||
$res = $model->updateAll(['remark'=>$remark], ['id'=>$pid]);
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '参数保存成功!');
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '参数保存失败!');
|
||||
}
|
||||
return $this->redirect(['plat/ext']);
|
||||
}
|
||||
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcPlat();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('plat/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '平台删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '平台删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcPlat();
|
||||
$res = $model->findOne($id);
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '平台数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '平台隐藏成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
} else {
|
||||
$return['msg'] = '平台隐藏失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '平台显示成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '平台显示失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@
|
||||
# @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
|
||||
# @Last modified time: 2024-08-09T08:53:58+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers\client\v1;
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use vendor\aliyun\dysms\Sms;
|
||||
@@ -20,7 +20,7 @@ class SmsController extends Common
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class SmsController extends Common
|
||||
];
|
||||
$this->result('您正使用CMTS-CLIENT系统短信管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
|
||||
public function actionSend()
|
||||
{
|
||||
global $START_TIME;
|
||||
@@ -144,19 +144,19 @@ class SmsController extends Common
|
||||
//数据取出方法
|
||||
$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);
|
||||
|
||||
//验证手机号
|
||||
$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'; //验证码使用场景
|
||||
$codetype = $dataPost['scence'] ?? 'vcode'; //验证码使用场景
|
||||
|
||||
$config = array();
|
||||
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : $params['aliDySms']['accessKeyId'];
|
||||
@@ -165,35 +165,35 @@ class SmsController extends Common
|
||||
|
||||
$option = array();
|
||||
$sms = new Sms($option, $config);
|
||||
$_time = time();
|
||||
$vcodeModel = new CVcode();
|
||||
$_time = time();
|
||||
$vcodeModel = new CVcode();
|
||||
//查询上次发送记录
|
||||
$where=[];
|
||||
$where['mobile'] = $phone;
|
||||
$where['deleted'] = 0;
|
||||
$where['type'] = $codetype;
|
||||
$res = $vcodeModel->find()->where($where)->one();
|
||||
if ($res) {
|
||||
if ($res) {
|
||||
if (($_time-$res->create_at)<300) {
|
||||
//设置5分钟内,验证码仍然可用
|
||||
//设置5分钟内,验证码仍然可用
|
||||
$code = $res->code;
|
||||
$msg = '上次发送的验证码仍然可用;请注意查看手机 '.$phoneMask;
|
||||
$data = ['errorcode'=>2];
|
||||
if(YII_DEBUG){
|
||||
$data['code'] = $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);
|
||||
$code = mt_rand(1000, 9999);
|
||||
$content['code'] = $code;
|
||||
|
||||
//验证码准备入库
|
||||
|
||||
//验证码准备入库
|
||||
$vcode = [];
|
||||
$vcode['code'] = $code;
|
||||
$vcode['type'] = $codetype;
|
||||
@@ -202,46 +202,46 @@ class SmsController extends Common
|
||||
foreach ($vcode as $key=>$val) {
|
||||
$vcodeModel->$key = $val;
|
||||
}
|
||||
$tmpls = $params['aliDySms']['tmpl'];
|
||||
$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 '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:
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// 发送前控制
|
||||
$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['uid'] = 0;
|
||||
$smsdata['mid'] = $this->user_id;
|
||||
$smsdata['mobile'] = $phone;
|
||||
$smsdata['content'] = json_encode($content, JSON_UNESCAPED_UNICODE);
|
||||
@@ -263,10 +263,10 @@ class SmsController extends Common
|
||||
$vcodeModel->save();
|
||||
$msg .= "发送成功";
|
||||
}
|
||||
$data = ['errorcode'=>$errorcode];
|
||||
if(!$debug || YII_DEBUG){
|
||||
$data['data'] = $content;
|
||||
}
|
||||
$data = ['errorcode' => $errorcode];
|
||||
if (!$debug || YII_DEBUG) {
|
||||
$data['data'] = $content;
|
||||
}
|
||||
$this->result($msg, $data, 200);
|
||||
}
|
||||
|
||||
@@ -276,14 +276,14 @@ class SmsController extends Common
|
||||
$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';
|
||||
$codetype = 'caiwu';
|
||||
//查询上次发送记录
|
||||
$_time = time();
|
||||
$where=[];
|
||||
@@ -293,7 +293,7 @@ class SmsController extends Common
|
||||
$res = $vcodeModel->find()->where($where)->one();
|
||||
if ($res) {
|
||||
if (($_time-$res->create_at)<7200) {
|
||||
//设置2小时内,验证码仍然可用
|
||||
//设置2小时内,验证码仍然可用
|
||||
$code = $res->code;
|
||||
$this->result('上次发送的验证码仍然可用;请注意查看财务手机!', ['errorcode'=>2], 200);
|
||||
} else {
|
||||
@@ -301,17 +301,17 @@ class SmsController extends Common
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
//数据取出方法
|
||||
|
||||
//数据取出方法
|
||||
$dataPost = $this->postdata; //YII应用内的真实或模拟POST数据
|
||||
$params = Yii::$app->params;
|
||||
|
||||
$content = [];
|
||||
|
||||
$content = [];
|
||||
$code = mt_rand(1000, 9999);
|
||||
$content['code'] = $code;
|
||||
$tmpl = $params['aliDySms']['tmpl']['cwVcode'];
|
||||
|
||||
//验证码准备入库
|
||||
|
||||
//验证码准备入库
|
||||
$vcode = [];
|
||||
$vcode['code'] = $code;
|
||||
$vcode['type'] = $codetype;
|
||||
@@ -320,14 +320,14 @@ class SmsController extends Common
|
||||
foreach ($vcode as $key=>$val) {
|
||||
$vcodeModel->$key = $val;
|
||||
}
|
||||
|
||||
$config = array();
|
||||
|
||||
$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);
|
||||
$sms = new Sms($option, $config);
|
||||
$result = $sms->send($phone, $tmpl, $content); //编排发送短信
|
||||
//保存发送记录
|
||||
$smsModel = new CSms();
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-16T16:31:49+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-06-29T15:44:54+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcStore;
|
||||
|
||||
class StoreController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'网点清单',
|
||||
'detail'=>'网点详情'
|
||||
];
|
||||
$this->result('您正使用CMTS系统网点管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = $pid;
|
||||
$citys = Yii::$app->params['citys'];
|
||||
$post = $this->postdata;
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$where['status_code'] = 1;
|
||||
$data = $model->find()->where($where);
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
if (!$res) {
|
||||
$this->result('没有符合条件的结果');
|
||||
}
|
||||
$stores = [];
|
||||
foreach ($res as $k=>$v) {
|
||||
$stores[$v->id] = $v->toArray();
|
||||
}
|
||||
$return = [];
|
||||
$return['data'] = [
|
||||
'stores'=>$stores,
|
||||
'citys'=>$citys,
|
||||
];
|
||||
$return['total'] = $data->count();
|
||||
$return['page'] = $this->page;
|
||||
$this->result('网点列表', $return, 200);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new AcStore();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$citys = Yii::$app->params['citys'];
|
||||
$post = Yii::$app->request->post();
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$where['status_code'] = 1;
|
||||
$data = $model->find()->where($where);
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2 = ['LIKE','title',$search['title']];
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = ['0'=>'隐藏','1'=>'正常'];
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'store';
|
||||
return $this->render('select', [
|
||||
'stores'=>$res,
|
||||
'pager' => $pages,
|
||||
'citys'=>$citys,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,422 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:38:08+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:38:08+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
|
||||
class TruckController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
//板车列表
|
||||
public function actionList()
|
||||
{
|
||||
$AcTruck = new AcTruck();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','num_left',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $AcTruck->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['TruckStatus'];
|
||||
$AcDriver = new AcDriver();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_drivers = $AcDriver->find()->where($where)->all();
|
||||
$drivers = [];
|
||||
foreach ($_drivers as $s) {
|
||||
$drivers[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
return $this->render('list', [
|
||||
'trucks'=>$res,
|
||||
'pager' => $pages,
|
||||
'drivers'=>$drivers,
|
||||
'status'=>$status,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$AcTruck = new AcTruck();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','num_left',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $AcTruck->find()->where($where);
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['TruckStatus'];
|
||||
$AcDriver = new AcDriver();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_drivers = $AcDriver->find()->where($where)->all();
|
||||
$drivers = [];
|
||||
foreach ($_drivers as $s) {
|
||||
$drivers[$s->id] = $s->toArray();
|
||||
}
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truck';
|
||||
return $this->render('select', [
|
||||
'trucks'=>$res,
|
||||
'pager' => $pages,
|
||||
'drivers'=>$drivers,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
$status = Yii::$app->params['TruckStatus'];
|
||||
$AcTruck = new AcTruck();
|
||||
$AcTruck->status_code = 0;
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$AcTruck]);
|
||||
}
|
||||
|
||||
//编辑板车资料
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new AcTruck();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
$AcDriver = new AcDriver();
|
||||
$driver = $AcDriver->find()->where(['id' => $res['driver_id']])->one();
|
||||
if ($driver) {
|
||||
$res['driver_title'] = $driver->name;
|
||||
}
|
||||
$driver2 = $AcDriver->find()->where(['id' => $res['driver2_id']])->one();
|
||||
if ($driver2) {
|
||||
$res['driver2_title'] = $driver2->name;
|
||||
}
|
||||
$status = Yii::$app->params['TruckStatus'];
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$res]);
|
||||
}
|
||||
|
||||
//保存板车资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['num_p'=>'num_p','num_area'=>'num_area','num_left'=>'num_left'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
//查询车牌号是否在库
|
||||
$hasTruck = AcTruck::find()->where(['num_p'=>$data['num_p'],'num_area'=>$data['num_area'],'num_left'=>$data['num_left']])->one();
|
||||
if ($hasTruck) {
|
||||
if ($id && $id!=$hasTruck->id) {
|
||||
\Yii::$app->getSession()->setFlash('danger', '保存失败,该车牌号已在库!');
|
||||
return $this->goBack();
|
||||
} else {
|
||||
$id = $hasTruck->id;
|
||||
}
|
||||
}
|
||||
|
||||
$cols = ['driver_id'=>'driver','driver2_id'=>'driver2','status_code'=>'status_code','max_cars'=>'max_cars','deleted'=>'deleted'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
// $data['status_code'] = 1;
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存板车资料
|
||||
$AcTruck = new AcTruck();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcTruck->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$AcTruck->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcTruck->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcTruck->save();
|
||||
$id = $AcTruck->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '板车资料保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '板车资料保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除板车
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcTruck();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('truck/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '板车删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '板车删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcTruck();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['ajax'] = 1;
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
} else {
|
||||
$return['msg'] = '板车数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '板车停用标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
} else {
|
||||
$return['msg'] = '板车停用标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '板车入库记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'primary'];
|
||||
} else {
|
||||
$return['msg'] = '板车入库标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'lock':
|
||||
$data['status_code'] = 99;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '板车锁定标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'danger'];
|
||||
} else {
|
||||
$return['msg'] = '板车锁定标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'repair':
|
||||
$data['status_code'] = 2;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '板车检修标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'warning'];
|
||||
} else {
|
||||
$return['msg'] = '板车检修标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'reset':
|
||||
$data['status_code'] = 2;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '板车保养标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
} else {
|
||||
$return['msg'] = '板车保养标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'working':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '板车恢复正常,标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'success'];
|
||||
} else {
|
||||
$return['msg'] = '板车恢复标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
//发车
|
||||
public function actionFache()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
$truck = $AcTruck->findOne($id);
|
||||
if (!$truck) {
|
||||
$return['msg'] = '板车数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($truck->status_code==4) {
|
||||
$return = [];
|
||||
// $return['url'] = Url::toRoute('truckol/modify');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['msg'] = '当前板车已在装车中,发车操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
} elseif ($truck->status_code==5) {
|
||||
$return = [];
|
||||
// $return['url'] = Url::toRoute('truckol/modify');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['msg'] = '当前板车已在运输途中,发车操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
} elseif ($truck->status_code!=1) {
|
||||
$return['msg'] = '当前板车状态不允许发车,请先确认板车已归为正常状态';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['status_code'] = 4;
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcTruck->$key = $val;
|
||||
}
|
||||
$res = $AcTruck->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
// $return['url'] = Url::toRoute('truckol/modify');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '发车成功,请进行下一步操作';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '发车操作失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
//浏览板车资料
|
||||
public function actionDetail()
|
||||
{
|
||||
$model = new AcTruck();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
}
|
||||
$AcDriver = new AcDriver();
|
||||
$driver = $AcDriver->find()->where(['id' => $res['driver_id']])->one();
|
||||
if ($driver) {
|
||||
$res['driver_title'] = $driver->name;
|
||||
$res['driver_mobile'] = $driver->mobile;
|
||||
}
|
||||
$driver2 = $AcDriver->find()->where(['id' => $res['driver2_id']])->one();
|
||||
if ($driver2) {
|
||||
$res['driver2_title'] = $driver2->name;
|
||||
$res['driver2_mobile'] = $driver2->mobile;
|
||||
}
|
||||
$status = Yii::$app->params['TruckStatus'];
|
||||
return $this->render('detail', ['status'=>$status,'detail'=>$res]);
|
||||
}
|
||||
}
|
||||
@@ -1,561 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:38:28+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:38:28+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcTruckOnline;
|
||||
use addons\models\AcTruckCars;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcGps;
|
||||
use addons\models\AcGpsRoute;
|
||||
|
||||
class TruckcarController extends Common
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
//所有装车记录列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
|
||||
|
||||
$AcTruckCars = new AcTruckCars();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',Yii::$app->session->get('pid')];
|
||||
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
$search['start_city'] = isset($search['start_city']) ? trim(htmlspecialchars_decode($search['start_city'])) : '';
|
||||
if (!empty($search['start_city'])) {
|
||||
$where[] = ['LIKE','from_city',$search['start_city']];
|
||||
}
|
||||
$search['aim_city'] = isset($search['aim_city']) ? trim(htmlspecialchars_decode($search['aim_city'])) : '';
|
||||
if (!empty($search['aim_city'])) {
|
||||
$where[] = ['LIKE','to_city',$search['aim_city']];
|
||||
}
|
||||
$search['car_id'] = isset($search['car_id']) ? (int)$search['car_id'] : 0;
|
||||
$CarModel = new AcCar();
|
||||
if (!empty($search['car_id'])) {
|
||||
$where[] = ['=','car_id',$search['car_id']];
|
||||
$car = $CarModel->findOne($search['car_id']);
|
||||
$search['car_title'] = isset($car->title) ? $car->title : '';
|
||||
}
|
||||
$search['status_code'] = isset($search['status_code']) ? $search['status_code'] : 'all';
|
||||
if ($search['status_code']!='all') {
|
||||
$where[] = ['=','status_code',(int)$search['status_code']];
|
||||
}
|
||||
//按月份筛选
|
||||
$search['start_m'] = isset($search['start_m']) ? $search['start_m'] : '';
|
||||
if (!empty($search['start_m'])) {
|
||||
$start = strtotime($search['start_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of ".$s);
|
||||
$m = date("Y-m-d", $ldm)." 23:59:59";
|
||||
$end = strtotime($m);
|
||||
$where[] = ['between','from_time',$start,$end];
|
||||
}
|
||||
|
||||
$where[] = ['=','deleted',0];
|
||||
$data = $AcTruckCars->find()->where($where);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('status_code ASC,id DESC')->all();
|
||||
|
||||
$car_ids = [];
|
||||
foreach ($res as $r) {
|
||||
$car_ids[] = $r->car_id;
|
||||
}
|
||||
|
||||
$AcCar = new AcCar();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$car_ids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$cars = $AcCar->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$status = Yii::$app->params['TruckCarsStatus'];
|
||||
|
||||
return $this->render('list', [
|
||||
'list'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'cars'=>$cars,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
$status = Yii::$app->params['TruckCarsStatus'];
|
||||
$AcTruckCars = [];
|
||||
$AcTruckCars['status_code'] = 0;
|
||||
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
|
||||
$AcTruckCars['online_id'] = $online_id;
|
||||
$order_id = Yii::$app->request->get('order_id'); //待承运订单ID
|
||||
$AcTruckCars['order_id'] = $order_id;
|
||||
$car_id = Yii::$app->request->get('car_id'); //待装客车ID
|
||||
$AcTruckCars['car_id'] = $car_id;
|
||||
return $this->render('create', ['status'=>$status,'detail'=>$AcTruckCars]);
|
||||
}
|
||||
|
||||
//编辑客车上板信息
|
||||
public function actionEdit()
|
||||
{
|
||||
$id = Yii::$app->request->get('id'); //承运单ID
|
||||
$truck_id = $online_id = $store_id = $store2_id = 0;
|
||||
$truckCar = $truckol = [];
|
||||
|
||||
$AcTruckCars = new AcTruckCars();
|
||||
$res = $AcTruckCars->findOne($id);
|
||||
if ($res) {
|
||||
$truckCar = $res->toArray();
|
||||
$online_id = $res->online_id;
|
||||
$store2_id = $res->to_store;
|
||||
$store_id = $res->from_store;
|
||||
$order_id = $res->order_id;
|
||||
}
|
||||
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($order_id);
|
||||
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$res = $AcTruckOnline->findOne($online_id);
|
||||
if ($res) {
|
||||
$truck_id = $res->truck_id;
|
||||
$truckol = $res->toArray();
|
||||
}
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
if (!$truck) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truck/list',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
$truckCar['truck_id'] = $truck_id;
|
||||
$truckCar['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
|
||||
$truckCar['truck_num'] = $truckCar['truck_title'] ? $truckCar['truck_title'] : $truckol['truck_num'];
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckCar['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckCar['endstore_title'] = $store2->title;
|
||||
}
|
||||
|
||||
$AcDriver = new AcDriver();
|
||||
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
|
||||
$truckCar['driver_title'] = $truckCar['driver_mobile'] = '';
|
||||
if ($driver) {
|
||||
$truckCar['driver_title'] = $driver->name;
|
||||
$truckCar['driver_mobile'] = $driver->mobile;
|
||||
}
|
||||
$truckCar['from_time'] = !empty($truckCar['from_time']) ? $truckCar['from_time'] : $truckol['from_date'];
|
||||
$truckCar['to_time'] = !empty($truckCar['to_time']) ? $truckCar['to_time'] : $truckol['end_date'];
|
||||
$from_city = $order->start_city;
|
||||
$truckCar['from_city'] = !empty($truckCar['from_city']) ? $truckCar['from_city'] : $from_city;
|
||||
$truckCar['from_city'] = $truckCar['from_city'] ? $truckCar['from_city'] : $truckol['from_city'];
|
||||
$end_city = $order->aim_city;
|
||||
$truckCar['to_city'] = !empty($truckCar['to_city']) ? $truckCar['to_city'] : $end_city;
|
||||
$truckCar['to_city'] = $truckCar['to_city'] ? $truckCar['to_city'] : $truckol['end_city'];
|
||||
$truckCar['driver_name'] = isset($truckCar['driver_name']) ? $truckCar['driver_name'] : $truckol['driver_name'];
|
||||
$truckCar['driver_mobiles'] = isset($truckCar['driver_mobiles']) ? $truckCar['driver_mobiles'] : $truckol['driver_mobiles'];
|
||||
$status = Yii::$app->params['TruckCarsStatus'];
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$truckCar]);
|
||||
}
|
||||
|
||||
//保存客车上板信息(直接指派方式)
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['from_city'=>'from_city','to_city'=>'to_city'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
|
||||
$cols = ['online_id'=>'online_id','from_store'=>'from_store','to_store'=>'to_store'];
|
||||
if (isset($_GET['debug'])&&($_GET['debug']==1)) {
|
||||
$cols['status_code'] = 'status_code';
|
||||
}
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
|
||||
/*出车计划判断*/
|
||||
$online_id = $data['online_id'];
|
||||
if (!$online_id) {
|
||||
$return['msg'] = '未关联板车出车计划信息,保存失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckol = $AcTruckOnline->findOne($online_id);
|
||||
if (!$truckol) {
|
||||
$return['msg'] = '未找到指定板车出车计划,保存失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$key = 'remark';
|
||||
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
|
||||
|
||||
$_time = time();
|
||||
$key = 'to_time';
|
||||
if (isset($post[$key]) && $post[$key]!="") {
|
||||
$data[$key] = strtotime($post[$key]);
|
||||
}
|
||||
$key = 'from_time';
|
||||
if (isset($post[$key]) && $post[$key]!="") {
|
||||
$data[$key] = strtotime($post[$key]);
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
$data['create_at'] = $_time;
|
||||
}
|
||||
$data['update_at'] = $_time;
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存上板信息
|
||||
$AcTruckCars = new AcTruckCars();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcTruckCars->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$res = $AcTruckCars->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcTruckCars->save();
|
||||
$id = $AcTruckCars->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
//修改对应运单状态
|
||||
$_code = 0;
|
||||
if (isset($data['status_code'])) {
|
||||
if ($data['status_code'] == 1) {
|
||||
$_code = 2;
|
||||
} elseif ($data['status_code'] == 99) {
|
||||
$_code = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_code) {
|
||||
$order_id = isset($post['order_id']) ? (int)$post['order_id'] : 0;
|
||||
if (!$order_id) {
|
||||
$car = $AcTruckCars->findOne($id);
|
||||
$order_id = $car->order_id;
|
||||
}
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($order_id);
|
||||
$order->update_at = $_time;
|
||||
|
||||
$order->status_code = $_code;
|
||||
$order->save();
|
||||
}
|
||||
|
||||
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
//保存客车上板信息(板车出车界面车辆管理方式)
|
||||
public function actionSave2()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['from_city'=>'from_city','to_city'=>'to_city'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
|
||||
$cols = ['online_id'=>'online_id','from_store'=>'from_store','to_store'=>'to_store','order_id'=>'order_id','car_id'=>'car_id'];
|
||||
if (isset($_GET['debug'])&&($_GET['debug']==1)) {
|
||||
$cols['status_code'] = 'status_code';
|
||||
}
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
|
||||
/*出车计划判断*/
|
||||
$online_id = $data['online_id'];
|
||||
if (!$online_id) {
|
||||
$return['msg'] = '未关联板车出车计划信息,保存失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckol = $AcTruckOnline->findOne($online_id);
|
||||
if (!$truckol) {
|
||||
$return['msg'] = '未找到指定板车出车计划,保存失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$key = 'remark';
|
||||
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
|
||||
|
||||
$_time = time();
|
||||
$key = 'to_time';
|
||||
if (isset($post[$key]) && $post[$key]!="") {
|
||||
$data[$key] = strtotime($post[$key]);
|
||||
}
|
||||
$key = 'from_time';
|
||||
if (isset($post[$key]) && $post[$key]!="") {
|
||||
$data[$key] = strtotime($post[$key]);
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
$data['create_at'] = $_time;
|
||||
}
|
||||
$data['update_at'] = $_time;
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存上板信息
|
||||
$AcTruckCars = new AcTruckCars();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcTruckCars->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$res = $AcTruckCars->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcTruckCars->save();
|
||||
$id = $AcTruckCars->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
//修改对应运单状态
|
||||
$_code = 0;
|
||||
if (isset($data['status_code'])) {
|
||||
if ($data['status_code'] == 1) {
|
||||
$_code = 2;
|
||||
} elseif ($data['status_code'] == 99) {
|
||||
$_code = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_code) {
|
||||
$order_id = isset($post['order_id']) ? (int)$post['order_id'] : 0;
|
||||
if (!$order_id) {
|
||||
$car = $AcTruckCars->findOne($id);
|
||||
$order_id = $car->order_id;
|
||||
}
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($order_id);
|
||||
$order->update_at = $_time;
|
||||
|
||||
$order->status_code = $_code;
|
||||
$order->save();
|
||||
}
|
||||
|
||||
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除板车
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
$data = $return = [];
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcTruckCars();
|
||||
$car = $model->findOne($id);
|
||||
if (!$car) {
|
||||
$return['msg'] = '数据不存在,删除失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($car->pid !=$pid) {
|
||||
$return['msg'] = '非本平台数据,不允许操作';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($car->deleted !=0) {
|
||||
$return['msg'] = '数据已被删除过,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data, ['id'=>$id]);
|
||||
|
||||
|
||||
$return['url'] = Url::toRoute('truckcar/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '上板记录删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '上板记录删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
$data = $return = [];
|
||||
$_time = time();
|
||||
$data['update_at'] = $_time;
|
||||
|
||||
$model = new AcTruckCars();
|
||||
$car = $model->findOne($id);
|
||||
if (!$car) {
|
||||
$return['msg'] = '数据不存在,删除失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($car->pid !=$pid) {
|
||||
$return['msg'] = '非本平台数据,不允许操作';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($car->deleted !=0) {
|
||||
$return['msg'] = '数据已被删除,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$online_id = $car->online_id;
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckol = $AcTruckOnline->findOne($online_id);
|
||||
$order_id = $car->order_id;
|
||||
$AcOrder = new AcOrder();
|
||||
$order = $AcOrder->findOne($order_id);
|
||||
|
||||
$return['timeout'] = 1; //n秒后自动跳转
|
||||
|
||||
$where = ['id'=>$id];
|
||||
switch ($get['do']) {
|
||||
case 'intruck':
|
||||
if ($car->status_code !=0) {
|
||||
$return['msg'] = '当前运单并非待承运状态,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$data['status_code'] = 1;
|
||||
$data['from_time'] = $_time;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
//增加板车一辆装车统计
|
||||
$truckol->update_at = $_time;
|
||||
$truckol->updateCounters(['cars'=>1]);
|
||||
$truckol->save();
|
||||
//修改对应订单的状态
|
||||
$order->update_at = $_time;
|
||||
$order->status_code = 2;
|
||||
$order->save();
|
||||
$return['msg'] = '客车上板标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'success'];
|
||||
} else {
|
||||
$return['msg'] = '客车上板标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'arrive':
|
||||
if ($car->status_code ==0) {
|
||||
$return['msg'] = '当前任务尚待承运,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$data['status_code'] = 99;
|
||||
$data['to_time'] = $_time;
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
//修改对应订单的状态
|
||||
$order->update_at = $_time;
|
||||
$order->status_code = 3;
|
||||
$order->save();
|
||||
$return['msg'] = '客车运达标记记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'primary'];
|
||||
} else {
|
||||
$return['msg'] = '客车运达标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'fix':
|
||||
$data['status_code'] = 80;
|
||||
if ($car->status_code != 1) {
|
||||
$return['msg'] = '当前运单并非运输中状态,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$res = $model->updateAll($data, $where);
|
||||
if ($res) {
|
||||
$return['msg'] = '客车运达标记记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'primary'];
|
||||
} else {
|
||||
$return['msg'] = '客车运达标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,923 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:37:46+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:37:46+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcTruckOnline;
|
||||
use addons\models\AcTruckCars;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcEmployee;
|
||||
use addons\models\AcGps;
|
||||
use addons\models\AcGpsRoute;
|
||||
|
||||
class TruckolController extends Common
|
||||
{
|
||||
//出车单
|
||||
public function actionIndex()
|
||||
{
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',Yii::$app->session->get('pid')];
|
||||
$where[] = ['>','status_code',0];
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where[] = ['LIKE','num_left',$search['title']];
|
||||
}
|
||||
$where[] = ['=','deleted',0];
|
||||
$data = $AcTruckOnline->find()->where($where);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '10']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
|
||||
$status = Yii::$app->params['TruckOnlineStatus'];
|
||||
|
||||
$stores = [];
|
||||
$AcStore = new AcStore();
|
||||
if ($res) {
|
||||
$store_ids = [];
|
||||
foreach ($res as $r) {
|
||||
$store_ids[$r->from_store] = $r->from_store;
|
||||
$store_ids[$r->end_store] = $r->end_store;
|
||||
}
|
||||
array_unique($store_ids);
|
||||
$_stores = $AcStore->find()->where(['IN','id',$store_ids])->all();
|
||||
if ($_stores) {
|
||||
foreach ($_stores as $r) {
|
||||
$stores[$r->id] = $r->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('index', [
|
||||
'list'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'stores'=>$stores,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
//在线板车列表(标记了发车状态——装车中的)
|
||||
public function actionList()
|
||||
{
|
||||
$AcTruck = new AcTruck();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',Yii::$app->session->get('pid')];
|
||||
$where[] = ['=','status_code',4];
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where[] = ['LIKE','num_left',$search['title']];
|
||||
}
|
||||
$where[] = ['=','deleted',0];
|
||||
$data = $AcTruck->find()->where($where);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['TruckStatus'];
|
||||
$AcDriver = new AcDriver();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_drivers = $AcDriver->find()->where($where)->all();
|
||||
$drivers = [];
|
||||
foreach ($_drivers as $s) {
|
||||
$drivers[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
return $this->render('list', [
|
||||
'trucks'=>$res,
|
||||
'pager' => $pages,
|
||||
'drivers'=>$drivers,
|
||||
'status'=>$status,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
//选择可装车的板车
|
||||
public function actionSelect()
|
||||
{
|
||||
$AcTruck = new AcTruck();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',Yii::$app->session->get('pid')];
|
||||
$where[] = ['=','status_code',4];
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where[] = ['LIKE','num_left',$search['title']];
|
||||
}
|
||||
$where[] = ['=','deleted',0];
|
||||
$data = $AcTruck->find()->where($where);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = Yii::$app->params['TruckStatus'];
|
||||
$AcDriver = new AcDriver();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_drivers = $AcDriver->find()->where($where)->all();
|
||||
$drivers = [];
|
||||
foreach ($_drivers as $s) {
|
||||
$drivers[$s->id] = $s->toArray();
|
||||
}
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truckol';
|
||||
|
||||
return $this->render('select', [
|
||||
'trucks'=>$res,
|
||||
'pager' => $pages,
|
||||
'drivers'=>$drivers,
|
||||
'status'=>$status,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect2()
|
||||
{
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',Yii::$app->session->get('pid')];
|
||||
$where[] = ['>','status_code',0];
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where[] = ['LIKE','num_left',$search['title']];
|
||||
}
|
||||
$where[] = ['=','deleted',0];
|
||||
$data = $AcTruckOnline->find()->where($where);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '10']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
|
||||
$status = Yii::$app->params['TruckOnlineStatus'];
|
||||
|
||||
$stores = [];
|
||||
$AcStore = new AcStore();
|
||||
if ($res) {
|
||||
$store_ids = [];
|
||||
foreach ($res as $r) {
|
||||
$store_ids[$r->from_store] = $r->from_store;
|
||||
$store_ids[$r->end_store] = $r->end_store;
|
||||
}
|
||||
array_unique($store_ids);
|
||||
$_stores = $AcStore->find()->where(['IN','id',$store_ids])->all();
|
||||
if ($_stores) {
|
||||
foreach ($_stores as $r) {
|
||||
$stores[$r->id] = $r->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truckol';
|
||||
|
||||
return $this->render('select2', [
|
||||
'list'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'stores'=>$stores,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
$status = Yii::$app->params['TruckOnlineStatus'];
|
||||
$AcTruckOnline = [];
|
||||
$AcTruckOnline['status_code'] = 0;
|
||||
return $this->render('edit', ['status'=>$status,'detail'=>$AcTruckOnline]);
|
||||
}
|
||||
|
||||
//编辑板车装车计划资料
|
||||
public function actionEdit()
|
||||
{
|
||||
// $id = Yii::$app->request->get('id'); //装车任务ID
|
||||
$id = 0;
|
||||
$truck_id = Yii::$app->request->get('truck_id'); //板车ID
|
||||
$store_id = $store2_id = 0;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$AcTruck = new AcTruck();
|
||||
$truckol = [];
|
||||
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
if (!$truck) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truck/list',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
if (!$id) {
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['=','truck_id',$truck_id];
|
||||
$where[] = ['<','status_code',99];
|
||||
$where[] = ['=','deleted',0];
|
||||
$res = $AcTruckOnline->find()->where($where)->orderby('id ASC')->one();
|
||||
if ($res) {
|
||||
$id = $res->id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
$truckol['truck_id'] = $truck_id;
|
||||
$truckol['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
|
||||
$truckol['truck_num'] = $truckol['truck_title'] ? $truckol['truck_title'] : $truckol['truck_num'];
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
|
||||
$AcDriver = new AcDriver();
|
||||
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
|
||||
$truckol['driver_title'] = $truckol['driver_mobile'] = '';
|
||||
if ($driver) {
|
||||
$truckol['driver_title'] = $driver->name;
|
||||
$truckol['driver_mobile'] = $driver->mobile;
|
||||
}
|
||||
$truckol['driver_name'] = isset($truckol['driver_name']) ? $truckol['driver_name'] : $truckol['driver_title'];
|
||||
$truckol['driver_mobiles'] = isset($truckol['driver_mobiles']) ? $truckol['driver_mobiles'] : $truckol['driver_mobile'];
|
||||
$status = Yii::$app->params['TruckOnlineStatus'];
|
||||
return $this->render('edit', ['status'=>$status,'detail'=>$truckol]);
|
||||
}
|
||||
|
||||
//更新板车装车任务资料
|
||||
public function actionModify()
|
||||
{
|
||||
$id = Yii::$app->request->get('id'); //装车任务ID
|
||||
// $truck_id = Yii::$app->request->get('truck_id'); //板车ID
|
||||
$truck_id = 0;
|
||||
$store_id = $store2_id = 0;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$AcTruck = new AcTruck();
|
||||
$truckol = [];
|
||||
|
||||
$res = $AcTruckOnline->findOne($id);
|
||||
if ($res) {
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
}
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
|
||||
if (!$truck) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truck/list',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
|
||||
$truckol['truck_id'] = $truck_id;
|
||||
$truckol['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
|
||||
$truckol['truck_num'] = $truckol['truck_title'] ? $truckol['truck_title'] : $truckol['truck_num'];
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
|
||||
$AcDriver = new AcDriver();
|
||||
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
|
||||
$truckol['driver_title'] = $truckol['driver_mobile'] = '';
|
||||
if ($driver) {
|
||||
$truckol['driver_title'] = $driver->name;
|
||||
$truckol['driver_mobile'] = $driver->mobile;
|
||||
}
|
||||
$truckol['driver_name'] = isset($truckol['driver_name']) ? $truckol['driver_name'] : $truckol['driver_title'];
|
||||
$truckol['driver_mobiles'] = isset($truckol['driver_mobiles']) ? $truckol['driver_mobiles'] : $truckol['driver_mobile'];
|
||||
$status = Yii::$app->params['TruckOnlineStatus'];
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$truckol]);
|
||||
}
|
||||
|
||||
//保存装车基础资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['driver_name'=>'driver_name','driver_mobiles'=>'driver_mobiles','driver_idcard'=>'driver_idcard','truck_num'=>'truck_num','end_city'=>'end_city','from_city'=>'from_city'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
|
||||
$cols = ['truck_id'=>'truck_id','from_store'=>'from_store','end_store'=>'end_store'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$key = 'status_code';
|
||||
if (isset($post[$key])) {
|
||||
$data[$key] = (int)$post[$key];
|
||||
}
|
||||
/*板车规则判断
|
||||
*一辆板车只能有一条可用装车任务表单
|
||||
**/
|
||||
$truck_id = $data['truck_id'];
|
||||
if (!$truck_id) {
|
||||
$return['msg'] = '未指定板车信息,保存失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$AcTruck = new AcTruck();
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
if (!$truck) {
|
||||
$return['msg'] = '未找到指定板车,保存失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['=','truck_id',$truck_id];
|
||||
$where[] = ['<','status_code',99];
|
||||
$where[] = ['=','deleted',0];
|
||||
$truckol = $AcTruckOnline->find()->where($where)->orderby('id ASC')->one();
|
||||
if ($truckol) {
|
||||
if ($id != $truckol->id) {
|
||||
$return['msg'] = '该板车已有未完成的托运任务,不允许重复指派';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
||||
$key = 'remark';
|
||||
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
|
||||
|
||||
$_time = time();
|
||||
$key = 'from_date';
|
||||
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
|
||||
$key = 'end_date';
|
||||
if (isset($post[$key])) {
|
||||
$data[$key] = strtotime($post[$key]);
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
$data['create_at'] = $_time;
|
||||
}
|
||||
$data['update_at'] = $_time;
|
||||
;
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存板车资料
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcTruckOnline->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$res = $AcTruckOnline->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcTruckOnline->save();
|
||||
$id = $AcTruckOnline->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
|
||||
return $this->redirect(['modify','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//随车车辆管理
|
||||
public function actionCars()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$id = Yii::$app->request->get('id'); //装车任务ID
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckol = [];
|
||||
$res = $AcTruckOnline->findOne($id);
|
||||
if (!$res) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '发车任务记录获取失败,请重新获取';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truckol/list',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
|
||||
$online_id = $id;
|
||||
$AcTruckCars = new AcTruckCars();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['=','online_id',$online_id];
|
||||
$where[] = ['=','deleted',0];
|
||||
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
|
||||
$carids = $orderids = [];
|
||||
if ($truckcars) {
|
||||
foreach ($truckcars as $t) {
|
||||
$carids[] = $t->car_id;
|
||||
$orderids[] = $t->order_id;
|
||||
}
|
||||
}
|
||||
|
||||
$AcCar = new AcCar();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$carids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$cars = $AcCar->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$status = Yii::$app->params['TruckCarsStatus'];
|
||||
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
|
||||
|
||||
return $this->render('cars', [
|
||||
'status'=>$status,
|
||||
'truckOnLineStatus'=>$truckOnLineStatus,
|
||||
'truckol'=>$truckol,
|
||||
'cars'=>$cars,
|
||||
'truckcars'=>$truckcars
|
||||
]);
|
||||
}
|
||||
|
||||
//保存装车随车资料
|
||||
public function actionCarssave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$online_id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['car_id','order_id'];
|
||||
foreach ($cols as $key) {
|
||||
if (!isset($post[$key])) {
|
||||
$return['msg'] = '未传入的运单或车辆信息,保存失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
$car_ids = $post['car_id'];
|
||||
if (!is_array($car_ids)) {
|
||||
$return['msg'] = '传入的车辆数据不正确,保存失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$order_ids = $post['order_id'];
|
||||
if (!is_array($order_ids)) {
|
||||
$return['msg'] = '传入的运单数据不正确,保存失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if (count($car_ids) != count($order_ids)) {
|
||||
$return['msg'] = '传入的车辆数据与运单数据不匹配,保存失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
/*筛除已在运输中的运单及车辆数据 TBD*/
|
||||
|
||||
$AcTruckCars = new AcTruckCars();
|
||||
$cars = [];
|
||||
$_time = time();
|
||||
foreach ($car_ids as $k=>$car_id) {
|
||||
$car = [];
|
||||
$car['pid'] = $pid;
|
||||
$car['online_id'] = $online_id;
|
||||
$car['car_id'] = $car_id;
|
||||
$car['order_id'] = $order_ids[$k];
|
||||
$car['create_at'] = $_time;
|
||||
$car['update_at'] = $_time;
|
||||
$cars[] = $car;
|
||||
$model = clone $AcTruckCars;
|
||||
foreach ($car as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
$model->save();
|
||||
}
|
||||
|
||||
$return['msg'] = '操作完成,请刷新页面并检查数据';
|
||||
$return['errorcode'] = 200;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
//板车出发
|
||||
public function actionChufa()
|
||||
{
|
||||
$id = Yii::$app->request->get('id'); //装车任务ID
|
||||
$return = [];
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckol = [];
|
||||
$res = $AcTruckOnline->findOne($id);
|
||||
if (!$res) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return['msg'] = '发车任务记录获取失败,请重新获取';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($res->status_code!=0) {
|
||||
$return['msg'] = '关联出车任务非“待出发”状态,操作失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$truck_id = $res->truck_id;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
if (!$truck) {
|
||||
$return['msg'] = '关联板车数据获取异常,操作失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
/*更新数据*/
|
||||
$_time = time();
|
||||
$data = [];
|
||||
$data['update_at'] = $_time;
|
||||
$data['status_code'] = 1;
|
||||
$res = $AcTruckOnline->updateAll($data, ['id'=>$id]);
|
||||
|
||||
$data = [];
|
||||
$data['update_at'] = $_time;
|
||||
$data['status_code'] = 5;
|
||||
$AcTruck->updateAll($data, ['id'=>$truck_id]);
|
||||
|
||||
if ($res) {
|
||||
$return['msg'] = '出车任务出发标记操作成功';
|
||||
$return['errorcode'] = 200;
|
||||
} else {
|
||||
$return['msg'] = '出发标记操作失败';
|
||||
$return['errorcode'] = 100;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
//板车到达
|
||||
public function actionArrive()
|
||||
{
|
||||
$id = Yii::$app->request->get('id'); //装车任务ID
|
||||
$return = [];
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckol = [];
|
||||
$res = $AcTruckOnline->findOne($id);
|
||||
if (!$res) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return['msg'] = '发车任务记录获取失败,请重新获取';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($res->status_code!=1) {
|
||||
$return['msg'] = '关联出车任务非“进行中”(在途)状态,操作失败';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$truck_id = $res->truck_id;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
if (!$truck) {
|
||||
$return['msg'] = '关联板车数据获取异常,操作失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
/*更新数据*/
|
||||
$_time = time();
|
||||
$data = [];
|
||||
$data['update_at'] = $_time;
|
||||
$data['status_code'] = 99;
|
||||
$res = $AcTruckOnline->updateAll($data, ['id'=>$id]);
|
||||
|
||||
$data = [];
|
||||
$data['update_at'] = $_time;
|
||||
$data['status_code'] = 0;
|
||||
$AcTruck->updateAll($data, ['id'=>$truck_id]);
|
||||
|
||||
if ($res) {
|
||||
$return['msg'] = '出车任务运达标记操作成功';
|
||||
$return['errorcode'] = 200;
|
||||
} else {
|
||||
$return['msg'] = '运达标记操作失败';
|
||||
$return['errorcode'] = 100;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
|
||||
//删除板车装车任务
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcTruck();
|
||||
$res = $model->updateAll($data, $where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('truckol/index');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '板车装车任务删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '板车装车任务删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
//打印出车单
|
||||
public function actionPrint()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$id = Yii::$app->request->get('id'); //装车任务ID
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckol = [];
|
||||
$res = $AcTruckOnline->findOne($id);
|
||||
if (!$res) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '发车任务记录获取失败,请重新获取';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truckol/list',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
$AcTruck = new AcTruck();
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
|
||||
$online_id = $id;
|
||||
$AcTruckCars = new AcTruckCars();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['=','online_id',$online_id];
|
||||
$where[] = ['=','deleted',0];
|
||||
$where[] = ['>','status_code',0];
|
||||
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
|
||||
$carids = $orderids = [];
|
||||
if ($truckcars) {
|
||||
foreach ($truckcars as $t) {
|
||||
$carids[] = $t->car_id;
|
||||
$orderids[] = $t->order_id;
|
||||
}
|
||||
}
|
||||
|
||||
$counts = [];
|
||||
|
||||
$AcCar = new AcCar();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$carids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$cars = $AcCar->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$AcOrder = new AcOrder();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$orderids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$orders = $AcOrder->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$employee_ids = [];
|
||||
$count['fee_total'] = $count['pay_receive'] = 0;
|
||||
foreach ($orders as $v) {
|
||||
$employee_ids[] = $v->employee_id;
|
||||
$count['fee_total'] += $v->fee_total;
|
||||
$count['pay_receive'] += $v->pay_receive;
|
||||
}
|
||||
$AcEmployee = new AcEmployee();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$employee_ids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$employees = $AcEmployee->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$count['cars'] = count($truckcars);
|
||||
|
||||
$status = Yii::$app->params['TruckCarsStatus'];
|
||||
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
|
||||
return $this->render('print', [
|
||||
'status'=>$status,
|
||||
'truckOnLineStatus'=>$truckOnLineStatus,
|
||||
'truckol'=>$truckol,
|
||||
'cars'=>$cars,
|
||||
'orders'=>$orders,
|
||||
'employees'=>$employees,
|
||||
'truckcars'=>$truckcars,
|
||||
'count'=>$count
|
||||
]);
|
||||
}
|
||||
|
||||
//浏览详情
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$id = Yii::$app->request->get('id'); //装车任务ID
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckol = [];
|
||||
$res = $AcTruckOnline->findOne($id);
|
||||
if (!$res) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '发车任务记录获取失败,请重新获取';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truckol/list',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
$AcTruck = new AcTruck();
|
||||
$truck = $AcTruck->findOne($truck_id);
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
|
||||
$online_id = $id;
|
||||
$AcTruckCars = new AcTruckCars();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['=','online_id',$online_id];
|
||||
$where[] = ['=','deleted',0];
|
||||
$where[] = ['>','status_code',1];
|
||||
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
|
||||
$carids = $orderids = [];
|
||||
if ($truckcars) {
|
||||
foreach ($truckcars as $t) {
|
||||
$carids[] = $t->car_id;
|
||||
$orderids[] = $t->order_id;
|
||||
}
|
||||
}
|
||||
|
||||
$counts = [];
|
||||
|
||||
$AcCar = new AcCar();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$carids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$cars = $AcCar->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$AcOrder = new AcOrder();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$orderids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$orders = $AcOrder->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$employee_ids = [];
|
||||
$count['fee_total'] = $count['pay_receive'] = 0;
|
||||
foreach ($orders as $v) {
|
||||
$employee_ids[] = $v->employee_id;
|
||||
$count['fee_total'] += $v->fee_total;
|
||||
$count['pay_receive'] += $v->pay_receive;
|
||||
}
|
||||
$AcEmployee = new AcEmployee();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$employee_ids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$employees = $AcEmployee->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$count['cars'] = count($truckcars);
|
||||
|
||||
$status = Yii::$app->params['TruckCarsStatus'];
|
||||
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
|
||||
return $this->render('detail', [
|
||||
'status'=>$status,
|
||||
'truckOnLineStatus'=>$truckOnLineStatus,
|
||||
'truckol'=>$truckol,
|
||||
'cars'=>$cars,
|
||||
'orders'=>$orders,
|
||||
'employees'=>$employees,
|
||||
'truckcars'=>$truckcars,
|
||||
'count'=>$count
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,378 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:37:26+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-22T07:37:26+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcTruckOnline;
|
||||
use addons\models\AcTruckCars;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcGps;
|
||||
use addons\models\AcGpsRoute;
|
||||
use addons\models\AcTruckRoute;
|
||||
|
||||
class TruckrouteController extends Common
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
$session = Yii::$app->session;
|
||||
if (isset($_GET['pid']) && (int)$_GET['pid']>0) {
|
||||
$session->set('pid', (int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if (!$pid) {
|
||||
return Yii::$app->response->redirect(['index/index']);
|
||||
}
|
||||
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
|
||||
if (!$online_id) {
|
||||
$online_id = $session->get('online_id');
|
||||
} else {
|
||||
$session->set('online_id', $online_id);
|
||||
}
|
||||
if (!$online_id) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '请先选择好要查看的出车大板';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truckol/index',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
$truckol = $session->get('truckOnline');
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$res = true;
|
||||
if (!$truckol) {
|
||||
$res = $AcTruckOnline->findOne($online_id);
|
||||
if ($res) {
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
$session->set('truckOnline', $truckol);
|
||||
}
|
||||
}
|
||||
if ($online_id != $truckol['id']) {
|
||||
$res = $AcTruckOnline->findOne($online_id);
|
||||
if ($res) {
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
$session->set('truckOnline', $truckol);
|
||||
}
|
||||
}
|
||||
if (!$res) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '请先选择好要查看的出车大板';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truckol/index',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
}
|
||||
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
}
|
||||
|
||||
//所有板车位置记录列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
$where = [];
|
||||
$where[]='and';
|
||||
$where[] = ['=','pid',Yii::$app->session->get('pid')];
|
||||
if ($online_id) {
|
||||
$where[] = ['=','online_id',$online_id];
|
||||
}
|
||||
$where[] = ['=','deleted',0];
|
||||
$data = $AcTruckRoute->find()->where($where)->orderby('orderby ASC,id DESC');
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
|
||||
$truck_ids = [];
|
||||
foreach ($res as $r) {
|
||||
$truck_ids[] = $r->truck_id;
|
||||
}
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=','pid',$pid];
|
||||
$where[] = ['IN','id',$truck_ids];
|
||||
$where[] = ['=','deleted',0];
|
||||
$trucks = $AcTruck->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
|
||||
return $this->render('list', [
|
||||
'list'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'trucks'=>$trucks,
|
||||
'online_id'=>$online_id,
|
||||
'truckol'=>$truckol
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$AcTruckRoute = [];
|
||||
$AcTruckRoute['status_code'] = 0;
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
|
||||
$AcTruckRoute['truck_id'] = $truckol['truck_id'];
|
||||
$AcTruckRoute['truck_num'] = $truckol['truck_num'];
|
||||
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$AcTruckRoute,'online_id'=>$online_id,'truckol'=>$truckol]);
|
||||
}
|
||||
|
||||
//编辑板车位置信息
|
||||
public function actionEdit()
|
||||
{
|
||||
$id = Yii::$app->request->get('id'); //记录ID
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
$route = $AcTruckRoute->findOne($id);
|
||||
if (!$route) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '位置记录数据获取异常,请重新选择获取';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = '';
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
$route = $route->toArray();
|
||||
$route['truck_id'] = $truckol['truck_id'];
|
||||
$route['online_id'] = $online_id;
|
||||
$route['truck_num'] = $truckol['truck_num'];
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
return $this->render('modify', ['status'=>$status,'detail'=>$route,'online_id'=>$online_id,'truckol'=>$truckol]);
|
||||
}
|
||||
|
||||
//保存位置记录信息
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$online_id = Yii::$app->session->get('online_id');
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
$data = [];
|
||||
$data['truck_id'] = $truckol['truck_id'];
|
||||
$data['online_id'] = $online_id;
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['longt'=>'lng','lat'=>'lat','addr'=>'addr'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
|
||||
$cols = ['orderby'=>'orderby','status_code'=>'status_code'];
|
||||
foreach ($cols as $col=>$key) {
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
|
||||
$_time = time();
|
||||
$key = 'update_at';
|
||||
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
|
||||
|
||||
if (!$id) {
|
||||
$data['create_at'] = $_time;
|
||||
}
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存位置资料
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
foreach ($data as $key=>$val) {
|
||||
$AcTruckRoute->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$res = $AcTruckRoute->updateAll($data, ['id'=>$id]);
|
||||
} else {
|
||||
$res = $AcTruckRoute->save();
|
||||
$id = $AcTruckRoute->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除记录
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$return = [];
|
||||
|
||||
$model = new AcTruckRoute();
|
||||
$route = $model->findOne($id);
|
||||
if (!$route) {
|
||||
$return['msg'] = '数据不存在,删除失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->pid !=$pid) {
|
||||
$return['msg'] = '非本平台数据,不允许操作';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->deleted !=0) {
|
||||
$return['msg'] = '数据已被删除过,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$route->deleted = 1;
|
||||
$res = $route->save();
|
||||
|
||||
$return['url'] = '';
|
||||
$return['timeout'] = 1; //n秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '位置记录删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '位置记录删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$return = [];
|
||||
|
||||
$model = new AcTruckRoute();
|
||||
$route = $model->findOne($id);
|
||||
if (!$route) {
|
||||
$return['msg'] = '数据不存在,删除失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->pid !=$pid) {
|
||||
$return['msg'] = '非本平台数据,不允许操作';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
if ($route->deleted !=0) {
|
||||
$return['msg'] = '数据已被删除,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$return['timeout'] = 1; //n秒后自动跳转
|
||||
$res = true;
|
||||
switch ($get['do']) {
|
||||
case 'show':
|
||||
if ($route->status_code!=1) {
|
||||
$route->status_code = 1;
|
||||
$res = $route->save();
|
||||
}
|
||||
if ($res) {
|
||||
$return['msg'] = '记录显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'success'];
|
||||
} else {
|
||||
$return['msg'] = '客车上板标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'hide':
|
||||
if ($route->status_code!=0) {
|
||||
$route->status_code = 0;
|
||||
$res = $route->save();
|
||||
}
|
||||
if ($res) {
|
||||
$return['msg'] = '记录隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'success'];
|
||||
} else {
|
||||
$return['msg'] = '客车上板标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -1,379 +0,0 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-10T01:13:34+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2022-05-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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,98 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user