Commit abb82ccf by Aeolus

代理商收入查看修改

parent 0753af61
...@@ -17,9 +17,12 @@ class Production(BaseModel): ...@@ -17,9 +17,12 @@ class Production(BaseModel):
return_machine_id = Column(Integer, comment='还的机柜id') return_machine_id = Column(Integer, comment='还的机柜id')
return_hatch_no = Column(Integer, comment='还的仓口') return_hatch_no = Column(Integer, comment='还的仓口')
return_time = Column(DateTime, comment='还的时间') return_time = Column(DateTime, comment='还的时间')
agent_return_time = Column(DateTime, comment='代理商看的归还的时间')
is_refund = Column(Integer, nullable=False, server_default=FetchedValue(), comment='是否退款') is_refund = Column(Integer, nullable=False, server_default=FetchedValue(), comment='是否退款')
refund_no = Column(String(191, 'utf8mb4_unicode_ci'), comment='退款单号') refund_no = Column(String(191, 'utf8mb4_unicode_ci'), comment='退款单号')
refund_time = Column(DateTime, comment='退款时间') refund_time = Column(DateTime, comment='代理商看的退款的时间')
agent_refund_time = Column(DateTime, comment='退款时间')
total = Column(Integer, comment='消费金额') total = Column(Integer, comment='消费金额')
agent_total = Column(Integer, comment='代理商看的收入')
spot_id = Column(Integer, nullable=False, comment='景点id') spot_id = Column(Integer, nullable=False, comment='景点id')
business_id = Column(Integer, nullable=False, comment='商家id') business_id = Column(Integer, nullable=False, comment='商家id')
...@@ -17,6 +17,7 @@ class Rent(BaseModel): ...@@ -17,6 +17,7 @@ class Rent(BaseModel):
customer_id = Column(Integer, nullable=False, comment='用户id') customer_id = Column(Integer, nullable=False, comment='用户id')
total = Column(Integer, nullable=False, server_default=FetchedValue(), comment='应收金额') total = Column(Integer, nullable=False, server_default=FetchedValue(), comment='应收金额')
real_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='退款金额') back_money = Column(Integer, nullable=False, server_default=FetchedValue(), comment='退款金额')
is_pay = 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预约') rent_type = Column(Integer, nullable=False, server_default=FetchedValue(), comment='租借类型1现场租借2预约')
......
...@@ -20,12 +20,13 @@ class IndexService(): ...@@ -20,12 +20,13 @@ class IndexService():
:return: :return:
''' '''
income_info = db.session.query(Production.total).filter(Production.spot_id == spot_id, Production.total > 0, income_info = db.session.query(Production.agent_total).filter(Production.spot_id == spot_id,
Production.created_at >= start_time, Production.total > 0,
Production.created_at <= end_time).all() Production.created_at >= start_time,
Production.created_at <= end_time).all()
total = 0 total = 0
for info in income_info: for info in income_info:
total += info.total total += info.agent_total
return round(total / 100, 2), len(income_info) return round(total / 100, 2), len(income_info)
@staticmethod @staticmethod
......
...@@ -30,7 +30,7 @@ class RentService(): ...@@ -30,7 +30,7 @@ class RentService():
cur_info = {} cur_info = {}
cur_info['rent_no'] = info.Rent.rent_no cur_info['rent_no'] = info.Rent.rent_no
cur_info['hatch_no'] = info.Production.rent_hatch_no cur_info['hatch_no'] = info.Production.rent_hatch_no
cur_info['total'] = 0 if info.Production.total is None else info.Production.total cur_info['total'] = 0 if info.Production.agent_total is None else info.Production.agent_total
if info.Production.is_return == 1: if info.Production.is_return == 1:
if cur_info['total'] <= 0: if cur_info['total'] <= 0:
if info.Production.return_hatch_no == 127: if info.Production.return_hatch_no == 127:
...@@ -60,7 +60,7 @@ class RentService(): ...@@ -60,7 +60,7 @@ class RentService():
tmp = { tmp = {
'rent_no': info.Rent.rent_no, 'rent_no': info.Rent.rent_no,
'hatch_no': info.Production.rent_hatch_no, 'hatch_no': info.Production.rent_hatch_no,
'total': 0 if info.Production.total is None else info.Production.total, 'total': 0 if info.Production.agent_total is None else info.Production.agent_total,
'status': 0 'status': 0
} }
data.append(tmp) data.append(tmp)
...@@ -80,7 +80,7 @@ class RentService(): ...@@ -80,7 +80,7 @@ class RentService():
cur_info = {} cur_info = {}
cur_info['rent_no'] = info.Rent.rent_no cur_info['rent_no'] = info.Rent.rent_no
cur_info['hatch_no'] = info.Production.rent_hatch_no cur_info['hatch_no'] = info.Production.rent_hatch_no
cur_info['total'] = 0 if info.Production.total is None else info.Production.total cur_info['total'] = 0 if info.Production.agent_total is None else info.Production.agent_total
if info.Production.is_return == 1: if info.Production.is_return == 1:
if cur_info['total'] <= 0: if cur_info['total'] <= 0:
if info.Production.return_hatch_no == 127: if info.Production.return_hatch_no == 127:
...@@ -145,8 +145,8 @@ class RentService(): ...@@ -145,8 +145,8 @@ class RentService():
def get_production_detail_new(rent_no, hatch_no): def get_production_detail_new(rent_no, hatch_no):
print('production_Detail') print('production_Detail')
sql = ''' sql = '''
SELECT rent.deposit, rent.is_over, production.is_return, production.total, production.return_hatch_no, SELECT rent.deposit, rent.is_over, production.is_return, production.agent_total as total, production.return_hatch_no,
production.rent_machine_id, rent.customer_id, rent.real_total, rent.rent_no, production.return_time, production.rent_machine_id, rent.customer_id, rent.agent_total as real_total, rent.rent_no, production.return_time,
rent.free_time, rent.one_day_price, rent.pay_time, rent.spot_id, production.is_refund, production.refund_no, rent.free_time, rent.one_day_price, rent.pay_time, rent.spot_id, production.is_refund, production.refund_no,
rent_refund.refund_no AS rent_refund_no FROM rent rent_refund.refund_no AS rent_refund_no FROM rent
LEFT JOIN production ON production.rent_id = rent.id LEFT JOIN production ON production.rent_id = rent.id
...@@ -245,7 +245,7 @@ class RentService(): ...@@ -245,7 +245,7 @@ class RentService():
@staticmethod @staticmethod
def get_search_info_(key_word, page, limit): def get_search_info_(key_word, page, limit):
sql = ''' sql = '''
SELECT rent.rent_no, rent.rent_type, rent.machine_id, rent.is_pay, rent.is_over, production.rent_hatch_no, production.total, production.is_return, SELECT rent.rent_no, rent.rent_type, rent.machine_id, rent.is_pay, rent.is_over, production.rent_hatch_no, production.agent_total as total, production.is_return,
production.return_hatch_no, customers.phone, rent.pay_time FROM rent production.return_hatch_no, customers.phone, rent.pay_time FROM rent
LEFT JOIN production ON production.rent_id = rent.id LEFT JOIN production ON production.rent_id = rent.id
LEFT JOIN customers ON customers.id = rent.customer_id LEFT JOIN customers ON customers.id = rent.customer_id
......
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