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

主要修复ctms-api、dacms对PHP新版本的支持问题
This commit is contained in:
2025-07-13 19:37:42 +08:00
parent 65bbd06981
commit 037f274ec5
413 changed files with 107271 additions and 72326 deletions
+95
View File
@@ -0,0 +1,95 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-16T16:31:49+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2024-08-09T09:19:58+08:00
# @Copyright: www.hiluker.cn
namespace api\controllers\gm\v1;
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
]);
}
}