Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2874dde9
authored
Dec 09, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix-1209' into develop
parents
beb69cec
42a58ead
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
6 deletions
+72
-6
app/Admin/Controllers/DosageController.php
+1
-1
app/Admin/Controllers/PharmacyDrugController.php
+1
-1
app/Api/Controllers/PatientController.php
+2
-2
app/Api/Controllers/PharmacistController.php
+12
-2
app/helpers.php
+56
-0
No files found.
app/Admin/Controllers/DosageController.php
View file @
2874dde9
...
...
@@ -42,7 +42,7 @@ protected function grid()
});
// 行按钮控制
$grid
->
disableDeleteButton
();
// 禁用删除按钮
//
$grid->disableDeleteButton(); // 禁用删除按钮
$grid
->
disableViewButton
();
// 禁用详情按钮
// 工具栏按钮控制
...
...
app/Admin/Controllers/PharmacyDrugController.php
View file @
2874dde9
...
...
@@ -133,7 +133,7 @@ protected function form()
});
// 右上角按钮控制
$form
->
disableDeleteButton
();
// 去掉删除按钮
#
$form->disableDeleteButton(); // 去掉删除按钮
$form
->
disableViewButton
();
// 去掉跳转详情页按钮
});
}
...
...
app/Api/Controllers/PatientController.php
View file @
2874dde9
...
...
@@ -68,7 +68,7 @@ public function add(Request $request)
$idValidator
=
new
IdValidator
();
// if (! $idValidator->isValid($data['id_card'])) {
// if( !in_array(strlen($data['id_card']),[15,18])){
if
(
isset
(
$data
[
'id_card'
])
&&
strlen
(
$data
[
'id_card'
])
!=
18
)
{
// 身份证非必填项
if
(
isset
(
$data
[
'id_card'
])
&&
!
validateIDCard
(
$data
[
'id_card'
])
)
{
// 身份证非必填项
return
$this
->
failed
(
'身份证格式错误'
);
}
...
...
@@ -116,7 +116,7 @@ public function update(Request $request)
// 验证身份证格式
$idValidator
=
new
IdValidator
();
// if (! $idValidator->isValid($id_card)) {
if
(
isset
(
$id_card
)
&&
strlen
(
$id_card
)
!=
18
)
{
if
(
isset
(
$id_card
)
&&
!
validateIDCard
(
$id_card
)
)
{
return
$this
->
failed
(
'身份证格式错误'
);
}
...
...
app/Api/Controllers/PharmacistController.php
View file @
2874dde9
...
...
@@ -83,10 +83,15 @@ public function add(Request $request)
$authInfo
=
auth
(
'api'
)
->
user
();
// 获取药店信息
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
$id_card
=
$request
->
input
(
'id_card'
);
if
(
isset
(
$id_card
)
&&
!
validateIDCard
(
$id_card
)
)
{
return
$this
->
failed
(
'身份证号格式错误'
);
}
$pharmacist
=
new
PharmacistModel
();
$pharmacist
->
pharmacy_id
=
$pharmacy
->
id
;
$pharmacist
->
name
=
str_replace
(
' '
,
''
,
$request
->
input
(
'name'
));
$pharmacist
->
id_card
=
str_replace
(
' '
,
''
,
$
request
->
input
(
'id_card'
)
);
$pharmacist
->
id_card
=
str_replace
(
' '
,
''
,
$
id_card
);
$pharmacist
->
mobile
=
str_replace
(
' '
,
''
,
$request
->
input
(
'mobile'
));
$pharmacist
->
license_number
=
str_replace
(
' '
,
''
,
$request
->
input
(
'license_number'
));
$pharmacist
->
practicing_license
=
$request
->
input
(
'practicing_license'
);
// 执业注册证书链接
...
...
@@ -150,6 +155,11 @@ public function update(Request $request)
if
(
empty
(
$pharmacist
))
{
return
$this
->
failed
(
'该药师不存在'
);
}
$id_card
=
$request
->
input
(
'id_card'
);
if
(
isset
(
$id_card
)
&&
!
validateIDCard
(
$id_card
)
)
{
return
$this
->
failed
(
'身份证号格式错误'
);
}
$practicing_license
=
$request
->
input
(
'practicing_license'
);
$practicing_license_path
=
''
;
if
(
!
empty
(
$practicing_license
))
{
...
...
@@ -165,7 +175,7 @@ public function update(Request $request)
}
$pharmacist
->
name
=
str_replace
(
' '
,
''
,
$request
->
input
(
'name'
));
$pharmacist
->
id_card
=
str_replace
(
' '
,
''
,
$request
->
input
(
'id_card'
)
);
$pharmacist
->
id_card
=
str_replace
(
' '
,
''
,
$id_card
);
$pharmacist
->
mobile
=
str_replace
(
' '
,
''
,
$request
->
input
(
'mobile'
));
$pharmacist
->
license_number
=
str_replace
(
' '
,
''
,
$request
->
input
(
'license_number'
));
$pharmacist
->
practicing_license
=
$practicing_license_path
;
// 执业注册证书链接
...
...
app/helpers.php
View file @
2874dde9
...
...
@@ -177,3 +177,58 @@ function validateBirthday($birthday)
}
}
if
(
!
function_exists
(
'validateIDCard'
))
{
function
validateIDCard
(
$idCard
)
{
// 长度检查
if
(
!
preg_match
(
'/^\d{15}$|^\d{17}[\dXx]$/'
,
$idCard
))
{
return
false
;
}
// 15位转18位(如果是15位身份证)
if
(
strlen
(
$idCard
)
===
15
)
{
$idCard
=
convertIDCard15to18
(
$idCard
);
}
// 检查出生日期
$birthDate
=
substr
(
$idCard
,
6
,
8
);
// 提取出生日期部分
$year
=
substr
(
$birthDate
,
0
,
4
);
$month
=
substr
(
$birthDate
,
4
,
2
);
$day
=
substr
(
$birthDate
,
6
,
2
);
if
(
!
checkdate
((
int
)
$month
,
(
int
)
$day
,
(
int
)
$year
))
{
return
false
;
}
// 校验码验证
return
checkIDCardChecksum
(
$idCard
);
}
function
convertIDCard15to18
(
$idCard15
)
{
// 15位身份证转换为18位
$prefix
=
substr
(
$idCard15
,
0
,
6
)
.
'19'
.
substr
(
$idCard15
,
6
);
$checksum
=
calculateChecksum
(
$prefix
);
return
$prefix
.
$checksum
;
}
function
checkIDCardChecksum
(
$idCard18
)
{
// 检查身份证校验码
$base
=
substr
(
$idCard18
,
0
,
17
);
$checksum
=
calculateChecksum
(
$base
);
return
strtoupper
(
$checksum
)
===
strtoupper
(
$idCard18
[
17
]);
}
function
calculateChecksum
(
$base
)
{
// 计算校验码
$weights
=
[
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
];
$checksumMap
=
[
'1'
,
'0'
,
'X'
,
'9'
,
'8'
,
'7'
,
'6'
,
'5'
,
'4'
,
'3'
,
'2'
];
$sum
=
0
;
for
(
$i
=
0
;
$i
<
17
;
$i
++
)
{
$sum
+=
$base
[
$i
]
*
$weights
[
$i
];
}
return
$checksumMap
[
$sum
%
11
];
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment