Merge branch 'master' of ssh://47.101.48.251:/data/git/wx.sstbc.com

master
lion 11 months ago
commit 2fbfc7d2f1

@ -0,0 +1,79 @@
<?php
namespace App\Console\Commands;
use App\Models\EmailRecord;
use App\Models\EmailRecordUser;
use App\Models\User;
use App\Repositories\MeetRepository;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
class SendEmail extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'send_email';
/**
* The console command description.
*
* @var string
*/
protected $description = '发送邮件';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$emailRecords = EmailRecord::whereHas('emailRecordUsers', function ($query) {
$query->where('status', 0);
})->where(function ($query) {
$query->whereNull('time')->orWhere('time', '<', date('Y-m-d H:i:s'));
})->get();
foreach ($emailRecords as $records) {
// 获取模版配置
$emailTemplate = $records->emailTemplate;
// 获取未发送人员
$emailRecordUsers = $records->emailRecordUsers->where('status', 0);
foreach ($emailRecordUsers as $recordUser) {
// 替换后的标题
$title = EmailRecordUser::template($records->subject, $recordUser->var_data);
// 替换后的内容
$template = EmailRecordUser::template($emailTemplate->content, $recordUser->var_data);
try {
// 发送邮件
EmailRecordUser::email($title, $template, $recordUser->email);
$recordUser->status = 1;
} catch (\Exception $e) {
$recordUser->status = 2;
$recordUser->reason = $e->getMessage();
}
$recordUser->send_time = date('Y-m-d H:i:s');
$recordUser->save();
}
$records->status = 1;
$records->send_time = date('Y-m-d H:i:s');
$records->save();
}
return $this->info('更新完成');
}
}

@ -0,0 +1,49 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use App\Repositories\MeetRepository;
use Illuminate\Console\Command;
class UpdateCompany extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_company';
/**
* The console command description.
*
* @var string
*/
protected $description = '批量公司信息';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$users = User::get();
return $this->info('更新完成');
}
}

