2024-11-04 10:49:10 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
|
|
|
|
use app\common\controller\Api;
|
2024-12-11 19:03:47 +08:00
|
|
|
|
use app\common\library\Sqlscript;
|
|
|
|
|
use app\common\library\Virtual;
|
2024-12-05 18:41:08 +08:00
|
|
|
|
use app\common\model\school\Area;
|
2024-12-13 18:37:50 +08:00
|
|
|
|
use app\common\model\school\classes\order\ServiceOrder;
|
2024-11-16 18:01:16 +08:00
|
|
|
|
use app\common\model\style\HomeImages;
|
2024-12-11 19:03:47 +08:00
|
|
|
|
use think\Db;
|
|
|
|
|
use think\exception\PDOException;
|
2024-11-04 10:49:10 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 首页接口
|
|
|
|
|
*/
|
|
|
|
|
class Index extends Api
|
|
|
|
|
{
|
|
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
|
|
|
|
/**
|
2024-12-11 19:03:47 +08:00
|
|
|
|
* 执行sql脚本
|
2024-12-19 17:30:50 +08:00
|
|
|
|
* @ApiMethod(GET)
|
|
|
|
|
* @ApiParams(name = "page", type = "int",required=false,description = "页数")
|
|
|
|
|
* @ApiParams(name = "limit", type = "int",required=false,description = "每页条数")
|
2024-11-04 10:49:10 +08:00
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
2024-12-19 17:30:50 +08:00
|
|
|
|
$limit = $this->request->param('limit/d', 1000);
|
|
|
|
|
$page = $this->request->param('page/d', 1);
|
2024-12-11 19:03:47 +08:00
|
|
|
|
Db::startTrans();
|
|
|
|
|
try {
|
2024-12-13 18:37:50 +08:00
|
|
|
|
// $da = ServiceOrder::getCost("dgadasdasdsds12343","2024121214396382520","aaaaa",$param=[],true);
|
|
|
|
|
// var_dump($da);
|
2024-12-19 17:30:50 +08:00
|
|
|
|
// Sqlscript::deleteClasses(1,1000);
|
|
|
|
|
Sqlscript::importClasses($page,$limit);
|
|
|
|
|
Sqlscript::importUser($page,$limit);
|
2024-12-11 19:03:47 +08:00
|
|
|
|
Db::commit();
|
|
|
|
|
} catch (PDOException|\Exception $e) {
|
|
|
|
|
Db::rollback();
|
|
|
|
|
$this->error($e->getMessage().$e->getFile().$e->getLine());
|
|
|
|
|
}
|
2024-11-04 10:49:10 +08:00
|
|
|
|
$this->success('请求成功');
|
|
|
|
|
}
|
2024-11-05 18:05:18 +08:00
|
|
|
|
|
2024-11-16 18:01:16 +08:00
|
|
|
|
/**
|
|
|
|
|
* 各种协议文章
|
2024-12-13 18:37:50 +08:00
|
|
|
|
* @ApiSummary(about_us 关于夜校 entry_agreement 入驻协议 privacy 隐私协议 user_protocol 用户协议)
|
2024-11-16 18:01:16 +08:00
|
|
|
|
* @ApiMethod (GET)
|
|
|
|
|
*/
|
|
|
|
|
public function agreement()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
'about_us' => config("site.about_us"),
|
2024-12-06 18:47:05 +08:00
|
|
|
|
'entry_agreement' => config("site.entry_agreement"),
|
|
|
|
|
"privacy"=> config("site.privacy"),
|
2024-12-13 18:37:50 +08:00
|
|
|
|
"user_protocol"=> config("site.user_protocol"),
|
|
|
|
|
'entry_agreement_file' => config("site.entry_agreement_file"),
|
|
|
|
|
"privacy_file"=> config("site.privacy_file"),
|
|
|
|
|
"user_protocol_file"=> config("site.user_protocol_file"),
|
2024-11-16 18:01:16 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$this->success(__('查询成功'), $data);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-05 18:05:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ApiTitle(init接口,小程序初始化参数接口)
|
|
|
|
|
* @ApiSummary(小程序初始化参数接口)
|
|
|
|
|
* @ApiRoute(/api/index/init)
|
|
|
|
|
* @ApiMethod(GET)
|
|
|
|
|
* @ApiReturn({
|
|
|
|
|
"code" => 1,
|
|
|
|
|
"msg" => "获取成功",
|
|
|
|
|
"data" => {}
|
|
|
|
|
*})
|
|
|
|
|
*/
|
|
|
|
|
public function init() {
|
|
|
|
|
|
2024-11-16 18:01:16 +08:00
|
|
|
|
$home_data = [];
|
|
|
|
|
$home_data['top_image'] = [
|
|
|
|
|
'type' => config('site.home_top_type'),
|
|
|
|
|
'image' => cdnurl(config('site.home_top_image'), true),
|
|
|
|
|
'url' => config('site.home_top_url'),
|
|
|
|
|
];
|
|
|
|
|
//首页轮播图
|
|
|
|
|
$home_data['top_images'] = HomeImages::allList(1, 20);
|
|
|
|
|
$base_info = [
|
|
|
|
|
"site_name"=>config('site.name'),
|
|
|
|
|
// "site_logo"=>cdnurl(config('site.logo'), true),
|
|
|
|
|
"site_beian"=>config('site.beian'),
|
|
|
|
|
"site_version"=>''.config('site.version'),
|
2024-12-11 19:03:47 +08:00
|
|
|
|
"site_city"=> Virtual::getNowCity(),
|
2024-11-16 18:01:16 +08:00
|
|
|
|
"site_timezone"=>config('site.timezone'),
|
|
|
|
|
];
|
2024-12-30 18:09:23 +08:00
|
|
|
|
$customer_service = [
|
|
|
|
|
"image"=>cdnurl(config('site.customer_service_image'),true),
|
|
|
|
|
"mobile"=>config('site.customer_service_mobile'),
|
|
|
|
|
];
|
2024-11-26 17:59:18 +08:00
|
|
|
|
$upload_config = config('upload');
|
2024-11-16 18:01:16 +08:00
|
|
|
|
|
2024-12-30 18:09:23 +08:00
|
|
|
|
$this->success('',["customer_service"=>$customer_service,"upload_config"=>$upload_config,"base_info"=>$base_info,"home_data"=>$home_data]);
|
2024-11-05 18:05:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-05 18:41:08 +08:00
|
|
|
|
/**
|
|
|
|
|
* @ApiTitle(省市区数据)
|
|
|
|
|
* @ApiSummary(省市区数据)
|
|
|
|
|
* @ApiRoute(/api/index/area)
|
|
|
|
|
* @ApiMethod(GET)
|
|
|
|
|
* @ApiReturn({
|
|
|
|
|
"code" => 1,
|
|
|
|
|
"msg" => "获取成功",
|
|
|
|
|
"data" => {}
|
|
|
|
|
*})
|
|
|
|
|
*/
|
|
|
|
|
public function area()
|
|
|
|
|
{
|
|
|
|
|
$data['provinceData'] = Area::where('level', 1)->order('id asc')->field('id as value, name as label, pid, level')->select();
|
|
|
|
|
foreach ($data['provinceData'] as $k => $p) {
|
|
|
|
|
$data['cityData'][$k] = Area::where(['level' => 2, 'pid' => $p->value])->order('id asc')->field('id as value, name as label, pid, level')->select();
|
|
|
|
|
foreach ($data['cityData'][$k] as $i => $c) {
|
|
|
|
|
$data['areaData'][$k][$i] = Area::where(['level' => 3, 'pid' => $c->value])->order('id asc')->field('id as value, name as label, pid, level')->select();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->success('省市区', $data);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ApiTitle(省市区数据预加载接口)
|
|
|
|
|
* @ApiSummary(省市区数据预加载接口)
|
|
|
|
|
* @ApiRoute(/api/index/get_area)
|
|
|
|
|
* @ApiMethod(GET)
|
|
|
|
|
* @ApiParams(name = "province", type = "string",required=false,description = "省编号")
|
|
|
|
|
* @ApiParams(name = "city", type = "string",required=false,description = "市编号")
|
|
|
|
|
* @ApiReturn({
|
|
|
|
|
"code" => 1,
|
|
|
|
|
"msg" => "获取成功",
|
|
|
|
|
"data" => {}
|
|
|
|
|
*})
|
|
|
|
|
*/
|
|
|
|
|
public function get_area()
|
|
|
|
|
{
|
|
|
|
|
$province = $this->request->get('province/s', ''); //机构店铺id
|
|
|
|
|
$city = $this->request->get('city/s', ''); //机构店铺id
|
|
|
|
|
$model = new Area();
|
|
|
|
|
if($province && !$city){
|
|
|
|
|
$model = $model->where("pid",$province)->where("level",2);
|
|
|
|
|
}elseif ($city){
|
|
|
|
|
$model = $model->where("pid",$city)->where("level",3);
|
|
|
|
|
}else{
|
|
|
|
|
$model = $model->where("level",1);
|
|
|
|
|
}
|
|
|
|
|
$data = $model->order('id asc')->field('id as value, name as label, pid, level')->select();
|
|
|
|
|
|
|
|
|
|
$this->success('省市区', $data);
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-05 18:05:18 +08:00
|
|
|
|
|
2024-11-04 10:49:10 +08:00
|
|
|
|
}
|