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
0a63d925
authored
Nov 19, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.imohe.com/zhaozengyu/tzt-admin
parents
15ac49c6
92d3794c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
76 additions
and
51 deletions
+76
-51
app/Admin/Controllers/PharmacyController.php
+13
-4
app/Api/Controllers/PharmacistController.php
+12
-25
app/Api/Controllers/PharmacyController.php
+2
-2
app/Api/Controllers/PrescriptionController.php
+6
-5
app/Models/DoctorModel.php
+1
-1
app/Models/PharmacistModel.php
+1
-1
app/Models/PharmacyModel.php
+28
-6
app/Models/PrescriptionModel.php
+9
-3
routes/api.php
+4
-4
No files found.
app/Admin/Controllers/PharmacyController.php
View file @
0a63d925
...
...
@@ -3,6 +3,8 @@
namespace
App\Admin\Controllers
;
use
App\Admin\Repositories\PharmacyRepository
;
use
App\Models\PharmacistModel
;
use
App\Models\PharmacyModel
;
use
App\Models\User
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
...
...
@@ -28,7 +30,7 @@ protected function grid()
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'status'
)
->
switch
();
$grid
->
column
(
'is_open'
)
->
switch
(
)
->
help
(
'药店控制'
);
$grid
->
column
(
'is_open'
)
->
using
(
PharmacyModel
::
IS_OPEN_MAP
)
->
help
(
'药店控制'
);
$grid
->
column
(
'name'
);
// $grid->column('business_license')->image('', 50, 50);
// $grid->column('drug_biz_license')->image('', 50, 50);
...
...
@@ -125,10 +127,17 @@ protected function form()
$form
->
map
(
'lat'
,
'lng'
,
'经纬度坐标'
);
$form
->
select
(
'user_id'
)
->
options
(
User
::
all
()
->
pluck
(
'openid'
,
'id'
))
->
width
(
4
)
->
help
(
'实际后台操作可以不用关联'
);
$form
->
switch
(
'status'
)
->
width
(
4
);
$form
->
switch
(
'is_open'
)
->
width
(
4
);
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'updated_at'
)
->
width
(
4
);
$form
->
saving
(
function
(
Form
$form
)
{
$status
=
$form
->
status
;
$pharmacistNum
=
PharmacistModel
::
where
(
'status'
,
1
)
->
count
();
if
(
$status
==
1
&&
$pharmacistNum
<=
0
)
{
return
$form
->
response
()
->
error
(
'开启失败,至少启用一个药师才可以开启药店~'
);
}
// 中断后续逻辑
});
$form
->
saved
(
function
(
Form
$form
,
$result
)
{
DB
::
beginTransaction
();
...
...
@@ -137,8 +146,8 @@ protected function form()
$role
=
Role
::
where
(
'slug'
,
'pharmacy'
)
->
first
();
// 从表单模型获取手机号和其他信息
$mobile
=
$form
->
mobile
;
$name
=
$form
->
name
;
$mobile
=
$form
->
mo
del
()
->
mo
bile
;
$name
=
$form
->
model
()
->
name
;
$pharmacyId
=
$form
->
getKey
();
// 查找当前是否已有管理员
...
...
app/Api/Controllers/PharmacistController.php
View file @
0a63d925
...
...
@@ -7,6 +7,7 @@
use
App\Models\PharmacyModel
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Storage
;
use
Illuminate\Support\Facades\Validator
;
class
PharmacistController
extends
BaseApiController
{
...
...
@@ -49,9 +50,13 @@ public function uploadCertificate(Request $request)
{
// 验证上传的图片文件
$validat
ed
=
$request
->
validate
(
[
'image'
=>
'required|image|mimes:jpeg,png,jpg
,gif,svg
|max:2048'
,
$validat
or
=
Validator
::
make
(
$request
->
all
(),
[
'image'
=>
'required|image|mimes:jpeg,png,jpg|max:2048'
,
]);
if
(
$validator
->
fails
())
{
return
$this
->
failed
(
'图片必须2Mb以内,且是jpeg,png,jpg三种格式~'
);
}
// 验证药师编号
$authInfo
=
auth
(
'api'
)
->
user
();
// 获取药店信息
...
...
@@ -62,31 +67,13 @@ public function uploadCertificate(Request $request)
// 获取上传的图片
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
]);
$path
=
Storage
::
putFile
(
'license-images'
,
$request
->
file
(
'image'
));
// 返回完整图片地址
$imageUrl
=
Storage
::
url
(
$path
);
return
$this
->
success
([
'image_id'
=>
$path
,
'full_url'
=>
$imageUrl
]);
}
else
{
return
$this
->
failed
(
'
图片上传失败
'
);
return
$this
->
failed
(
'
请上传图片~
'
);
}
}
...
...
app/Api/Controllers/PharmacyController.php
View file @
0a63d925
...
...
@@ -29,8 +29,8 @@ public function PharmacyList(Request $request)
// ->orWhere('address','like',"%{$search_input}%");
}
// 是否闭店、是否在营业时间段、是否启用
$query
=
$query
->
where
(
'is_open'
,
1
)
->
where
(
'status'
,
1
)
$query
=
$query
->
where
(
'is_open'
,
PharmacyModel
::
IS_OPEN_TRUE
)
->
where
(
'status'
,
PharmacyModel
::
STATUS_TRUE
)
->
where
(
'business_start'
,
'<='
,
Carbon
::
now
()
->
format
(
'H:i'
))
->
where
(
'business_end'
,
'>='
,
Carbon
::
now
()
->
format
(
'H:i'
));
...
...
app/Api/Controllers/PrescriptionController.php
View file @
0a63d925
...
...
@@ -105,6 +105,7 @@ public function create(Request $request)
}
else
{
return
$this
->
failed
(
'pharmacy_id不能为空'
);
}
// 生成处方
$prescription
=
new
PrescriptionModel
;
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_PENDING
;
...
...
@@ -132,7 +133,7 @@ public function create(Request $request)
$is_abnormal
=
1
;
// 如果有一个answer是1,设置$is_abnormal为1
}
}
$prescription
->
inquiry_info
=
json_encode
(
$inquiry_info
)
;
$prescription
->
inquiry_info
=
$inquiry_info
;
// 用药信息
$drug_info
=
[];
foreach
(
$drugs
as
$drug
)
{
...
...
@@ -147,7 +148,7 @@ public function create(Request $request)
'num'
=>
$drug
[
'num'
],
];
}
$prescription
->
drug_info
=
json_encode
(
$drug_info
)
;
$prescription
->
drug_info
=
$drug_info
;
// 获取全局开方配置
$site_config
=
admin_setting_array
(
'site_config'
);
...
...
@@ -202,7 +203,7 @@ public function create(Request $request)
$prescription
->
doctor_department
=
$randomDoctor
->
department
;
$prescription
->
doctor_title
=
$randomDoctor
->
doctor_title
;
$prescription
->
doctor_license_no
=
$randomDoctor
->
license_no
;
$prescription
->
doctor_signed_pic
=
$randomDoctor
->
signed_pic
;
$prescription
->
doctor_signed_pic
=
$randomDoctor
->
getRawOriginal
(
'signed_pic'
)
;
// 药店信息
$prescription
->
pharmacy_id
=
$pharmacy
->
id
;
$prescription
->
pharmacy_name
=
$pharmacy
->
name
;
...
...
@@ -211,14 +212,14 @@ public function create(Request $request)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
where
(
function
(
$query
)
{
$query
->
where
(
'is_default'
,
1
)
->
orWhere
Null
(
'is_default'
);
->
orWhere
(
'is_default'
,
0
);
})
->
inRandomOrder
()
->
first
();
$prescription
->
pharmacist_id
=
$pharmacist
->
id
;
$prescription
->
pharmacist_name
=
$pharmacist
->
name
;
$prescription
->
pharmacist_license_number
=
$pharmacist
->
license_number
;
$prescription
->
pharmacist_signed_pic
=
$pharmacist
->
signed_pic
;
$prescription
->
pharmacist_signed_pic
=
$pharmacist
->
getRawOriginal
(
'signed_pic'
)
;
// 生成处方单信息
$prescription_at
=
Carbon
::
now
()
->
subMinutes
(
12
);
...
...
app/Models/DoctorModel.php
View file @
0a63d925
...
...
@@ -23,7 +23,7 @@ public function user()
public
function
getSignedPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
app/Models/PharmacistModel.php
View file @
0a63d925
...
...
@@ -23,7 +23,7 @@ public function pharmacy()
public
function
getSignedPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
app/Models/PharmacyModel.php
View file @
0a63d925
...
...
@@ -16,6 +16,28 @@ class PharmacyModel extends Model
protected
$table
=
'pharmacy'
;
// 平台启用店铺状态状态[0=启用,1=禁用]
const
STATUS_FALSE
=
0
;
const
STATUS_TRUE
=
1
;
// 平台启用店铺状态状态-文字映射
const
STATUS_MAP
=
[
self
::
STATUS_FALSE
=>
'闭店'
,
self
::
STATUS_TRUE
=>
'开店'
,
];
// 开店状态[0=闭店,1=开店]
const
IS_OPEN_FALSE
=
0
;
const
IS_OPEN_TRUE
=
1
;
// 是否问题是否通用通用-文字映射
const
IS_OPEN_MAP
=
[
self
::
IS_OPEN_FALSE
=>
'闭店'
,
self
::
IS_OPEN_TRUE
=>
'开店'
,
];
// 药店所属于的用户,一对一
public
function
user
()
{
...
...
@@ -36,7 +58,7 @@ public function patient()
public
function
getDrugBizLicenseAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
@@ -45,7 +67,7 @@ public function getDrugBizLicenseAttribute($value)
public
function
getBusinessLicenseAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
@@ -54,7 +76,7 @@ public function getBusinessLicenseAttribute($value)
public
function
getFoodBizLicenseAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
@@ -63,7 +85,7 @@ public function getFoodBizLicenseAttribute($value)
public
function
getMedDeviceBizLicenseAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
@@ -72,7 +94,7 @@ public function getMedDeviceBizLicenseAttribute($value)
public
function
getDrugInfoServiceCertAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
@@ -81,7 +103,7 @@ public function getDrugInfoServiceCertAttribute($value)
public
function
getPrePackagedFoodAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
app/Models/PrescriptionModel.php
View file @
0a63d925
...
...
@@ -15,6 +15,12 @@ class PrescriptionModel extends Model
protected
$table
=
'prescription'
;
// 数组json相互转换
protected
$casts
=
[
'drug_info'
=>
'array'
,
'inquiry_info'
=>
'array'
,
];
// 审方状态[0=待开方,1=待审方,2=审方成功]
const
PRESCRIPTION_STATUS_PENDING
=
0
;
...
...
@@ -42,7 +48,7 @@ class PrescriptionModel extends Model
public
function
getDoctorSignedPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
@@ -51,7 +57,7 @@ public function getDoctorSignedPicAttribute($value)
public
function
getPharmacistSignedPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
@@ -60,7 +66,7 @@ public function getPharmacistSignedPicAttribute($value)
public
function
getPrescriptionPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
))
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
...
...
routes/api.php
View file @
0a63d925
...
...
@@ -67,9 +67,9 @@
# 问诊人删除
Route
::
post
(
'/patients-delete'
,
'App\Api\Controllers\PatientController@delete'
);
# 设置默认问诊人
Route
::
post
(
'/patients-set
D
efault'
,
'App\Api\Controllers\PatientController@setDefault'
);
Route
::
post
(
'/patients-set
d
efault'
,
'App\Api\Controllers\PatientController@setDefault'
);
# 获取默认问诊人
Route
::
post
(
'/patients-get
D
efault'
,
'App\Api\Controllers\PatientController@getDefault'
);
Route
::
post
(
'/patients-get
d
efault'
,
'App\Api\Controllers\PatientController@getDefault'
);
# 获取问诊问题列表
Route
::
get
(
'/inquirys'
,
'App\Api\Controllers\InquiryController@InquirytList'
);
# 处方列表
...
...
@@ -93,13 +93,13 @@
# 药师详情
Route
::
post
(
'/pharmacist-detail'
,
'App\Api\Controllers\PharmacistController@detail'
);
# 证书上传
Route
::
post
(
'/pharmacist-upload
C
ertificate'
,
'App\Api\Controllers\PharmacistController@uploadCertificate'
);
Route
::
post
(
'/pharmacist-upload
c
ertificate'
,
'App\Api\Controllers\PharmacistController@uploadCertificate'
);
# 药师新增
Route
::
post
(
'/pharmacist-add'
,
'App\Api\Controllers\PharmacistController@add'
);
# 药师编辑
Route
::
post
(
'/pharmacist-update'
,
'App\Api\Controllers\PharmacistController@update'
);
# 设置默认药师
Route
::
post
(
'/pharmacist-set
D
efault'
,
'App\Api\Controllers\PharmacistController@setDefault'
);
Route
::
post
(
'/pharmacist-set
d
efault'
,
'App\Api\Controllers\PharmacistController@setDefault'
);
# 药师签名上传
Route
::
post
(
'/pharmacist-upload'
,
'App\Api\Controllers\PharmacistController@upload'
);
# 药师删除
...
...
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