init:初始化多余的,添加班型列表

This commit is contained in:
lwh 2023-04-18 21:20:25 +08:00
parent e7955eeef3
commit 60692fa902
25 changed files with 361 additions and 5713 deletions

23
.env Normal file
View File

@ -0,0 +1,23 @@
APP_DEBUG = true
APP_SHOW_ERROR = true
APP_MODE = production
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
DEFAULT_IMG_URL = http://localhost:3000
[DATABASE]
TYPE = mysql
HOSTNAME = 47.242.159.172
# HOSTNAME = 127.0.0.1
DATABASE = houde_web
USERNAME = houde_web
PASSWORD = houde_web@aerwen
# USERNAME = root
# PASSWORD = root
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
.env .env
*.http *.http
runtime/* runtime/*
app/admin/controller/Gen/Gen.php

View File

@ -0,0 +1,148 @@
<?php
namespace app\admin\controller\Enrol;
use app\BaseController;
use app\common\model\Enrol\Classes as ModelClasses;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use app\common\exception\Tool;
use think\facade\Db;
use think\facade\Env;
class Classes extends BaseController
{
/**
* 获取班型列表
*/
public function getClassesList(Request $request): array
{
$params = $request->param();
$con = [];
$con = Tool::getOptionalQuery(['classes_name', 'LIKE'],);
$query = ModelClasses::where($con)
->field([
'classes_id',
'classes_guid',
'classes_name',
'classes_desc',
'classes_content',
'classes_sort'
])
->order('classes_sort', 'asc');
return msg("获取班型列表成功!", $query);
}
/**
* 编辑班型
*/
public function editClasses(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'classes_name|名称' => 'require',
'classes_content|内容' => 'require',
'classes_sort|排序' => 'require'
]);
$model = ModelClasses::where('classes_guid', $params['classes_guid'])->find();
if (!$model) throwErrorMsg("该班型不存在", 1);
$model->allowField([
'classes_update_user_guid',
'classes_name',
'classes_desc',
'classes_content',
'classes_sort'
])->save($params);
return msg('编辑成功!');
}
/**
* 添加班型
*/
public function addClasses(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'classes_name|名称' => 'require',
'classes_content|内容' => 'require',
'classes_sort|排序' => 'require'
]);
$model = ModelClasses::create($params, [
'classes_guid',
'classes_create_user_guid',
'classes_update_user_guid',
'classes_name',
'classes_desc',
'classes_content',
'classes_sort'
]);
return msg('添加成功!');
}
/**
* 删除班型
*/
public function deleteClasses(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'classes_guid' => 'require',
]);
$classes = ModelClasses::where([
'classes_guid' => explode(',', $params['classes_guid'])
])->select();
$classes->delete();
return msg('删除成功!');
}
/**
* 导出Excel
*/
public function exportExcel(Request $request)
{
$params = $request->param();
$select = ModelClasses::field([
'classes_name',
'classes_desc',
'classes_content',
'classes_sort'
])
->order('classes_sort', 'asc')
->select();
return ModelClasses::exportExcel($select);
}
/**
* 下载导入模板
*/
public function downloadTemplate(Request $request)
{
$params = $request->param();
$data = array_values(ModelClasses::EXCELFIELD);
$excel = (new Excel())->exporTsheet($data);
$excel->save('班型导入模板.xlsx');
}
/**
* 导入excel
*/
public function importExcel(Request $request)
{
$file = new UploadFile('uploads', 'fileExt:xlsx');
$file->putFile('classes');
$msg = ModelClasses::importExcel($file);
return [
'code' => 0,
'msg' => $msg
];
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,291 +0,0 @@
<?php
namespace app\admin\controller\News;
use app\BaseController;
use app\common\model\News\News as ModelNews;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use think\facade\Env;
class News extends BaseController
{
/**
* 获取新闻列表
*/
public function getNewsList(Request $request): array
{
$params = $request->param();
$con = [];
if (isset($params['news_title']) && $params['news_title']) {
$con[] = ['news_title', 'LIKE', '%' . $params['news_title'] . '%'];
};
if (isset($params['news_type']) && $params['news_type']) {
$con[] = ['news_type', '=', $params['news_type']];
};
$query = ModelNews::where($con);
$select = self::pageWrapper($query)
->field([
'news_id',
'news_guid',
'news_title',
'news_author',
'news_intro',
'news_type',
'news_img',
'news_content',
'news_num'
])
->order('news_update_time', 'desc')
->select();
$count = $query->count();
return [
'code' => 0,
'data' => $select,
'count' => $count,
'msg' => 'ok'
];
}
/**
* 编辑新闻
*/
public function editNews(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'news_title|新闻标题' => 'require',
'news_author|新闻作者' => 'require',
'news_intro|新闻简介' => 'require',
'news_type|新闻类型' => 'require',
'news_img|新闻封面' => 'require',
]);
$model = ModelNews::where('news_guid', $params['news_guid'])->find();
if (!$model) throwErrorMsg("该新闻不存在", 1);
$model->allowField([
'news_update_user_guid',
'news_title',
'news_author',
'news_intro',
'news_type',
'news_img',
'news_content',
'news_num'
])->save($params);
return [
'code' => 0,
'msg' => '编辑成功'
];
}
/**
* 添加新闻
*/
public function addNews(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'news_title|新闻标题' => 'require',
'news_author|新闻作者' => 'require',
'news_intro|新闻简介' => 'require',
'news_type|新闻类型' => 'require',
'news_img|新闻封面' => 'require',
]);
$model = ModelNews::create($params, [
'news_guid',
'news_create_user_guid',
'news_update_user_guid',
'news_title',
'news_author',
'news_intro',
'news_type',
'news_img',
'news_content',
'news_num'
]);
return [
'code' => 0,
'msg' => '添加成功'
];
}
/**
* 删除新闻
*/
public function deleteNews(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'news_guid' => 'require',
]);
$news = ModelNews::where([
'news_guid' => explode(',', $params['news_guid'])
])->select();
$news->delete();
return [
'code' => 0,
'msg' => "删除成功"
];
}
/**
* 导出Excel
*/
public function exportExcel(Request $request)
{
$params = $request->param();
$select = ModelNews::field([
'news_title',
'news_author',
'news_intro',
'news_type',
'news_img',
'news_content',
'news_num'
])
->order('news_update_time', 'desc')
->select();
$data = [[
'新闻标题',
'新闻作者',
'新闻简介',
'新闻类型',
'新闻封面',
'新闻内容',
'新闻数量'
]];
foreach ($select as $key => $val) {
$data[] = [
$val['news_title'],
$val['news_author'],
$val['news_intro'],
$val['news_type'],
$val['news_img'],
$val['news_content'],
$val['news_num'],
];
}
$excel = (new Excel())->exporTsheet($data);
$excel->save('新闻.xlsx');
}
/**
* 下载导入模板
*/
public function downloadTemplate(Request $request)
{
$params = $request->param();
$data = [
'新闻标题',
'新闻作者',
'新闻简介',
'新闻类型',
'新闻封面',
'新闻内容',
'新闻数量'
];
$excel = (new Excel())->exporTsheet($data);
$excel->save('新闻导入模板.xlsx');
}
/**
* 导入excel
*/
public function importExcel(Request $request)
{
$file = new UploadFile('uploads', 'fileExt:xlsx');
$file->putFile('news');
Db::startTrans();
try {
$excel = new Excel($file);
$data = $excel->parseExcel(
[[
'title' => '新闻标题',
'validate' => 'require',
'field' => 'news_title',
], [
'title' => '新闻作者',
'validate' => 'require',
'field' => 'news_author',
], [
'title' => '新闻简介',
'validate' => 'require',
'field' => 'news_intro',
], [
'title' => '新闻类型',
'validate' => 'require',
'field' => 'news_type',
], [
'title' => '新闻封面',
'validate' => 'require',
'field' => 'news_img',
], [
'title' => '新闻内容',
'validate' => 'require',
'field' => 'news_content',
], [
'title' => '新闻数量',
'validate' => 'require',
'field' => 'news_num',
],],
[
'titleLine' => [1]
]
);
if (!$data) throwErrorMsg('excel无数据', 1);
$error = [];
foreach ($data as $line => $value) {
try {
$news_title = $value['news_title'];
$news_author = $value['news_author'];
$news_intro = $value['news_intro'];
$news_type = $value['news_type'];
$news_img = $value['news_img'];
$news_content = $value['news_content'];
$news_data = $value['news_data'];
$news_time = $value['news_time'];
$news_num = $value['news_num'];
ModelNews::create([
'news_title' => $news_title,
'news_author' => $news_author,
'news_intro' => $news_intro,
'news_type' => $news_type,
'news_img' => $news_img,
'news_content' => $news_content,
'news_num' => $news_num,
]);
} catch (\Throwable $th) {
$error[] = $line . '' . $th->getMessage();
}
}
if ($error) throwErrorMsg(implode(', ', $error), 1);
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
return [
'code' => 0,
'msg' => '导入成功!'
];
}
}

View File

