ctms/ctms-api/controllers/client/v1/IndexController.php
fm453 314745edf8 优化ctms-api语法、修复已知BUG;
主要修复ctms-api、dacms对PHP新版本的支持问题
2025-04-10 23:19:15 +08:00

189 lines
6.1 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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