Commit 80187017 by Aeolus

退款同时修改代理商收入

parent e44c720d
......@@ -370,14 +370,17 @@ def rent_money_refund():
# 重新计算订单对应所有讲解器总收入,退款金额
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
......@@ -388,8 +391,7 @@ def rent_money_refund():
"total_fee": rent_info.Rent.deposit * rent_info.Rent.number,
"refund_fee": refund_money
}
# result = WeChatService().refund(data)
result = True
result = WeChatService().refund(data)
if result:
try:
rent_refund = RentRefund()
......@@ -400,9 +402,11 @@ def rent_money_refund():
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)
......
......@@ -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')
......@@ -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预约')
......
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