@ -1,220 +0,0 @@
<?php
namespace app\admin\controller\Product;
use app\BaseController;
use app\common\model\Product\Product as ModelProduct;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use app\common\exception\Tool;
use think\facade\Db;
use think\facade\Env;
class Product extends BaseController
{
/**
* 获取产品列表接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function getProductList(Request $request): array
{
Db::startTrans();
try {
$params = $request->param();
$con = [];
$con = Tool::getOptionalQuery(
['product.product_name', 'LIKE'],
['product.product_type_guid'],
);
$query = ModelProduct::where($con)
->leftJoin('product_type', 'product_type.product_type_guid = product.product_type_guid')
->field([
'product.product_id',
'product.product_guid',
'product.product_type_guid',
'product.product_name',
'product.product_img',
'product.product_params',
'product.product_details',
'product.product_price',
'product_type.product_type_name'
])
->order('product_id', 'desc');
return msg("获取产品列表成功!", $query);
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 编辑产品接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function editProduct(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'product_type_guid|产品系列guid' => 'require',
'product_name|名称' => 'require',
'product_img|图片' => 'require',
'product_details|详情' => 'require',
'product_price|价格' => 'require'
]);
$model = ModelProduct::where('product_guid', $params['product_guid'])->find();
if (!$model) throwErrorMsg("该产品不存在", 1);
// Tool::sortEditProc(
// new ModelProduct,
// ["product_guid" => $params['product_guid']],
// ["product_type_order" => $params['product_type_order']],
// );
$model->allowField([
'product_update_user_guid',
'product_type_guid',
'product_name',
'product_img',
'product_params',
'product_details',
'product_price'
])->save($params);
return msg('编辑成功!');
}
/**
* 添加产品接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function addProduct(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'product_type_guid|产品系列guid' => 'require',
'product_name|名称' => 'require',
'product_img|图片' => 'require',
'product_details|详情' => 'require',
'product_price|价格' => 'require'
]);
ModelProduct::create($params, [
'product_guid',
'product_create_user_guid',
'product_update_user_guid',
'product_type_guid',
'product_name',
'product_img',
'product_params',
'product_details',
'product_price'
]);
return msg('添加成功!');
}
/**
* 删除产品接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function deleteProduct(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'product_guid|产品系列' => 'require',
]);
$product = ModelProduct::where([
'product_guid' => explode(',', $params['product_guid'])
])->select();
$product->delete();
return msg('删除成功!');
}
/**
* 导出Excel接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function exportExcel(Request $request)
{
$params = $request->param();
$select = ModelProduct::field([
'product_type_guid',
'product_name',
'product_img',
'product_params',
'product_details',
'product_price'
])
->order('product_update_time', 'desc')
->select();
return ModelProduct::exportExcel($select);
}
/**
* 下载导入模板接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function downloadTemplate(Request $request)
{
$params = $request->param();
$data = array_values(ModelProduct::EXCELFIELD);
$excel = (new Excel())->exporTsheet($data);
$excel->save('产品导入模板.xlsx');
}
/**
* 导入excel接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function importExcel(Request $request)
{
$file = new UploadFile('uploads', 'fileExt:xlsx');
$file->putFile('product');
$msg = ModelProduct::importExcel($file);
return [
'code' => 0,
'msg' => $msg
];
}
}

View File

@ -1,148 +0,0 @@
<?php
namespace app\admin\controller\Product;
use app\BaseController;
use app\common\model\Product\ProductParam as ModelProductParam;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use app\common\exception\Tool;
use think\facade\Db;
use think\facade\Env;
class ProductParam extends BaseController
{
/**
* 获取产品参数列表接口
*
* @param Request request
* @date 2023-04-02
* @example
* @author xjh
* @since 1.0.0
*/
public function getProductParamList(Request $request): array
{
$con = Tool::getOptionalQuery(['product_param.product_type_guid', '=']);
$query = ModelProductParam::where($con)
->field([
'product_param.product_param_id',
'product_param.product_param_guid',
'product_param.product_param_name',
'product_param.product_type_guid',
'product_param.product_param_order',
'product_type.product_type_name'
])
->leftJoin('product_type', 'product_type.product_type_guid = product_param.product_type_guid')
->order('product_param_order', 'asc');
return msg("获取产品参数列表成功!", $query);
}
/**
* 获取指定系列参数模板接口
*
* @param Request request
* @date 2023-04-02
* @example
* @author xjh
* @since 1.0.0
*/
public function getProductParamTemplate(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'product_type_guid|产品系列guid' => 'require'
]);
$data = ModelProductParam::field(['product_param_name', 'product_param_order'])
->where('product_type_guid', $params['product_type_guid'])
->order('product_param_order', 'desc')
->append(['product_param_value'])
->select();
return msg(0, '获取指定系列参数模板成功!', ['data' => $data]);
}
/**
* 编辑产品参数接口
*
* @param Request request
* @date 2023-04-02
* @example
* @author xjh
* @since 1.0.0
*/
public function editProductParam(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'product_param_name|产品参数名称' => 'require',
'product_type_guid|产品系列guid' => 'require'
]);
$model = ModelProductParam::where('product_param_guid', $params['product_param_guid'])->find();
if (!$model) throwErrorMsg("该产品参数不存在", 1);
$model->allowField([
'product_param_update_user_guid',
'product_param_name',
'product_type_guid',
'product_param_order'
])->save($params);
return msg('编辑成功!');
}
/**
* 添加产品参数接口
*
* @param Request request
* @date 2023-04-02
* @example
* @author xjh
* @since 1.0.0
*/
public function addProductParam(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'product_param_name|产品参数名称' => 'require',
'product_type_guid|产品系列guid' => 'require'
]);
$model = ModelProductParam::create($params, [
'product_param_guid',
'product_param_create_user_guid',
'product_param_update_user_guid',
'product_param_name',
'product_param_order',
'product_type_guid'
]);
return msg('添加成功!');
}
/**
* 删除产品参数接口
*
* @param Request request
* @date 2023-04-02
* @example
* @author xjh
* @since 1.0.0
*/
public function deleteProductParam(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'product_param_guid' => 'require',
]);
$product_param = ModelProductParam::where([
'product_param_guid' => explode(',', $params['product_param_guid'])
])->select();
$product_param->delete();
return msg('删除成功!');
}
}

View File

@ -1,271 +0,0 @@
<?php
namespace app\admin\controller\Product;
use app\BaseController;
use app\common\model\Product\ProductType as ModelProductType;
use app\common\arw\adjfut\src\Traverse;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use app\common\exception\Tool;
use think\facade\Db;
use think\facade\Env;
class ProductType extends BaseController
{
/**
* 获取产品系列树形列表接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function getProductTypeTree(Request $request): array
{
$con = Tool::getOptionalQuery(
['b.product_delete_time', 'NULL'],
['a.product_type_name', 'LIKE']
);
$product_type = ModelProductType::field([
'a.product_type_parent_guid',
'a.product_type_name',
'b.product_type_name' => "product_type_parent_name",
'a.product_type_order',
'a.product_type_guid',
'a.product_type_icon',
'a.product_type_cover',
])
->alias('a')
->leftjoin('product_type b', 'a.product_type_parent_guid = b.product_type_guid')
->where($con)
->order(['product_type_order' => 'asc'])
->select()->toArray();
$Traverse = new Traverse('product_type_guid', 'product_type_parent_guid');
$product_type_tree = $Traverse->tree($product_type, '0', function ($v) {
return [
'product_type_name' => $v['product_type_name'],
'product_type_parent_name' => $v['product_type_parent_name'],
'product_type_guid' => $v['product_type_guid'],
'product_type_parent_guid' => $v['product_type_parent_guid'],
'product_type_order' => $v['product_type_order'],
'product_type_icon' => $v['product_type_icon'],
'product_type_cover' => $v['product_type_cover'],
];
});
return msg("获取产品系列列表成功!", $product_type_tree);
}
/**
* 编辑产品系列接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function editProductType(Request $request): array
{
Db::startTrans();
try {
$params = $request->param();
$this->validate($params, [
'product_type_name|产品系列名称' => 'require',
'product_type_icon|产品系列图标' => 'require',
'product_type_cover|产品系列封面' => 'require',
'product_type_guid|产品系列guid' => 'require',
'product_type_order|产品系列排序' => 'require',
]);
$model = ModelProductType::where('product_type_guid', $params['product_type_guid'])->find();
if (!$model) throwErrorMsg("该产品系列不存在", 1);
ModelProductType::isDuplicateName($params['product_type_name'], $params['product_type_guid']);
$params['product_type_ancestors_guid'] = ModelProductType::buildAncestorsGuid($params['product_type_parent_guid']);
Tool::sortEditProc(
new ModelProductType,
["product_type_order" => $params['product_type_order']],
["product_type_guid" => $params['product_type_guid']],
["product_type_parent_guid" => $params['product_type_parent_guid']],
);
$model->allowField([
'product_type_update_user_guid',
'product_type_title',
'product_type_icon',
'product_type_cover',
'product_type_ancestors_guid',
'product_type_parent_guid',
'product_type_order',
])->save($params);
Db::commit();
return msg('编辑成功!');
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 添加产品系列接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function addProductType(Request $request): array
{
Db::startTrans();
try {
$params = $request->param();
$this->validate($params, [
'product_type_name|产品类型名称' => 'require',
'product_type_icon|产品系列图标' => 'require',
'product_type_cover|产品系列封面' => 'require',
'product_type_order|产品系列排序' => 'require'
]);
ModelProductType::isDuplicateName($params['product_type_name']);
$product_type_parent_where = [];
if (!empty($params['product_type_parent_guid'])) {
$params['product_type_ancestors_guid'] = ModelProductType::buildAncestorsGuid($params['product_type_parent_guid']);
$product_type_parent_where['product_type_parent_guid'] = $params['product_type_parent_guid'];
}
Tool::sortInsertProc(
new ModelProductType,
["product_type_order" => $params['product_type_order']],
$product_type_parent_where,
);
ModelProductType::create($params, [
'product_type_guid',
'product_type_create_user_guid',
'product_type_update_user_guid',
'product_type_parent_guid',
'product_type_ancestors_guid',
'product_type_name',
'product_type_icon',
'product_type_cover',
'product_type_order'
]);
Db::commit();
return msg("添加成功!");
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 删除产品系列接口接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function deleteProductType(Request $request): array
{
Db::startTrans();
try {
$params = $request->param();
$this->validate($params, [
'product_type_guid|产品系列guid' => 'require',
]);
$guids = explode(',', $params['product_type_guid']);
Tool::sortDeleteProc(
new ModelProductType,
'product_type_order',
["product_type_guid" => $guids],
["product_type_parent_guid"],
);
ModelProductType::where(['product_type_guid' => $guids])->select()->delete();
Db::commit();
return msg('删除成功!');
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 导出Excel接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function exportExcel(Request $request)
{
$params = $request->param();
$select = ModelProductType::field([
'product_type_title',
'product_type_icon',
'product_type_cover'
])
->order('product_type_update_time', 'desc')
->select();
return ModelProductType::exportExcel($select);
}
/**
* 下载导入模板接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function downloadTemplate(Request $request)
{
$params = $request->param();
$data = array_values(ModelProductType::EXCELFIELD);
$excel = (new Excel())->exporTsheet($data);
$excel->save('产品系列导入模板.xlsx');
}
/**
* 导入excel接口
*
* @param Request request
* @date 2023-03-25
* @example
* @author xjh
* @since 1.0.0
*/
public function importExcel(Request $request)
{
$file = new UploadFile('uploads', 'fileExt:xlsx');
$file->putFile('product_type');
$msg = ModelProductType::importExcel($file);
return [
'code' => 0,
'msg' => $msg
];
}
}

