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
1398eea4
authored
Nov 19, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开店状态判断
parent
61409061
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
4 deletions
+35
-4
app/Admin/Controllers/PharmacyController.php
+11
-2
app/Api/Controllers/PharmacyController.php
+2
-2
app/Models/PharmacyModel.php
+22
-0
No files found.
app/Admin/Controllers/PharmacyController.php
View file @
1398eea4
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
namespace
App\Admin\Controllers
;
namespace
App\Admin\Controllers
;
use
App\Admin\Repositories\PharmacyRepository
;
use
App\Admin\Repositories\PharmacyRepository
;
use
App\Models\PharmacistModel
;
use
App\Models\PharmacyModel
;
use
App\Models\User
;
use
App\Models\User
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Grid
;
...
@@ -28,7 +30,7 @@ protected function grid()
...
@@ -28,7 +30,7 @@ protected function grid()
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'status'
)
->
switch
();
$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
(
'name'
);
// $grid->column('business_license')->image('', 50, 50);
// $grid->column('business_license')->image('', 50, 50);
// $grid->column('drug_biz_license')->image('', 50, 50);
// $grid->column('drug_biz_license')->image('', 50, 50);
...
@@ -125,10 +127,17 @@ protected function form()
...
@@ -125,10 +127,17 @@ protected function form()
$form
->
map
(
'lat'
,
'lng'
,
'经纬度坐标'
);
$form
->
map
(
'lat'
,
'lng'
,
'经纬度坐标'
);
$form
->
select
(
'user_id'
)
->
options
(
User
::
all
()
->
pluck
(
'openid'
,
'id'
))
->
width
(
4
)
->
help
(
'实际后台操作可以不用关联'
);
$form
->
select
(
'user_id'
)
->
options
(
User
::
all
()
->
pluck
(
'openid'
,
'id'
))
->
width
(
4
)
->
help
(
'实际后台操作可以不用关联'
);
$form
->
switch
(
'status'
)
->
width
(
4
);
$form
->
switch
(
'status'
)
->
width
(
4
);
$form
->
switch
(
'is_open'
)
->
width
(
4
);
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'updated_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
)
{
$form
->
saved
(
function
(
Form
$form
,
$result
)
{
DB
::
beginTransaction
();
DB
::
beginTransaction
();
...
...
app/Api/Controllers/PharmacyController.php
View file @
1398eea4
...
@@ -29,8 +29,8 @@ public function PharmacyList(Request $request)
...
@@ -29,8 +29,8 @@ public function PharmacyList(Request $request)
// ->orWhere('address','like',"%{$search_input}%");
// ->orWhere('address','like',"%{$search_input}%");
}
}
// 是否闭店、是否在营业时间段、是否启用
// 是否闭店、是否在营业时间段、是否启用
$query
=
$query
->
where
(
'is_open'
,
1
)
$query
=
$query
->
where
(
'is_open'
,
PharmacyModel
::
IS_OPEN_TRUE
)
->
where
(
'status'
,
1
)
->
where
(
'status'
,
PharmacyModel
::
STATUS_TRUE
)
->
where
(
'business_start'
,
'<='
,
Carbon
::
now
()
->
format
(
'H:i'
))
->
where
(
'business_start'
,
'<='
,
Carbon
::
now
()
->
format
(
'H:i'
))
->
where
(
'business_end'
,
'>='
,
Carbon
::
now
()
->
format
(
'H:i'
));
->
where
(
'business_end'
,
'>='
,
Carbon
::
now
()
->
format
(
'H:i'
));
...
...
app/Models/PharmacyModel.php
View file @
1398eea4
...
@@ -16,6 +16,28 @@ class PharmacyModel extends Model
...
@@ -16,6 +16,28 @@ class PharmacyModel extends Model
protected
$table
=
'pharmacy'
;
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
()
public
function
user
()
{
{
...
...
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