You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.6 KiB
45 lines
1.6 KiB
|
2 weeks ago
|
from django.db.models import Q
|
||
|
|
import datetime
|
||
|
|
from ai.models import *
|
||
|
|
from ai.utils.show_database import GetData
|
||
|
|
|
||
|
|
def get_cinema_show_result_func(_zz_code, _show_date):
|
||
|
|
cinema = TestCinema.objects.filter(zz_code=_zz_code).first()
|
||
|
|
start = datetime.datetime.strftime(datetime.datetime.strptime(_show_date, '%Y-%m-%d') + datetime.timedelta(hours=6),
|
||
|
|
'%Y-%m-%d %H:%M:%S')
|
||
|
|
end = datetime.datetime.strftime(
|
||
|
|
datetime.datetime.strptime(_show_date, '%Y-%m-%d') + datetime.timedelta(hours=29, minutes=59, seconds=59),
|
||
|
|
'%Y-%m-%d %H:%M:%S')
|
||
|
|
show = ''
|
||
|
|
income = ''
|
||
|
|
if cinema:
|
||
|
|
print(cinema)
|
||
|
|
data = GetData(cinema)
|
||
|
|
show = data.get_show_data(start, end)
|
||
|
|
income = data.get_total_income(start, end)
|
||
|
|
print(show, income)
|
||
|
|
show_db = AiShow.objects.filter(Q(is_ai_show=False) & Q(zz_code=_zz_code) & Q(show_date=_show_date)).order_by(
|
||
|
|
'-id').first()
|
||
|
|
if show_db:
|
||
|
|
print('show_db', show_db)
|
||
|
|
show_db.show = show
|
||
|
|
show_db.income = income
|
||
|
|
show_db.save()
|
||
|
|
else:
|
||
|
|
try:
|
||
|
|
AiShow.objects.create(
|
||
|
|
cinema=cinema.name,
|
||
|
|
zz_code=cinema.zz_code,
|
||
|
|
show_date=_show_date,
|
||
|
|
is_ai_show=False,
|
||
|
|
show=show,
|
||
|
|
sales=income,
|
||
|
|
prompt='',
|
||
|
|
result='',
|
||
|
|
message='',
|
||
|
|
take_times=0,
|
||
|
|
take_tokens='0'
|
||
|
|
)
|
||
|
|
except Exception as e:
|
||
|
|
print(e)
|
||
|
|
return show, income
|