Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tamp_course_order
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
tamp_course_order
Commits
480fce5d
Commit
480fce5d
authored
Nov 27, 2020
by
pengxiong@wealthgrow.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户是否重复购买同一商品
parent
f03624e7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1531 additions
and
4 deletions
+1531
-4
app.py
app/api/app.py
+2
-0
errors.py
app/config/errors.py
+3
-1
order_service.py
app/service/order_service.py
+12
-3
tamp_course_order.log
logs/tamp_course_order.log
+1514
-0
No files found.
app/api/app.py
View file @
480fce5d
...
@@ -14,6 +14,8 @@ from app.controller.errorhandler import add_errorhandler
...
@@ -14,6 +14,8 @@ from app.controller.errorhandler import add_errorhandler
from
app.router.version1
import
add_route
from
app.router.version1
import
add_route
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
app
.
config
[
"JSON_AS_ASCII"
]
=
False
app
.
config
.
update
(
RESTFUL_JSON
=
dict
(
ensure_ascii
=
False
))
api
=
Api
(
app
)
api
=
Api
(
app
)
add_route
(
api
)
add_route
(
api
)
add_errorhandler
(
app
)
add_errorhandler
(
app
)
...
...
app/config/errors.py
View file @
480fce5d
...
@@ -16,6 +16,7 @@ class Errors:
...
@@ -16,6 +16,7 @@ class Errors:
TANGPU_BALANCE_NOT_ENOUGH
=
'9004'
TANGPU_BALANCE_NOT_ENOUGH
=
'9004'
APPLE_VOCHER_USED
=
'9005'
APPLE_VOCHER_USED
=
'9005'
INPUT_PARAMS_ERROR
=
'9006'
INPUT_PARAMS_ERROR
=
'9006'
REPEAT_BUY
=
'9007'
MSG
=
{
MSG
=
{
TOKEN_INVALID
:
'TOKEN失效'
,
TOKEN_INVALID
:
'TOKEN失效'
,
...
@@ -23,5 +24,6 @@ class Errors:
...
@@ -23,5 +24,6 @@ class Errors:
APPLE_VOCHER_INVALID
:
'苹果证书无效'
,
APPLE_VOCHER_INVALID
:
'苹果证书无效'
,
TANGPU_BALANCE_NOT_ENOUGH
:
'探普币余额不足'
,
TANGPU_BALANCE_NOT_ENOUGH
:
'探普币余额不足'
,
APPLE_VOCHER_USED
:
'该支付凭证已使用'
,
APPLE_VOCHER_USED
:
'该支付凭证已使用'
,
INPUT_PARAMS_ERROR
:
'入参错误'
INPUT_PARAMS_ERROR
:
'入参错误'
,
REPEAT_BUY
:
'请勿重复购买商品'
}
}
app/service/order_service.py
View file @
480fce5d
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
# @Email : acepengxiong@163.com
# @Email : acepengxiong@163.com
# @Software : PyCharm
# @Software : PyCharm
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
import
datetime
import
time
import
time
from
sqlalchemy.sql.elements
import
and_
from
sqlalchemy.sql.elements
import
and_
...
@@ -155,12 +156,16 @@ class CurriculumOrderService:
...
@@ -155,12 +156,16 @@ class CurriculumOrderService:
args
[
'ab_ordernum'
]
=
time
.
strftime
(
'
%
Y
%
m
%
d'
,
time
.
localtime
(
time
.
time
()))
+
str
(
int
(
time
.
time
()
*
100000
))
args
[
'ab_ordernum'
]
=
time
.
strftime
(
'
%
Y
%
m
%
d'
,
time
.
localtime
(
time
.
time
()))
+
str
(
int
(
time
.
time
()
*
100000
))
amount
=
tamp_user_session
.
query
(
CurriculumPrice
.
price
)
.
filter
(
CurriculumPrice
.
rel_id
==
args
[
'ab_proid'
])
.
first
()[
0
]
amount
=
tamp_user_session
.
query
(
CurriculumPrice
.
price
)
.
filter
(
CurriculumPrice
.
rel_id
==
args
[
'ab_proid'
])
.
first
()[
0
]
args
[
'id'
]
=
OrderFlow
.
__tablename__
+
str
(
int
(
time
.
time
()
*
100000
))
args
[
'id'
]
=
OrderFlow
.
__tablename__
+
str
(
int
(
time
.
time
()
*
100000
))
args
[
'ab_payment'
]
=
amount
*
100
args
[
'ab_payment'
]
=
amount
args
[
'ab_status'
]
=
'WAIT'
args
[
'ab_status'
]
=
'WAIT'
subject
=
args
.
get
(
'prod_name'
,
''
)
subject
=
args
.
get
(
'prod_name'
,
''
)
out_trade_no
=
args
[
'ab_ordernum'
]
out_trade_no
=
args
[
'ab_ordernum'
]
notify_path
=
'/tamp_order/micro_shop/topUpOrderNotify'
notify_path
=
'/tamp_order/micro_shop/topUpOrderNotify'
pay_params
=
None
pay_params
=
None
# 该用户是否重复购买同一商品
repeat_buy
=
tamp_user_session
.
query
(
OrderFlow
.
id
)
.
filter
(
and_
(
OrderFlow
.
createby
==
args
[
'uesr_id'
]),
OrderFlow
.
ab_proid
==
args
[
'ab_proid'
],
OrderFlow
.
ab_status
==
'SUCCESS'
)
.
all
()
if
repeat_buy
:
raise
CustomFlaskErr
(
Errors
.
REPEAT_BUY
)
if
args
[
'ab_pay_mode'
]
==
4
:
if
args
[
'ab_pay_mode'
]
==
4
:
# 探普币支付
# 探普币支付
if
args
[
'env'
]
==
'ios'
:
if
args
[
'env'
]
==
'ios'
:
...
@@ -215,7 +220,9 @@ def topUpSuccessAction(order_no):
...
@@ -215,7 +220,9 @@ def topUpSuccessAction(order_no):
if
topup_order
.
ab_status
==
'SUCCESS'
:
if
topup_order
.
ab_status
==
'SUCCESS'
:
return
False
return
False
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
update
({
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
update
({
'ab_status'
:
'SUCCESS'
'ab_status'
:
'SUCCESS'
,
'pay_time'
:
datetime
.
datetime
.
now
(),
'complete_time'
:
datetime
.
datetime
.
now
()
})
})
# 账户充值
# 账户充值
account_topup_order
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
first
()
.
to_dict
()
account_topup_order
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
first
()
.
to_dict
()
...
@@ -238,7 +245,9 @@ def consumeSucessAction(order_no):
...
@@ -238,7 +245,9 @@ def consumeSucessAction(order_no):
if
curriculum_order
.
ab_status
==
'SUCCESS'
:
if
curriculum_order
.
ab_status
==
'SUCCESS'
:
return
False
return
False
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
update
({
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
update
({
'ab_status'
:
'SUCCESS'
'ab_status'
:
'SUCCESS'
,
'pay_time'
:
datetime
.
datetime
.
now
(),
'complete_time'
:
datetime
.
datetime
.
now
()
})
})
tamp_user_session
.
commit
()
tamp_user_session
.
commit
()
...
...
logs/tamp_course_order.log
View file @
480fce5d
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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