View File

@ -1,111 +0,0 @@
<?php
namespace app\admin\controller\School;
use app\BaseController;
use app\common\model\School\Classes as ModelClasses;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use think\facade\Env;
class Classes extends BaseController
{
/**
* 获取班级列表
*/
public function getClassesList(Request $request): array
{
$params = $request->param();
$con = [];
if (isset($params['classes_name']) && $params['classes_name']) {
$con[] = ['classes_name', 'LIKE', '%' . $params['classes_name'] . '%'];
};
$query = ModelClasses::where($con);
$select = self::pageWrapper($query)
->field([
'classes_id',
'classes_guid',
'classes_name'
])
->order('classes_update_time', 'desc')
->select();
$count = $query->count();
return [
'code' => 0,
'data' => $select,
'count' => $count,
'msg' => 'ok'
];
}
/**
* 编辑班级
*/
public function editClasses(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'classes_name|班级名称' => 'require'
]);
$model = ModelClasses::where('classes_guid', $params['classes_guid'])->find();
if (!$model) throwErrorMsg("该班级不存在", 1);
$model->allowField([
'classes_update_user_guid',
'classes_name'
])->save($params);
return [
'code' => 0,
'msg' => '编辑成功'
];
}
/**
* 添加班级
*/
public function addClasses(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'classes_name|班级名称' => 'require'
]);
$model = ModelClasses::create($params, [
'classes_guid',
'classes_create_user_guid',
'classes_update_user_guid',
'classes_name'
]);
return [
'code' => 0,
'msg' => '添加成功'
];
}
/**
* 删除班级
*/
public function deleteClasses(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'classes_guid' => 'require',
]);
$classes = ModelClasses::where([
'classes_guid' => explode(',', $params['classes_guid'])
])->select();
$classes->delete();
return [
'code' => 0,
'msg' => "删除成功"
];
}
}

View File

