Commit 1270fe0d by Aeolus

新增转化率查询接口

parent 3c2f578d
......@@ -92,3 +92,6 @@ TAKEOUT_TOOL_TIPS_PHONE = [
'15279120691',
'13870952089'
]
# 挪出订单的景区对应编号
move_spot_ids = {16: 50, 42: 51, 48: 49}
......@@ -3,10 +3,12 @@ import datetime
from flask import Blueprint, jsonify, request, g
from Config.common_config import move_spot_ids
from Libs.ErrorTips import BASE_RESPONSE, OPERATE_LEVEL_ERROR
from Libs.Helper import Helper
from Model.Base import db
from Model.Customer.CustomerModel import Customer
from Model.Garden.GardenModels import DayVisitorCountModel
from Model.Machine.MachineModel import Machine
from Model.Production.ProductionModel import Production
from Service.ReportService import ReportService
......@@ -163,7 +165,6 @@ def get_machine_rent_number():
for info in machine_info:
machines[str(info.id)] = [str(info.mac_no)[-3:], 0]
move_spot_ids = {16: 50, 42: 51, 48: 49}
sql_spot_id = spot_id
while True:
sql = """
......@@ -191,3 +192,33 @@ def get_machine_rent_number():
data = list(machines.values())
return jsonify(
{'error_code': 200, 'error_message': 'Success', 'data': data})
@route_report.route('/spot_visitor_user_number', methods=['GET', 'POST'])
def get_spot_visitor_user_number():
print(g.user)
if g.user.status != 1 or g.user.level != 1:
return jsonify(OPERATE_LEVEL_ERROR)
json_data = request.get_json()
spot_id = int(json_data['spot_id']) if 'spot_id' in json_data else 0
query_date = json_data.get('query_date', datetime.datetime.now().strftime("%Y-%m-%d"))
sql = "SELECT count(1) as number FROM production WHERE"
if move_spot_ids.get(spot_id, None):
sql += " (spot_id = '{}' or spot_id = '{}') ".format(spot_id, move_spot_ids[spot_id])
else:
sql += " spot_id = '{}' ".format(spot_id)
sql += "and DATE_FORMAT(created_at, '%Y-%m-%d')='{}' and total>0 ".format(query_date)
result = db.session.execute(sql).fetchone()
if result:
user_num = result.number
else:
user_num = 0
visitor_num = 0
result = DayVisitorCountModel.query.filter_by(spot_id=spot_id, today=query_date).first()
if result:
visitor_num = result.left_num
return_data = [user_num, visitor_num]
return jsonify({'error_code': 200, 'error_message': 'Success', 'data': return_data})
# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from Model.Base import db, BaseModel
Base = declarative_base()
metadata = Base.metadata
class DaySaleCountModel(BaseModel):
__tablename__ = 'day_sale_count'
id = Column(Integer, primary_key=True, comment="")
check_sum = Column(Integer, nullable=False, comment="预约上限人数")
total_sum = Column(Integer, nullable=False, comment="已预约人数")
week_check_sum = Column(Integer, nullable=False, comment="=本周预约人数")
lastweek_check_sum = Column(Integer, nullable=False, comment="上周预约人数")
today = Column(db.DateTime, nullable=False, comment="数据日期")
class DayBookCountModel(BaseModel):
__tablename__ = 'day_book_count'
id = Column(Integer, primary_key=True)
spot_id = Column(Integer, nullable=False)
spot_name = Column(String(40, 'utf8mb4_unicode_ci'), nullable=False)
fixed_total_num = Column(Integer, nullable=False, comment="预约上限人数")
fixed_usable_num = Column(Integer, nullable=False, comment="预约人数")
individual_limit = Column(Integer, nullable=False, comment="")
team_total_num = Column(Integer, nullable=False, comment="")
team_usable_num = Column(Integer, nullable=False, comment="")
total_num = Column(Integer, nullable=False, comment="预约上限人数")
usable_num = Column(Integer, nullable=False, comment="可预约人数")
today = Column(db.DateTime, nullable=False, comment="数据日期")
class DayVisitorCountModel(BaseModel):
__tablename__ = 'day_visitor_count'
id = Column(Integer, primary_key=True, comment="")
spot_id = Column(Integer, nullable=False, comment="")
spot_name = Column(String(40, 'utf8mb4_unicode_ci'), nullable=False, comment="")
foot_num = Column(Integer, nullable=False, comment="在园人数")
foreigner_num = Column(Integer, nullable=False, comment="")
free_num = Column(Integer, nullable=False, comment="")
left_num = Column(Integer, nullable=False, comment="已入园人数")
limit_num = Column(Integer, nullable=False, comment="当日人数上限")
old_num = Column(Integer, nullable=False, comment="")
total_num = Column(Integer, nullable=False, comment="当日售票人数")
today = Column(db.DateTime, nullable=False, comment="数据日期")
class DaySZMuseumVisitorCountModel(BaseModel):
__tablename__ = 'day_sz_museum_visitor_count'
id = Column(Integer, primary_key=True, comment="")
spot_id = Column(Integer, nullable=False, comment="")
spot_name = Column(String(40, 'utf8mb4_unicode_ci'), nullable=False, comment="")
total_count = Column(Integer, nullable=False, comment="总接待数")
current_count = Column(Integer, nullable=False, comment="在园人数")
incount1 = Column(Integer, nullable=False, comment="")
incount2 = Column(Integer, nullable=False, comment="")
outcount1 = Column(Integer, nullable=False, comment="")
outcount2 = Column(Integer, nullable=False, comment="出园人数")
today = Column(db.DateTime, nullable=False, comment="数据日期")
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