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
81822a71
Commit
81822a71
authored
Jun 24, 2020
by
Aeolus
1
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev_aeolus'
parents
0753af61
80187017
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
163 additions
and
24 deletions
+163
-24
Controller/RentController.py
+159
-24
Model/Production/ProductionModel.py
+3
-0
Model/Rent/RentModel.py
+1
-0
No files found.
Controller/RentController.py
View file @
81822a71
...
...
@@ -9,7 +9,7 @@ from sqlalchemy.exc import SQLAlchemyError
from
Config.base_config
import
ACTION_PWD
from
Libs.ErrorTips
import
BASE_RESPONSE
,
REFUND_NOT_RENT_INFO
,
REFUND_BACK_TIME_ERROR
,
REFUND_NOT_PRODUCTION_INFO
,
\
REFUND_MONEY_IS_ZERO
,
ACTION_CODE_ERROR
,
PARAMETER_ERROR
REFUND_MONEY_IS_ZERO
,
ACTION_CODE_ERROR
,
PARAMETER_ERROR
,
MACHINE_NOT_EXIST_ERROR
from
Libs.Helper
import
Helper
from
Libs.Logger
import
logger
from
Model.Base
import
db
...
...
@@ -17,6 +17,7 @@ from Model.Customer.CustomerModel import Customer
from
Model.Machine.MachineModel
import
Machine
from
Model.Power.PowerModel
import
Power
from
Model.Production.ProductionModel
import
Production
from
Model.Rent.FeeMinuteModel
import
FeeMinuteModel
from
Model.Rent.RentModel
import
Rent
from
Model.Rent.RentRefundModel
import
RentRefund
from
Service.IndexService
import
IndexService
...
...
@@ -272,6 +273,71 @@ def rent_search():
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'
])
def
rent_money_refund
():
json_data
=
request
.
get_json
()
...
...
@@ -283,8 +349,9 @@ def rent_money_refund():
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
[]
if
not
rent_no
or
not
hatch_no
or
not
comment
:
if
not
rent_no
or
not
hatch_no
or
not
comment
or
not
time_price
:
return
jsonify
(
PARAMETER_ERROR
)
rent_info
=
db
.
session
.
query
(
Production
,
Rent
)
.
join
(
Rent
,
Rent
.
id
==
Production
.
rent_id
)
.
filter
(
...
...
@@ -292,43 +359,58 @@ def rent_money_refund():
if
not
rent_info
:
return
jsonify
(
REFUND_NOT_PRODUCTION_INFO
)
rent
=
rent_info
.
Rent
production
=
rent_info
.
Production
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
new_total
=
time_price
[
-
1
]
refund_money
=
production
.
total
-
new_total
if
refund_money
<=
0
:
return
jsonify
(
REFUND_MONEY_IS_ZERO
)
# 重新计算订单对应所有讲解器总收入,退款金额
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_total
else
:
rent_total
+=
tmp
.
total
rent_real_total
+=
tmp
.
total
rent_agent_total
+=
tmp
.
agent_total
rent_back_money
=
rent
.
deposit
*
rent
.
number
-
rent_total
# 退款操作
data
=
{
"out_refund_no"
:
rent_refund_no
,
"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"
:
re
al_single_refund
"refund_fee"
:
re
fund_money
}
result
=
WeChatService
()
.
refund
(
data
)
if
result
:
try
:
rent_refund
=
RentRefund
()
rent_refund
.
refund_no
=
rent_refund_no
rent_refund
.
refund_no
=
data
[
"out_refund_no"
]
rent_refund
.
production_id
=
rent_info
.
Production
.
id
rent_refund
.
fee
=
re
al_single_refund
rent_refund
.
fee
=
re
fund_money
rent_refund
.
comment
=
comment
rent_refund
.
created_at
=
datetime
.
datetime
.
now
()
rent_refund
.
updated_at
=
datetime
.
datetime
.
now
()
rent_info
.
Production
.
total
=
0
rent
.
total
=
rent_total
rent
.
real_total
=
rent_real_total
rent
.
agent_total
=
rent_agent_total
rent
.
back_money
=
rent_back_money
production
.
total
=
new_total
production
.
agent_total
=
new_total
db
.
session
.
add
(
rent_refund
)
db
.
session
.
add
(
rent
_info
.
Rent
)
db
.
session
.
add
(
rent_info
.
P
roduction
)
db
.
session
.
add
(
rent
)
db
.
session
.
add
(
p
roduction
)
db
.
session
.
commit
()
except
SQLAlchemyError
as
e
:
db
.
session
.
rollback
()
...
...
@@ -528,3 +610,56 @@ def rent_money_liuyuan():
return
jsonify
(
BASE_RESPONSE
()
.
to_dict
())
else
:
return
jsonify
(
BASE_RESPONSE
(
error_code
=-
1
,
error_message
=
'refund failed'
)
.
to_dict
())
@route_rent.route
(
'/machine_price'
,
methods
=
[
'POST'
])
def
get_machine_price
():
json_data
=
request
.
get_json
()
mac_no
=
json_data
.
get
(
"mac_no"
,
None
)
if
not
mac_no
:
return
jsonify
(
PARAMETER_ERROR
)
# 验证机柜是否存在
machine
=
Machine
.
query
.
filter_by
(
mac_no
=
mac_no
)
.
first
()
if
not
machine
:
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
data
=
{
"price_type"
:
machine
.
price_type
,
"one_day_price"
:
machine
.
one_day_price
,
"desposit"
:
machine
.
deposit
,
"time_price"
:
[]
}
if
machine
.
price_type
==
1
:
# 免费时间
data
[
"time_price"
]
.
append
([
str
(
0
)
+
'天'
,
0
])
max_days
=
machine
.
deposit
//
machine
.
one_day_price
+
1
i
=
1
while
i
<
max_days
:
data
[
"time_price"
]
.
append
([
str
(
i
)
+
'天'
,
machine
.
one_day_price
*
i
])
i
+=
1
data
[
"time_price"
]
.
append
([
str
(
max_days
)
+
'天'
,
machine
.
deposit
])
elif
machine
.
price_type
==
2
:
data
[
"price_type"
]
=
2
fee_minutes
=
FeeMinuteModel
.
query
.
filter_by
(
machine_id
=
machine
.
id
,
status
=
1
)
.
order_by
(
FeeMinuteModel
.
index
.
asc
())
.
all
()
data
[
"time_price"
]
.
append
([
'0分钟'
,
'0分钟'
,
0
])
max_hours
=
len
(
fee_minutes
)
n
=
0
while
n
<
max_hours
-
1
:
data
[
"time_price"
]
.
append
(
[
str
(
fee_minutes
[
n
]
.
minute
)
+
"分钟"
,
str
(
fee_minutes
[
n
+
1
]
.
minute
)
+
"分钟"
,
fee_minutes
[
n
]
.
price
])
n
+=
1
data
[
"time_price"
]
.
append
(
[
str
(
fee_minutes
[
n
]
.
minute
)
+
"分钟"
,
"1天"
,
fee_minutes
[
n
]
.
price
])
max_days
=
machine
.
deposit
//
machine
.
one_day_price
+
1
i
=
2
while
i
<
max_days
:
data
[
"time_price"
]
.
append
([
str
(
i
)
+
'天'
,
machine
.
one_day_price
*
i
])
i
+=
1
data
[
"time_price"
]
.
append
([
str
(
max_days
)
+
'天'
,
machine
.
deposit
])
else
:
pass
return
jsonify
(
BASE_RESPONSE
(
data
=
data
)
.
to_dict
())
Model/Production/ProductionModel.py
View file @
81822a71
...
...
@@ -17,9 +17,12 @@ class Production(BaseModel):
return_machine_id
=
Column
(
Integer
,
comment
=
'还的机柜id'
)
return_hatch_no
=
Column
(
Integer
,
comment
=
'还的仓口'
)
return_time
=
Column
(
DateTime
,
comment
=
'还的时间'
)
agent_return_time
=
Column
(
DateTime
,
comment
=
'代理商看的归还的时间'
)
is_refund
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'是否退款'
)
refund_no
=
Column
(
String
(
191
,
'utf8mb4_unicode_ci'
),
comment
=
'退款单号'
)
refund_time
=
Column
(
DateTime
,
comment
=
'退款时间'
)
agent_refund_time
=
Column
(
DateTime
,
comment
=
'代理商看的退款的时间'
)
total
=
Column
(
Integer
,
comment
=
'消费金额'
)
agent_total
=
Column
(
Integer
,
comment
=
'代理商看的收入'
)
spot_id
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'景点id'
)
business_id
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'商家id'
)
Model/Rent/RentModel.py
View file @
81822a71
...
...
@@ -17,6 +17,7 @@ class Rent(BaseModel):
customer_id
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'用户id'
)
total
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'应收金额'
)
real_total
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'实收金额'
)
agent_total
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'代理商看的收入'
)
back_money
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'退款金额'
)
is_pay
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'是否支付'
)
rent_type
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'租借类型1现场租借2预约'
)
...
...
冯佳佳
@fengjiajia
mentioned in commit
5580332d
Jun 24, 2020
mentioned in commit
5580332d
mentioned in commit 5580332d5062f0bf42bc7f926333a437336d3207
Toggle commit list
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