Commit 2bd4ad76 by 魏强

留园退款接口;

parent fb374149
......@@ -333,3 +333,58 @@ def rent_money_refund():
return jsonify(BASE_RESPONSE().to_dict())
else:
return jsonify(BASE_RESPONSE(error_code=-1, error_message='refund failed').to_dict())
@route_rent.route('/force_refund', methods=['GET', 'POST'])
def force_refund():
json_data = request.get_json()
action_pwd = json_data.get('action_pwd', None)
if action_pwd != ACTION_PWD:
return jsonify(ACTION_CODE_ERROR)
rent_no = json_data.get('rent_no', None)
money = json_data.get('money', None)
comment = json_data.get('comment', None)
if not rent_no or not money or not comment:
return jsonify(PARAMETER_ERROR)
rent_info = db.session.query(Production, Rent).join(Rent, Rent.id == Production.rent_id).filter(
Rent.rent_no == rent_no).first()
if not rent_info:
return jsonify(REFUND_NOT_PRODUCTION_INFO)
rent_info.Rent.back_money = int(money)
rent_info.Rent.total = 9900 - int(money)
rent_info.real_total = 9900 - int(money)
rent_refund_no = RentService.create_refund_no()
data = {
"out_refund_no": rent_refund_no,
"out_trade_no": rent_info.rent_no,
"total_fee": rent_info.deposit,
"refund_fee": int(money)
}
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 = int(money)
rent_refund.comment = comment
rent_refund.created_at = datetime.datetime.now()
rent_refund.updated_at = datetime.datetime.now()
db.session.add(rent_refund)
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())
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