Commit 223077ac by 赵增煜

问诊人修改

parent 6b52cb70
......@@ -55,9 +55,9 @@ public function add(Request $request)
$pharmacy = PharmacyModel::query()->where('user_id', $authInfo->id)->first();
$data['pharmacy_id'] = $pharmacy->id;
}
# 验证身份证格式
if(!validateIdCard($data['id_card'])){
return $this->error(401, '身份证格式错误');
// 验证身份证格式
if (! validateIdCard($data['id_card'])) {
return $this->failed('身份证格式错误');
}
$idCardInfo = Util::getIdCardInfo($data['id_card']);
$data['gender'] = $idCardInfo['gender'];
......@@ -66,7 +66,7 @@ public function add(Request $request)
if ($res) {
return $this->success($res);
} else {
return $this->error(401, '添加失败');
return $this->failed('添加失败');
}
}
......@@ -75,15 +75,15 @@ public function update(Request $request)
{
$id = $request->input('id');
$id_card = $request->input('id_card');
# 验证身份证格式
if(!validateIdCard($id_card)){
return $this->error(401, '身份证格式错误');
// 验证身份证格式
if (! validateIdCard($id_card)) {
return $this->failed('身份证格式错误');
}
$idCardInfo = Util::getIdCardInfo($id_card);
$data = PatientModel::find($id);
if (! $data) {
return $this->error(401, '该问诊人不存在');
return $this->failed('该问诊人不存在');
}
$data->name = $request->input('name');
$data->id_card = $id_card;
......@@ -98,7 +98,7 @@ public function delete(Request $request)
$id = $request->input('id');
$data = PatientModel::find($id);
if (! $data) {
return $this->error(401, '该问诊人不存在');
return $this->failed('该问诊人不存在');
}
$data->delete();
......@@ -128,7 +128,7 @@ public function setDefault(Request $request)
$id = $request->input('id');
$data = PatientModel::find($id);
if (! $data) {
return $this->error(401, '该问诊人不存在');
return $this->failed('该问诊人不存在');
}
$data->is_default = 1;
$data->save();
......@@ -153,7 +153,7 @@ public function getDefault(Request $request)
if ($data) {
return $this->success($data);
} else {
return $this->error(401, '暂无默认问诊人');
return $this->failed('暂无默认问诊人');
}
}
}
......@@ -245,11 +245,9 @@ function data_masking(string $strType, $str = '')
}
}
if(!function_exists('validateIdCard')){
if (! function_exists('validateIdCard')) {
/**
* 身份证号码校验
* @param $value
*/
function validateIdCard($value)
{
......@@ -259,21 +257,23 @@ function validateIdCard($value)
}
if ($len === 18) {
$birthday = substr($value, 6, 8); // 6-14 出生日期
if (!validateBirthday($birthday)) {
if (! validateBirthday($birthday)) {
return false;
}
$sex = substr($value, -2, 1);
if (!validateISO7064($value)) {
if (! validateISO7064($value)) {
return false;
}
return true;
} else {
$birthday = substr($value, 6, 6);
$birthday = '19' . $birthday;
if (!validateBirthday($birthday)) {
$birthday = '19'.$birthday;
if (! validateBirthday($birthday)) {
return false;
}
$sex = substr($value, -1);
return true;
}
}
......@@ -284,6 +284,7 @@ function validateBirthday($birthday)
$month = substr($birthday, 4, 2);
$day = substr($birthday, 6, 2);
$timestamp = mktime(0, 0, 0, $month, $day, $year);
return $timestamp !== false && $timestamp < strtotime('midnight');
}
......@@ -293,7 +294,7 @@ function validateISO7064($value)
$arr_ch = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
$sign = 0;
for ($i = 0; $i < 17; $i++) {
$b = (int)$value[$i];
$b = (int) $value[$i];
$w = $bits[$i];
$sign += $b * $w;
}
......@@ -301,8 +302,9 @@ function validateISO7064($value)
$r = $arr_ch[$n];
$last = substr($value, -1);
return ($r == $last)
|| $r == 10 && ($last == 'x' || $last == 'X');
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment