|
|
<?php
|
|
|
|
|
|
namespace Database\Seeders;
|
|
|
|
|
|
use App\Models\DictItem;
|
|
|
use App\Models\DictType;
|
|
|
use App\Models\Teacher;
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
/**
|
|
|
* 老师库下拉字典。来源不含课程/活动(报名走学员库 → 转入老师库)。
|
|
|
*/
|
|
|
class TeacherDictionarySeeder extends Seeder
|
|
|
{
|
|
|
public function run(): void
|
|
|
{
|
|
|
$source = DictType::query()->updateOrCreate(
|
|
|
['code' => 'teacher_source'],
|
|
|
['name' => '老师来源', 'remark' => '老师库-来源筛选', 'status' => 1, 'sort' => 50]
|
|
|
);
|
|
|
$level = DictType::query()->updateOrCreate(
|
|
|
['code' => 'teacher_level'],
|
|
|
['name' => '老师星级', 'remark' => '老师库-星级;value 用于跟进日计算', 'status' => 1, 'sort' => 51]
|
|
|
);
|
|
|
$status = DictType::query()->updateOrCreate(
|
|
|
['code' => 'teacher_status'],
|
|
|
['name' => '老师跟进状态', 'remark' => '伙伴/持续跟进/暂停跟进', 'status' => 1, 'sort' => 52]
|
|
|
);
|
|
|
$method = DictType::query()->updateOrCreate(
|
|
|
['code' => 'follow_method'],
|
|
|
['name' => '跟进方式', 'remark' => '跟进记录-方式', 'status' => 1, 'sort' => 53]
|
|
|
);
|
|
|
$urgency = DictType::query()->updateOrCreate(
|
|
|
['code' => 'follow_urgency'],
|
|
|
['name' => '跟进紧急程度', 'remark' => '跟进记录-紧急程度', 'status' => 1, 'sort' => 54]
|
|
|
);
|
|
|
|
|
|
foreach ([
|
|
|
['label' => '论文库', 'value' => 'paper', 'sort' => 10],
|
|
|
['label' => '高校抓取', 'value' => 'faculty_crawl', 'sort' => 15],
|
|
|
['label' => '手动录入', 'value' => 'manual', 'sort' => 20],
|
|
|
['label' => '小程序学员', 'value' => 'miniapp', 'sort' => 30],
|
|
|
] as $row) {
|
|
|
DictItem::query()->updateOrCreate(
|
|
|
['dict_type_id' => $source->id, 'value' => $row['value']],
|
|
|
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
|
|
|
);
|
|
|
}
|
|
|
|
|
|
// 已废弃:爬虫采集(论文作者入库统一为「论文库」)
|
|
|
$crawlIds = DictItem::query()
|
|
|
->where('dict_type_id', $source->id)
|
|
|
->where('value', 'crawl')
|
|
|
->pluck('id');
|
|
|
$paperSourceId = DictItem::query()
|
|
|
->where('dict_type_id', $source->id)
|
|
|
->where('value', 'paper')
|
|
|
->where('status', 1)
|
|
|
->value('id');
|
|
|
if ($paperSourceId && $crawlIds->isNotEmpty()) {
|
|
|
Teacher::query()
|
|
|
->whereIn('source_dict_item_id', $crawlIds)
|
|
|
->update(['source_dict_item_id' => $paperSourceId]);
|
|
|
}
|
|
|
DictItem::query()->whereIn('id', $crawlIds)->update(['status' => 0]);
|
|
|
|
|
|
// 已废弃:课程/活动报名不再直接进入老师库,改由学员库转入
|
|
|
$deprecatedIds = DictItem::query()
|
|
|
->where('dict_type_id', $source->id)
|
|
|
->whereIn('value', ['course', 'activity'])
|
|
|
->pluck('id');
|
|
|
DictItem::query()->whereIn('id', $deprecatedIds)->update(['status' => 0]);
|
|
|
|
|
|
$manualId = DictItem::query()
|
|
|
->where('dict_type_id', $source->id)
|
|
|
->where('value', 'manual')
|
|
|
->where('status', 1)
|
|
|
->value('id');
|
|
|
if ($manualId && $deprecatedIds->isNotEmpty()) {
|
|
|
Teacher::query()
|
|
|
->whereIn('source_dict_item_id', $deprecatedIds)
|
|
|
->update(['source_dict_item_id' => $manualId]);
|
|
|
}
|
|
|
|
|
|
foreach ([
|
|
|
['label' => '五星', 'value' => '5', 'sort' => 10],
|
|
|
['label' => '四星', 'value' => '4', 'sort' => 20],
|
|
|
['label' => '三星', 'value' => '3', 'sort' => 30],
|
|
|
['label' => '二星', 'value' => '2', 'sort' => 40],
|
|
|
['label' => '一星', 'value' => '1', 'sort' => 50],
|
|
|
['label' => '待定', 'value' => 'pending', 'sort' => 60],
|
|
|
] as $row) {
|
|
|
DictItem::query()->updateOrCreate(
|
|
|
['dict_type_id' => $level->id, 'value' => $row['value']],
|
|
|
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
|
|
|
);
|
|
|
}
|
|
|
|
|
|
foreach ([
|
|
|
['label' => '伙伴', 'value' => 'partner', 'sort' => 10],
|
|
|
['label' => '持续跟进', 'value' => 'active', 'sort' => 20],
|
|
|
['label' => '暂停跟进', 'value' => 'paused', 'sort' => 30],
|
|
|
] as $row) {
|
|
|
DictItem::query()->updateOrCreate(
|
|
|
['dict_type_id' => $status->id, 'value' => $row['value']],
|
|
|
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
|
|
|
);
|
|
|
}
|
|
|
|
|
|
foreach ([
|
|
|
['label' => '电话', 'value' => 'phone', 'sort' => 10],
|
|
|
['label' => '拜访', 'value' => 'visit', 'sort' => 20],
|
|
|
['label' => '线上会议', 'value' => 'online', 'sort' => 30],
|
|
|
['label' => '邮件', 'value' => 'email', 'sort' => 40],
|
|
|
['label' => '活动沟通', 'value' => 'activity', 'sort' => 50],
|
|
|
] as $row) {
|
|
|
DictItem::query()->updateOrCreate(
|
|
|
['dict_type_id' => $method->id, 'value' => $row['value']],
|
|
|
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
|
|
|
);
|
|
|
}
|
|
|
|
|
|
foreach ([
|
|
|
['label' => '紧急', 'value' => 'urgent', 'sort' => 10],
|
|
|
['label' => '普通', 'value' => 'normal', 'sort' => 20],
|
|
|
['label' => '低', 'value' => 'low', 'sort' => 30],
|
|
|
] as $row) {
|
|
|
DictItem::query()->updateOrCreate(
|
|
|
['dict_type_id' => $urgency->id, 'value' => $row['value']],
|
|
|
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
}
|