Merge branch 'master' of http://git.kingsome.cn/ops/promotion
This commit is contained in:
commit
8d66d7e254
@ -29,7 +29,7 @@ def send_cache_data():
|
|||||||
all = []
|
all = []
|
||||||
# 添加无天数限定的记录
|
# 添加无天数限定的记录
|
||||||
get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort," \
|
get_full_data = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,a.ad_sort," \
|
||||||
f"a.companyid,a.gameid,a.jump_status,b.area,b.type,b.mode from ad a,location b where \
|
f"a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a,location b where \
|
||||||
a.locationid=b.id AND begin_time='{BEGIN}' or end_time='{END}'"""
|
a.locationid=b.id AND begin_time='{BEGIN}' or end_time='{END}'"""
|
||||||
full_data = mydb.query(get_full_data)
|
full_data = mydb.query(get_full_data)
|
||||||
|
|
||||||
@ -40,15 +40,15 @@ def send_cache_data():
|
|||||||
item = {}
|
item = {}
|
||||||
try:
|
try:
|
||||||
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[
|
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[
|
||||||
'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['jump_status'], item[
|
'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[
|
||||||
'area'], item['type'], item['mode'] = line
|
'jump_status'], item['area'], item['type'], item['mode'], item['locationid'] = line
|
||||||
all.append(item)
|
all.append(item)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error("split data failed", exc_info=True)
|
log.error("split data failed", exc_info=True)
|
||||||
|
|
||||||
# 添加有天数限定的记录
|
# 添加有天数限定的记录
|
||||||
get_data_sql = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,\
|
get_data_sql = f"""select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.jump_param,\
|
||||||
a.ad_sort,a.companyid,a.gameid,a.jump_status,b.area,b.type,b.mode from ad a ,location b \
|
a.ad_sort,a.companyid,a.gameid,a.channelid,a.jump_status,b.area,b.type,b.mode,b.id from ad a ,location b \
|
||||||
where'{now}'>a.begin_time and '{now}'<a.end_time and a.locationid=b.id ;"""
|
where'{now}'>a.begin_time and '{now}'<a.end_time and a.locationid=b.id ;"""
|
||||||
|
|
||||||
data = mydb.query(get_data_sql)
|
data = mydb.query(get_data_sql)
|
||||||
@ -58,7 +58,8 @@ def send_cache_data():
|
|||||||
item = {}
|
item = {}
|
||||||
try:
|
try:
|
||||||
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[
|
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[
|
||||||
'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['jump_status'],item['area'],item['type'],item['mode'] = line
|
'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[
|
||||||
|
'jump_status'], item['area'], item['type'], item['mode'], item['locationid'] = line
|
||||||
all.append(item)
|
all.append(item)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error("split data failed", exc_info=True)
|
log.error("split data failed", exc_info=True)
|
||||||
@ -66,7 +67,8 @@ def send_cache_data():
|
|||||||
if all:
|
if all:
|
||||||
# log.info(f"get data was {all}!\n")
|
# log.info(f"get data was {all}!\n")
|
||||||
for line in all:
|
for line in all:
|
||||||
key = f"ad::{line.get('gameid', 0)}::{line.get('locationid', 0)}"
|
key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{line.get('area').split(',')[0]}\
|
||||||
|
::{line.get('locationid', 0)}"
|
||||||
|
|
||||||
if int(line['ad_num']) > 0:
|
if int(line['ad_num']) > 0:
|
||||||
num = my_redis.get(f"ad::{line['id']}::num")
|
num = my_redis.get(f"ad::{line['id']}::num")
|
||||||
|
@ -24,6 +24,7 @@ log = logging.getLogger(__name__)
|
|||||||
parser = reqparse.RequestParser()
|
parser = reqparse.RequestParser()
|
||||||
parser.add_argument('id')
|
parser.add_argument('id')
|
||||||
parser.add_argument('gameid')
|
parser.add_argument('gameid')
|
||||||
|
parser.add_argument('channelid')
|
||||||
parser.add_argument('name')
|
parser.add_argument('name')
|
||||||
parser.add_argument('locationid')
|
parser.add_argument('locationid')
|
||||||
parser.add_argument('begin_time')
|
parser.add_argument('begin_time')
|
||||||
@ -55,16 +56,16 @@ class Ad(Resource):
|
|||||||
if not id:
|
if not id:
|
||||||
if companyid:
|
if companyid:
|
||||||
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \
|
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \
|
||||||
f"status,companyid,locationid,gameid,jump_status from ad where companyid={companyid};"
|
f"status,companyid,locationid,gameid,channelid,jump_status from ad where companyid={companyid};"
|
||||||
elif status or status == 0:
|
elif status or status == 0:
|
||||||
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \
|
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \
|
||||||
f"status,companyid,locationid,gameid,jump_status from ad where status={status};"
|
f"status,companyid,locationid,gameid,channelid,jump_status from ad where status={status};"
|
||||||
else:
|
else:
|
||||||
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \
|
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \
|
||||||
f"status,companyid,locationid,gameid,jump_status from ad ;"
|
f"status,companyid,locationid,gameid,channelid,jump_status from ad ;"
|
||||||
else:
|
else:
|
||||||
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \
|
sel_sql = f"select id,name,begin_time,end_time,ad_num,ad_title,ad_body,ad_image,jump_param,ad_sort," \
|
||||||
f"status,companyid,locationid,gameid,jump_status from ad where id={id};"
|
f"status,companyid,locationid,gameid,channelid,jump_status from ad where id={id};"
|
||||||
data = self.mydb.query(sel_sql)
|
data = self.mydb.query(sel_sql)
|
||||||
log.info(f"sql={sel_sql},data={data}")
|
log.info(f"sql={sel_sql},data={data}")
|
||||||
if data:
|
if data:
|
||||||
@ -75,7 +76,7 @@ class Ad(Resource):
|
|||||||
ad_info['id'], ad_info['name'], ad_info['begin_time'], ad_info['end_time'], ad_info['ad_num'], \
|
ad_info['id'], ad_info['name'], ad_info['begin_time'], ad_info['end_time'], ad_info['ad_num'], \
|
||||||
ad_info['ad_title'], ad_info['ad_body'], ad_info['ad_image'], ad_info['jump_param'], ad_info[
|
ad_info['ad_title'], ad_info['ad_body'], ad_info['ad_image'], ad_info['jump_param'], ad_info[
|
||||||
'ad_sort'], ad_info['status'], ad_info['companyid'], ad_info['locationid'], ad_info[
|
'ad_sort'], ad_info['status'], ad_info['companyid'], ad_info['locationid'], ad_info[
|
||||||
'gameid'],ad_info['jump_status'] = line
|
'gameid'],ad_info['channelid'],ad_info['jump_status'] = line
|
||||||
all.append(ad_info)
|
all.append(ad_info)
|
||||||
return jsonify({'code': 200, 'message': all})
|
return jsonify({'code': 200, 'message': all})
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -90,6 +91,7 @@ class Ad(Resource):
|
|||||||
ad['id'] = id
|
ad['id'] = id
|
||||||
ad['name'] = self.args['name']
|
ad['name'] = self.args['name']
|
||||||
ad['gameid'] = self.args['gameid']
|
ad['gameid'] = self.args['gameid']
|
||||||
|
ad['channelid'] = self.args['channelid']
|
||||||
ad['locationid'] = self.args['locationid']
|
ad['locationid'] = self.args['locationid']
|
||||||
ad['begin_time'] = self.args['begin_time'] or '1999-01-01'
|
ad['begin_time'] = self.args['begin_time'] or '1999-01-01'
|
||||||
ad['end_time'] = self.args['end_time'] or '3000-01-01'
|
ad['end_time'] = self.args['end_time'] or '3000-01-01'
|
||||||
@ -140,6 +142,7 @@ class Ad(Resource):
|
|||||||
ad['id'] = self.args['id']
|
ad['id'] = self.args['id']
|
||||||
ad['name'] = self.args['name']
|
ad['name'] = self.args['name']
|
||||||
ad['gameid'] = self.args['gameid']
|
ad['gameid'] = self.args['gameid']
|
||||||
|
ad['channelid'] = self.args['channelid']
|
||||||
ad['locationid'] = self.args['locationid']
|
ad['locationid'] = self.args['locationid']
|
||||||
ad['begin_time'] = self.args['begin_time'] or '1999-01-01'
|
ad['begin_time'] = self.args['begin_time'] or '1999-01-01'
|
||||||
ad['end_time'] = self.args['end_time'] or '3000-01-01'
|
ad['end_time'] = self.args['end_time'] or '3000-01-01'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user