Commit 9043de60 by Aeolus

update

parent 0dcc9fc3
......@@ -369,7 +369,8 @@ def run_day_bill():
end_date = json_data.get("endDate", None)
now = datetime.datetime.now().date()
select_sql = " SELECT sum(real_total) as real_total, bill_date "
select_sql = """ select SUM(tab1.real_total) AS real_total, tab1.bill_date, ifnull(draw_record.status,-2) as draw_status,
ifnull(draw_record.real_total,0) as drawed_total """
count_sql = " select count(1) as total_count"
from_sql = """
FROM
......@@ -392,17 +393,17 @@ def run_day_bill():
GROUP BY DATE_FORMAT(rent.created_at, '%Y-%m-%d') , rent.business_id) AS tab1
""".format(now.strftime("%Y-%m-%d %H:%M:%S"), g.user.id)
where_sql = """
where real_total > '0'
left join draw_record on draw_record.bill_date = tab1.bill_date and draw_record.status != -1
where tab1.real_total > '0'
"""
if start_date is not None:
where_sql += " and bill_date >= '{}'".format(start_date)
where_sql += " and tab1.bill_date >= '{}'".format(start_date)
if end_date is not None:
where_sql += " and bill_date <= '{}'".format(end_date)
where_sql += " and tab1.bill_date <= '{}'".format(end_date)
group_sql = """group by tab1.bill_date """
order_sql = " ORDER BY tab1.bill_date DESC "
limit_sql = " LIMIT {offset} , {page_size}".format(offset=(page - 1) * page_size, page_size=page_size)
print(count_sql + from_sql + where_sql + group_sql)
count_result = db.session.execute(count_sql + from_sql + where_sql).fetchone()
if not count_result:
......@@ -410,14 +411,15 @@ def run_day_bill():
else:
total_count = count_result.total_count
print(select_sql + from_sql + where_sql + group_sql + order_sql + limit_sql)
result = db.session.execute(select_sql + from_sql + where_sql + group_sql + order_sql + limit_sql).fetchall()
return_data = []
if result:
for info in result:
tmp = {
"real_total": int(info.real_total), "bill_date": info.bill_date, "total": float(info.real_total)
"real_total": int(info.real_total), "bill_date": info.bill_date, "total": float(info.real_total),
"draw_status": info.draw_status,
"drawed_total": info.drawed_total,
}
return_data.append(tmp)
......
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