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
a7d0e3c8
Commit
a7d0e3c8
authored
Nov 18, 2021
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
充值接口修改
parent
af2cd9f4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
24 deletions
+49
-24
config/base_config.py
+2
-0
myapps/sukang24h/api/nfc_card_portal.py
+47
-24
utils/error_code.py
+0
-0
utils/middlewares.py
+0
-0
No files found.
config/base_config.py
View file @
a7d0e3c8
...
...
@@ -11,3 +11,5 @@ SECRET_KEY = os.getenv('SECRET_KEY')
SQLALCHEMY_DATABASE_URI
=
os
.
getenv
(
"SQLALCHEMY_DATABASE_URI"
)
MONGO_DATABASE_URI
=
os
.
getenv
(
"MONGO_DATABASE_URI"
)
TENCENT_REDIS_URL
=
os
.
getenv
(
"TENCENT_REDIS_URL"
)
NFC_PAY_LOAD_SECRET
=
os
.
getenv
(
"NFC_PAY_LOAD_SECRET"
)
myapps/sukang24h/api/nfc_card_portal.py
View file @
a7d0e3c8
...
...
@@ -12,7 +12,9 @@ import time
from
flask
import
Blueprint
,
request
,
jsonify
,
g
from
sqlalchemy
import
extract
from
sqlalchemy.exc
import
SQLAlchemyError
from
config.base_config
import
NFC_PAY_LOAD_SECRET
from
config.commen_config
import
USER_RENT_PREPAY_ID
from
config.wechat_config
import
platform_appid_config_list
,
pay_config_list
,
NFC_PAY_CALLBCK_URL
from
models.base_model
import
db
...
...
@@ -20,7 +22,7 @@ from models.models import NfcCard, NfcCardPayRecord, NfcCardPayRefund
from
service.rent_service
import
RentService
from
service.wechat_service
import
WeChatPayService
from
utils.error_code
import
NFC_CARD_NOT_EXIST
,
NFC_CARD_ACTIVATED_ERROR
,
WE_MINIAPP_PAY_FAIL
,
NO_RENT_RECORD
,
\
NO_NFC_CARD_ERROR
NO_NFC_CARD_ERROR
,
NFC_PAY_LOAD_SECRET_ERROR
from
utils.my_redis_cache
import
redis_client
from
utils.my_response
import
BaseResponse
...
...
@@ -327,43 +329,64 @@ def run_nfc_card_pay_refund():
return
BaseResponse
()
#查询充值记录
# 查询充值记录
@nfc_card_route.route
(
'/user_pay_record'
,
methods
=
[
'POST'
])
def
run_nfc_card_user_pay_record
():
json_data
=
request
.
get_json
()
secret
=
json_data
[
"secret"
]
card_no
=
json_data
[
"card_no"
]
page
=
json_data
.
get
(
"page"
,
1
)
page_size
=
json_data
.
get
(
"page_size"
,
5
)
if
secret
!=
NFC_PAY_LOAD_SECRET
:
return
jsonify
(
NFC_PAY_LOAD_SECRET_ERROR
)
card_result
=
NfcCard
.
query
.
filter_by
(
card_no
=
card_no
,
status
=
1
)
.
first
()
if
not
card_result
:
return
jsonify
(
NFC_CARD_NOT_EXIST
)
card_result
=
NfcCardPayRecord
.
query
.
filter_by
(
card_no
=
card_no
,
is_pay
=
1
)
.
all
()
result_data
=
[]
for
card
in
card_result
:
record
=
{
"card_no"
:
card
.
card_no
,
"id"
:
card
.
id
,
"pay_money"
:
card
.
pay_money
,
"created_at"
:
card
.
created_at
,
"updated_at"
:
card
.
updated_at
total_count
=
NfcCardPayRecord
.
query
.
filter_by
(
card_no
=
card_no
,
status
=
1
)
.
count
()
if
not
total_count
:
return
BaseResponse
(
data
=
[],
total_count
=
0
,
page
=
page
,
page_size
=
page_size
)
pay_records
=
NfcCardPayRecord
.
query
.
filter_by
(
card_no
=
card_no
,
status
=
1
)
.
all
()
result_data
=
[]
for
record
in
pay_records
:
tmp_data
=
{
"card_no"
:
record
.
card_no
,
"record_no"
:
record
.
rent_no
,
"pay_money"
:
record
.
pay_money
,
"pay_time"
:
record
.
created_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
}
result_data
.
append
(
record
)
result_data
.
append
(
tmp_data
)
return
BaseResponse
(
data
=
result_data
)
return
BaseResponse
(
data
=
result_data
,
total
=
0
,
page
=
page
,
page_size
=
page_size
)
#充值成功后改变数据库
# 充值成功后改变数据库
@nfc_card_route.route
(
'/user_pay_succeed'
,
methods
=
[
'POST'
])
def
run_nfc_card_pay_succeed
():
json_data
=
request
.
get_json
()
for
key
,
val
in
json_data
.
items
():
id
=
json_data
[
key
][
"id"
]
card_no
=
json_data
[
key
][
"card_no"
]
pay_money
=
json_data
[
key
][
"pay_money"
]
json_data
=
request
.
get_json
()
secret
=
json_data
[
"secret"
]
record_nos
=
json_data
[
"record_nos"
]
card_no
=
json_data
[
"card_no"
]
if
secret
!=
NFC_PAY_LOAD_SECRET
:
return
jsonify
(
NFC_PAY_LOAD_SECRET_ERROR
)
card_result
=
NfcCard
.
query
.
filter_by
(
card_no
=
card_no
)
.
first
()
# 查询到卡号
card_record
=
NfcCardPayRecord
.
query
.
filter_by
(
id
=
id
)
.
first
()
#查询到充值记录
card_result
.
money
+=
pay_money
card_record
.
is_pay
=
2
db
.
session
.
add
(
card_record
,
card_record
)
if
not
card_result
:
return
jsonify
(
NO_NFC_CARD_ERROR
)
for
record_no
in
record_nos
:
card_record
=
NfcCardPayRecord
.
query
.
filter_by
(
rent_no
=
record_no
)
.
first
()
# 查询到充值记录
card_result
.
money
+=
card_record
.
pay_money
card_record
.
status
=
2
db
.
session
.
add
(
card_record
)
try
:
db
.
session
.
add
(
card_result
)
db
.
session
.
commit
()
except
SQLAlchemyError
as
e
:
db
.
session
.
rollback
()
return
BaseResponse
()
utils/error_code.py
View file @
a7d0e3c8
This diff is collapsed.
Click to expand it.
utils/middlewares.py
View file @
a7d0e3c8
This diff is collapsed.
Click to expand it.
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