@ -1,544 +0,0 @@
<?php
namespace app\admin\controller\School;
use app\BaseController;
use app\common\model\School\Student as ModelStudent;
use app\common\model\School\StudentService as ModelStudentService;
use app\common\model\Product\Product as ModelProduct;
use app\common\model\Product\ProductType as ModelProductType;
use app\common\model\Product\ProductParts as ModelProductParts;
use app\common\model\User\User as ModelUser;
use app\Request;
use app\common\arw\adjfut\src\Traverse;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use think\facade\Env;
use app\common\exception\Map;
class Student extends BaseController
{
public function index()
{
return $user_guid = Request::getCurrentUser()->user_guid;
$jwd = Map::getLongitudeAndLatitude("广东省佛山市顺德区容桂街道保利·德胜湾保利外滩一号");
return $jwd;
// return date('Y-m-d H:i:s', strtotime('+3 month'));
}
/**
* 获取学生列表
*/
public function getStudentList(Request $request)
{
$params = $request->param();
$con = [];
$conOr = [];
if (isset($params['student_name']) && $params['student_name']) {
$con[] = ['student_name', 'LIKE', '%' . $params['student_name'] . '%'];
};
if (isset($params['studnet_phone']) && $params['studnet_phone']) {
$con[] = ['studnet_phone', 'LIKE', '%' . $params['studnet_phone'] . '%'];
};
if (isset($params['student_id_card']) && $params['student_id_card']) {
$con[] = ['student_id_card', 'LIKE', '%' . $params['student_id_card'] . '%'];
};
if (isset($params['student_email']) && $params['student_email']) {
$con[] = ['student_email', 'LIKE', '%' . $params['student_email'] . '%'];
};
if (isset($params['student_sex']) && $params['student_sex']) {
$con[] = ['student_sex', '=', $params['student_sex']];
};
if (isset($params['student_membe_type']) && $params['student_membe_type']) {
$con[] = ['student_membe_type', '=', $params['student_membe_type']];
};
if (isset($params['student_audit_status']) && $params['student_audit_status']) {
$con[] = ['student_audit_status', '=', $params['student_audit_status']];
};
if (isset($params['product_type']) && $params['product_type']) {
$con[] = ['a.product_type', '=', $params['product_type']];
$conOr[] = ['c.product_type_parent_guid', '=', $params['product_type']];
};
if (isset($params['product_guid']) && $params['product_guid']) {
$con[] = ['a.product_guid', '=', $params['product_guid']];
};
if (isset($params['product_parts_guid']) && $params['product_parts_guid']) {
$con[] = ['a.product_parts_guid', '=', $params['product_parts_guid']];
};
if (isset($params['student_brithday']) && $params['student_brithday']) {
$con[] = ['student_brithday', 'BETWEEN', implode(',', $params['student_brithday'])];
};
// return $con;
$query = ModelStudent::alias('a')
->leftjoin('user b', 'a.user_guid = b.user_guid')
->leftjoin('product_type c', 'a.product_type = c.product_type_guid')
->leftjoin('product d', 'a.product_guid = d.product_guid')
->leftjoin('product_parts e', 'a.product_parts_guid = e.product_parts_guid')
->leftjoin('classes f', 'a.classes_guid = f.classes_guid')
->where($con)
->whereOr(function ($query) use ($conOr) {
$query->whereOr($conOr);
});
if (isset($params['student_member_time']) && $params['student_member_time']) {
$query->where("
(
student_member_begin_time >= '{$params['student_member_time'][0]}'
AND
student_member_begin_time <= '{$params['student_member_time'][1]}'
)
OR
(
student_member_end_time >= '{$params['student_member_time'][0]}'
AND
student_member_end_time <= '{$params['student_member_time'][1]}'
)
OR
(
student_member_begin_time >= '{$params['student_member_time'][0]}'
AND
student_member_end_time <= '{$params['student_member_time'][1]}'
)
");
}
$select = self::pageWrapper($query)
->field([
'a.student_id',
'a.student_guid',
'a.student_name',
'a.user_guid',
'b.user_name',
'a.classes_guid',
'f.classes_name',
'a.studnet_phone',
'a.student_id_card',
'a.student_email',
'a.student_sex',
'a.student_price',
'a.student_brithday',
'a.product_type',
'c.product_type_name',
'a.product_guid',
'd.product_name',
'a.product_parts_guid',
'e.product_parts_name',
'a.student_img',
'a.student_banner_img',
'a.student_attachment',
'a.student_intro',
'a.student_location',
'a.longitude',
'a.latitude',
'a.student_membe_type',
'a.student_member_begin_time',
'a.student_member_end_time',
'a.student_audit_status',
'a.student_audit_user_guid',
"(SELECT `user`.`user_name` FROM `user` WHERE `user`.user_guid = `a`.`student_audit_user_guid`) as student_audit_user_name",
])
->append([
'student_member_time',
'student_service',
])
->order('student_update_time', 'desc')
->select();
$count = $query->count();
return [
'code' => 0,
'data' => $select,
'count' => $count,
'msg' => 'ok'
];
}
/**
* 编辑学生
*/
public function editStudent(Request $request)
{
$params = $request->param();
$this->validate($params, [
'student_name|学生名称' => 'require',
'user_guid|用户' => 'require',
'classes_guid|班级' => 'require',
'studnet_phone|手机号' => 'require',
'student_id_card|身份证号' => 'require',
'student_sex|性别' => 'require',
'student_price|学生价格' => 'require',
'product_type|产品类型' => 'require',
'product_guid|产品' => 'require',
'product_parts_guid|产品零件' => 'require',
'student_img|头像' => 'require',
'student_intro|简介' => 'require',
'student_location|家庭住址' => 'require',
'longitude|经度' => 'require',
'latitude|纬度' => 'require'
]);
$model = ModelStudent::where('student_guid', $params['student_guid'])->find();
if (!$model) throwErrorMsg("该学生不存在", 1);
$student_member_time = $params['student_member_time'];
$params['student_member_begin_time'] = $student_member_time[0];
$params['student_member_end_time'] = $student_member_time[1];
// return $params;
$model->allowField([
'student_update_user_guid',
'student_name',
'user_guid',
'classes_guid',
'studnet_phone',
'student_id_card',
'student_email',
'student_sex',
'student_price',
'student_brithday',
'product_type',
'product_guid',
'product_parts_guid',
'student_img',
'student_banner_img',
'student_attachment',
'student_intro',
'student_location',
'longitude',
'latitude',
'student_membe_type',
'student_member_begin_time',
'student_member_end_time',
'student_audit_status',
'student_audit_user_guid'
])->save($params);
// 学生服务编辑
ModelStudent::editStudentService($params);
return [
'code' => 0,
'msg' => '编辑成功'
];
}
/**
* 添加学生
*/
public function addStudent(Request $request)
{
$params = $request->param();
$this->validate($params, [
'student_name|学生名称' => 'require',
'user_name|用户' => 'require',
'classes_guid|班级' => 'require',
'studnet_phone|手机号' => 'require',
'student_id_card|身份证号' => 'require',
'student_sex|性别' => 'require',
'student_price|学生价格' => 'require',
'product_type|产品类型' => 'require',
'product_guid|产品' => 'require',
'product_parts_guid|产品零件' => 'require',
'student_img|头像' => 'require',
'student_intro|简介' => 'require',
'student_location|家庭住址' => 'require',
'longitude|经度' => 'require',
'latitude|纬度' => 'require',
'student_membe_type|会员类型' => 'require',
]);
$params = ModelStudent::initAdd($params);
$model = ModelStudent::create($params, [
'student_guid',
'student_create_user_guid',
'student_update_user_guid',
'student_name',
'user_guid',
'classes_guid',
'studnet_phone',
'student_id_card',
'student_email',
'student_sex',
'student_price',
'student_brithday',
'product_type',
'product_guid',
'product_parts_guid',
'student_img',
'student_banner_img',
'student_attachment',
'student_intro',
'student_location',
'longitude',
'latitude',
'student_membe_type',
'student_member_begin_time',
'student_member_end_time',
'student_audit_status',
'student_audit_user_guid'
]);
if (!$model) throwErrorMsg("添加失败");
$student_guid = $model->student_guid;
// 添加学生服务
ModelStudent::addStudentService($student_guid, $params);
return [
'code' => 0,
'msg' => '添加成功'
];
}
/**
* 删除学生
*/
public function deleteStudent(Request $request): array
{
$params = $request->param();
$this->validate($params, [
'student_guid' => 'require',
]);
$student = ModelStudent::where([
'student_guid' => explode(',', $params['student_guid'])
])->select();
$student->delete();
// 从学生服务(副表)查询出所有当前学生的服务,进行删除
ModelStudentService::where('student_guid', $params['student_guid'])->select()->delete();
return [
'code' => 0,
'msg' => "删除成功"
];
}
/**
* 查找未绑定用户列表
*/
public function notBindUserList(Request $request)
{
$user = $request->param('user');
$con = [
'user_status' => 1,
];
$search = [];
if ($user) {
$search['user_name'] = $user;
}
$query = ModelUser::alias('a')
->join('student b', 'a.user_guid != b.user_guid')
->withSearch(array_keys($search), $search)->where($con)
->whereNotExists(function ($query) {
$query->table('student')->alias('b')->where("a.user_guid = b.user_guid");
});
$select = self::pageWrapper($query)->field([
'a.user_name',
])
->group('user.user_guid')->order([
'user.user_update_time' => 'desc'
])->select();
$count = $query->count();
return [
'code' => 0,
'data' => $select,
'count' => $count,
'msg' => 'ok'
];
}
/**
* 审核学生
*/
public function auditStudent(Request $request)
{
$params = $request->param();
$this->validate($params, [
'student_guid|学生guid' => 'require',
'student_audit_status|审核状态' => 'require|in:2,3',
]);
ModelStudent::auditStudent($params);
return [
'code' => 0,
'msg' => '审核成功'
];
}
/**
* 导出Excel
*/
public function exportExcel(Request $request)
{
$params = $request->param();
return ModelStudent::exportStudent();
}
/**
* 下载导入模板
*/
public function downloadTemplate(Request $request)
{
$params = $request->param();
$data = [
['学生名称', '用户', '班级', '手机号', '身份证号', '邮箱', '性别', '学生价格', '生日', '产品类型', '产品', '产品零件', '头像', '轮播图片', '简介', '家庭住址', '会员类型',]
];
$data[] = ['张思', '负责人', '网络3+2', '19882556281', '110223790813697', '2679599887@163.com', '男', '99.99', '2023-02-19', '小米10', '小米10代手机 全面屏 3亿像素', '小米专属钢化膜', 'https://hjczx.net/intelligent_clique/public/uploads/hjczx//student_img/2022/459/210744-compression.jpg', 'http://aerwen.net/prod-api/student/20230218/C9B76FC1E616EE6A.jpg,http://aerwen.net/prod-api/key/20230217/628A9C1A391ABD61.jpg', '我是三好学生', '广东省佛山市顺德区容桂街道胡锦超职业技术学校', '季卡'];
$excel = (new Excel())->exporTsheet($data);
$excel->save('学生导入模板.xlsx');
}
/**
* 导入excel
*/
public function importExcel(Request $request)
{
$file = new UploadFile('uploads', 'fileExt:xlsx');
$file->putFile('student');
$msg = ModelStudent::ImportStudent($file);
return [
'code' => 0,
'msg' => $msg
];
}
/**
* 获取点击后的产品列表
*/
public function getClickProduct(Request $request)
{
$params = $request->param();
$this->validate($params, [
'product_type_guid|产品类型' => 'require',
]);
$product_type_guid = $params['product_type_guid'];
$products = ModelProduct::alias('a')
->leftjoin('product_type b', "a.product_type_guid = b.product_type_guid")
->where("a.product_type_guid = '$product_type_guid' or b.product_type_parent_guid = '$product_type_guid'")->select();
return [
'code' => 0,
'data' => $products,
'msg' => "获取点击后的产品列表成功"
];
}
/**
* 获取点击后的产品零件列表
*/
public function getClickProductParts(Request $request)
{
$params = $request->param();
$this->validate($params, [
'product_guid|产品' => 'require',
]);
$products_parts = ModelProductParts::where('product_guid', $params['product_guid'])->select();
return [
'code' => 0,
'data' => $products_parts,
'msg' => "获取点击后的产品零件列表成功"
];
}
/**
* 获取侧边产品数据
*/
public function getProductTree(): array
{
$data = [];
$product_types = ModelProductType::field([
'product_type_name',
'product_type_guid',
'product_type_parent_guid',
])->select();
foreach ($product_types as $key => $value) {
$product_type_guid = $value['product_type_guid'];
$product_type_parent_guid = $value['product_type_parent_guid'];
$data[] = [
'id' => $product_type_guid,
'parent_id' => $product_type_parent_guid,
'name' => $value['product_type_name'],
'type' => 'product_type',
'data' => [
'parent_id' => $product_type_parent_guid,
'product_type_guid' => $value['product_type_guid']
],
];
}
$products = ModelProduct::field([
'product_name',
'product_guid',
'product_type_guid',
])->select();
foreach ($products as $value) {
$product_guid = $value['product_guid'];
$product_type_guid = $value['product_type_guid'];
$id = $product_guid;
$data[] = [
'id' => $id,
'parent_id' => $product_type_guid,
'name' => $value['product_name'],
'type' => 'product',
'data' => [
'product_type_guid' => $product_type_guid,
'product_guid' => $product_guid
],
];
$product_parts = ModelProductParts::field([
'product_parts_name',
'product_parts_guid',
'product_guid',
])->where('product_guid', $product_guid)->select();
foreach ($product_parts as $value) {
$product_parts_guid = $value['product_parts_guid'];
$product_guid = $value['product_guid'];
$id = $product_parts_guid;
$data[] = [
'id' => $id,
'parent_id' => $product_guid,
'name' => $value['product_parts_name'],
'type' => 'product_parts',
'data' => [
'product_type_guid' => $product_type_guid,
'product_guid' => $product_guid,
'product_parts_guid' => $product_parts_guid
],
];
}
}
// return $data;
$Traverse = new Traverse('id', 'parent_id');
return $Traverse->tree($data, '0', function (array $value) {
return $value;
});
return [
'code' => 0,
'data' => $data,
'msg' => 'ok'
];
}
}

View File

@ -1,105 +0,0 @@
<?php
namespace app\common\model\AboutUs;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class AboutUs extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'about_us_delete_time';
// 设置主键名
protected $pk = 'about_us_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"about_us_id" => "int",
"about_us_guid" => "string",
"about_us_img" => "string",
"about_us_text" => "string",
"about_us_why_img" => "string",
"about_us_why_text" => "string",
"about_us_company_idea_text" => "string",
"about_us_company_idea_img" => "string",
"about_us_why_create_time" => "",
"about_us_product_type_num" => "string",
"about_us_company_staff" => "string",
"about_us_create_time" => "datetime",
"about_us_create_user_guid" => "string",
"about_us_update_time" => "datetime",
"about_us_update_user_guid" => "string",
"about_us_delete_time" => "datetime",
"about_us_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'about_us_create_time';
// 修改时间
protected $updateTime = 'about_us_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
}

