Commit 8c564c9c by 魏强

update;

parent f0c3428e
...@@ -342,11 +342,11 @@ def force_refund(): ...@@ -342,11 +342,11 @@ def force_refund():
if action_pwd != ACTION_PWD: if action_pwd != ACTION_PWD:
return jsonify(ACTION_CODE_ERROR) return jsonify(ACTION_CODE_ERROR)
refund_type = json_data.get('type', None)
rent_no = json_data.get('rent_no', None) rent_no = json_data.get('rent_no', None)
money = json_data.get('money', None)
comment = json_data.get('comment', None) comment = json_data.get('comment', None)
if not rent_no or not money or not comment: if not refund_type or not rent_no or not comment:
return jsonify(PARAMETER_ERROR) return jsonify(PARAMETER_ERROR)
rent_info = db.session.query(Production, Rent).join(Rent, Rent.id == Production.rent_id).filter( rent_info = db.session.query(Production, Rent).join(Rent, Rent.id == Production.rent_id).filter(
...@@ -355,6 +355,24 @@ def force_refund(): ...@@ -355,6 +355,24 @@ def force_refund():
if not rent_info: if not rent_info:
return jsonify(REFUND_NOT_PRODUCTION_INFO) return jsonify(REFUND_NOT_PRODUCTION_INFO)
if refund_type == '1':
# 扣15元
money = 1500
elif refund_type == '2':
# 扣25元
money = 2500
elif refund_type == '3':
# 扣99元
money = 9900
elif refund_type == '4':
# 按时间扣款
back_time = json_data.get('back_time', None)
money = RentService.check_fee_liuyuan(rent_info.Rent.pay_time.strftime('%Y-%m-%d %H:%M:%S'),
back_time.strftime('%Y-%m-%d %H:%M:%S'),
rent_info.Rent.one_day_price, rent_info.Rent.free_time)
else:
return jsonify({'code': -1, 'msg': 'refund type error!'})
rent_info.Rent.back_money = rent_info.Rent.back_money + int(money) rent_info.Rent.back_money = rent_info.Rent.back_money + int(money)
rent_info.Rent.total = rent_info.Rent.total - int(money) rent_info.Rent.total = rent_info.Rent.total - int(money)
rent_info.Rent.real_total = rent_info.Rent.real_total - int(money) rent_info.Rent.real_total = rent_info.Rent.real_total - int(money)
......
...@@ -275,6 +275,33 @@ class RentService(): ...@@ -275,6 +275,33 @@ class RentService():
total = one_day_price * (days + 1) total = one_day_price * (days + 1)
return {'total': total, 'use_m': use_m} return {'total': total, 'use_m': use_m}
@classmethod
def check_fee_liuyuan(cls, rent_time, back_time, one_day_price, free_time):
back_time_date = datetime.datetime.strptime(back_time, '%Y-%m-%d %H:%M:%S')
rent_time_date = datetime.datetime.strptime(rent_time, '%Y-%m-%d %H:%M:%S')
use_time = (back_time_date - rent_time_date).total_seconds()
total = 0
use_m = round(use_time / 60, 2)
if use_time > free_time * 60:
days = (datetime.datetime(back_time_date.year, back_time_date.month,
back_time_date.day) - datetime.datetime(rent_time_date.year, rent_time_date.month,
rent_time_date.day)).days
# 超过一天的,按天收费,天数*25
if days >= 1:
total = (days + 1) * one_day_price
else:
# 60分钟以内,不收费
if use_time <= 60 * 60:
total = 0
# 超时15分钟以内的,收费15元
elif use_time <= (60 + 15) * 60:
total = 1500
# 超时15分钟以上的,按25元/天收费
else:
total = 2500
return {'total': total, 'use_m': use_m}
@staticmethod @staticmethod
def create_refund_no(): def create_refund_no():
''' '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment