Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Automat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯佳佳
Automat
Commits
119d0a0f
Commit
119d0a0f
authored
Jun 13, 2022
by
于方蒙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reset 修改失败
parent
3a6c4808
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
18 deletions
+4
-18
myapps/automat/api/hatch_portal.py
+4
-18
No files found.
myapps/automat/api/hatch_portal.py
View file @
119d0a0f
...
@@ -104,34 +104,20 @@ def run_hatch_open():
...
@@ -104,34 +104,20 @@ def run_hatch_open():
machine_no
=
json_data
[
'machine_no'
]
machine_no
=
json_data
[
'machine_no'
]
hatch_no
=
json_data
[
'hatch_no'
]
hatch_no
=
json_data
[
'hatch_no'
]
user_id
=
g
.
user
.
id
user_id
=
g
.
user
.
id
rent_detail
=
RentDetail
.
query
.
filter
(
RentDetail
.
user_id
==
user_id
,
RentDetail
.
machine_no
==
machine_no
,
rent_detail
=
RentDetail
.
query
.
filter
(
RentDetail
.
user_id
==
user_id
,
RentDetail
.
machine_no
==
machine_no
,
RentDetail
.
hatch_no
==
hatch_no
,
RentDetail
.
hatch_no
==
hatch_no
,
RentDetail
.
status
!=
-
1
,
RentDetail
.
status
!=
-
1
,
RentDetail
.
is_take
==
0
)
.
order_by
(
RentDetail
.
id
.
desc
())
.
first
()
RentDetail
.
is_take
==
0
)
.
order_by
(
RentDetail
.
id
.
desc
())
.
first
()
if
rent_detail
:
if
rent_detail
:
# 改变rentDatail中的is_take
rent_detail
.
is_take
=
1
db
.
session
.
add
(
rent_detail
)
# 查询到柜子中的物品 数量减一
# 查询到柜子中的物品 数量减一
sql
=
"update hatch set left_count = left_count - 1 where machine_no = '{}' and hatch_no='{}'"
.
format
(
sql
=
"update hatch set left_count = left_count - 1 where machine_no = '{}' and hatch_no='{}'"
.
format
(
machine_no
,
hatch_no
)
machine_no
,
hatch_no
)
# 对订单中已经取出过的数量 + 1
sql_updata
=
"update rent_detail set takeout_count = takeout_count + 1 where id = '{}'"
.
format
(
rent_detail
.
id
)
db
.
session
.
execute
(
sql
)
db
.
session
.
execute
(
sql
)
db
.
session
.
commit
()
db
.
session
.
commit
()
db
.
session
.
execute
(
sql_updata
)
db
.
session
.
commit
()
# 改变rentDatail中的is_take
# 22-06-08 Author famon
# 已取出的数量 和 订单数量一致才算取出
# 再去查询一次
rent_detail_sql
=
RentDetail
.
query
.
filter
(
RentDetail
.
user_id
==
user_id
,
RentDetail
.
machine_no
==
machine_no
,
RentDetail
.
hatch_no
==
hatch_no
,
RentDetail
.
status
!=
-
1
,
RentDetail
.
is_take
==
0
)
.
order_by
(
RentDetail
.
id
.
desc
())
.
first
()
if
rent_detail_sql
.
takeout_count
==
rent_detail_sql
.
rent_count
:
rent_detail_sql
.
is_take
=
1
db
.
session
.
add
(
rent_detail_sql
)
db
.
session
.
commit
()
# 当数量小于等于1时,将柜子物品状态改为已售空
# 当数量小于等于1时,将柜子物品状态改为已售空
left_res
=
Hatch
.
query
.
filter
(
Hatch
.
hatch_no
==
hatch_no
,
left_res
=
Hatch
.
query
.
filter
(
Hatch
.
hatch_no
==
hatch_no
,
...
...
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