View File

@ -1,77 +0,0 @@
<?php
namespace app\common\model\Banner;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\Request;
class Banner extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'banner_delete_time';
// 设置主键名
protected $pk = 'banner_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"banner_id" => "int",
"banner_guid" => "string",
"banner_img" => "string",
"banner_create_user_guid" => "string",
"banner_create_time" => "datetime",
"banner_update_user_guid" => "string",
"banner_update_time" => "datetime",
"banner_delete_user_guid" => "string",
"banner_delete_time" => "datetime",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'banner_create_time';
// 修改时间
protected $updateTime = 'banner_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
}

View File

@ -1,101 +0,0 @@
<?php
namespace app\common\model\Consult;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
use app\common\model\Product\Product as ModelProduct;
class Consult extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'consult_delete_time';
// 设置主键名
protected $pk = 'consult_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"consult_id" => "int",
"consult_guid" => "string",
"consult_contact" => "string",
"product_guid" => "string",
"consult_user_name" => "string",
"consult_content" => "string",
"consult_status" => "int",
"consult_create_time" => "datetime",
"consult_create_user_guid" => "string",
"consult_update_time" => "datetime",
"consult_update_user_guid" => "string",
"consult_delete_time" => "datetime",
"consult_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'consult_create_time';
// 修改时间
protected $updateTime = 'consult_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
/**
* 获取器(咨询产品集合)
*/
public function getConsultProductsAttr($value, $data): array
{
return ModelProduct::field(['product_name', 'product_img'])
->where([['product_guid', 'in', explode(',', $data['product_guid'])]])
->select()
->toArray();
}
}

View File

@ -1,101 +0,0 @@
<?php
namespace app\common\model\ContactUs;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class ContactUs extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'contact_us_delete_time';
// 设置主键名
protected $pk = 'contact_us_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"contact_us_id" => "int",
"contact_us_guid" => "string",
"contact_us_telephone" => "string",
"contact_us_mobile_phone" => "string",
"contact_us_email" => "string",
"contact_us_location" => "string",
"longitude" => "string",
"latitude" => "string",
"contact_us_img" => "string",
"contact_us_create_time" => "datetime",
"contact_us_create_user_guid" => "string",
"contact_us_update_time" => "datetime",
"contact_us_update_user_guid" => "string",
"contact_us_delete_time" => "datetime",
"contact_us_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'contact_us_create_time';
// 修改时间
protected $updateTime = 'contact_us_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
}

View File

