Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tour_business
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
0
Merge Requests
0
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
魏强
tour_business
Commits
29732f3e
Commit
29732f3e
authored
Apr 14, 2021
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量退款接口上线
parent
ea8525bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
0 deletions
+104
-0
Controller/RentController.py
+104
-0
No files found.
Controller/RentController.py
View file @
29732f3e
...
@@ -764,3 +764,107 @@ def get_machine_price():
...
@@ -764,3 +764,107 @@ def get_machine_price():
else
:
else
:
pass
pass
return
jsonify
(
BASE_RESPONSE
(
data
=
data
)
.
to_dict
())
return
jsonify
(
BASE_RESPONSE
(
data
=
data
)
.
to_dict
())
@route_rent.route
(
'/multi_return'
,
methods
=
[
'POST'
])
def
run_multi_return
():
json_data
=
request
.
get_json
()
rent_datas
=
json_data
.
get
(
"rent_datas"
,
[])
back_time
=
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
return_data
=
{
"success"
:
[],
"fail"
:
[]}
for
rent_data
in
rent_datas
:
rent_info
=
db
.
session
.
query
(
Production
,
Rent
)
.
join
(
Rent
,
Rent
.
id
==
Production
.
rent_id
)
.
filter
(
Production
.
rent_hatch_no
==
rent_data
[
"hatch_no"
],
Rent
.
rent_no
==
rent_data
[
"rent_no"
])
.
first
()
if
not
rent_info
:
return
jsonify
(
REFUND_NOT_PRODUCTION_INFO
)
rent
=
rent_info
.
Rent
production
=
rent_info
.
Production
machine
=
Machine
.
query
.
filter_by
(
id
=
rent
.
machine_id
)
.
first
()
if
not
machine
:
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
fee
=
RentService
.
check_fee
(
rent
.
pay_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
),
str
(
back_time
),
rent
.
one_day_price
,
rent
.
free_time
,
machine
.
id
,
machine
.
price_type
)
new_total
=
fee
[
'total'
]
# 寒山寺agent_total把25修改为20,80%的比例
if
rent
.
spot_id
in
(
48
,
49
):
new_agent_total
=
new_total
*
0.8
else
:
new_agent_total
=
new_total
if
production
.
is_return
:
refund_money
=
production
.
total
-
new_total
else
:
refund_money
=
rent
.
deposit
-
new_total
if
refund_money
<=
0
:
return_data
[
"success"
]
.
append
({
"rent_no"
:
rent_data
[
"rent_no"
],
"hatch_no"
:
rent_data
[
"hatch_no"
]})
continue
# 重新计算订单对应所有讲解器总收入,退款金额
rent_total
=
0
rent_real_total
=
0
rent_agent_total
=
0
productions
=
Production
.
query
.
filter_by
(
rent_id
=
rent
.
id
)
.
all
()
for
tmp
in
productions
:
if
tmp
.
id
==
production
.
id
:
rent_total
+=
new_total
rent_real_total
+=
new_total
rent_agent_total
+=
new_agent_total
else
:
rent_total
+=
tmp
.
total
if
tmp
.
total
is
not
None
else
0
rent_real_total
+=
tmp
.
total
if
tmp
.
total
is
not
None
else
0
rent_agent_total
+=
tmp
.
agent_total
if
tmp
.
agent_total
is
not
None
else
0
rent_back_money
=
rent
.
deposit
*
rent
.
number
-
rent_total
# 退款操作
data
=
{
"out_refund_no"
:
RentService
.
create_refund_no
(),
"out_trade_no"
:
rent_info
.
Rent
.
rent_no
,
"total_fee"
:
rent_info
.
Rent
.
deposit
*
rent_info
.
Rent
.
number
,
"refund_fee"
:
refund_money
}
result
=
WeChatService
()
.
refund
(
data
)
if
result
:
try
:
rent_refund
=
RentRefund
()
rent_refund
.
refund_no
=
data
[
"out_refund_no"
]
rent_refund
.
production_id
=
rent_info
.
Production
.
id
rent_refund
.
fee
=
refund_money
rent_refund
.
comment
=
"批量归还"
rent_refund
.
cause
=
"手动批量归还"
rent
.
total
=
rent_total
rent
.
real_total
=
rent_real_total
rent
.
agent_total
=
rent_agent_total
rent
.
back_money
=
rent_back_money
rent
.
is_over
=
1
production
.
total
=
new_total
production
.
agent_total
=
new_agent_total
if
not
production
.
is_return
:
production
.
is_return
=
1
production
.
return_time
=
datetime
.
datetime
.
now
()
production
.
return_hatch_no
=
production
.
rent_hatch_no
production
.
return_machine_id
=
production
.
rent_machine_id
if
not
production
.
is_refund
:
production
.
is_refund
=
1
production
.
refund_time
=
datetime
.
datetime
.
now
()
production
.
refund_no
=
data
[
"out_refund_no"
]
db
.
session
.
add
(
rent_refund
)
db
.
session
.
add
(
rent
)
db
.
session
.
add
(
production
)
db
.
session
.
commit
()
except
SQLAlchemyError
as
e
:
db
.
session
.
rollback
()
raise
e
return_data
[
"success"
]
.
append
({
"rent_no"
:
rent_data
[
"rent_no"
],
"hatch_no"
:
rent_data
[
"hatch_no"
]})
else
:
return_data
[
"fail"
]
.
append
({
"rent_no"
:
rent_data
[
"rent_no"
],
"hatch_no"
:
rent_data
[
"hatch_no"
]})
return
jsonify
(
BASE_RESPONSE
(
data
=
return_data
)
.
to_dict
())
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