feat: H5首页对齐原型(暗色监控卡/圆形图标/服务排期) + demo演示数据
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class DemoClientSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$store = DB::table('stores')->first();
|
||||
if (!$store) {
|
||||
$this->command->warn('No store found. Run InitSeeder first.');
|
||||
return;
|
||||
}
|
||||
$storeId = $store->id;
|
||||
|
||||
// ── 1. Demo 客户 ──────────────────────────────────────────────────────
|
||||
$customerId = DB::table('customers')->insertGetId([
|
||||
'store_id' => $storeId,
|
||||
'name' => '李婉婷',
|
||||
'phone' => '13800138001',
|
||||
'password' => Hash::make('123456'),
|
||||
'wechat' => 'liwanting88',
|
||||
'expected_date' => now()->subDays(14)->toDateString(),
|
||||
'actual_date' => now()->subDays(14)->toDateString(),
|
||||
'baby_count' => 1,
|
||||
'status' => 3, // 在住
|
||||
'remark' => '顺产,宝宝健康,无过敏史',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
// ── 2. 护理档案 ───────────────────────────────────────────────────────
|
||||
$profileId = DB::table('care_profiles')->insertGetId([
|
||||
'customer_id' => $customerId,
|
||||
'type' => 1,
|
||||
'birth_method' => 1, // 顺产
|
||||
'risk_level' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
// ── 3. 护理记录(近7天)─────────────────────────────────────────────
|
||||
$careTypes = [
|
||||
[1, '产后按摩,疏通经络,妈妈表示很舒适'],
|
||||
[1, '乳腺疏通护理,双侧通畅'],
|
||||
[2, '宝宝抚触操,脐带护理正常'],
|
||||
[1, '产后盆底肌恢复训练,第3次'],
|
||||
[2, '宝宝沐浴、脐带护理、黄疸监测'],
|
||||
[1, '子宫复旧按摩,复旧良好'],
|
||||
[2, '宝宝生长评估,体重增长正常'],
|
||||
];
|
||||
foreach ($careTypes as $i => [$type, $remark]) {
|
||||
DB::table('care_records')->insert([
|
||||
'care_profile_id' => $profileId,
|
||||
'type' => $type,
|
||||
'remark' => $remark,
|
||||
'nurse_id' => 1,
|
||||
'recorded_at' => now()->subDays($i)->setHour(10)->setMinute(0),
|
||||
'created_at' => now()->subDays($i),
|
||||
'updated_at' => now()->subDays($i),
|
||||
]);
|
||||
}
|
||||
|
||||
// ── 4. 健康指标(近10条)──────────────────────────────────────────────
|
||||
$metricData = [
|
||||
[1, 36.5, '℃'],
|
||||
[2, 58.2, 'kg'],
|
||||
[1, 36.7, '℃'],
|
||||
[4, 8.2, 'mg/dL'],
|
||||
[5, 3.65, 'kg'],
|
||||
[6, 36.8, '℃'],
|
||||
[1, 36.4, '℃'],
|
||||
[2, 57.9, 'kg'],
|
||||
[3, '110/70', 'mmHg'],
|
||||
[5, 3.72, 'kg'],
|
||||
];
|
||||
foreach ($metricData as $i => [$type, $value, $unit]) {
|
||||
DB::table('health_metrics')->insert([
|
||||
'care_profile_id' => $profileId,
|
||||
'metric_type' => $type,
|
||||
'value' => $value,
|
||||
'unit' => $unit,
|
||||
'measured_at' => now()->subDays((int)($i / 2))->setHour(8 + $i % 3),
|
||||
'created_at' => now()->subDays((int)($i / 2)),
|
||||
]);
|
||||
}
|
||||
|
||||
// ── 5. 今日 & 近7天膳食计划 ───────────────────────────────────────────
|
||||
$mealsByDay = [
|
||||
// 今天
|
||||
[0, 1, [['name'=>'小米红枣粥'],['name'=>'鸡蛋羹'],['name'=>'红糖姜水']]],
|
||||
[0, 2, [['name'=>'清蒸鲈鱼'],['name'=>'猪肝菠菜汤'],['name'=>'米饭']]],
|
||||
[0, 3, [['name'=>'枸杞红枣炖乌鸡'],['name'=>'核桃露']]],
|
||||
[0, 4, [['name'=>'番茄蛋花汤'],['name'=>'清炒时蔬'],['name'=>'糙米饭']]],
|
||||
// 昨天
|
||||
[1, 1, [['name'=>'燕麦南瓜粥'],['name'=>'水煮蛋']]],
|
||||
[1, 2, [['name'=>'鲫鱼豆腐汤'],['name'=>'香菇蒸鸡'],['name'=>'米饭']]],
|
||||
[1, 4, [['name'=>'花生猪脚汤'],['name'=>'蒜蓉青菜']]],
|
||||
[1, 5, [['name'=>'红豆薏米水']]],
|
||||
// 前天
|
||||
[2, 1, [['name'=>'黑米红豆粥'],['name'=>'荷包蛋']]],
|
||||
[2, 2, [['name'=>'冬瓜排骨汤'],['name'=>'清炒豆芽'],['name'=>'米饭']]],
|
||||
[2, 4, [['name'=>'参鸡汤'],['name'=>'蒸南瓜']]],
|
||||
// 3天前
|
||||
[3, 1, [['name'=>'紫米粥'],['name'=>'银耳莲子羹']]],
|
||||
[3, 2, [['name'=>'红枣枸杞炖排骨'],['name'=>'米饭']]],
|
||||
[3, 3, [['name'=>'核桃芝麻糊']]],
|
||||
[3, 4, [['name'=>'番茄豆腐汤'],['name'=>'清蒸时蔬']]],
|
||||
];
|
||||
foreach ($mealsByDay as [$daysAgo, $mealType, $dishes]) {
|
||||
DB::table('daily_meal_plans')->insert([
|
||||
'store_id' => $storeId,
|
||||
'customer_id' => $customerId,
|
||||
'plan_date' => now()->subDays($daysAgo)->toDateString(),
|
||||
'meal_type' => $mealType,
|
||||
'dishes' => json_encode($dishes),
|
||||
'status' => $daysAgo > 0 ? 2 : 1, // 历史=已送达, 今天=已备餐
|
||||
'created_at' => now()->subDays($daysAgo),
|
||||
'updated_at' => now()->subDays($daysAgo),
|
||||
]);
|
||||
}
|
||||
|
||||
// 给昨天2条膳食添加评价
|
||||
$planIds = DB::table('daily_meal_plans')
|
||||
->where('customer_id', $customerId)
|
||||
->where('plan_date', now()->subDay()->toDateString())
|
||||
->pluck('id');
|
||||
foreach ($planIds->take(2) as $planId) {
|
||||
DB::table('meal_reviews')->insert([
|
||||
'daily_meal_plan_id' => $planId,
|
||||
'customer_id' => $customerId,
|
||||
'score' => rand(4, 5),
|
||||
'content' => '味道很好,营养均衡,非常感谢厨师团队!',
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
}
|
||||
|
||||
// ── 6. 月嫂 + 派单 ────────────────────────────────────────────────────
|
||||
$nannyId = DB::table('nannies')->insertGetId([
|
||||
'store_id' => $storeId,
|
||||
'name' => '王秀珍',
|
||||
'phone' => '13900139001',
|
||||
'level' => 3, // 高级
|
||||
'experience_years' => 8,
|
||||
'skills' => json_encode(['产后护理', '宝宝沐浴', '乳腺疏通', '产后恢复']),
|
||||
'introduction' => '从业8年,持高级育婴师证书,服务过200余位妈妈,口碑优秀',
|
||||
'status' => 2, // 服务中
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('nanny_orders')->insert([
|
||||
'store_id' => $storeId,
|
||||
'customer_id' => $customerId,
|
||||
'nanny_id' => $nannyId,
|
||||
'order_no' => 'NO' . date('YmdHis'),
|
||||
'service_type'=> 1,
|
||||
'start_date' => now()->subDays(14)->toDateString(),
|
||||
'end_date' => now()->addDays(16)->toDateString(),
|
||||
'days' => 30,
|
||||
'price' => 12000.00,
|
||||
'status' => 2, // 已签约/服务中
|
||||
'created_at' => now()->subDays(14),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
// ── 7. 服务订单 ───────────────────────────────────────────────────────
|
||||
$serviceOrders = [
|
||||
['产后修复套餐', 2, 3980.00],
|
||||
['宝宝游泳抚触课程', 2, 1200.00],
|
||||
['气血能量房体验', 2, 680.00],
|
||||
];
|
||||
foreach ($serviceOrders as [$name, $status, $amount]) {
|
||||
DB::table('service_orders')->insert([
|
||||
'store_id' => $storeId,
|
||||
'customer_id' => $customerId,
|
||||
'order_no' => 'SO' . date('YmdHis') . rand(100, 999),
|
||||
'type' => 1,
|
||||
'items' => json_encode([['name' => $name, 'qty' => 1, 'price' => $amount]]),
|
||||
'total_amount' => $amount,
|
||||
'actual_amount' => $amount,
|
||||
'status' => $status,
|
||||
'pay_method' => 1,
|
||||
'paid_at' => now()->subDays(14),
|
||||
'created_at' => now()->subDays(14),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// ── 8. 客户账户 + 流水 ────────────────────────────────────────────────
|
||||
$accountId = DB::table('customer_accounts')->insertGetId([
|
||||
'store_id' => $storeId,
|
||||
'customer_id' => $customerId,
|
||||
'cash_balance' => 3200.00,
|
||||
'card_balance' => 8800.00,
|
||||
'points' => 1580,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$txs = [
|
||||
[1, 20000.00, 20000.00, '签约充值'],
|
||||
[2, 3980.00, 16020.00, '产后修复套餐'],
|
||||
[2, 1200.00, 14820.00, '宝宝游泳课程'],
|
||||
[3, 500.00, 15320.00, '退款:项目未使用'],
|
||||
[2, 680.00, 14640.00, '气血能量房体验'],
|
||||
[2, 2640.00, 12000.00, '月嫂服务首期'],
|
||||
];
|
||||
foreach ($txs as $i => [$type, $amount, $balanceAfter, $desc]) {
|
||||
DB::table('account_transactions')->insert([
|
||||
'store_id' => $storeId,
|
||||
'customer_account_id' => $accountId,
|
||||
'customer_id' => $customerId,
|
||||
'type' => $type,
|
||||
'amount' => $amount,
|
||||
'balance_after' => $balanceAfter,
|
||||
'description' => $desc,
|
||||
'created_at' => now()->subDays(14 - $i * 2),
|
||||
]);
|
||||
}
|
||||
|
||||
// ── 9. 投诉反馈 ───────────────────────────────────────────────────────
|
||||
DB::table('complaints')->insert([
|
||||
[
|
||||
'store_id' => $storeId,
|
||||
'customer_id' => $customerId,
|
||||
'type' => 1,
|
||||
'content' => '昨晚空调温度偏低,宝宝有点凉,希望能保持在26度左右',
|
||||
'status' => 2,
|
||||
'handle_result' => '已通知客房调整空调,确保室温维持在25-26℃,感谢您的反馈!',
|
||||
'handle_at' => now()->subDays(1),
|
||||
'created_at' => now()->subDays(2),
|
||||
'updated_at' => now()->subDays(1),
|
||||
],
|
||||
[
|
||||
'store_id' => $storeId,
|
||||
'customer_id' => $customerId,
|
||||
'type' => 2,
|
||||
'content' => '今日午餐的汤偏咸,建议减少盐量,产后饮食应清淡',
|
||||
'status' => 1,
|
||||
'created_at' => now()->subHours(5),
|
||||
'updated_at' => now()->subHours(5),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->command->info("✅ Demo 客户创建成功!");
|
||||
$this->command->info(" 手机号:13800138001 密码:123456");
|
||||
$this->command->info(" 姓名:李婉婷 状态:在住第14天");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user