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
ad691edb
Commit
ad691edb
authored
Apr 19, 2021
by
etscript
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改配置
parent
d5d4393a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
9 deletions
+72
-9
config.yaml
app/config/config.yaml
+12
-2
order.py
app/controller/order.py
+9
-0
order_service.py
app/service/order_service.py
+51
-7
No files found.
app/config/config.yaml
View file @
ad691edb
...
...
@@ -6,6 +6,8 @@ dev:
tamp_course_db
:
tamp_course
host
:
mysql
port
:
3306
# host: 47.101.189.151
# port: 31931
user
:
dev
password
:
qimeng123
redis
:
...
...
@@ -13,6 +15,10 @@ dev:
port
:
6379
db
:
0
password
:
# host: 127.0.0.1
# port: 6379
# db: 0
# password: ''
log
:
filename
:
/logs/tamp_course_order.log
filemode
:
a
...
...
@@ -30,15 +36,19 @@ test:
tamp_pay_db
:
tamp_pay
tamp_zhibo_db
:
tamp_zhibo
tamp_course_db
:
tamp_course
host
:
118.190.63.109
host
:
rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com
port
:
3306
user
:
root
user
:
tamp_admin
password
:
'
@imeng123'
redis
:
host
:
redis.caixiaoquan.com
port
:
56379
db
:
0
password
:
qimeng123
# host: 127.0.0.1
# port: 6379
# db: 0
# password: ''
log
:
filename
:
/logs/tamp_course_order.log
filemode
:
a
...
...
app/controller/order.py
View file @
ad691edb
...
...
@@ -47,6 +47,7 @@ class TopUpOrder(Resource):
self
.
parser
.
add_argument
(
'receipt_data'
,
type
=
str
,
required
=
False
)
self
.
parser
.
add_argument
(
'product_id'
,
type
=
str
,
required
=
False
)
args
=
self
.
parser
.
parse_args
()
args
[
'user_id'
]
=
request
.
user_id
args
[
'remote_addr'
]
=
request
.
remote_addr
args
[
'host_url'
]
=
request
.
host_url
...
...
@@ -96,6 +97,14 @@ class ConsumeOrder(Resource):
self
.
parser
.
add_argument
(
'ab_pro_siid'
,
type
=
str
,
required
=
False
)
self
.
parser
.
add_argument
(
'openid'
,
type
=
str
,
required
=
False
)
args
=
self
.
parser
.
parse_args
()
if
request
.
headers
.
get
(
'env'
)
in
[
'ios'
,
'android'
]:
token
=
request
.
headers
.
get
(
'tampToken'
,
''
)
elif
request
.
headers
.
get
(
'env'
)
in
[
'wechat'
,
'xcx'
]:
token
=
request
.
cookies
.
get
(
'qimsession'
,
''
)
args
[
'env'
]
=
request
.
headers
.
get
(
'env'
)
args
[
'tampToken'
]
=
token
if
'ab_pro_siid'
not
in
args
:
raise
CustomFlaskErr
(
Errors
.
PARAMS_ERROR
)
args
[
'user_id'
]
=
request
.
user_id
...
...
app/service/order_service.py
View file @
ad691edb
...
...
@@ -27,7 +27,11 @@ from app.utils.alipay.alipayWap import prePay
from
app.utils.apple_pay
import
apple_pay
from
app.utils.wxpay
import
wx_jsapi_pay
from
app.utils.wxpay.wx_app_pay
import
WXPay
import
requests
# course_price_api = "http://devtamper.tanpuyun.com/course/res/money/price"
course_price_api
=
"http://s-nginx/course/res/money/price"
class
TopUpOrderService
:
""""""
...
...
@@ -239,13 +243,53 @@ class CurriculumOrderService:
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_pay_engine
)
as
tamp_pay
:
tamp_user_session
,
tamp_pay_session
=
tamp_user
.
session
,
tamp_pay
.
session
args
[
'ab_ordernum'
]
=
time
.
strftime
(
'
%
Y
%
m
%
d'
,
time
.
localtime
(
time
.
time
()))
+
str
(
int
(
time
.
time
()
*
100000
))
# if args['ab_type'] != "300":
# amount = tamp_user_session.query(CurriculumPrice.price).filter(CurriculumPrice.rel_id == args['ab_proid']).first()
# if not amount:
# raise CustomFlaskErr(Errors.PROD_NOPRICE)
# else:
# amount = amount[0]
amount
=
0.01
if
args
[
'ab_type'
]
!=
"300"
:
data
=
{
"payReqs"
:
[{
"resId"
:
args
[
'ab_proid'
]}],
"userId"
:
args
[
'user_id'
]
}
headers
=
{
"Content-Type"
:
"application/json"
,
"tampToken"
:
args
[
'tampToken'
],
"env"
:
args
[
'env'
]
}
amount
=
requests
.
post
(
course_price_api
,
headers
=
headers
,
json
=
data
)
try
:
amount
=
amount
.
json
()
'''
{
"statusCode": "0000",
"message": "成功",
"attributes": {
"COURSE_PACKAGE16185457769740": {
"resId": "COURSE_PACKAGE16185457769740",
"totalPrice": "998",
"chargeMode": 3,
"discountPrice": "8",
"time3Type": null,
"memberDiscountPrice": null,
"memberTime3Type": null,
"finalPrice": "998",
"isNeedBuy": 1,
"isBuy": 2
}
},
"success": true
}
'''
amount
=
[
amount
[
"attributes"
][
args
[
'ab_proid'
]][
"finalPrice"
]]
except
:
raise
CustomFlaskErr
(
Errors
.
PROD_NOPRICE
)
else
:
amount
=
tamp_user_session
.
query
(
CurriculumPrice
.
price
)
.
filter
(
CurriculumPrice
.
rel_id
==
args
[
'ab_proid'
])
.
first
()
if
not
amount
:
raise
CustomFlaskErr
(
Errors
.
PROD_NOPRICE
)
amount
=
amount
[
0
]
args
[
'id'
]
=
OrderFlow
.
__tablename__
+
str
(
int
(
time
.
time
()
*
100000
))
args
[
'ab_payment'
]
=
amount
args
[
'ab_status'
]
=
'WAIT'
...
...
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