Commit 6735f2ba by Aeolus

退款时进行行锁

parent 0639410a
......@@ -215,9 +215,9 @@ def rent_money_refund_new():
if not rent_info:
return jsonify(REFUND_NOT_PRODUCTION_INFO)
rent = rent_info.Rent
rent_detail = rent_info.RentDetail
wx_user = rent_info.WxUser
rent = Rent.query.filter_by(rent_no=rent_no).with_for_update().first()
rent_detail = RentDetail.query.filter_by(rent_no=rent_no, id=rent_detail_id).with_for_update().first()
wx_user = WxUser.query.filter_by(id=rent.user_id).first()
refund_count = int(json_data["refund_count"])
refund_money = refund_count * rent_detail.price
......@@ -244,6 +244,7 @@ def rent_money_refund_new():
"total_fee": rent.total,
"refund_fee": refund_money
}
result = WeChatPayService(app_id=platform_appid_config_list[wx_user.platform],
config_name=pay_config_list[rent.mch_platform]).do_refund(data)
if result:
......@@ -270,6 +271,7 @@ def rent_money_refund_new():
db.session.commit()
except SQLAlchemyError as e:
db.session.rollback()
logger.info(e)
raise e
return BaseResponse()
else:
......
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