@ -40,7 +40,7 @@ class UpdateUserNo extends Command
*/
public function handle()
{
$users = User::get();
$users = User::whereNull('no')->get();
foreach ($users as $user) {
$no = User::updateNo($user->id);
$this->info($no . '更新成功');

@ -22,6 +22,8 @@ class Kernel extends ConsoleKernel
$schedule->command('update_appointment_total')->dailyAt('1:00');
// 生日检测
$schedule->command('check_birthday')->dailyAt('09:00');
// 邮件群发
$schedule->command('send_email')->everyMinute();
}
/**

@ -91,6 +91,14 @@ class BaseController extends CommonController
if ($op == 'notlike') {
$query->where($key, 'not like', '%' . $value . '%');
}
// null搜索
if ($op == 'null') {
$query->whereNull($key);
}
// notnull搜索
if ($op == 'notnull') {
$query->whereNotNull($key);
}
// 范围搜索
if ($op == 'range') {
list($from, $to) = explode(',', $value);
@ -243,7 +251,7 @@ class BaseController extends CommonController
public function excelShow()
{
$file = \request()->file('file');
$data = \request('data',[]);
$data = \request('data', []);
//判断文件是否有效
if (!(\request()->hasFile('file') && $file->isValid())) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '文件不存在或无效']);

@ -35,16 +35,7 @@ class CalendarsController extends BaseController
* tags={"日历管理"},
* summary="列表",
* description="",
* @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是"),
* @OA\Parameter(name="export_fields", in="query", @OA\Schema(type="string"), required=false, description="需要导出的字段数组"),
* @OA\Parameter(name="filter", in="query", @OA\Schema(type="string"), required=false, description="查询条件。数组"),
* @OA\Parameter(name="show_relation", in="query", @OA\Schema(type="string"), required=false, description="需要输出的关联关系数组包括teachercourseSettingscoursePeriods"),
* @OA\Parameter(name="page_size", in="query", @OA\Schema(type="string"), required=false, description="每页显示的条数"),
* @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"),
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=true, description="关键词"),
* @OA\Parameter(name="month", in="query", @OA\Schema(type="string"), required=true, description="月份"),
* @OA\Response(
* response="200",
* description="暂无"
@ -53,70 +44,17 @@ class CalendarsController extends BaseController
*/
public function index()
{
$all = request()->all();
$list = $this->model->with('courseContent')->where(function ($query) use ($all) {
if (isset($all['filter']) && !empty($all['filter'])) {
foreach ($all['filter'] as $condition) {
$key = $condition['key'] ?? null;
$op = $condition['op'] ?? null;
$value = $condition['value'] ?? null;
if (!isset($key) || !isset($op) || !isset($value)) {
continue;
}
// 等于
if ($op == 'eq') {
$query->where($key, $value);
}
// 不等于
if ($op == 'neq') {
$query->where($key, '!=', $value);
}
// 大于
if ($op == 'gt') {
$query->where($key, '>', $value);
}
// 大于等于
if ($op == 'egt') {
$query->where($key, '>=', $value);
}
// 小于
if ($op == 'lt') {
$query->where($key, '<', $value);
}
// 小于等于
if ($op == 'elt') {
$query->where($key, '<=', $value);
}
// 模糊搜索
if ($op == 'like') {
$query->where($key, 'like', '%' . $value . '%');
}
// 否定模糊搜索
if ($op == 'notlike') {
$query->where($key, 'not like', '%' . $value . '%');
}
// 范围搜索
if ($op == 'range') {
list($from, $to) = explode(',', $value);
if (empty($from) || empty($to)) {
continue;
}
$query->whereBetween($key, [$from, $to]);
}
}
}
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc');
if (isset($all['is_export']) && !empty($all['is_export'])) {
$list = $list->get()->toArray();
$export_fields = $all['export_fields'] ?? [];
// 导出文件名字
$tableName = $this->model->getTable();
$filename = (new CustomForm())->getTableComment($tableName);
return Excel::download(new BaseExport($export_fields, $list, $tableName), $filename . date('YmdHis') . '.xlsx');
} else {
// 输出
$list = $list->paginate($all['page_size'] ?? 20);
$all = \request()->all();
$messages = [
'month.required' => '月份必填',
];
$validator = Validator::make($all, [
'month' => 'required',
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$list = Calendar::with('course', 'courseContent')->where('date', 'like', $all['month'] . '%')->orderBy('date')->get();
return $this->success($list);
}
@ -158,9 +96,12 @@ class CalendarsController extends BaseController
* summary="保存",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="integer", format="int64"), required=true, description="ID存在则更新不存在则新增"),
* @OA\Parameter(name="type", in="query", @OA\Schema(type="integer"), required=false, description="类型1课程2课堂3事件"),
* @OA\Parameter(name="course_id", in="query", @OA\Schema(type="integer"), required=false, description="课程ID"),
* @OA\Parameter(name="course_content_id", in="query", @OA\Schema(type="integer"), required=false, description="课程课堂ID"),
* @OA\Parameter(name="date", in="query", @OA\Schema(type="string", format="date"), required=false, description="日期YYYY-MM-DD"),
* @OA\Parameter(name="title", in="query", @OA\Schema(type="string", maxLength=255), required=false, description="标题"),
* @OA\Parameter(name="url", in="query", @OA\Schema(type="string", maxLength=255), required=false, description="url"),
* @OA\Parameter(name="content", in="query", @OA\Schema(type="string", format="mediumtext"), required=false, description="内容"),
* @OA\Parameter(name="start_time", in="query", @OA\Schema(type="string", format="date-time"), required=false, description="开始时间YYYY-MM-DD HH:MM:SS"),
* @OA\Parameter(name="end_time", in="query", @OA\Schema(type="string", format="date-time"), required=false, description="结束时间YYYY-MM-DD HH:MM:SS"),

@ -0,0 +1,248 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Exports\BaseExport;
use App\Helpers\ResponseCode;
use App\Models\AppointmentType;
use App\Models\Book;
use App\Models\Calendar;
use App\Models\Company;
use App\Models\CourseContentEvaluationAsk;
use App\Models\CourseContentEvaluationForm;
use App\Models\CustomForm;
use App\Models\CustomFormField;
use App\Models\EmailTemplate;
use App\Models\SupplyDemand;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Maatwebsite\Excel\Facades\Excel;
use Rap2hpoutre\FastExcel\FastExcel;
class CompanyController extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
parent::__construct(new Company());
}
/**
* @OA\Get(
* path="/api/admin/company/index",
* tags={"公司管理"},
* summary="列表",
* description="",
* @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是"),
* @OA\Parameter(name="export_fields", in="query", @OA\Schema(type="string"), required=false, description="需要导出的字段数组"),
* @OA\Parameter(name="filter", in="query", @OA\Schema(type="string"), required=false, description="查询条件。数组"),
* @OA\Parameter(name="show_relation", in="query", @OA\Schema(type="string"), required=false, description="需要输出的关联关系数组包括teachercourseSettingscoursePeriods"),
* @OA\Parameter(name="page_size", in="query", @OA\Schema(type="string"), required=false, description="每页显示的条数"),
* @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"),
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function index()
{
$all = request()->all();
$list = $this->model->with(['users' => function ($query) {
$query->whereHas('courseSigns', function ($q) {
$q->where('status', 1);
})->with('courseSigns.course');
}])->where(function ($query) use ($all) {
if (isset($all['filter']) && !empty($all['filter'])) {
foreach ($all['filter'] as $condition) {
$key = $condition['key'] ?? null;
$op = $condition['op'] ?? null;
$value = $condition['value'] ?? null;
if (!isset($key) || !isset($op) || !isset($value)) {
continue;
}
// 等于
if ($op == 'eq') {
$query->where($key, $value);
}
// 不等于
if ($op == 'neq') {
$query->where($key, '!=', $value);
}
// 大于
if ($op == 'gt') {
$query->where($key, '>', $value);
}
// 大于等于
if ($op == 'egt') {
$query->where($key, '>=', $value);
}
// 小于
if ($op == 'lt') {
$query->where($key, '<', $value);
}
// 小于等于
if ($op == 'elt') {
$query->where($key, '<=', $value);
}
// 模糊搜索
if ($op == 'like') {
$query->where($key, 'like', '%' . $value . '%');
}
// 否定模糊搜索
if ($op == 'notlike') {
$query->where($key, 'not like', '%' . $value . '%');
}
// 范围搜索
if ($op == 'range') {
list($from, $to) = explode(',', $value);
if (empty($from) || empty($to)) {
continue;
}
$query->whereBetween($key, [$from, $to]);
}
}
}
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc');
if (isset($all['is_export']) && !empty($all['is_export'])) {
$list = $list->get()->toArray();
$export_fields = $all['export_fields'] ?? [];
// 导出文件名字
$tableName = $this->model->getTable();
$filename = (new CustomForm())->getTableComment($tableName);
return Excel::download(new BaseExport($export_fields, $list, $tableName), $filename . date('YmdHis') . '.xlsx');
} else {
// 输出
$list = $list->paginate($all['page_size'] ?? 20);
}
return $this->success($list);
}
/**
* @OA\Get(
* path="/api/admin/company/show",
* tags={"公司管理"},
* summary="详情",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
* @OA\Parameter(name="show_relation", in="query", @OA\Schema(type="string"), required=false, description="需要输出的关联关系数组,填写输出指定数据"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function show()
{
$all = \request()->all();
$messages = [
'id.required' => 'Id必填',
];
$validator = Validator::make($all, [
'id' => 'required'
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$detail = $this->model->with(['users' => function ($query) {
$query->whereHas('courseSigns', function ($q) {
$q->where('status', 1);
})->with('courseSigns.course');
}])->find($all['id']);
return $this->success($detail);
}
/**
* @OA\Post(
* path="/api/admin/company/save",
* tags={"公司管理"},
* summary="保存",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="int"), required=true, description="Id(存在更新,不存在新增)"),
* @OA\Parameter(name="company_name", in="query", @OA\Schema(type="string", nullable=true), description="企业名字"),
* @OA\Parameter(name="company_attribute", in="query", @OA\Schema(type="string", nullable=true), description="行业类型"),
* @OA\Parameter(name="company_tag", in="query", @OA\Schema(type="string", nullable=true), description="标签"),
* @OA\Parameter(name="company_scale", in="query", @OA\Schema(type="string", nullable=true), description="企业规模"),
* @OA\Parameter(name="company_date", in="query", @OA\Schema(type="string", format="date", nullable=true), description="成立时间"),
* @OA\Parameter(name="company_legal_representative", in="query", @OA\Schema(type="string", nullable=true), description="法人代表"),
* @OA\Parameter(name="company_shareholder", in="query", @OA\Schema(type="string", nullable=true), description="股东信息"),
* @OA\Parameter(name="management_platform", in="query", @OA\Schema(type="string", nullable=true), description="管理平台"),
* @OA\Parameter(name="project_manager", in="query", @OA\Schema(type="string", nullable=true), description="项目经理"),
* @OA\Parameter(name="market_value", in="query", @OA\Schema(type="integer", format="int64", nullable=true), description="市值"),
* @OA\Parameter(name="company_fund", in="query", @OA\Schema(type="integer", format="int64", nullable=true), description="公司融资情况"),
* @OA\Parameter(name="valuation", in="query", @OA\Schema(type="integer", format="int64", nullable=true), description="估值"),
* @OA\Parameter(name="company_address", in="query", @OA\Schema(type="string", nullable=true), description="公司地址"),
* @OA\Parameter(name="company_area", in="query", @OA\Schema(type="string", nullable=true), description="公司区域"),
* @OA\Parameter(name="company_city", in="query", @OA\Schema(type="string", nullable=true), description="公司城市"),
* @OA\Parameter(name="company_market", in="query", @OA\Schema(type="string", nullable=true), description="是否上市0否1是"),
* @OA\Parameter(name="company_industry", in="query", @OA\Schema(type="string", nullable=true), description="公司所属行业"),
* @OA\Parameter(name="is_schoolmate", in="query", @OA\Schema(type="string", nullable=true), description="是否校友企业-0非校友1校友"),
* @OA\Parameter(name="company_need_fund", in="query", @OA\Schema(type="string", nullable=true), description="公司是否需要融资-0否1是"),
* @OA\Parameter(name="company_introduce", in="query", @OA\Schema(type="string", format="textarea", nullable=true), description="公司简介"),
* @OA\Parameter(name="company_other", in="query", @OA\Schema(type="string", nullable=true), description="其他"),
* @OA\Parameter(name="company_product", in="query", @OA\Schema(type="string", format="textarea", nullable=true), description="产品"),
* @OA\Parameter(name="overseas_experience", in="query", @OA\Schema(type="string", nullable=true), description="海外经验"),
* @OA\Parameter(name="sales_volume", in="query", @OA\Schema(type="string", nullable=true), description="销售额"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"),
* @OA\Response(
* response="200",
* description="操作成功"
* )
* )
*/
public function save()
{
$all = \request()->all();
DB::beginTransaction();
try {
if (isset($all['id'])) {
$model = $this->model->find($all['id']);
if (empty($model)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '数据不存在']);
}
} else {
$model = $this->model;
$all['admin_id'] = $this->getUserId();
$all['department_id'] = $this->getUser()->department_id;
}
$original = $model->getOriginal();
$model->fill($all);
$model->save();
DB::commit();
// 记录日志
$this->saveLogs($original, $model);
return $this->success($model);
} catch (\Exception $exception) {
DB::rollBack();
return $this->fail([$exception->getCode(), $exception->getMessage()]);
}
}
/**
* @OA\Get(
* path="/api/admin/company/destroy",
* tags={"公司管理"},
* summary="删除",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function destroy()
{
return parent::destroy();
}
}

@ -80,6 +80,15 @@ class CourseContentController extends BaseController
if ($op == 'notlike') {
$query->where($key, 'not like', '%' . $value . '%');
}
// null搜索
if ($op == 'null') {
$query->whereNull($key)->orWhere('json_length(' . $key . ') =', 0);
}
// notnull搜索
if ($op == 'notnull') {
// 不是null并且不是空json这个是一个json字段
$query->whereNotNull($key)->where('json_length(' . $key . ') >', 0);
}
// 范围搜索
if ($op == 'range') {
list($from, $to) = explode(',', $value);
@ -147,6 +156,10 @@ class CourseContentController extends BaseController
* @OA\Parameter(name="teacher_id", in="query", @OA\Schema(type="integer"), description="老师ID"),
* @OA\Parameter(name="address", in="query", @OA\Schema(type="string"), description="地址"),
* @OA\Parameter(name="theme", in="query", @OA\Schema(type="string"), description="主题"),
* @OA\Parameter(name="longitude", in="query", @OA\Schema(type="string"), description="经度"),
* @OA\Parameter(name="latitude", in="query", @OA\Schema(type="string"), description="纬度"),
* @OA\Parameter(name="address_detail", in="query", @OA\Schema(type="string"), description="详细地址"),
* @OA\Parameter(name="file_ids", in="query", @OA\Schema(type="string"), description="文件id数组"),
* @OA\Response(
* response=200,
* description="操作成功"
@ -235,17 +248,34 @@ class CourseContentController extends BaseController
if (!in_array('上课地点', $keyList)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '上课地点字段不存在']);
}
if (!in_array('联系方式', $keyList)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '联系方式字段不存在']);
}
if (!in_array('性别', $keyList)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '性别字段不存在']);
}
$list = [];
foreach ($dataArray as $value) {
if (empty($value['授课老师']) && empty($value['联系方式'])) {
continue;
}
if ($value['授课老师']) {
$teacher_id = Teacher::where('name', $value['授课老师'])->value('id');
}
if ($value['联系方式']) {
$teacher_id = Teacher::where('mobile', $value['联系方式'])->value('id');
}
$list[] = [
'course_id' => $course_id,
'date' => Carbon::parse($value['日期'])->toDateString(),
'period' => $value['时间'],
'teacher_name' => $value['授课老师'],
'teacher_introduce' => $value['老师简介'],
'teacher_id' => Teacher::where('name', $value['授课老师'])->value('id'),
'address' => $value['上课地点'],
'theme' => $value['课程主题']
'period' => $value['时间'] ?? '',
'teacher_name' => $value['授课老师'] ?? '',
'teacher_introduce' => $value['老师简介'] ?? '',
'teacher_id' => $teacher_id ?? null,
'address' => $value['上课地点'] ?? '',
'theme' => $value['课程主题'] ?? '',
'sex' => $value['性别'] ?? '',
'mobile' => $value['联系方式'] ?? ''
];
}
return $this->success($list);
@ -289,10 +319,27 @@ class CourseContentController extends BaseController
foreach ($records as $item) {
if (!isset($item['teacher_id']) || empty($item['teacher_id'])) {
// 写入老师表
$where = ['name' => $item['teacher_name']];
$data = ['name' => $item['teacher_name'], 'introduce' => $item['teacher_introduce']];
if ($item['mobile']) {
$where = ['mobile' => $item['mobile']];
}
if ($item['teacher_name']) {
$where = ['name' => $item['teacher_name']];
}
$data = [
'mobile' => $item['mobile'],
'name' => $item['teacher_name'],
'introduce' => $item['teacher_introduce'],
'sex' => $item['sex'],
];
$teacher = Teacher::updateOrCreate($where, $data);
$item['teacher_id'] = $teacher->id;
} else {
$teacher = Teacher::find($item['teacher_id']);
$teacher->name = $item['teacher_name'];
$teacher->mobile = $item['mobile'];
$teacher->introduce = $item['teacher_introduce'];
$teacher->sex = $item['sex'];
$teacher->save();
}
CourseContent::create($item);
}
@ -304,4 +351,34 @@ class CourseContentController extends BaseController
}
}
/**
* @OA\Get(
* path="/api/admin/course-contents/qrcode",
* tags={"排课"},
* summary="签到二维码",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function qrcode()
{
$all = \request()->all();
$messages = [
'id.required' => 'Id必填',
];
$validator = Validator::make($all, [
'id' => 'required'
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$url = (new CourseContent())->getCourseContentCheckQrcode($all['id']);
return $this->success($url);
}
}

@ -526,7 +526,7 @@ class CourseSignController extends BaseController
return $this->success(['total' => count($records)]);
} catch (\Exception $exception) {
DB::rollBack();
return $this->fail([$exception->getCode(), $exception->getMessage()]);
return $this->fail([$exception->getTrace(), $exception->getMessage()]);
}
}

@ -75,6 +75,7 @@ class CourseTypeController extends BaseController
* @OA\Parameter(name="fault_tip", in="query", @OA\Schema(type="string", format="date"), description="不通过提示"),
* @OA\Parameter(name="back_tip", in="query", @OA\Schema(type="string", format="date"), description="备选提示"),
* @OA\Parameter(name="year_total", in="query", @OA\Schema(type="string", format="date"), description="年预约次数"),
* @OA\Parameter(name="is_chart", in="query", @OA\Schema(type="string", format="date"), description="是否参与首页统计0否1是"),
* @OA\Response(
* response=200,
* description="操作成功"

@ -0,0 +1,338 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Exports\BaseExport;
use App\Helpers\ResponseCode;
use App\Models\AppointmentType;
use App\Models\Book;
use App\Models\Calendar;
use App\Models\CourseContentEvaluationAsk;
use App\Models\CourseContentEvaluationForm;
use App\Models\CustomForm;
use App\Models\CustomFormField;
use App\Models\EmailRecord;
use App\Models\EmailRecordUser;
use App\Models\EmailTemplate;
use App\Models\SupplyDemand;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Maatwebsite\Excel\Facades\Excel;
use Rap2hpoutre\FastExcel\FastExcel;
class EmailRecordController extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
parent::__construct(new EmailRecord());
}
/**
* @OA\Get(
* path="/api/admin/email-record/index",
* tags={"邮件发送配置"},
* summary="列表",
* description="",
* @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是"),
* @OA\Parameter(name="export_fields", in="query", @OA\Schema(type="string"), required=false, description="需要导出的字段数组"),
* @OA\Parameter(name="filter", in="query", @OA\Schema(type="string"), required=false, description="查询条件。数组"),
* @OA\Parameter(name="show_relation", in="query", @OA\Schema(type="string"), required=false, description="需要输出的关联关系数组包括teachercourseSettingscoursePeriods"),
* @OA\Parameter(name="page_size", in="query", @OA\Schema(type="string"), required=false, description="每页显示的条数"),
* @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"),
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function index()
{
$all = request()->all();
$list = $this->model->with('emailTemplate')
->withCount('emailRecordUsers')
->where(function ($query) use ($all) {
if (isset($all['filter']) && !empty($all['filter'])) {
foreach ($all['filter'] as $condition) {
$key = $condition['key'] ?? null;
$op = $condition['op'] ?? null;
$value = $condition['value'] ?? null;
if (!isset($key) || !isset($op) || !isset($value)) {
continue;
}
// 等于
if ($op == 'eq') {
$query->where($key, $value);
}
// 不等于
if ($op == 'neq') {
$query->where($key, '!=', $value);
}
// 大于
if ($op == 'gt') {
$query->where($key, '>', $value);
}
// 大于等于
if ($op == 'egt') {
$query->where($key, '>=', $value);
}
// 小于
if ($op == 'lt') {
$query->where($key, '<', $value);
}
// 小于等于
if ($op == 'elt') {
$query->where($key, '<=', $value);
}
// 模糊搜索
if ($op == 'like') {
$query->where($key, 'like', '%' . $value . '%');
}
// 否定模糊搜索
if ($op == 'notlike') {
$query->where($key, 'not like', '%' . $value . '%');
}
// 范围搜索
if ($op == 'range') {
list($from, $to) = explode(',', $value);
if (empty($from) || empty($to)) {
continue;
}
$query->whereBetween($key, [$from, $to]);
}
}
}
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc');
if (isset($all['is_export']) && !empty($all['is_export'])) {
$list = $list->get()->toArray();
$export_fields = $all['export_fields'] ?? [];
// 导出文件名字
$tableName = $this->model->getTable();
$filename = (new CustomForm())->getTableComment($tableName);
return Excel::download(new BaseExport($export_fields, $list, $tableName), $filename . date('YmdHis') . '.xlsx');
} else {
// 输出
$list = $list->paginate($all['page_size'] ?? 20);
foreach ($list as $detail) {
// 成功数量
$detail->success_count = $detail->emailRecordUsers->where('status', 1)->count();
// 失败数量
$detail->fail_count = $detail->emailRecordUsers->where('status', 2)->count();
}
}
return $this->success($list);
}
/**
* @OA\Get(
* path="/api/admin/email-record/show",
* tags={"邮件发送配置"},
* summary="详情",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
* @OA\Parameter(name="show_relation", in="query", @OA\Schema(type="string"), required=false, description="需要输出的关联关系数组,填写输出指定数据"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function show()
{
$all = \request()->all();
$messages = [
'title.required' => '标题必填',
];
$validator = Validator::make($all, [
'title' => 'required'
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$detail = $this->model->with('emailTemplate', 'emailRecordUsers')->withCount('emailRecordUsers')->find($all['id']);
// 成功数量
$detail->success_count = $detail->emailRecordUsers->where('status', 1)->count();
// 失败数量
$detail->fail_count = $detail->emailRecordUsers->where('status', 2)->count();
return $this->success($detail);
}
/**
* @OA\Post(
* path="/api/admin/email-record/save",
* tags={"邮件发送配置"},
* summary="保存",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="integer", format="int64"), required=true, description="ID存在则更新不存在则新增"),
* @OA\Parameter(name="time", in="query", @OA\Schema(type="string", format="date"), required=false, description="发送时间"),
* @OA\Parameter(name="subject", in="query", @OA\Schema(type="string", maxLength=255), required=false, description="主题"),
* @OA\Parameter(name="email_template_id", in="query", @OA\Schema(type="string", format="mediumtext"), required=false, description="邮件模版id"),
* @OA\Parameter(name="email_record_users", in="query", @OA\Schema(type="string", format="mediumtext"), required=false, description="二维数组包括建明emailvar_data自定义数据"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"),
* @OA\Response(
* response="200",
* description="操作成功"
* )
* )
*/
public function save()
{
$all = \request()->all();
DB::beginTransaction();
try {
if (isset($all['id'])) {
$model = $this->model->find($all['id']);
if (empty($model)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '数据不存在']);
}
} else {
$model = $this->model;
$all['admin_id'] = $this->getUserId();
$all['department_id'] = $this->getUser()->department_id;
}
$original = $model->getOriginal();
$model->fill($all);
$model->save();
if (isset($all['email_record_users'])) {
$model->emailRecordUsers()->delete();
$model->emailRecordUsers()->createMany($all['email_record_users']);
}
DB::commit();
// 记录日志
$this->saveLogs($original, $model);
return $this->success($model);
} catch (\Exception $exception) {
DB::rollBack();
return $this->fail([$exception->getCode(), $exception->getMessage()]);
}
}
/**
* @OA\Post(
* path="/api/admin/email-record/send-example",
* tags={"邮件发送配置"},
* summary="发送测试邮件",
* description="",
* @OA\Parameter(name="email_template_id", in="query", @OA\Schema(type="integer", format="int64"), required=true, description="模版id"),
* @OA\Parameter(name="subject", in="query", @OA\Schema(type="string", format="date"), required=false, description="标题"),
* @OA\Parameter(name="email", in="query", @OA\Schema(type="string", format="date"), required=false, description="邮箱地址"),
* @OA\Parameter(name="var_data", in="query", @OA\Schema(type="string", format="mediumtext"), required=false, description="数组var_data自定义数据"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"),
* @OA\Response(
* response="200",
* description="操作成功"
* )
* )
*/
public function sendExample()
{
$all = \request()->all();
$validator = Validator::make($all, [
'email_template_id' => 'required',
'subject' => 'required',
'email' => 'required',
'var_data' => 'required',
]);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
try {
$emailTemplate = EmailTemplate::find($all['email_template_id']);
// 替换后的标题
$title = EmailRecordUser::template($all['subject'], $all['var_data']);
// 替换后的内容
$template = EmailRecordUser::template($emailTemplate->content, $all['var_data']);
try {
// 发送邮件
EmailRecordUser::email($title, $template, $all['email']);
return $this->success("发送成功");
} catch (\Exception $e) {
return $this->fail([ResponseCode::ERROR_BUSINESS, $e->getMessage()]);
}
} catch (\Exception $exception) {
return $this->fail([$exception->getCode(), $exception->getMessage()]);
}
}
/**
* @OA\Get(
* path="/api/admin/email-record/destroy",
* tags={"邮件发送配置"},
* summary="删除",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function destroy()
{
return parent::destroy();
}
/**
* @OA\Post(
* path="/api/admin/email-record/excel-show",
* tags={"邮件发送配置"},
* summary="导入预览",
* description="",
* @OA\Parameter(name="file", in="query", @OA\Schema(type="string"), required=true, description="文件"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function excelShow()
{
$file = \request()->file('file');
//判断文件是否有效
if (!(\request()->hasFile('file') && $file->isValid())) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '文件不存在或无效']);
}
//获取文件大小
$img_size = floor($file->getSize() / 1024);
if ($img_size >= 50 * 1024) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '文件必须小于50M']);
}
//过滤文件后缀
$ext = $file->getClientOriginalExtension();
if (!in_array($ext, ['xls', 'xlsx', 'csv'])) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '仅支持xls/xlsx/csv格式']);
}
$tempFile = $file->getRealPath();
$dataArray = (new FastExcel)->import($tempFile)->toArray();
$list = [];
foreach ($dataArray as $key => $value) {
if (!isset($value['邮箱']) || empty($value['邮箱'])) {
continue;
}
// 时间标准格式化
foreach ($value as $k => &$v) {
if ($v instanceof \DateTimeImmutable) {
$v = Carbon::parse($v)->rawFormat('Y-m-d H:i');
}
}
$list[] = [
'email' => $value['邮箱'],
'var_data' => $value
];
}
return $this->success($list);
}
}

@ -11,6 +11,7 @@ use App\Models\CourseContentEvaluationAsk;
use App\Models\CourseContentEvaluationForm;
use App\Models\CustomForm;
use App\Models\CustomFormField;
use App\Models\EmailTemplate;
use App\Models\SupplyDemand;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@ -25,14 +26,14 @@ class EmailTemplateController extends BaseController
*/
public function __construct()
{
parent::__construct(new Calendar());
parent::__construct(new EmailTemplate());
}
/**
* @OA\Get(
* path="/api/admin/calendars/index",
* tags={"日历管理"},
* path="/api/admin/email-template/index",
* tags={"邮件模版管理"},
* summary="列表",
* description="",
* @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是"),
@ -44,7 +45,6 @@ class EmailTemplateController extends BaseController
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=true, description="关键词"),
* @OA\Response(
* response="200",
* description="暂无"
@ -54,7 +54,7 @@ class EmailTemplateController extends BaseController
public function index()
{
$all = request()->all();
$list = $this->model->with('courseContent')->where(function ($query) use ($all) {
$list = $this->model->withCount('emailRecords')->where(function ($query) use ($all) {
if (isset($all['filter']) && !empty($all['filter'])) {
foreach ($all['filter'] as $condition) {
$key = $condition['key'] ?? null;
@ -122,8 +122,8 @@ class EmailTemplateController extends BaseController
/**
* @OA\Get(
* path="/api/admin/calendars/show",
* tags={"日历管理"},
* path="/api/admin/email-template/show",
* tags={"邮件模版管理"},
* summary="详情",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
@ -139,31 +139,28 @@ class EmailTemplateController extends BaseController
{
$all = \request()->all();
$messages = [
'id.required' => 'Id必填',
'title.required' => '标题必填',
];
$validator = Validator::make($all, [
'id' => 'required'
'title' => 'required'
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$detail = $this->model->with('courseContent')->find($all['id']);
$detail = $this->model->withCount('emailRecords')->find($all['id']);
return $this->success($detail);
}
/**
* @OA\Post(
* path="/api/admin/calendars/save",
* tags={"日历管理"},
* path="/api/admin/email-template/save",
* tags={"邮件模版管理"},
* summary="保存",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="integer", format="int64"), required=true, description="ID存在则更新不存在则新增"),
* @OA\Parameter(name="course_content_id", in="query", @OA\Schema(type="integer"), required=false, description="课程课堂ID"),
* @OA\Parameter(name="date", in="query", @OA\Schema(type="string", format="date"), required=false, description="日期YYYY-MM-DD"),
* @OA\Parameter(name="title", in="query", @OA\Schema(type="string", maxLength=255), required=false, description="标题"),
* @OA\Parameter(name="content", in="query", @OA\Schema(type="string", format="mediumtext"), required=false, description="内容"),
* @OA\Parameter(name="start_time", in="query", @OA\Schema(type="string", format="date-time"), required=false, description="开始时间YYYY-MM-DD HH:MM:SS"),
* @OA\Parameter(name="end_time", in="query", @OA\Schema(type="string", format="date-time"), required=false, description="结束时间YYYY-MM-DD HH:MM:SS"),
* @OA\Parameter(name="title", in="query", @OA\Schema(type="integer"), required=false, description="标题"),
* @OA\Parameter(name="description", in="query", @OA\Schema(type="string", format="date"), required=false, description="描述"),
* @OA\Parameter(name="content", in="query", @OA\Schema(type="string", maxLength=255), required=false, description="邮件内容"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"),
* @OA\Response(
* response="200",
@ -173,13 +170,37 @@ class EmailTemplateController extends BaseController
*/
public function save()
{
return parent::save();
$all = \request()->all();
DB::beginTransaction();
try {
if (isset($all['id'])) {
$model = $this->model->find($all['id']);
if (empty($model)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '数据不存在']);
}
} else {
$model = $this->model;
$all['admin_id'] = $this->getUserId();
$all['department_id'] = $this->getUser()->department_id;
}
$original = $model->getOriginal();
$all['var'] = getVar($all['content']);
$model->fill($all);
$model->save();
DB::commit();
// 记录日志
$this->saveLogs($original, $model);
return $this->success($model);
} catch (\Exception $exception) {
DB::rollBack();
return $this->fail([$exception->getCode(), $exception->getMessage()]);
}
}
/**
* @OA\Get(
* path="/api/admin/calendars/destroy",
* tags={"日历管理"},
* path="/api/admin/email-template/destroy",
* tags={"邮件模版管理"},
* summary="删除",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),

@ -7,11 +7,16 @@ use App\Models\Admin;
use App\Models\Appointment;
use App\Models\AppointmentConfig;
use App\Models\CarparkLog;
use App\Models\Company;
use App\Models\CourseSign;
use App\Models\CourseType;
use App\Models\CustomFormField;
use App\Models\Department;
use App\Models\ParameterDetail;
use App\Models\User;
use App\Repositories\DoorRepository;
use App\Repositories\EntranceRepository;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Models\Course;
use EasyWeChat\Factory;
@ -20,6 +25,67 @@ use Illuminate\Filesystem\Filesystem;
class OtherController extends CommonController
{
/**
* @OA\Get(
* path="/api/admin/other/home",
* tags={"其他"},
* summary="驾驶舱",
* description="",
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function home()
{
// 校友总数
$schoolmate['schoolmate_total'] = User::where('is_schoolmate', 1)->count();
// 2025年校友数
$schoolmate['schoolmate_year'] = User::where('is_schoolmate', 1)->where('created_at', 'like', '%' . date('Y') . '%')->count();
// 上市企业总市值
$company['company_market'] = Company::where('company_market', 1)->sum('market_value');
// 校友企业总融资额
$company['company_fund'] = Company::where('is_schoolmate', 1)->sum('company_fund');
// 校友企业总估值
$company['valuation'] = Company::where('is_schoolmate', 1)->sum('valuation');
// 校友企业所属领域
$industryTotal = [];
$industries = ParameterDetail::where('parameter_id', 4)->get();
foreach ($industries as $item) {
$level2Names = ParameterDetail::where('parameter_id', 10)->where('remark', $item->value)->pluck('value');
$industryTotal[] = [
'industry' => $item->value,
'total' => User::whereIn('company_industry', $level2Names)->count()
];
}
// 追加其他领域
$industryTotal[] = [
'industry' => '其他',
'total' => User::count() - collect($industryTotal)->sum('total')
];
// 课程统计
$courseTypes = CourseType::where('is_chart', 1)->get();
foreach ($courseTypes as $courseType) {
$courseIds = Course::where('type', $courseType->id)->pluck('id');
$courseType->course_signs_total = CourseSign::whereIn('course_id', $courseIds)
->where('status', 1)
->count();
}
// 苏州区域数据
$suzhou = Company::where('company_city', '苏州市')
// 根据company_area分组查询公司数量
->select('company_area', DB::raw('count(*) as company_total'))
->groupBy('company_area')
->get();
// 全国数据
$country = Company::select('company_city', DB::raw('count(*) as company_total'))
->groupBy('company_city')
->get();
return $this->success(compact('courseTypes', 'schoolmate', 'company', 'industryTotal', 'suzhou', 'country'));
}
/**
* @OA\Post(
* path="/api/admin/other/admin-user-list",

@ -156,7 +156,7 @@ class SupplyDemandController extends BaseController
* @OA\Parameter(name="wechat", in="query", @OA\Schema(type="string"), required=false, description="微信号"),
* @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=false, description="电话"),
* @OA\Parameter(name="email", in="query", @OA\Schema(type="string"), required=false, description="邮箱"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=false, description="审核状态0待审核1通过2拒绝"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=false, description="状态0待审核1通过2拒绝3退回修改4永久隐藏"),
* @OA\Response(
* response=200,
* description="操作成功"

@ -21,6 +21,7 @@ use App\Models\Notice;
use App\Models\Order;
use App\Models\User;
use EasyWeChat\Factory;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
@ -243,7 +244,7 @@ class CourseController extends CommonController
*/
public function myCourseContent()
{
$list = CourseContent::with('course.typeDetail', 'teacher','courseContentEvaluation')->whereHas('course', function ($query) {
$list = CourseContent::with('course.typeDetail', 'teacher', 'courseContentEvaluation')->whereHas('course', function ($query) {
$query->where('course_status', '!=', 40)->where('course_content_status', 1);
$query->whereHas('courseSigns', function ($query) {
$query->where('user_id', $this->getUserId())->where('status', 1)->where(function ($q) {
@ -310,12 +311,12 @@ class CourseController extends CommonController
$messages = [
'course_content_evaluation_id.required' => '问卷id必填',
'data.required' => '表单数据必填',
// 'time_total.required' => '用时必填'
// 'time_total.required' => '用时必填'
];
$validator = Validator::make($all, [
'course_content_evaluation_id' => 'required',
'data' => 'required',
// 'time_total' => 'required'
// 'time_total' => 'required'
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
@ -339,7 +340,7 @@ class CourseController extends CommonController
$model = CourseContentEvaluationForm::create([
'course_content_evaluation_id' => $all['course_content_evaluation_id'],
'user_id' => $this->getUserId(),
'time_total' => $all['time_total']??0,
'time_total' => $all['time_total'] ?? 0,
'data' => $all['data']
]);
return $this->success($model);
@ -814,7 +815,20 @@ class CourseController extends CommonController
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$list = Calendar::with('courseContent')->where('date', 'like', $all['month'] . '%')->orderBy('date')->get();
$startDate = $all['month'] . '-01';
$endDate = date('Y-m-t', strtotime($startDate));
$range = getDates($startDate, $endDate);
$list = [];
foreach ($range as $date) {
// 查询Calendar模型里start_time和end_time在日期内的数据,其中date是年月日start_time和end_time是时分秒
$list[] = [
'date' => $date,
'details' => Calendar::with('course', 'courseContent')
->whereDate('start_time', '<=', $date)
->whereDate('end_time', '>=', $date)
->get()
];
}
return $this->success($list);
}

@ -16,6 +16,7 @@ use App\Models\SupplyDemand;
use App\Models\SupplyDemandKeep;
use App\Notifications\BirthdayNotify;
use App\Notifications\SupplyDemandNotify;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Validator;
@ -32,11 +33,12 @@ class SupplyDemandController extends CommonController
* @OA\Parameter(name="myself", in="query", @OA\Schema(type="integer"), required=true, description="是否只看自己的0否1是"),
* @OA\Parameter(name="type", in="query", @OA\Schema(type="integer"), required=true, description="类型"),
* @OA\Parameter(name="keyword", in="query", @OA\Schema(type="integer"), required=true, description="关键词"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=true, description="状态0待审核1通过2拒绝"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=true, description="状态0待审核1通过2拒绝3退回修改4永久隐藏"),
* @OA\Parameter(name="page_size", in="query", @OA\Schema(type="string"), required=false, description="每页显示的条数"),
* @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"),
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="expire_type", in="query", @OA\Schema(type="string"), required=false, description="有效期类型1有效期内2失效的"),
* @OA\Response(
* response="200",
* description="暂无"
@ -63,6 +65,15 @@ class SupplyDemandController extends CommonController
if (isset($all['myself']) && $all['myself'] == 1) {
$query->where('user_id', $this->getUserId());
}
if (isset($all['expire_type'])) {
if ($all['expire_type'] == 1) {
$query->where(function ($q) {
$q->whereNull('expire_time')->orWhere('expire_time', '>', Carbon::now());
});
} else {
$query->where('expire_time', '<', Carbon::now());
}
}
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')
->paginate($all['page_size'] ?? 20);
return $this->success(compact('supplyDemands'));
@ -100,6 +111,8 @@ class SupplyDemandController extends CommonController
// 增加view_count
$detail->increment('view_count');
$detail->save();
// 判断是否发送过私信
$detail->messages_count = Message::where('supply_demand_id', $detail->id)->where('user_id', $this->getUserId())->count();
return $this->success($detail);
}
@ -118,7 +131,10 @@ class SupplyDemandController extends CommonController
* @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=false, description="电话"),
* @OA\Parameter(name="email", in="query", @OA\Schema(type="string"), required=false, description="邮箱"),
* @OA\Parameter(name="expire_time", in="query", @OA\Schema(type="string"), required=false, description="过期时间"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=false, description="审核状态0待审核1通过2拒绝"),
* @OA\Parameter(name="public_way", in="query", @OA\Schema(type="string"), required=false, description="公开模式1直接公开2私信后自动公开3不公开"),
* @OA\Parameter(name="file_ids", in="query", @OA\Schema(type="string"), required=false, description="文件id数组"),
* @OA\Parameter(name="contact_name", in="query", @OA\Schema(type="string"), required=false, description="联系人名字"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=false, description="状态0待审核1通过2拒绝3退回修改4永久隐藏"),
* @OA\Response(
* response="200",
* description="暂无"

@ -240,7 +240,8 @@ class UserController extends CommonController
$query->where('start_date', '<=', $nowDate)->where('end_date', '>=', $nowDate);
})->first();
if ($course_signs) {
$course_signs->qrcode = $doorRepository->getEmpQrCodeByCourse($course_signs, $out);
//$course_signs->qrcode = $doorRepository->getEmpQrCodeByCourse($course_signs, $out);
$course_signs->qrcode = '';
}
// 是否有资格进入校友库
$enter_schoolmate = User::whereHas('courseSigns', function ($query) {

@ -676,7 +676,8 @@ function isMultiDimensionalArray($array)
* @param lng1,lng2 经度
* @return float 距离单位为km
**/
function getDistance($lat1,$lng1,$lat2,$lng2){
function getDistance($lat1, $lng1, $lat2, $lng2)
{
//将角度转为狐度
$radLat1 = deg2rad($lat1);//deg2rad()函数将角度转换为弧度
$radLat2 = deg2rad($lat2);
@ -684,6 +685,36 @@ function getDistance($lat1,$lng1,$lat2,$lng2){
$radLng2 = deg2rad($lng2);
$a = $radLat1 - $radLat2;
$b = $radLng1 - $radLng2;
$s =2*asin(sqrt(pow(sin($a/2),2)+cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)))*6371;
return round($s,1);
$s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6371;
return round($s, 1);
}
/**
* 提取中括号里的数据
*/
function getVar($text)
{
$pattern = '/\{.*?\}/';
preg_match_all($pattern, $text, $matches);
if (count($matches[0]) > 0) {
// 数组转英文逗号分割的字符串
return implode(',', $matches[0]);
}
return '';
}
/**
* 获取两个日期之间的所有日期
*/
function getDates($start, $end)
{
$dt_start = strtotime($start);
$dt_end = strtotime($end);
$temp = [];
while ($dt_start <= $dt_end) {
$re = date('Y-m-d', $dt_start);
$temp[] = $re;
$dt_start = strtotime('+1 day', $dt_start);
}
return $temp; // 返回data型数据
}

@ -9,6 +9,11 @@ use Illuminate\Support\Facades\Cache;
class Calendar extends SoftDeletesModel
{
public function course()
{
return $this->hasOne(Course::class, 'id', 'course_id');
}
public function courseContent()
{
return $this->hasMany(CourseContent::class, 'id', 'course_content_id');

@ -0,0 +1,12 @@
<?php
namespace App\Models;
class Company extends SoftDeletesModel
{
public function users()
{
return $this->hasMany(User::class, 'company_id', 'id');
}
}

@ -4,11 +4,20 @@
namespace App\Models;
use EasyWeChat\Factory;
use Illuminate\Filesystem\Filesystem;
class CourseContent extends SoftDeletesModel
{
protected $casts = ['publicize_ids' => 'json'];
protected $casts = ['publicize_ids' => 'json', 'file_ids' => 'json'];
protected $appends = ['publicize', 'files'];
protected $appends = ['publicize'];
public function getFilesAttribute($value)
{
if (empty($this->file_ids)) return [];
return Upload::whereIn('id', $this->file_ids)->get();
}
public function getPublicizeAttribute($value)
{
@ -51,5 +60,32 @@ class CourseContent extends SoftDeletesModel
return $this->hasOne(CourseContentEvaluation::class, 'course_content_id', 'id');
}
/**
* 获取课程详情小程序码
*/
public function getCourseContentCheckQrcode($courseContentId)
{
$courseContent = self::find($courseContentId);
$path = config('filesystems.disks.public.root') . '/course_content_qrcode/' . $courseContent->id . '.png';
$url = config('filesystems.disks.public.url') . '/course_content_qrcode/' . $courseContent->id . '.png';
$fileSys = new Filesystem();
if ($fileSys->exists($path)) {
return $url;
}
$config = [
'app_id' => \config('app.applet_appid'),
'secret' => \config('app.applet_secret')
];
$app = Factory::miniProgram($config);
$tmp = $app->app_code->get('/packages/surveyFill/index?course_content_id' . $courseContentId, [
'env_version' => "release" // 正式版
// 'env_version' => "trial" // 体验版
]);
$dir = dirname($path);
$fileSys->ensureDirectoryExists($dir, 0755, true);
$fileSys->put($path, $tmp);
return $url;
}
}

@ -9,5 +9,15 @@ use Illuminate\Support\Facades\Cache;
class EmailRecord extends SoftDeletesModel
{
public function emailTemplate()
{
return $this->hasOne(EmailTemplate::class, 'id', 'email_template_id');
}
public function emailRecordUsers()
{
return $this->hasMany(EmailRecordUser::class, 'email_record_id', 'id');
}
}

@ -5,9 +5,42 @@ namespace App\Models;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Mail;
class EmailRecordUser extends SoftDeletesModel
{
protected $casts = ['var_data' => 'json'];
public function emailRecord()
{
return $this->hasOne(EmailRecord::class, 'id', 'email_record_id');
}
/**
* 邮件模版内容替换
* @param $template
* @param $email_record_users
*/
public static function template($template, $var_data)
{
foreach ($var_data as $key => $var) {
$template = str_replace('{' . $key . '}', $var, $template);
}
return $template;
}
/**
* 发送邮件
*/
public static function email($title, $template, $email)
{
Mail::send('email', compact('template'), function ($message) use ($email, $title) {
$message->from(env('MAIL_USERNAME'), '苏州科技商学院');
$message->to($email)->subject($title);
});
return true;
}
}

@ -9,5 +9,10 @@ use Illuminate\Support\Facades\Cache;
class EmailTemplate extends SoftDeletesModel
{
public function emailRecords()
{
return $this->hasMany(EmailRecord::class, 'email_template_id', 'id');
}
}

@ -9,6 +9,13 @@ use Illuminate\Support\Facades\Cache;
class SupplyDemand extends SoftDeletesModel
{
protected $casts = ['file_ids' => 'json'];
public function getFilesAttribute($value)
{
if (empty($this->file_ids)) return [];
return Upload::whereIn('id', $this->file_ids)->get();
}
public function user()
{
return $this->hasOne(User::class, 'id', 'user_id');

@ -18,9 +18,62 @@ class User extends Authenticatable implements Auditable
use \OwenIt\Auditing\Auditable;
use SoftDeletes;
protected $guarded = ['id'];
protected $fillable = [
'remember_token',
'created_at',
'updated_at',
'nickname',
'openid',
'country',
'province',
'city',
'headimgurl',
'username',
'password',
'name',
'sex',
'birthday',
'mobile',
'idcard',
'education',
'company_name',
'company_position',
'company_has_share',
'type',
'company_type',
'company_fund',
'company_area',
'company_address',
'company_industry',
'company_product',
'school',
'speciality',
'overseas_experience',
'sign_from',
'email',
'sales_volume',
'valuation',
'market_value',
'is_yuanhe',
'plate',
'introduce',
'honour',
'company_need_fund',
'company_other',
'remark',
'is_import',
'is_vip',
'is_schoolmate',
'appointment_total',
'letter',
'code',
'score',
'pid',
'company_introduce',
'company_date',
'deleted_at',
'no',
];
protected $appends = ['is_vip_text', 'is_schoolmate_text', 'appointment_total', 'name'];
// 更新时候覆盖更新的字段
@ -129,8 +182,41 @@ class User extends Authenticatable implements Auditable
*/
public static function updateNo($userId)
{
// todo::编号可能回重复,还需要详细排查
$user = self::find($userId);
$no = date('Ymd', strtotime($user->created_at)) . str_pad($userId, 6, '0', STR_PAD_LEFT);
if (!empty($user->no)) {
return false;
}
// 获取最早一条审核通过的报名数据
$courseSigns = CourseSign::with('course')
->where('user_id', $userId)
->where('status', 1)
->orderBy('created_at', 'asc')
->first();
if (empty($courseSigns)) {
return false;
}
if (empty($courseSigns->course->start_date)) {
return false;
}
// 编号前缀
$prefix = date('Ymd', strtotime($courseSigns->course->start_date));
// 获取同一天开始的所有课程
$course = Course::where('start_date', $courseSigns->course->start_date)->orderBy('created_at', 'asc')->get();
// 获取同一天开始所有课程的报名信息
$courseSignsList = CourseSign::whereIn('id', function ($query) use ($course) {
$query->from('course_signs')
->where('status', 1)
->whereIn('course_id', $course->pluck('id'))
->selectRaw('MIN(id)')
->groupBy('user_id');
})->orderBy('created_at', 'asc')->get();
// 获取当前用户id在$courseSigns中第几位
$index = $courseSignsList->search(function ($item) use ($user) {
return $item->user_id == $user->id;
});
$no = $prefix . str_pad($index + 1, 3, '0', STR_PAD_LEFT);
$user->no = $no;
$user->save();
return $user->no;

@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*
@ -15,7 +14,10 @@ return new class extends Migration
{
Schema::table('users', function (Blueprint $table) {
$table->string('no')->nullable()->comment('学号');
$table->integer('company_id')->nullable()->comment('企业id');
$table->date('birthday')->nullable()->comment('生日')->change();
// no字段唯一索引
$table->unique('no');
});
}

@ -31,7 +31,7 @@ return new class extends Migration {
// 邮箱
$table->string('email')->nullable()->comment('邮箱');
// 审核状态
$table->tinyInteger('status')->default(0)->comment('状态0待审核1通过2拒绝');
$table->tinyInteger('status')->default(0)->comment('状态0待审核1通过2拒绝3退回修改4永久隐藏');
// 浏览次数
$table->integer('view_count')->default(0)->comment('浏览次数');
// 联系次数

@ -22,6 +22,11 @@ return new class extends Migration
$table->dateTime('start_time')->nullable()->comment('开始时间');
// 结束时间
$table->dateTime('end_time')->nullable()->comment('结束时间');
$table->json('file_ids')->nullable()->comment('文件id数组');
// 详细地址
$table->string('address_detail')->nullable()->comment('详细地址');
$table->string('sex')->nullable()->comment('性别');
$table->string('mobile')->nullable()->comment('联系方式');
});
}

@ -14,6 +14,10 @@ return new class extends Migration {
{
Schema::create('calendars', function (Blueprint $table) {
$table->id();
// 类型
$table->tinyInteger('type')->nullable()->comment('类型1课程2课堂3事件');
//课程id
$table->integer('course_id')->nullable()->comment('课程id');
// 课程课堂id
$table->integer('course_content_id')->nullable()->comment('课程课堂id');
// 日期
@ -26,6 +30,8 @@ return new class extends Migration {
$table->dateTime('start_time')->nullable()->comment('开始时间');
// 结束时间
$table->dateTime('end_time')->nullable()->comment('结束时间');
// 链接
$table->string('url')->nullable()->comment('链接');
$table->timestamps();
$table->softDeletes();
});

@ -20,6 +20,10 @@ return new class extends Migration {
$table->string('subject')->nullable()->comment('邮件主题');
// 邮件模版id
$table->integer('email_template_id')->nullable()->comment('邮件模版id');
// 状态
$table->tinyInteger('status')->nullable()->default(0)->comment('状态0:待处理1:已处理');
// 发送时间
$table->dateTime('send_time')->nullable()->comment('发送时间');
$table->timestamps();
$table->softDeletes();
});

@ -16,12 +16,15 @@ return new class extends Migration {
$table->id();
// 发送配置id
$table->integer('email_record_id')->nullable()->comment('发送记录id');
// 接收用户id
$table->integer('user_id')->nullable()->comment('接收用户id');
$table->json('var_data')->nullable()->comment('自定义的数据');
// 邮箱
$table->string('email')->nullable()->comment('邮箱');
// 状态
$table->tinyInteger('status')->nullable()->comment('状态0:待发送1:成功 2:失败');
$table->tinyInteger('status')->nullable()->default(0)->comment('状态0:待发送1:成功 2:失败');
// 发送时间
$table->dateTime('send_time')->nullable()->comment('发送时间');
// 原因
$table->string('reason')->nullable()->comment('原因');
$table->timestamps();
$table->softDeletes();
});

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('supply_demands', function (Blueprint $table) {
// 联系方式公开模式
$table->boolean('public_way')->default(false)->comment('公开模式1直接公开2私信后自动公开3不公开');
$table->json('file_ids')->nullable()->comment('文件');
// 联系人名字
$table->string('contact_name')->nullable()->comment('联系人名字');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('supply_demands', function (Blueprint $table) {
//
});
}
};

@ -0,0 +1,70 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('companies', function (Blueprint $table) {
$table->id();
$table->integer('admin_id')->nullable();
$table->integer('department_id')->nullable();
// 企业名字
$table->string('company_name')->nullable()->comment('企业名字');
// 行业类型
$table->string('company_attribute')->nullable()->comment('行业类型');
// 标签
$table->string('company_tag')->nullable()->comment('标签');
// 企业规模
$table->string('company_scale')->nullable()->comment('企业规模');
// 成立时间
$table->date('company_date')->nullable()->comment('成立时间');
// 法人代表
$table->string('company_legal_representative')->nullable()->comment('法人代表');
// 管理平台
$table->string('management_platform')->nullable()->comment('管理平台');
// 项目经理
$table->string('project_manager')->nullable()->comment('项目经理');
$table->bigInteger('market_value')->nullable()->comment('市值');
$table->bigInteger('company_fund')->nullable()->comment('公司融资情况');
$table->bigInteger('valuation')->nullable()->comment('估值');
$table->string('company_address')->nullable()->comment('公司地址');
$table->string('company_area')->nullable()->comment('公司区域');
$table->string('company_city')->nullable()->comment('公司城市');
$table->string('company_province')->nullable()->comment('公司省份');
// 是否上市
$table->boolean('company_market')->nullable()->comment('公司性质-0未上市1已上市');
// 是否校友企业
$table->boolean('is_schoolmate')->nullable()->comment('是否校友企业-0非校友1校友');
$table->boolean('company_need_fund')->nullable()->comment('公司是否需要融资-0否1是');
// 股东信息
$table->string('company_shareholder')->nullable()->comment('股东信息');
$table->string('company_industry')->nullable()->comment('公司所属行业');
$table->text('company_introduce')->nullable()->comment('公司简介');
$table->string('company_other')->nullable()->comment('其他');
$table->text('company_product')->nullable()->comment('产品');
$table->string('overseas_experience')->nullable()->comment('海外经验');
$table->string('sales_volume')->nullable()->comment('销售额');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('companies');
}
};

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('course_types', function (Blueprint $table) {
// 是否参与统计
$table->boolean('is_chart')->default(true)->comment('是否参与统计0否1是');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('course_types', function (Blueprint $table) {
//
});
}
};

@ -0,0 +1,7 @@
<html>
<head>
</head>
<body>
{!! $template !!}
</body>
</html>

@ -34,6 +34,8 @@ Route::group(["namespace" => "Admin", "prefix" => "admin"], function () {
Route::get('users/index', [\App\Http\Controllers\Admin\UserController::class, "index"]);
Route::get('other/table-fileds', [\App\Http\Controllers\Admin\OtherController::class, "tableFileds"]);
Route::get('other/home', [\App\Http\Controllers\Admin\OtherController::class, "home"]);
// 验证码登陆
Route::get('auth/sms-login', [\App\Http\Controllers\Admin\AuthController::class, "smsLogin"]);
Route::get('auth/send-sms', [\App\Http\Controllers\Admin\AuthController::class, "sendSms"]);
@ -55,6 +57,7 @@ Route::group(["namespace" => "Admin", "prefix" => "admin"], function () {
Route::get('course-contents/destroy', [\App\Http\Controllers\Admin\CourseContentController::class, "destroy"]);
Route::post('course-contents/excel-show', [\App\Http\Controllers\Admin\CourseContentController::class, "excelShow"]);
Route::post('course-contents/import', [\App\Http\Controllers\Admin\CourseContentController::class, "import"]);
Route::get('course-contents/qrcode', [\App\Http\Controllers\Admin\CourseContentController::class, "qrcode"]);
// 课程类别
Route::get('course-types/index', [\App\Http\Controllers\Admin\CourseTypeController::class, "index"]);
@ -205,11 +208,24 @@ Route::group(["namespace" => "Admin", "prefix" => "admin"], function () {
Route::get('calendars/destroy', [\App\Http\Controllers\Admin\CalendarsController::class, "destroy"]);
// 邮件模版
Route::get('email-template/index', [\App\Http\Controllers\Admin\EmailTemplatesController::class, "index"]);
Route::get('email-template/show', [\App\Http\Controllers\Admin\EmailTemplatesController::class, "show"]);
Route::post('email-template/save', [\App\Http\Controllers\Admin\EmailTemplatesController::class, "save"]);
Route::get('email-template/destroy', [\App\Http\Controllers\Admin\EmailTemplatesController::class, "destroy"]);
Route::get('email-template/index', [\App\Http\Controllers\Admin\EmailTemplateController::class, "index"]);
Route::get('email-template/show', [\App\Http\Controllers\Admin\EmailTemplateController::class, "show"]);
Route::post('email-template/save', [\App\Http\Controllers\Admin\EmailTemplateController::class, "save"]);
Route::get('email-template/destroy', [\App\Http\Controllers\Admin\EmailTemplateController::class, "destroy"]);
// 邮件发送配置
Route::get('email-record/index', [\App\Http\Controllers\Admin\EmailRecordController::class, "index"]);
Route::get('email-record/show', [\App\Http\Controllers\Admin\EmailRecordController::class, "show"]);
Route::post('email-record/save', [\App\Http\Controllers\Admin\EmailRecordController::class, "save"]);
Route::post('email-record/send-example', [\App\Http\Controllers\Admin\EmailRecordController::class, "sendExample"]);
Route::get('email-record/destroy', [\App\Http\Controllers\Admin\EmailRecordController::class, "destroy"]);
Route::post('email-record/excel-show', [\App\Http\Controllers\Admin\EmailRecordController::class, "excelShow"]);
// 企业管理
Route::get('company/index', [\App\Http\Controllers\Admin\CompanyController::class, "index"]);
Route::get('company/show', [\App\Http\Controllers\Admin\CompanyController::class, "show"]);
Route::post('company/save', [\App\Http\Controllers\Admin\CompanyController::class, "save"]);
Route::get('company/destroy', [\App\Http\Controllers\Admin\CompanyController::class, "destroy"]);
});
});

Loading…
Cancel
Save