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
85ed3f67
authored
Nov 17, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增药师控制
parent
9c1c7b76
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
186 additions
and
28 deletions
+186
-28
app/Api/Controllers/DoctorController.php
+1
-1
app/Api/Controllers/PharmacistController.php
+150
-7
app/Api/Controllers/PharmacyController.php
+17
-4
app/Services/SmsService.php
+18
-16
composer.lock
+0
-0
No files found.
app/Api/Controllers/DoctorController.php
View file @
85ed3f67
...
...
@@ -88,7 +88,7 @@ public function prescription(Request $request)
}
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
;
if
(
$prescription
->
save
())
{
#
TODO 增加开方日志
//
TODO 增加开方日志
return
$this
->
success
(
'开方成功'
);
}
else
{
...
...
app/Api/Controllers/PharmacistController.php
View file @
85ed3f67
...
...
@@ -10,17 +10,160 @@
class
PharmacistController
extends
BaseApiController
{
// 药师列表
public
function
pharmacistList
()
{}
// 药师信息
# 药师列表
public
function
pharmacistList
()
{
$authInfo
=
auth
(
'api'
)
->
user
();
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'药店信息不存在'
);
}
$pharmacist
=
PharmacistModel
::
where
(
'pharmacy_id'
,
$pharmacy
->
id
)
->
get
();
return
$this
->
success
(
$pharmacist
);
}
# 药师信息
public
function
detail
(
Request
$request
)
{
$pharmacist_id
=
$request
->
input
(
'pharmacist_id'
);
if
(
empty
(
$pharmacist_id
)
||
!
filter_var
(
$pharmacist_id
,
FILTER_VALIDATE_INT
))
{
return
$this
->
failed
(
'ID不能为空且必须为整数'
);
}
$authInfo
=
auth
(
'api'
)
->
user
();
// 获取药店信息
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'药店信息不存在'
);
}
$pharmacist
=
PharmacistModel
::
where
(
'pharmacy_id'
,
$pharmacy
->
id
)
->
where
(
'id'
,
$pharmacist_id
)
->
first
();
if
(
!
$pharmacist
)
{
return
$this
->
failed
(
'该药师不存在'
);
}
else
{
return
$this
->
success
(
$pharmacist
);
}
}
// 药师新增
# 证书上传
public
function
uploadCertificate
(
Request
$request
)
{
// 验证上传的图片文件
$validated
=
$request
->
validate
([
'image'
=>
'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
,
]);
// 验证药师编号
$pharmacist_id
=
$request
->
input
(
'pharmacist_id'
);
if
(
empty
(
$pharmacist_id
)
||
!
filter_var
(
$pharmacist_id
,
FILTER_VALIDATE_INT
))
{
return
$this
->
failed
(
'ID不能为空且必须为整数'
);
}
$authInfo
=
auth
(
'api'
)
->
user
();
// 获取药店信息
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
if
(
empty
(
$pharmacy
))
{
return
$this
->
failed
(
'该药店不存在'
);
}
// 获取药师信息
$pharmacist
=
PharmacistModel
::
where
(
'id'
,
$pharmacist_id
)
->
where
(
'pharmacy_id'
,
$pharmacy
->
id
)
->
first
();
if
(
empty
(
$pharmacist
))
{
return
$this
->
failed
(
'该药师不存在'
);
}
// 药师编辑
// 获取上传的图片
if
(
$request
->
hasFile
(
'image'
))
{
// 获取图片文件
$image
=
$request
->
file
(
'image'
);
// 设置默认药师
// 生成唯一文件名
$fileName
=
time
()
.
'.'
.
$image
->
getClientOriginalExtension
();
// 保存图片到指定路径
$tempPath
=
$image
->
storeAs
(
'app/public'
,
$fileName
);
// 药师签名上传
// 读取文件内容
$fileContent
=
file_get_contents
(
storage_path
(
'app/public/'
.
$fileName
));
// 上传到腾讯云
Storage
::
disk
(
'cos'
)
->
put
(
'license-images/'
.
$fileName
,
$fileContent
);
// 返回图片地址
$imageUrl
=
Storage
::
disk
(
'cos'
)
->
url
(
'license-images/'
.
$fileName
);
// 删除临时文件
unlink
(
storage_path
(
'app/public/'
.
$fileName
));
return
$this
->
success
([
'message'
=>
'ok'
,
'url'
=>
$imageUrl
]);
}
else
{
return
$this
->
failed
(
'签名图片上传失败'
);
}
}
# 药师新增
public
function
add
(
Request
$request
)
{
$authInfo
=
auth
(
'api'
)
->
user
();
// 获取药店信息
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
$pharmacist
=
new
PharmacistModel
();
$pharmacist
->
pharmacy_id
=
$pharmacy
->
id
;
$pharmacist
->
name
=
$request
->
input
(
'name'
);
$pharmacist
->
id_card
=
$request
->
input
(
'id_card'
);
$pharmacist
->
mobile
=
$request
->
input
(
'mobile'
);
$pharmacist
->
license_number
=
$request
->
input
(
'license_number'
);
$pharmacist
->
practicing_license
=
$request
->
input
(
'practicing_license'
);
# 执业注册证书链接
$pharmacist
->
practicing_license_expired_time
=
$request
->
input
(
'practicing_license_expired_time'
);
$pharmacist
->
physician_license
=
$request
->
input
(
'physician_license'
);
# 执业资格证书链接
$pharmacist
->
status
=
0
;
if
(
$pharmacist
->
save
()
){
return
$this
->
success
(
$pharmacist
);
}
return
$this
->
failed
(
"药师新增失败!"
);
}
# 药师编辑
public
function
update
(
Request
$request
)
{
$authInfo
=
auth
(
'api'
)
->
user
();
// 获取药店信息
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'该药店不存在'
);
}
$pharmacist
=
PharmacistModel
::
where
(
'id'
,
$request
->
input
(
'id'
))
->
where
(
'pharmacy_id'
,
$pharmacy
->
id
)
->
first
();
if
(
empty
(
$pharmacist
))
{
return
$this
->
failed
(
'该药师不存在'
);
}
$pharmacist
->
name
=
$request
->
input
(
'name'
);
$pharmacist
->
id_card
=
$request
->
input
(
'id_card'
);
$pharmacist
->
mobile
=
$request
->
input
(
'mobile'
);
$pharmacist
->
license_number
=
$request
->
input
(
'license_number'
);
$pharmacist
->
practicing_license
=
$request
->
input
(
'practicing_license'
);
# 执业注册证书链接
$pharmacist
->
practicing_license_expired_time
=
$request
->
input
(
'practicing_license_expired_time'
);
$pharmacist
->
physician_license
=
$request
->
input
(
'physician_license'
);
# 执业资格证书链接
if
(
$pharmacist
->
save
()
){
return
$this
->
success
(
$pharmacist
);
}
return
$this
->
failed
(
"药师编辑失败"
);
}
# 设置默认药师
public
function
setDefault
(
Request
$request
)
{
$authInfo
=
auth
(
'api'
)
->
user
();
// 获取药店信息
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'该药店不存在'
);
}
# 把该药店下的所有药师默认状态改为0
PharmacistModel
::
where
(
'pharmacy_id'
,
$pharmacy
->
id
)
->
update
([
'is_default'
=>
0
]);
$pharmacist
=
PharmacistModel
::
where
(
'id'
,
$request
->
input
(
'id'
))
->
first
();
if
(
empty
(
$pharmacist
))
{
return
$this
->
failed
(
'该药师不存在'
);
}
$pharmacist
->
is_default
=
1
;
if
(
$pharmacist
->
save
()
){
return
$this
->
success
(
$pharmacist
);
}
return
$this
->
failed
(
"设置默认药师失败!"
);
}
# 药师签名上传
public
function
upload
(
Request
$request
)
{
...
...
app/Api/Controllers/PharmacyController.php
View file @
85ed3f67
...
...
@@ -3,9 +3,13 @@
namespace
App\Api\Controllers
;
use
App\Http\Controllers\BaseApiController
;
use
App\Models\PatientModel
;
use
App\Models\PharmacyCorrectionModel
;
use
App\Models\PrescriptionModel
;
use
App\Models\PharmacyModel
;
use
App\Models\PharmacistModel
;
use
App\Models\PrescriptionModel
;
use
App\Models\PrescriptionLogModel
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
// 药店控制器
...
...
@@ -75,7 +79,8 @@ public function correction(Request $request)
}
// 药店审方
public
function
prescription
(
Request
$request
)
{
public
function
prescription
(
Request
$request
)
{
$id
=
$request
->
input
(
'id'
);
if
(
empty
(
$id
)
||
!
filter_var
(
$id
,
FILTER_VALIDATE_INT
))
{
return
$this
->
failed
(
'ID 不能为空且必须为整数'
);
...
...
@@ -86,12 +91,20 @@ public function prescription(Request $request) {
return
$this
->
failed
(
'药店信息不存在'
);
}
$prescription
=
PrescriptionModel
::
where
(
'id'
,
$id
)
->
where
(
'pharmacy_id'
,
$Pharmacy
->
id
)
->
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_REVIEWING
)
->
first
();
if
(
$prescription
)
{
if
(
$prescription
)
{
return
$this
->
failed
(
'该处方已审核'
);
}
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
;
if
(
$prescription
->
save
())
{
# TODO 增加审方日志
$patient_id
=
$prescription
->
patient_id
;
$patient
=
PatientModel
::
where
(
'id'
,
$patient_id
)
->
first
();
// TODO 增加审方日志
$pharmacistLog
=
new
PrescriptionLogModel
;
$pharmacistLog
->
pharmacy_id
=
$prescription
->
pharmacy_id
;
$pharmacistLog
->
pharmacy_name
=
$prescription
->
pharmacy_name
;
$currentTime
=
Carbon
::
now
()
->
toDateTimeString
();
$pharmacistLog
->
log_info
=
$prescription
->
pharmacist_name
.
'在'
.
$currentTime
.
'为'
.
$prescription
->
patient_name
.
'('
.
$patient
->
mobile
.
')审方(处方单编号:'
.
$prescription
->
id
.
')'
;
$pharmacistLog
->
save
();
return
$this
->
success
(
'审方成功'
);
}
else
{
...
...
app/Services/SmsService.php
View file @
85ed3f67
...
...
@@ -2,13 +2,16 @@
namespace
App\Services
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Config
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Log
;
class
SmsService
{
protected
$username
;
protected
$password
;
protected
$apiUrl
;
public
function
__construct
()
...
...
@@ -21,12 +24,12 @@ public function __construct()
/**
* 发送短信
*
* @param
string $mobile
手机号码,多个号码用半角逗号分隔
* @param
string $templateName
模板名称
* @param
array $templateData
模板中的变量数据
* @param
string|null $seqid
客户自定义消息ID
* @param
string|null $dstime
定时时间,格式:yyyy-MM-dd HH:mm:ss
* @param
string|null $ext
用户自定义扩展
* @param
string $mobile
手机号码,多个号码用半角逗号分隔
* @param
string $templateName
模板名称
* @param
array $templateData
模板中的变量数据
* @param
string|null $seqid
客户自定义消息ID
* @param
string|null $dstime
定时时间,格式:yyyy-MM-dd HH:mm:ss
* @param
string|null $ext
用户自定义扩展
* @return array 返回接口的响应
*/
public
function
sendSms
(
$mobile
,
$templateName
,
$templateData
=
[],
$seqid
=
null
,
$dstime
=
null
,
$ext
=
null
)
...
...
@@ -34,12 +37,12 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul
// 获取模板内容并替换变量
$content
=
$this
->
getFormattedContent
(
$templateName
,
$templateData
);
if
(
!
$content
)
{
if
(
!
$content
)
{
return
[
'resultCode'
=>
'0'
,
'resultMsg'
=>
'无效的模板名称'
];
}
// 生成签名
$sign
=
md5
(
$this
->
username
.
$this
->
password
.
$mobile
.
$content
);
$sign
=
md5
(
$this
->
username
.
$this
->
password
.
$mobile
.
$content
);
// 构造请求数据
$payload
=
[
...
...
@@ -49,9 +52,9 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul
'content'
=>
$content
,
'seqid'
=>
$seqid
,
'dstime'
=>
$dstime
,
'ext'
=>
$ext
'ext'
=>
$ext
,
];
#
记录短信日志
//
记录短信日志
Log
::
info
(
$this
->
apiUrl
,
$payload
);
// 发送 HTTP 请求
$response
=
Http
::
withoutVerifying
()
->
post
(
$this
->
apiUrl
,
$payload
);
...
...
@@ -62,8 +65,8 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul
/**
* 获取格式化的模板内容
*
* @param
string $templateName
模板名称
* @param
array $templateData
模板数据
* @param
string $templateName
模板名称
* @param
array $templateData
模板数据
* @return string|null 返回替换变量后的内容
*/
protected
function
getFormattedContent
(
$templateName
,
$templateData
)
...
...
@@ -71,7 +74,7 @@ protected function getFormattedContent($templateName, $templateData)
// 从配置文件中获取模板
$template
=
Config
::
get
(
"sms.templates.
{
$templateName
}
"
);
if
(
!
$template
)
{
if
(
!
$template
)
{
return
null
;
// 如果模板不存在,返回null
}
...
...
@@ -82,4 +85,4 @@ protected function getFormattedContent($templateName, $templateData)
return
$template
;
}
}
\ No newline at end of file
}
composer.lock
View file @
85ed3f67
This diff is collapsed.
Click to expand it.
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