# 订单系统 - 诊单表关联更新 ## 更新说明 订单系统已更新,现在患者信息关联到诊单表 `zyt_tcm_diagnosis` 而不是用户表。 --- ## 变更内容 ### 1. Order 模型更新 **文件**: `server/app/common/model/Order.php` #### patient 关系修改 ```php // 修改前 public function patient() { return $this->belongsTo('app\common\model\user\User', 'patient_id', 'id'); } // 修改后 public function patient() { return $this->belongsTo('app\common\model\tcm\Diagnosis', 'patient_id', 'id'); } ``` #### 搜索器更新 ```php // 修改前 $q->where('nickname|mobile', 'like', '%' . $value . '%'); // 修改后 $q->where('patient_name|patient_phone', 'like', '%' . $value . '%'); ``` #### 获取器字段更新 ```php // 患者名称获取器 return $patient ? $patient->patient_name : ''; // 从 nickname 改为 patient_name // 患者电话获取器 return $patient ? $patient->patient_phone : ''; // 从 mobile 改为 patient_phone ``` ### 2. OrderLists 列表更新 **文件**: `server/app/adminapi/lists/order/OrderLists.php` #### 患者搜索表名修改 ```php // 修改前 $query->table('la_user') ->where('nickname|mobile', 'like', '%' . $this->params['patient_keyword'] . '%') // 修改后 $query->table('zyt_tcm_diagnosis') ->where('patient_name|patient_phone', 'like', '%' . $this->params['patient_keyword'] . '%') ``` 同时更新了 `lists()` 和 `count()` 两个方法。 --- ## 数据库表关系 ### 订单表 (la_order) ``` patient_id → zyt_tcm_diagnosis.id creator_id → zyt_admin.id ``` ### 诊单表 (zyt_tcm_diagnosis) ``` id: 诊单ID patient_name: 患者姓名 patient_phone: 患者电话 patient_id_card: 患者身份证 gender: 性别 age: 年龄 ``` --- ## 功能影响 ### 订单列表 - ✅ 患者信息现在从诊单表获取 - ✅ 患者搜索使用诊单表的患者字段 - ✅ 患者名称和电话显示正确 ### 订单创建 - ✅ 患者选择仍然使用诊单表搜索 - ✅ patient_id 指向诊单表的 ID ### 订单详情 - ✅ 患者信息显示正确 - ✅ 患者名称和电话来自诊单表 --- ## 测试清单 - ✅ 订单列表加载 - ✅ 患者信息显示 - ✅ 患者关键词搜索 - ✅ 订单创建时患者选择 - ✅ 订单详情显示 --- ## 相关文件 - `server/app/common/model/Order.php` - 订单模型 - `server/app/adminapi/lists/order/OrderLists.php` - 订单列表 - `server/app/common/model/tcm/Diagnosis.php` - 诊单模型 --- ## 版本信息 - **更新版本**: 1.2.0 - **更新日期**: 2026-03-10 - **更新类型**: 数据关联调整 - **状态**: ✅ 完成 --- **更新完成** ✅