Commit 45909203 by Aeolus

Merge remote-tracking branch 'origin/dev_agent'

parents 5580332d fa88a9b2
...@@ -183,6 +183,7 @@ def rent_refund(): ...@@ -183,6 +183,7 @@ def rent_refund():
try: try:
rent.total = rent.total + total rent.total = rent.total + total
rent.real_total = rent.real_total + total rent.real_total = rent.real_total + total
rent.agent_total = rent.agent_total + total
rent.is_over = 1 rent.is_over = 1
rent.over_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') rent.over_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
rent.back_money = rent.back_money + refund_money rent.back_money = rent.back_money + refund_money
...@@ -192,6 +193,7 @@ def rent_refund(): ...@@ -192,6 +193,7 @@ def rent_refund():
production.return_machine_id = production_info.Machine.id production.return_machine_id = production_info.Machine.id
production.return_time = back_time production.return_time = back_time
production.total = total production.total = total
production.agent_total = total
production.is_refund = 1 production.is_refund = 1
production.refund_no = refund_no production.refund_no = refund_no
if refund_type == '1': if refund_type == '1':
...@@ -304,8 +306,10 @@ def rent_money_refund(): ...@@ -304,8 +306,10 @@ def rent_money_refund():
rent_total = rent_info.Rent.total - rent_info.Production.total rent_total = rent_info.Rent.total - rent_info.Production.total
rent_real_total = rent_info.Rent.real_total - real_single_refund rent_real_total = rent_info.Rent.real_total - real_single_refund
rent_agent_total = rent_info.Rent.agent_total - real_single_refund
rent_info.Rent.total = rent_total if rent_total > 0 else 0 rent_info.Rent.total = rent_total if rent_total > 0 else 0
rent_info.Rent.real_total = rent_real_total if rent_real_total > 0 else 0 rent_info.Rent.real_total = rent_real_total if rent_real_total > 0 else 0
rent_info.Rent.agent_total = rent_agent_total if rent_agent_total > 0 else 0
data = { data = {
"out_refund_no": rent_refund_no, "out_refund_no": rent_refund_no,
...@@ -325,6 +329,7 @@ def rent_money_refund(): ...@@ -325,6 +329,7 @@ def rent_money_refund():
rent_refund.updated_at = datetime.datetime.now() rent_refund.updated_at = datetime.datetime.now()
rent_info.Production.total = 0 rent_info.Production.total = 0
rent_info.Production.agent_total = 0
db.session.add(rent_refund) db.session.add(rent_refund)
db.session.add(rent_info.Rent) db.session.add(rent_info.Rent)
...@@ -412,6 +417,7 @@ def force_refund(): ...@@ -412,6 +417,7 @@ def force_refund():
try: try:
rent.total = rent.deposit - int(money) rent.total = rent.deposit - int(money)
rent.real_total = rent.deposit - int(money) rent.real_total = rent.deposit - int(money)
rent.agent_total = rent.deposit - int(money)
rent.is_over = 1 rent.is_over = 1
rent.over_time = back_time rent.over_time = back_time
rent.back_money += int(money) rent.back_money += int(money)
...@@ -420,6 +426,7 @@ def force_refund(): ...@@ -420,6 +426,7 @@ def force_refund():
production.return_machine_id = production.rent_machine_id production.return_machine_id = production.rent_machine_id
production.return_time = back_time production.return_time = back_time
production.total = rent.deposit - int(money) production.total = rent.deposit - int(money)
production.agent_total = rent.deposit - int(money)
production.is_refund = 1 production.is_refund = 1
production.refund_no = rent_refund_no production.refund_no = rent_refund_no
production.return_hatch_no = production.rent_hatch_no production.return_hatch_no = production.rent_hatch_no
...@@ -506,6 +513,7 @@ def rent_money_liuyuan(): ...@@ -506,6 +513,7 @@ def rent_money_liuyuan():
try: try:
rent_info.Rent.total -= int(money) rent_info.Rent.total -= int(money)
rent_info.Rent.real_total -= int(money) rent_info.Rent.real_total -= int(money)
rent_info.Rent.agent_total -= int(money)
rent_info.Rent.back_money += int(money) rent_info.Rent.back_money += int(money)
# rent_refund_log = RentRefund() # rent_refund_log = RentRefund()
...@@ -517,6 +525,7 @@ def rent_money_liuyuan(): ...@@ -517,6 +525,7 @@ def rent_money_liuyuan():
# rent_refund_log.updated_at = datetime.datetime.now() # rent_refund_log.updated_at = datetime.datetime.now()
rent_info.Production.total -= int(money) rent_info.Production.total -= int(money)
rent_info.Production.agent_total -= int(money)
# db.session.add(rent_refund_log) # db.session.add(rent_refund_log)
db.session.add(rent_info.Rent) db.session.add(rent_info.Rent)
......
...@@ -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