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
3db5cabd
Commit
3db5cabd
authored
Nov 25, 2021
by
yanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
成功卖出
数量-1 ,数量为零时,已售空
parent
3dd3b5fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
models/models.py
+2
-0
myapps/sukang24h/api/hatch_portal.py
+11
-0
No files found.
models/models.py
View file @
3db5cabd
...
...
@@ -38,6 +38,8 @@ class Hatch(Base):
name
=
Column
(
String
(
100
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品名称'
)
title
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品标题'
)
brand_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'品牌ID'
)
left_count
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'余额'
)
total_count
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'总数'
)
brand_name
=
Column
(
String
(
100
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品名称'
)
cate_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'分类ID'
)
cate_name
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品标题'
)
...
...
myapps/sukang24h/api/hatch_portal.py
View file @
3db5cabd
...
...
@@ -103,13 +103,24 @@ def run_hatch_open():
machine_no
=
json_data
[
'machine_no'
]
hatch_no
=
json_data
[
'hatch_no'
]
user_id
=
g
.
user
.
id
rent_detail
=
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
:
# 改变rentDatail中的is_take
rent_detail
.
is_take
=
1
db
.
session
.
add
(
rent_detail
)
# 查询到柜子中的物品 数量减一
left_res
=
Hatch
.
query
.
filter
(
Hatch
.
hatch_no
==
hatch_no
,
Hatch
.
machine_no
==
machine_no
)
.
first
()
left_res
.
left_count
=
left_res
.
left_count
-
1
# 当数量等于1时,将柜子物品状态改为已售空
if
left_res
.
left_count
==
0
:
left_res
.
status
=
2
# 执行语句
db
.
session
.
add
(
left_res
)
db
.
session
.
commit
()
return
BaseResponse
()
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