refactor(app): 优化邮件模板

master
cody 4 weeks ago
parent cd549b5f0e
commit 20f7d92764

@ -43,14 +43,14 @@ class UpdateUserNo extends Command
public function handle() public function handle()
{ {
// 已经开始的课程日期(所有历史数据处理) // 已经开始的课程日期(所有历史数据处理)
// $dateList = Course::whereNotNull('start_date') $dateList = Course::whereNotNull('start_date')
// ->where('start_date', '<=', date('Y-m-d')) ->where('start_date', '<=', date('Y-m-d'))
// ->orderBy('start_date') ->orderBy('start_date')
// ->groupBy('start_date') ->groupBy('start_date')
// ->pluck('start_date') ->pluck('start_date')
// ->toArray(); ->toArray();
// 当日数据处理(日常定时任务) // 当日数据处理(日常定时任务)
$dateList = [date('Y-m-d')]; //$dateList = [date('Y-m-d')];
foreach ($dateList as $date) { foreach ($dateList as $date) {
$courses = Course::with(['courseSigns' => function ($query) { $courses = Course::with(['courseSigns' => function ($query) {
$query->where('status', 1); $query->where('status', 1);
@ -59,14 +59,13 @@ class UpdateUserNo extends Command
->get(); ->get();
$i = 1; $i = 1;
// 编号前缀 // 编号前缀
$prefix = date('Ymd', strtotime($date));
foreach ($courses as $course) { foreach ($courses as $course) {
foreach ($course->courseSigns as $sign) { foreach ($course->courseSigns as $sign) {
$user = User::find($sign->user_id); $user = User::find($sign->user_id);
if ($user->no) { if ($user->no) {
continue; continue;
} }
$no = $prefix . str_pad($i, 3, '0', STR_PAD_LEFT); $no = $course->student_prefix . str_pad($i, 3, '0', STR_PAD_LEFT);
// 更新用户编号 // 更新用户编号
$user->no = $no; $user->no = $no;
$user->save(); $user->save();

@ -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('courses', function (Blueprint $table) {
// 学生编号前缀
$table->string('student_prefix')->nullable()->comment('学生编号前缀');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('courses', function (Blueprint $table) {
//
});
}
};
Loading…
Cancel
Save