@ -0,0 +1,185 @@
<?php
namespace app\common\model\Enrol;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class Classes extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'classes_delete_time';
// 设置主键名
protected $pk = 'classes_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"classes_id" => "int",
"classes_guid" => "string",
"classes_name" => "string",
"classes_desc" => "string",
"classes_content" => "string",
"classes_sort" => "string",
"classes_create_time" => "datetime",
"classes_create_user_guid" => "string",
"classes_update_time" => "datetime",
"classes_update_user_guid" => "string",
"classes_delete_time" => "datetime",
"classes_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'classes_create_time';
// 修改时间
protected $updateTime = 'classes_update_time';
//排序字段
public $order_field = 'classes_sort';
// excel导入/下载模板表头
public const EXCELFIELD = [
'classes_name' => '名称',
'classes_desc' => '简介',
'classes_content' => '内容',
'classes_sort' => '排序',
];
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
Validate::unique(self::class, $model->classes_guid, $model->getData(), [
'classes_name' => '班型名称',
]);
Tool::sortInsertProc(
self::class,
$model->classes_sort,
);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
Validate::unique(self::class, $model->classes_guid, $model->getData(), [
'classes_name' => '班型名称',
]);
Tool::sortEditProc(
self::class,
$model->classes_guid,
$model->classes_sort,
);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
Tool::sortDeleteProc(self::class, $model->classes_guid);
$model->completeDeleteField();
}
/**
* 导出Excel
*/
public static function exportExcel($select)
{
$data = [[
'名称',
'简介',
'内容',
'排序'
]];
foreach ($select as $key => $val) {
$data[] = [
$val['classes_name'],
$val['classes_desc'],
$val['classes_content'],
$val['classes_sort'],
];
}
$excel = (new Excel())->exporTsheet($data);
$excel->save('班型.xlsx');
}
/**
* 导入excel
*/
public static function importExcel($file)
{
$msg = [];
Db::startTrans();
try {
$excel = new Excel($file);
$data = $excel->parseExcel(
Tool::getExcelRule(self::EXCELFIELD),
[
'titleLine' => [1]
]
);
if (!$data) throwErrorMsg('excel无数据', 1);
$msg = [];
foreach ($data as $line => $value) {
try {
$model = self::importExcelInit($value);
$msg[] = "{$line} <span style='color:#27af49'>新增成功!</span><br>";
} catch (\Throwable $th) {
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
}
}
Db::commit();
return implode(', ', $msg);
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 导入excel初始化
*/
public static function importExcelInit($value)
{
$classes_name = $value['classes_name'];
$classes_desc = $value['classes_desc'];
$classes_content = $value['classes_content'];
$classes_sort = $value['classes_sort'];
return self::create([
'classes_name' => $classes_name,
'classes_desc' => $classes_desc,
'classes_content' => $classes_content,
'classes_sort' => $classes_sort,
]);
}
}

View File

@ -1,222 +0,0 @@
<?php
namespace app\common\model\LeaveMessage;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class LeaveMessage extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'leave_message_delete_time';
// 设置主键名
protected $pk = 'leave_message_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"leave_message_id" => "int",
"leave_message_guid" => "string",
"leave_message_content" => "string",
"leave_message_name" => "string",
"leave_message_email" => "string",
"leave_message_phone" => "int",
"leave_message_status" => "int",
"leave_message_create_time" => "datetime",
"leave_message_create_user_guid" => "string",
"leave_message_update_time" => "datetime",
"leave_message_update_user_guid" => "string",
"leave_message_delete_time" => "datetime",
"leave_message_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'leave_message_create_time';
// 修改时间
protected $updateTime = 'leave_message_update_time';
// excel导入/下载模板表头
public const EXCELFIELD = [
'leave_message_content' => '留言内容',
'leave_message_name' => '姓名',
'leave_message_email' => '邮箱',
'leave_message_phone' => '手机号',
'leave_message_status' => '留言受理状态',
];
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
/**
* 留言用户
*/
public static function auditLeaveMessage($params)
{
$params_audit_status = $params['leave_message_status'];
$leave_message_guids_arr = explode(',', $params['leave_message_guid']);
Db::startTrans();
try {
if (count($leave_message_guids_arr) > 1) {
foreach ($leave_message_guids_arr as $key => $value) {
self::audit($value,$params);
}
} else {
self::audit($params['leave_message_guid'],$params);
}
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 留言
*/
public static function audit($value,$params)
{
$model = self::where('leave_message_guid', $value)->find();
if (!$model) throwErrorMsg("该留言不存在", 1);
$audit_status = $model->leave_message_status;
$leave_message_name = $model->leave_message_name;
if ($audit_status == 2) throwErrorMsg("{$leave_message_name} 已通过留言!");
$model->allowField([
'leave_message_status',
])->save($params);
}
/**
* 导出Excel
*/
public static function exportExcel($select)
{
$data = [[
'留言内容',
'姓名',
'邮箱',
'手机号',
'留言受理状态'
]];
foreach ($select as $key => $val) {
$data[] = [
$val['leave_message_content'],
$val['leave_message_name'],
$val['leave_message_email'],
$val['leave_message_phone'],
$val['leave_message_status'],
];
}
$excel = (new Excel())->exporTsheet($data);
$excel->save('.xlsx');
}
/**
* 导入excel
*/
public static function importExcel($file)
{
$msg = [];
Db::startTrans();
try {
$excel = new Excel($file);
$data = $excel->parseExcel(
Tool::getExcelRule(self::EXCELFIELD),
[
'titleLine' => [1]
]
);
if (!$data) throwErrorMsg('excel无数据', 1);
$msg = [];
foreach ($data as $line => $value) {
try {
$model = self::importExcelInit($value);
$msg[] = "{$line} <span style='color:#27af49'>新增成功!</span><br>";
} catch (\Throwable $th) {
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
}
}
Db::commit();
return implode(', ', $msg);
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 导入excel初始化
*/
public static function importExcelInit($value)
{
$leave_message_content = $value['leave_message_content'];
$leave_message_name = $value['leave_message_name'];
$leave_message_email = $value['leave_message_email'];
$leave_message_phone = $value['leave_message_phone'];
$leave_message_status = $value['leave_message_status'];
return self::create([
'leave_message_content' => $leave_message_content,
'leave_message_name' => $leave_message_name,
'leave_message_email' => $leave_message_email,
'leave_message_phone' => $leave_message_phone,
'leave_message_status' => $leave_message_status,
]);
}
}

View File

@ -1,99 +0,0 @@
<?php
namespace app\common\model\News;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\Request;
class News extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'news_delete_time';
// 设置主键名
protected $pk = 'news_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"news_id" => "int",
"news_guid" => "string",
"news_title" => "string",
"news_author" => "string",
"news_intro" => "string",
"news_type" => "string",
"news_img" => "string",
"news_content" => "string",
"news_detail_time" => "datetime",
"news_num" => "int",
"news_create_time" => "datetime",
"news_create_user_guid" => "string",
"news_update_time" => "datetime",
"news_update_user_guid" => "string",
"news_delete_time" => "datetime",
"news_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'news_create_time';
// 修改时间
protected $updateTime = 'news_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
/**
* 产品类型获取器
*/
public function getNewsCreatedTimeAttr($value, $data)
{
$news_create_time = $data['news_create_time'];
$news_create_time = date("m-d");
return $news_create_time;
}
}

View File

@ -1,227 +0,0 @@
<?php
namespace app\common\model\Product;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class Product extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'product_delete_time';
// 设置主键名
protected $pk = 'product_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"product_id" => "int",
"product_guid" => "string",
"product_type_guid" => "string",
"product_name" => "string",
"product_img" => "string",
"product_params" => "string",
"product_details" => "string",
"product_price" => "",
"product_create_time" => "datetime",
"product_create_user_guid" => "string",
"product_update_time" => "datetime",
"product_update_user_guid" => "string",
"product_delete_time" => "datetime",
"product_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'product_create_time';
// 修改时间
protected $updateTime = 'product_update_time';
// excel导入/下载模板表头
public const EXCELFIELD = [
'product_type_guid' => '产品系列',
'product_name' => '名称',
'product_img' => '图片',
'product_params' => '参数',
'product_details' => '详情',
'product_price' => '价格',
];
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
/**
* 修改器(产品参数)
*/
public function setProductParamsAttr($value): string
{
return json_encode($value, JSON_UNESCAPED_UNICODE);
}
/**
* 获取器(产品参数)
*/
public function getProductParamsAttr($value): array
{
return json_decode($value);
}
/**
* 获取器(产品图片)
*/
public function getProductImgAttr($value): array
{
$data = [];
foreach (explode(',', $value) as $item) {
$data[] = ['url' => $item];
};
return $data;
}
/**
* 指定产品上下id获取
*
* @param string $product_id 当前产品id
* @param string $product_type_guid 产品系列guid
* @return array [上一个id,下一个idF]
*/
public static function getProductUpAndDownId(string $product_id, string $product_type_guid): array
{
$query = function ($op, $order) use ($product_id, $product_type_guid) {
return self::where([['product_id', $op, $product_id], ['product_type_guid', '=', $product_type_guid]])
->limit(1)
->order('product_id', $order)
->value('product_id');
};
return [$query('<', 'desc'), $query('>', 'asc')];
}
/**
* 导出Excel
*/
public static function exportExcel($select)
{
$data = [[
'产品系列',
'名称',
'图片',
'参数',
'详情',
'价格'
]];
foreach ($select as $key => $val) {
$data[] = [
$val['product_type_guid'],
$val['product_name'],
Excel::ExportImgFiled($val['product_img']),
$val['product_params'],
$val['product_details'],
$val['product_price'],
];
}
$excel = (new Excel())->exporTsheet($data);
$excel->save('产品.xlsx');
}
/**
* 导入excel
*/
public static function importExcel($file)
{
$msg = [];
Db::startTrans();
try {
$excel = new Excel($file);
$data = $excel->parseExcel(
Tool::getExcelRule(self::EXCELFIELD),
[
'titleLine' => [1]
]
);
if (!$data) throwErrorMsg('excel无数据', 1);
$msg = [];
foreach ($data as $line => $value) {
try {
$model = self::importExcelInit($value);
$msg[] = "{$line} <span style='color:#27af49'>新增成功!</span><br>";
} catch (\Throwable $th) {
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
}
}
Db::commit();
return implode(', ', $msg);
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 导入excel初始化
*/
public static function importExcelInit($value)
{
$product_type_guid = $value['product_type_guid'];
$product_name = $value['product_name'];
$product_img = $value['product_img'];
$product_params = $value['product_params'];
$product_details = $value['product_details'];
$product_price = $value['product_price'];
return self::create([
'product_type_guid' => $product_type_guid,
'product_name' => $product_name,
'product_img' => $product_img,
'product_params' => $product_params,
'product_details' => $product_details,
'product_price' => $product_price,
]);
}
}

View File

@ -1,93 +0,0 @@
<?php
namespace app\common\model\Product;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class ProductParam extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'product_param_delete_time';
// 设置主键名
protected $pk = 'product_param_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"product_param_id" => "int",
"product_param_guid" => "string",
"product_param_name" => "string",
"product_type_guid" => "string",
"product_type_order" => "int",
"product_param_create_time" => "datetime",
"product_param_create_user_guid" => "string",
"product_param_update_time" => "datetime",
"product_param_update_user_guid" => "string",
"product_param_delete_time" => "datetime",
"product_param_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'product_param_create_time';
// 修改时间
protected $updateTime = 'product_param_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
}

View File

@ -1,182 +0,0 @@
<?php
namespace app\common\model\Product;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class ProductType extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'product_type_delete_time';
// 设置主键名
protected $pk = 'product_type_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"product_type_id" => "int",
"product_type_guid" => "string",
"product_type_name" => "string",
"product_type_parent_guid" => "string",
"product_type_ancestors_guid" => "string",
"product_type_icon" => "string",
"product_type_cover" => "string",
"product_type_order" => "int",
"product_type_create_time" => "datetime",
"product_type_create_user_guid" => "string",
"product_type_update_time" => "datetime",
"product_type_update_user_guid" => "string",
"product_type_delete_time" => "datetime",
"product_type_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'product_type_create_time';
// 修改时间
protected $updateTime = 'product_type_update_time';
// excel导入/下载模板表头
public const EXCELFIELD = [
'product_type_name' => '产品系列名称',
'product_type_icon' => '产品系列图标',
'product_type_cover' => '产品系列封面',
];
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
/**
* 产品系列祖级guid构建
*
* @param string $product_type_parent_guid 产品系列父级guid
*/
public static function buildAncestorsGuid(string $product_type_parent_guid): string
{
if ($product_type_parent_guid == "0") return $product_type_parent_guid;
$product_type = self::where('product_type_guid', $product_type_parent_guid)->find();
if (!$product_type) throwErrorMsg('该父级产品系列不存在!');
return $product_type->product_type_ancestors_guid . ',' . $product_type_parent_guid;
}
/**
* 产品系列重名验证
*
* @param string $product_type_name 产品系列名称
* @param string $product_type_guid 产品系列guid
*/
public static function isDuplicateName(string $product_type_name, string $product_type_guid = null): void
{
$con = [
['product_type_name', '=', $product_type_name]
];
if ($product_type_guid) {
$con[] = ['product_type_guid', '<>', $product_type_guid];
}
if (self::where($con)->find()) {
throwErrorMsg('产品系列不可重名!');
};
}
/**
* 导出Excel
*/
public static function exportExcel($select)
{
$data = [[
'产品系列标题',
'产品系列图标',
'产品系列封面'
]];
foreach ($select as $key => $val) {
$data[] = [
$val['product_type_title'],
$val['product_type_icon'],
Excel::ExportImgFiled($val['product_type_cover']),
];
}
$excel = (new Excel())->exporTsheet($data);
$excel->save('产品系列.xlsx');
}
/**
* 导入excel
*/
public static function importExcel($file)
{
$msg = [];
Db::startTrans();
try {
$excel = new Excel($file);
$data = $excel->parseExcel(
Tool::getExcelRule(self::EXCELFIELD),
[
'titleLine' => [1]
]
);
if (!$data) throwErrorMsg('excel无数据', 1);
$msg = [];
foreach ($data as $line => $value) {
try {
$model = self::importExcelInit($value);
$msg[] = "{$line} <span style='color:#27af49'>新增成功!</span><br>";
} catch (\Throwable $th) {
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
}
}
Db::commit();
return implode(', ', $msg);
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 导入excel初始化
*/
public static function importExcelInit($value)
{
$product_type_title = $value['product_type_title'];
$product_type_icon = $value['product_type_icon'];
$product_type_cover = $value['product_type_cover'];
return self::create([
'product_type_title' => $product_type_title,
'product_type_icon' => $product_type_icon,
'product_type_cover' => $product_type_cover,
]);
}
}

View File

@ -1,77 +0,0 @@
<?php
namespace app\common\model\School;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\Request;
class Classes extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'classes_delete_time';
// 设置主键名
protected $pk = 'classes_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"classes_id" => "int",
"classes_guid" => "string",
"classes_name" => "string",
"classes_create_time" => "datetime",
"classes_create_user_guid" => "string",
"classes_update_time" => "datetime",
"classes_update_user_guid" => "string",
"classes_delete_time" => "datetime",
"classes_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'classes_create_time';
// 修改时间
protected $updateTime = 'classes_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
}

View File

@ -1,627 +0,0 @@
<?php
namespace app\common\model\School;
use app\common\model\School\StudentService as ModelStudentService;
use app\common\model\User\User as ModelUser;
use app\common\model\School\Classes as ModelClasses;
use app\common\model\Product\ProductType as ModelProductType;
use app\common\model\Product\Product as ModelProduct;
use app\common\model\Product\ProductParts as ModelProductParts;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\Request;
use think\facade\Db;
use app\common\exception\RegularVerification;
use app\common\arw\adjfut\src\Excel;
use app\common\exception\Map;
class Student extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'student_delete_time';
// 设置主键名
protected $pk = 'student_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"student_id" => "int",
"student_guid" => "string",
"student_name" => "string",
"user_guid" => "string",
"classes_guid" => "string",
"studnet_phone" => "string",
"student_id_card" => "string",
"student_email" => "string",
"student_sex" => "string",
"student_price" => "",
"student_brithday" => "date",
"product_type" => "string",
"product_guid" => "string",
"product_parts_guid" => "string",
"student_img" => "string",
"student_banner_img" => "string",
"student_attachment" => "string",
"student_intro" => "string",
"student_location" => "string",
"longitude" => "string",
"latitude" => "string",
"student_membe_type" => "string",
"student_member_begin_time" => "date",
"student_member_end_time" => "date",
"student_audit_status" => "string",
"student_audit_user_guid" => "string",
"student_create_time" => "datetime",
"student_create_user_guid" => "string",
"student_update_time" => "datetime",
"student_update_user_guid" => "string",
"student_delete_time" => "datetime",
"student_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'student_create_time';
// 修改时间
protected $updateTime = 'student_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
/**
* 审核学生
*/
public static function auditStudent($params)
{
$params_audit_status = $params['student_audit_status'];
$student_guids_arr = explode(',', $params['student_guid']);
Db::startTrans();
try {
if (count($student_guids_arr) > 1) {
foreach ($student_guids_arr as $key => $value) {
self::audit($value,$params);
}
} else {
self::audit($params['student_guid'],$params);
}
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 审核
*/
public static function audit($value,$params)
{
$model = self::where('student_guid', $value)->find();
if (!$model) throwErrorMsg("该学生不存在", 1);
$params['student_audit_user_guid'] = Request::getCurrentUser()->user_guid;
$audit_status = $model->student_audit_status;
$student_name = $model->student_name;
if ($audit_status == 2) throwErrorMsg("{$student_name} 学生已通过审核!");
if ($audit_status == 3) throwErrorMsg("{$student_name} 学生已驳回审核!");
$model->allowField([
'student_audit_status',
'student_audit_user_guid'
])->save($params);
}
/**
* 新增前初始化
*/
public static function initAdd($params)
{
$user = ModelUser::where('user_name', $params['user_name'])->find();
$params['user_guid'] = $user->user_guid;
$student_user = self::where('user_guid', $params['user_guid'])->find();
if ($student_user) throwErrorMsg("用户已经被绑定,请重新选择!");
$isPhone = RegularVerification::checkPreg($params['studnet_phone'], 'mobile');
if (!$isPhone) throwErrorMsg("电话格式错误");
$isIdCard = RegularVerification::checkPreg($params['student_id_card'], 'idcard');
if (!$isIdCard) throwErrorMsg("身份证格式错误");
$isEmail = RegularVerification::checkPreg($params['student_email'], 'email');
if (!$isEmail) throwErrorMsg("邮箱格式错误");
// 季卡
if ($params['student_membe_type'] == '1') {
$params['student_member_begin_time'] = date('Y-m-d H:i:s');
$params['student_member_end_time'] = date('Y-m-d H:i:s', strtotime('+3 month'));
}
// 年卡
if ($params['student_membe_type'] == '2') {
$params['student_member_begin_time'] = date('Y-m-d H:i:s');
$params['student_member_end_time'] = date('Y-m-d H:i:s', strtotime('+1 year'));
}
// 已审核
$params['student_audit_status'] = "1";
// $params['student_audit_user_guid'] = "ds4a3d2asd423s3as4d34asdd";
return $params;
}
/**
* 导入前初始化
*/
public static function ImportStudentInit($value)
{
// 用户判断
$user = ModelUser::where('user_name', $value['user_name'])->find();
// array_push($error, "{$line}: 产品类型不存在,导入失败!");
if (!$user) throwErrorMsg("用户 {$value['user_name']} 不存在");
$value['user_guid'] = $user->user_guid;
$student_user = self::where('user_guid', $value['user_guid'])->find();
if ($student_user) throwErrorMsg("用户 {$value['user_name']} 已经被绑定,请重新选择!");
// 班级判断
$classes = ModelClasses::where('classes_name', $value['classes_name'])->find();
if (!$classes) throwErrorMsg("班级不存在");
$value['classes_guid'] = $classes->classes_guid;
$isPhone = RegularVerification::checkPreg($value['studnet_phone'], 'mobile');
if (!$isPhone) throwErrorMsg("电话格式错误");
// $isIdCard = RegularVerification::checkPreg($value['student_id_card'], 'idcard');
// if (!$isIdCard) throwErrorMsg("身份证格式错误");
$isEmail = RegularVerification::checkPreg($value['student_email'], 'email');
if (!$isEmail) throwErrorMsg("邮箱格式错误");
$sex_val = [1 => '男', 2 => '女'];
// 性别判断
if (!in_array($value['student_sex'], ["", ""])) throwErrorMsg("请填写男或女");
else {
$value['student_sex'] = array_search($value['student_sex'], $sex_val);
// if ($value['student_sex'] == "男") $value['student_sex'] = 1;
// if ($value['student_sex'] == "女") $value['student_sex'] = 2;
}
// 价格判断
if (!is_numeric($value['student_price'])) throwErrorMsg("学生价格必须为整数");
if ($value['student_price'] < 0) throwErrorMsg("学生价格不能为负数");
// 产品类型判断
$product_type = ModelProductType::where('product_type_name', $value['product_type_name'])->find();
if (!$product_type) throwErrorMsg("{$value['product_type_name']} 产品类型不存在");
$value['product_type_guid'] = $product_type->product_type_guid;
// 产品判断
$product = ModelProduct::where('product_name', $value['product_name'])->find();
if (!$product) throwErrorMsg("{$value['product_name']} 产品不存在");
$value['product_guid'] = $product->product_guid;
$InProductType = ModelProduct::where('product_type_guid', $value['product_type_guid'])->find();
if (!$InProductType) throwErrorMsg("{$value['product_name']} 产品 没有绑定产品类型:{$value['product_type_name']}");
// 产品零件判断
$product_parts = ModelProductParts::where('product_parts_name', $value['product_parts_name'])->find();
if (!$product_parts) throwErrorMsg("{$value['product_parts_name']} 产品零件不存在");
$value['product_parts_guid'] = $product_parts->product_parts_guid;
$InProduct = ModelProductParts::where('product_guid', $value['product_guid'])->find();
if (!$InProduct) throwErrorMsg("{$value['product_parts_name']} 产品零件 没有绑定产品:{$value['product_name']}");
// 获取经纬度
$longitude_latitude_arr = Map::getLongitudeAndLatitude($value['student_location']);
$value['longitude'] = $longitude_latitude_arr['longitude'];
$value['latitude'] = $longitude_latitude_arr['latitude'];
// 季卡
if ($value['student_membe_type'] == '季卡') {
$value['student_membe_type'] = '1';
$value['student_member_begin_time'] = date('Y-m-d H:i:s');
$value['student_member_end_time'] = date('Y-m-d H:i:s', strtotime('+3 month'));
}
// 年卡
if ($value['student_membe_type'] == '年卡') {
$value['student_membe_type'] = '2';
$value['student_member_begin_time'] = date('Y-m-d H:i:s');
$value['student_member_end_time'] = date('Y-m-d H:i:s', strtotime('+1 year'));
}
// 已审核
$value['student_audit_status'] = "2";
$value['student_audit_user_guid'] = "ds4a3d2asd423s3as4d34asdd";
// 生日日期处理
$time = strtotime($value['student_brithday']);
$newformat = date('Y-m-d', $time);
return self::create([
'student_name' => $value['student_name'],
'user_guid' => $value['user_guid'],
'classes_guid' => $value['classes_guid'],
'studnet_phone' => $value['studnet_phone'],
'student_id_card' => $value['student_id_card'],
'student_email' => $value['student_email'],
'student_sex' => $value['student_sex'],
'student_price' => $value['student_price'],
'student_brithday' => $newformat,
'product_type' => $value['product_type_guid'],
'product_guid' => $value['product_guid'],
'product_parts_guid' => $value['product_parts_guid'],
'student_img' => $value['student_img'],
'student_banner_img' => $value['student_banner_img'],
'student_intro' => $value['student_intro'],
'student_location' => $value['student_location'],
'longitude' => $value['longitude'],
'latitude' => $value['latitude'],
'student_membe_type' => $value['student_membe_type'],
'student_member_begin_time' => $value['student_member_begin_time'],
'student_member_end_time' => $value['student_member_end_time'],
'student_audit_status' => $value['student_audit_status'],
'student_audit_user_guid' => $value['student_audit_user_guid'],
]);
}
/**
* 导入学生
*/
public static function ImportStudent($file)
{
$error = [];
Db::startTrans();
try {
$excel = new Excel($file);
$data = $excel->parseExcel(
[
[
'title' => '学生名称',
'validate' => 'require',
'field' => 'student_name',
], [
'title' => '用户',
'validate' => 'require',
'field' => 'user_name',
], [
'title' => '班级',
'validate' => 'require',
'field' => 'classes_name',
], [
'title' => '手机号',
'validate' => 'require',
'field' => 'studnet_phone',
], [
'title' => '身份证号',
'validate' => 'require',
'field' => 'student_id_card',
], [
'title' => '邮箱',
'validate' => 'require',
'field' => 'student_email',
], [
'title' => '性别',
'validate' => 'require',
'field' => 'student_sex',
], [
'title' => '学生价格',
'validate' => 'require',
'field' => 'student_price',
], [
'title' => '生日',
'validate' => 'require',
'field' => 'student_brithday',
], [
'title' => '产品类型',
'validate' => 'require',
'field' => 'product_type_name',
], [
'title' => '产品',
'validate' => 'require',
'field' => 'product_name',
], [
'title' => '产品零件',
'validate' => 'require',
'field' => 'product_parts_name',
], [
'title' => '头像',
'validate' => 'require',
'field' => 'student_img',
], [
'title' => '轮播图片',
'validate' => 'require',
'field' => 'student_banner_img',
], [
'title' => '简介',
'validate' => 'require',
'field' => 'student_intro',
], [
'title' => '家庭住址',
'validate' => 'require',
'field' => 'student_location',
], [
'title' => '会员类型',
'validate' => 'require',
'field' => 'student_membe_type',
],
// [
// 'title' => '会员开始时间',
// 'validate' => 'require',
// 'field' => 'student_member_begin_time',
// ], [
// 'title' => '会员结束时间',
// 'validate' => 'require',
// 'field' => 'student_member_end_time',
// ],
],
[
'titleLine' => [1]
]
);
if (!$data) throwErrorMsg('excel无数据', 1);
$error = [];
foreach ($data as $line => $value) {
try {
$model = self::ImportStudentInit($value);
$error[] = "{$line} 学生:【{$value['student_name']}】<span style='color:#27af49'>新增成功!</span><br>";
} catch (\Throwable $th) {
$error[] = "{$line} 学生:【{$value['student_name']}】<span style='color:red'>{$th->getMessage()}</span><br>";
}
}
Db::commit();
return implode(', ', $error);
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
return $error;
}
/**
* 导出学生
*/
public static function exportStudent()
{
$select = self::alias('a')
->field([
'a.student_name',
'b.user_name',
'f.classes_name',
'a.studnet_phone',
'a.student_id_card',
'a.student_email',
'a.student_sex',
'a.student_price',
'a.student_brithday',
'c.product_type_name',
'd.product_name',
'e.product_parts_name',
'a.student_img',
'a.student_banner_img',
'a.student_attachment',
'a.student_location',
'a.student_membe_type',
'a.student_member_begin_time',
'a.student_member_end_time',
'a.student_audit_status',
"(SELECT `user`.`user_name` FROM `user` WHERE `user`.user_guid = `a`.`student_audit_user_guid`) as student_audit_user_name",
])
->leftjoin('user b', 'a.user_guid = b.user_guid')
->leftjoin('product_type c', 'a.product_type = c.product_type_guid')
->leftjoin('product d', 'a.product_guid = d.product_guid')
->leftjoin('product_parts e', 'a.product_parts_guid = e.product_parts_guid')
->leftjoin('classes f', 'a.classes_guid = f.classes_guid')
->order('student_update_time', 'desc')->select();
$data = [[
'学生名称',
'用户',
'班级',
'手机号',
'身份证号',
'邮箱',
'性别',
'学生价格',
'生日',
'产品类型',
'产品',
'产品零件',
'头像',
'轮播图片',
'家庭住址',
'会员类型',
'会员开始时间',
'会员结束时间',
'审核状态',
'审核人'
]];
foreach ($select as $key => $val) {
$sex_arr = [1 => "", 2 => ""];
$member_arr = [1 => "季卡", 2 => "年卡"];
$audit_arr = [1 => "未审核", 2 => "已审核", 3 => "未通过"];
$val['student_sex'] = $sex_arr[$val['student_sex']];
$val['student_membe_type'] = $member_arr[$val['student_membe_type']];
$val['student_audit_status'] = $audit_arr[$val['student_audit_status']];
$val['student_img'] = Excel::ExportImgFiled($val['student_img']);
$val['student_banner_img'] = Excel::ExportImgFiled($val['student_banner_img']);
$data[] = [
$val['student_name'],
$val['user_name'],
$val['classes_name'],
$val['studnet_phone'],
$val['student_id_card'],
$val['student_email'],
$val['student_sex'],
$val['student_price'],
$val['student_brithday'],
$val['product_type_name'],
$val['product_name'],
$val['product_parts_name'],
$val['student_img'],
$val['student_banner_img'],
$val['student_location'],
$val['student_membe_type'],
$val['student_member_begin_time'],
$val['student_member_end_time'],
$val['student_audit_status'],
$val['student_audit_user_name'],
];
}
$excel = (new Excel())->exporTsheet($data);
$excel->save('学生.xlsx');
}
/**
* 新增学生服务
*/
public static function addStudentService($student_guid, $params): void
{
$student_service_arr = $params['student_service'];
foreach ($student_service_arr as $key => $item) {
Db::startTrans();
try {
$add_data = [
'student_guid' => $student_guid,
'student_service_name' => $item['service_name'],
'student_service_price' => $item['service_price'],
];
$student_service = ModelStudentService::create($add_data);
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
}
/**
* 编辑学生服务
*/
public static function editStudentService($params): void
{
// 从学生服务(副表)查询出所有当前学生的服务,进行删除
ModelStudentService::where('student_guid', $params['student_guid'])->select()->delete();
// 再把传值的数据,写入副表
$student_service_arr = $params['student_service'];
foreach ($student_service_arr as $key => $item) {
Db::startTrans();
try {
$add_data = [
'student_guid' => $params['student_guid'],
'student_service_name' => $item['service_name'],
'student_service_price' => $item['service_price'],
];
ModelStudentService::create($add_data);
Db::commit();
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
}
/**
* 会员时间获取器
*/
public function getStudentMemberTimeAttr($value, $data)
{
$student_member_time = [];
array_push($student_member_time, $data['student_member_begin_time']);
array_push($student_member_time, $data['student_member_end_time']);
return $student_member_time;
}
/**
* 学生服务获取器
*/
public function getStudentServiceAttr($value, $data)
{
$studnet_guid = $data['student_guid'];
$studetn_service = ModelStudentService::field([
'student_service_guid',
'student_service_name' => 'service_name',
'student_service_price' => 'service_price',
])->where('student_guid', $studnet_guid)->select();
return $studetn_service;
}
}

View File

@ -1,81 +0,0 @@
<?php
namespace app\common\model\School;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\Request;
class StudentService extends BaseModel
{
// use SoftDelete;
// 删除字段
protected $deleteTime = 'student_service_delete_time';
// 设置主键名
protected $pk = 'student_service_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"student_service_id" => "int",
"student_service_guid" => "string",
"student_guid" => "string",
"student_service_name" => "string",
"student_service_price" => "",
"student_service_create_time" => "datetime",
"student_service_create_user_guid" => "string",
"student_service_update_time" => "datetime",
"student_service_update_user_guid" => "string",
"student_service_delete_time" => "datetime",
"student_service_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'student_service_create_time';
// 修改时间
protected $updateTime = 'student_service_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
}

View File

@ -1,93 +0,0 @@
<?php
namespace app\common\model\ServiceSupport;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class ServiceSupport extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'service_support_delete_time';
// 设置主键名
protected $pk = 'service_support_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
"service_support_id" => "int",
"service_support_guid" => "string",
"service_support_idea" => "string",
"service_support_promise" => "string",
"service_support_network" => "string",
"service_support_create_time" => "datetime",
"service_support_create_user_guid" => "string",
"service_support_update_time" => "datetime",
"service_support_update_user_guid" => "string",
"service_support_delete_time" => "datetime",
"service_support_delete_user_guid" => "string",
];
// 设置json类型字段
protected $json = [''];
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 创建时间
protected $createTime = 'service_support_create_time';
// 修改时间
protected $updateTime = 'service_support_update_time';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
// self::checkRepeatData($model);
$model->completeCreateField();
}
/**
* 更新前
*/
public static function onBeforeUpdate(self $model): void
{
// self::checkRepeatData($model);
$model->completeUpdateField();
}
/**
* 删除前
*/
public static function onBeforeDelete(self $model): void
{
$model->completeDeleteField();
}
}

View File

@ -26,11 +26,11 @@ return [
// 服务器地址 // 服务器地址
'hostname' => env('database.hostname', '47.242.159.172'), 'hostname' => env('database.hostname', '47.242.159.172'),
// 数据库名 // 数据库名
'database' => env('database.database', 'php_web'), 'database' => env('database.database', 'houde_web'),
// 用户名 // 用户名
'username' => env('database.username', 'php_web'), 'username' => env('database.username', 'houde_web'),
// 密码 // 密码
'password' => env('database.password', 'php_web@aerwen'), 'password' => env('database.password', 'houde_web@aerwen'),
// 端口 // 端口
'hostport' => env('database.hostpost', '3306'), 'hostport' => env('database.hostpost', '3306'),
// 数据库连接参数 // 数据库连接参数