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
31e044ab
Commit
31e044ab
authored
Jun 24, 2020
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修改
parent
16bd1a29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
65 deletions
+75
-65
Controller/RentController.py
+75
-65
No files found.
Controller/RentController.py
View file @
31e044ab
...
@@ -273,71 +273,6 @@ def rent_search():
...
@@ -273,71 +273,6 @@ def rent_search():
return
jsonify
(
BASE_RESPONSE
(
data
=
info
)
.
to_dict
())
return
jsonify
(
BASE_RESPONSE
(
data
=
info
)
.
to_dict
())
# @route_rent.route('/rent_money_refund', methods=['GET', 'POST'])
# def rent_money_refund():
# json_data = request.get_json()
# action_pwd = json_data['action_pwd'] if 'action_pwd' in json_data else ''
#
# if action_pwd != ACTION_PWD:
# return jsonify(ACTION_CODE_ERROR)
#
# rent_no = json_data['rent_no'] if 'rent_no' in json_data else ''
# hatch_no = json_data['hatch_no'] if 'hatch_no' in json_data else ''
# comment = json_data['comment'] if 'comment' in json_data else ''
#
# if not rent_no or not hatch_no or not comment:
# return jsonify(PARAMETER_ERROR)
#
# rent_info = db.session.query(Production, Rent).join(Rent, Rent.id == Production.rent_id).filter(
# Production.rent_hatch_no == hatch_no, Rent.rent_no == rent_no).first()
#
# if not rent_info:
# return jsonify(REFUND_NOT_PRODUCTION_INFO)
#
# real_total_consume = rent_info.Rent.deposit * rent_info.Rent.number - rent_info.Rent.back_money
# real_single_refund = real_total_consume if real_total_consume < rent_info.Production.total else rent_info.Production.total
#
# rent_refund_no = RentService.create_refund_no()
#
# rent_info.Rent.back_money = rent_info.Rent.deposit * rent_info.Rent.number \
# if rent_info.Rent.back_money + real_single_refund > rent_info.Rent.deposit * rent_info.Rent.number \
# else rent_info.Rent.back_money + real_single_refund
#
# rent_total = rent_info.Rent.total - rent_info.Production.total
# rent_real_total = rent_info.Rent.real_total - real_single_refund
# rent_info.Rent.total = rent_total if rent_total > 0 else 0
# rent_info.Rent.real_total = rent_real_total if rent_real_total > 0 else 0
#
# data = {
# "out_refund_no": rent_refund_no,
# "out_trade_no": rent_info.Rent.rent_no,
# "total_fee": rent_info.Rent.deposit * rent_info.Rent.number,
# "refund_fee": real_single_refund
# }
# result = WeChatService().refund(data)
# if result:
# try:
# rent_refund = RentRefund()
# rent_refund.refund_no = rent_refund_no
# rent_refund.production_id = rent_info.Production.id
# rent_refund.fee = real_single_refund
# rent_refund.comment = comment
# rent_refund.created_at = datetime.datetime.now()
# rent_refund.updated_at = datetime.datetime.now()
#
# rent_info.Production.total = 0
#
# db.session.add(rent_refund)
# db.session.add(rent_info.Rent)
# db.session.add(rent_info.Production)
# db.session.commit()
# except SQLAlchemyError as e:
# db.session.rollback()
# raise e
# return jsonify(BASE_RESPONSE().to_dict())
# else:
# return jsonify(BASE_RESPONSE(error_code=-1, error_message='refund failed').to_dict())
@route_rent.route
(
'/rent_money_refund'
,
methods
=
[
'GET'
,
'POST'
])
@route_rent.route
(
'/rent_money_refund'
,
methods
=
[
'GET'
,
'POST'
])
def
rent_money_refund
():
def
rent_money_refund
():
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
...
@@ -349,6 +284,71 @@ def rent_money_refund():
...
@@ -349,6 +284,71 @@ def rent_money_refund():
rent_no
=
json_data
[
'rent_no'
]
if
'rent_no'
in
json_data
else
''
rent_no
=
json_data
[
'rent_no'
]
if
'rent_no'
in
json_data
else
''
hatch_no
=
json_data
[
'hatch_no'
]
if
'hatch_no'
in
json_data
else
''
hatch_no
=
json_data
[
'hatch_no'
]
if
'hatch_no'
in
json_data
else
''
comment
=
json_data
[
'comment'
]
if
'comment'
in
json_data
else
''
comment
=
json_data
[
'comment'
]
if
'comment'
in
json_data
else
''
if
not
rent_no
or
not
hatch_no
or
not
comment
:
return
jsonify
(
PARAMETER_ERROR
)
rent_info
=
db
.
session
.
query
(
Production
,
Rent
)
.
join
(
Rent
,
Rent
.
id
==
Production
.
rent_id
)
.
filter
(
Production
.
rent_hatch_no
==
hatch_no
,
Rent
.
rent_no
==
rent_no
)
.
first
()
if
not
rent_info
:
return
jsonify
(
REFUND_NOT_PRODUCTION_INFO
)
real_total_consume
=
rent_info
.
Rent
.
deposit
*
rent_info
.
Rent
.
number
-
rent_info
.
Rent
.
back_money
real_single_refund
=
real_total_consume
if
real_total_consume
<
rent_info
.
Production
.
total
else
rent_info
.
Production
.
total
rent_refund_no
=
RentService
.
create_refund_no
()
rent_info
.
Rent
.
back_money
=
rent_info
.
Rent
.
deposit
*
rent_info
.
Rent
.
number
\
if
rent_info
.
Rent
.
back_money
+
real_single_refund
>
rent_info
.
Rent
.
deposit
*
rent_info
.
Rent
.
number
\
else
rent_info
.
Rent
.
back_money
+
real_single_refund
rent_total
=
rent_info
.
Rent
.
total
-
rent_info
.
Production
.
total
rent_real_total
=
rent_info
.
Rent
.
real_total
-
real_single_refund
rent_info
.
Rent
.
total
=
rent_total
if
rent_total
>
0
else
0
rent_info
.
Rent
.
real_total
=
rent_real_total
if
rent_real_total
>
0
else
0
data
=
{
"out_refund_no"
:
rent_refund_no
,
"out_trade_no"
:
rent_info
.
Rent
.
rent_no
,
"total_fee"
:
rent_info
.
Rent
.
deposit
*
rent_info
.
Rent
.
number
,
"refund_fee"
:
real_single_refund
}
result
=
WeChatService
()
.
refund
(
data
)
if
result
:
try
:
rent_refund
=
RentRefund
()
rent_refund
.
refund_no
=
rent_refund_no
rent_refund
.
production_id
=
rent_info
.
Production
.
id
rent_refund
.
fee
=
real_single_refund
rent_refund
.
comment
=
comment
rent_refund
.
created_at
=
datetime
.
datetime
.
now
()
rent_refund
.
updated_at
=
datetime
.
datetime
.
now
()
rent_info
.
Production
.
total
=
0
db
.
session
.
add
(
rent_refund
)
db
.
session
.
add
(
rent_info
.
Rent
)
db
.
session
.
add
(
rent_info
.
Production
)
db
.
session
.
commit
()
except
SQLAlchemyError
as
e
:
db
.
session
.
rollback
()
raise
e
return
jsonify
(
BASE_RESPONSE
()
.
to_dict
())
else
:
return
jsonify
(
BASE_RESPONSE
(
error_code
=-
1
,
error_message
=
'refund failed'
)
.
to_dict
())
@route_rent.route
(
'/rent_money_refund_new'
,
methods
=
[
'GET'
,
'POST'
])
def
rent_money_refund_new
():
json_data
=
request
.
get_json
()
action_pwd
=
json_data
[
'action_pwd'
]
if
'action_pwd'
in
json_data
else
''
if
action_pwd
!=
ACTION_PWD
:
return
jsonify
(
ACTION_CODE_ERROR
)
rent_no
=
json_data
[
'rent_no'
]
if
'rent_no'
in
json_data
else
''
hatch_no
=
json_data
[
'hatch_no'
]
if
'hatch_no'
in
json_data
else
''
comment
=
json_data
[
'comment'
]
if
'comment'
in
json_data
else
''
time_price
=
json_data
[
'time_price'
]
if
'time_price'
in
json_data
else
[]
time_price
=
json_data
[
'time_price'
]
if
'time_price'
in
json_data
else
[]
if
not
rent_no
or
not
hatch_no
or
not
comment
or
not
time_price
:
if
not
rent_no
or
not
hatch_no
or
not
comment
or
not
time_price
:
...
@@ -407,9 +407,19 @@ def rent_money_refund():
...
@@ -407,9 +407,19 @@ def rent_money_refund():
rent
.
real_total
=
rent_real_total
rent
.
real_total
=
rent_real_total
rent
.
agent_total
=
rent_agent_total
rent
.
agent_total
=
rent_agent_total
rent
.
back_money
=
rent_back_money
rent
.
back_money
=
rent_back_money
rent
.
is_over
=
1
production
.
total
=
new_total
production
.
total
=
new_total
production
.
agent_total
=
new_total
production
.
agent_total
=
new_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_refund
)
db
.
session
.
add
(
rent
)
db
.
session
.
add
(
rent
)
...
...
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