|
|
|
|
@ -274,6 +274,7 @@ public function info(Request $request)
|
|
|
|
|
'sex' => isset($default_person->sex) ? $default_person->sex : null,
|
|
|
|
|
'phone' => isset($default_person->phone) ? $default_person->phone:null,
|
|
|
|
|
'id_number' => isset($default_person->id_number) ? $default_person->id_number:null,
|
|
|
|
|
'birthday' => isset($default_person->birthday) ? $default_person->birthday : null,
|
|
|
|
|
'count' => $count,
|
|
|
|
|
'openid' => $openid,
|
|
|
|
|
'person_id' => $default_person->id,
|
|
|
|
|
@ -458,4 +459,125 @@ public function UpdatePersonList($openid)
|
|
|
|
|
// }
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function checkChildCare(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$person_id = $request->post('person_id');
|
|
|
|
|
if (!$person_id) return \Yz::echoError1('person_id 不能为空');
|
|
|
|
|
|
|
|
|
|
$person = DB::table('web_user_person')->where(['id' => $person_id, 'is_del' => 0])->first();
|
|
|
|
|
if (!$person) return \Yz::echoError1('就诊人不存在');
|
|
|
|
|
|
|
|
|
|
// 获取出生日期,为空则从身份证号提取
|
|
|
|
|
$birthday = $person->birthday;
|
|
|
|
|
if (!$birthday && $person->id_number) {
|
|
|
|
|
$id_number = $person->id_number;
|
|
|
|
|
$len = strlen($id_number);
|
|
|
|
|
if ($len == 18) {
|
|
|
|
|
$birth = substr($id_number, 6, 8);
|
|
|
|
|
$birthday = substr($birth, 0, 4) . '-' . substr($birth, 4, 2) . '-' . substr($birth, 6, 2);
|
|
|
|
|
} elseif ($len == 15) {
|
|
|
|
|
$birth = substr($id_number, 6, 6);
|
|
|
|
|
$birthday = '19' . substr($birth, 0, 2) . '-' . substr($birth, 2, 2) . '-' . substr($birth, 4, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$birthday) return \Yz::echoError1('无法获取出生日期');
|
|
|
|
|
|
|
|
|
|
// 计算周岁年龄
|
|
|
|
|
$birth = new \DateTime($birthday);
|
|
|
|
|
$now = new \DateTime();
|
|
|
|
|
$age = $now->diff($birth)->y;
|
|
|
|
|
|
|
|
|
|
// 读取儿保科配置
|
|
|
|
|
$config = DB::table('configs')->where(['label' => '儿保科配置'])->first();
|
|
|
|
|
if (!$config) return \Yz::echoError1('儿保科配置未设置');
|
|
|
|
|
|
|
|
|
|
$configJson = json_decode($config->value, true);
|
|
|
|
|
if (!$configJson || !isset($configJson['age']) || !isset($configJson['check'])) {
|
|
|
|
|
return \Yz::echoError1('儿保科配置格式异常');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// status 灰度控制:0=白名单模式,1=全量模式
|
|
|
|
|
$status = $configJson['status'] ?? '1';
|
|
|
|
|
if ($status == '0') {
|
|
|
|
|
$testConfig = DB::table('configs')->where(['label' => '首页测试按钮'])->first();
|
|
|
|
|
$idList = $testConfig ? json_decode($testConfig->value, true) : [];
|
|
|
|
|
$inWhitelist = false;
|
|
|
|
|
|
|
|
|
|
if (is_array($idList)) {
|
|
|
|
|
if ($person->id_number) {
|
|
|
|
|
// 有身份证号,直接判断
|
|
|
|
|
$inWhitelist = in_array($person->id_number, $idList);
|
|
|
|
|
} else {
|
|
|
|
|
// 身份证号为空(新生儿),查同 user_id 下其他就诊人
|
|
|
|
|
$siblings = DB::table('web_user_person')
|
|
|
|
|
->where(['user_id' => $person->user_id, 'is_del' => 0])
|
|
|
|
|
->where('id', '!=', $person->id)
|
|
|
|
|
->whereNotNull('id_number')
|
|
|
|
|
->where('id_number', '!=', '')
|
|
|
|
|
->get();
|
|
|
|
|
foreach ($siblings as $sibling) {
|
|
|
|
|
if (in_array($sibling->id_number, $idList)) {
|
|
|
|
|
$inWhitelist = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$inWhitelist) {
|
|
|
|
|
return \Yz::Return(true, '成功', ['check' => '0', 'path' => '']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$configAge = (int)$configJson['age'];
|
|
|
|
|
$check = $configJson['check'];
|
|
|
|
|
$path = $age < $configAge ? ($configJson['path'] ?? '') : '';
|
|
|
|
|
|
|
|
|
|
return \Yz::Return(true, '成功', [
|
|
|
|
|
'check' => $check,
|
|
|
|
|
'path' => $path
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function checkTestButton(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$person_id = $request->post('person_id');
|
|
|
|
|
if (!$person_id) return \Yz::echoError1('person_id 不能为空');
|
|
|
|
|
|
|
|
|
|
$person = DB::table('web_user_person')->where(['id' => $person_id, 'is_del' => 0])->first();
|
|
|
|
|
if (!$person) return \Yz::echoError1('就诊人不存在');
|
|
|
|
|
|
|
|
|
|
// 读取首页测试按钮配置
|
|
|
|
|
$config = DB::table('configs')->where(['label' => '首页测试按钮'])->first();
|
|
|
|
|
if (!$config) return \Yz::Return(true, '成功', ['check' => '0']);
|
|
|
|
|
|
|
|
|
|
$idList = json_decode($config->value, true);
|
|
|
|
|
if (!is_array($idList)) return \Yz::Return(true, '成功', ['check' => '0']);
|
|
|
|
|
|
|
|
|
|
$inWhitelist = false;
|
|
|
|
|
|
|
|
|
|
if ($person->id_number) {
|
|
|
|
|
// 有身份证号,直接判断
|
|
|
|
|
$inWhitelist = in_array($person->id_number, $idList);
|
|
|
|
|
} else {
|
|
|
|
|
// 身份证号为空(新生儿),查同 user_id 下其他就诊人
|
|
|
|
|
$siblings = DB::table('web_user_person')
|
|
|
|
|
->where(['user_id' => $person->user_id, 'is_del' => 0])
|
|
|
|
|
->where('id', '!=', $person->id)
|
|
|
|
|
->whereNotNull('id_number')
|
|
|
|
|
->where('id_number', '!=', '')
|
|
|
|
|
->get();
|
|
|
|
|
foreach ($siblings as $sibling) {
|
|
|
|
|
if (in_array($sibling->id_number, $idList)) {
|
|
|
|
|
$inWhitelist = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$check = $inWhitelist ? '1' : '0';
|
|
|
|
|
return \Yz::Return(true, '成功', ['check' => $check]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|