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
685a6fa0
Commit
685a6fa0
authored
Feb 18, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同一笔订单退款需要间隔60s
parent
6735f2ba
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
10 deletions
+19
-10
config/commen_config.py
+3
-0
myapps/pc_management/api/rent_portal.py
+16
-10
utils/error_code.py
+0
-0
No files found.
config/commen_config.py
View file @
685a6fa0
...
...
@@ -34,6 +34,9 @@ WX_ACCESS_TOKEN = "W_A_T_"
# 微信公众号access_token过期时间
WX_ACCESS_TOKEN_EXPIRE
=
"W_A_T_E_"
# 订单退款锁
RENT_REFUND_LOCK
=
"R_R_L_"
LOGIN_TYPE
=
{
'code_login'
:
1
,
'token_login'
:
2
,
...
...
myapps/pc_management/api/rent_portal.py
View file @
685a6fa0
...
...
@@ -10,17 +10,20 @@ author:Aeolus
"""
import
datetime
import
logging
import
time
from
flask
import
Blueprint
,
g
,
request
,
jsonify
from
sqlalchemy.exc
import
SQLAlchemyError
from
config.commen_config
import
RENT_SALE_LOCK
from
config.wechat_config
import
platform_appid_config_list
,
pay_config_list
from
models.base_model
import
db
from
models.models
import
Rent
,
RentDetail
,
WxUser
,
Machine
,
RentRefund
,
DrawRecord
from
service.rent_service
import
RentService
from
service.wechat_service
import
WeChatPayService
from
utils.error_code
import
OPERATE_LEVEL_ERROR
,
ACTION_CODE_ERROR
,
REFUND_NOT_PRODUCTION_INFO
,
Param_Invalid_Error
,
\
REFUND_MONEY_IS_ZERO
,
REFUND_MONEY_ERROR
REFUND_MONEY_IS_ZERO
,
REFUND_MONEY_ERROR
,
REFUND_LOCK_ERROR
from
utils.my_redis_cache
import
redis_client
from
utils.my_response
import
BaseResponse
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -206,17 +209,20 @@ def rent_money_refund_new():
cause
=
json_data
[
'cause'
]
comment
=
json_data
[
'comment'
]
if
'comment'
in
json_data
else
''
rent_info
=
db
.
session
.
query
(
RentDetail
,
Rent
,
WxUser
,
Machine
)
.
join
(
Rent
,
Rent
.
rent_no
==
RentDetail
.
rent_no
)
.
join
(
WxUser
,
WxUser
.
id
==
Rent
.
user_id
)
.
filter
(
RentDetail
.
id
==
rent_detail_id
,
Rent
.
rent_no
==
rent_no
)
.
first
()
lock_res
=
redis_client
.
set
(
RENT_SALE_LOCK
+
str
(
rent_no
)
+
"_"
+
str
(
rent_detail_id
),
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
ex
=
60
,
nx
=
True
)
if
lock_res
:
pass
else
:
return
jsonify
(
REFUND_LOCK_ERROR
)
if
not
rent_info
:
return
jsonify
(
REFUND_NOT_PRODUCTION_INFO
)
rent
=
Rent
.
query
.
filter_by
(
rent_no
=
rent_no
)
.
with_for_update
()
.
first
()
if
not
rent
:
return
jsonify
(
REFUND_NOT_PRODUCTION_INFO
)
rent_detail
=
RentDetail
.
query
.
filter_by
(
rent_no
=
rent_no
,
id
=
rent_detail_id
)
.
with_for_update
()
.
first
()
if
not
rent_detail
:
return
jsonify
(
REFUND_NOT_PRODUCTION_INFO
)
wx_user
=
WxUser
.
query
.
filter_by
(
id
=
rent
.
user_id
)
.
first
()
refund_count
=
int
(
json_data
[
"refund_count"
])
...
...
@@ -240,7 +246,7 @@ def rent_money_refund_new():
# 退款操作
data
=
{
"out_refund_no"
:
RentService
.
create_refund_no
(),
"out_trade_no"
:
rent_
info
.
Rent
.
rent_
no
,
"out_trade_no"
:
rent_no
,
"total_fee"
:
rent
.
total
,
"refund_fee"
:
refund_money
}
...
...
utils/error_code.py
View file @
685a6fa0
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