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 = []
|
||||
# 添加无天数限定的记录
|
||||
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}'"""
|
||||
full_data = mydb.query(get_full_data)
|
||||
|
||||
@ -40,15 +40,15 @@ def send_cache_data():
|
||||
item = {}
|
||||
try:
|
||||
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)
|
||||
except Exception:
|
||||
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,\
|
||||
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 ;"""
|
||||
|
||||
data = mydb.query(get_data_sql)
|
||||
@ -58,7 +58,8 @@ def send_cache_data():
|
||||
item = {}
|
||||
try:
|
||||
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)
|
||||
except Exception:
|
||||
log.error("split data failed", exc_info=True)
|
||||
@ -66,7 +67,8 @@ def send_cache_data():
|
||||
if all:
|
||||
# log.info(f"get data was {all}!\n")
|
||||
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:
|
||||
num = my_redis.get(f"ad::{line['id']}::num")
|
||||
|
@ -24,6 +24,7 @@ log = logging.getLogger(__name__)
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument('id')
|
||||
parser.add_argument('gameid')
|
||||
parser.add_argument('channelid')
|
||||
parser.add_argument('name')
|
||||
parser.add_argument('locationid')
|
||||
parser.add_argument('begin_time')
|
||||
@ -55,16 +56,16 @@ class Ad(Resource):
|
||||
if not id:
|
||||
if companyid:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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)
|
||||
log.info(f"sql={sel_sql},data={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['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[
|
||||
'gameid'],ad_info['jump_status'] = line
|
||||
'gameid'],ad_info['channelid'],ad_info['jump_status'] = line
|
||||
all.append(ad_info)
|
||||
return jsonify({'code': 200, 'message': all})
|
||||
except Exception:
|
||||
@ -90,6 +91,7 @@ class Ad(Resource):
|
||||
ad['id'] = id
|
||||
ad['name'] = self.args['name']
|
||||
ad['gameid'] = self.args['gameid']
|
||||
ad['channelid'] = self.args['channelid']
|
||||
ad['locationid'] = self.args['locationid']
|
||||
ad['begin_time'] = self.args['begin_time'] or '1999-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['name'] = self.args['name']
|
||||
ad['gameid'] = self.args['gameid']
|
||||
ad['channelid'] = self.args['channelid']
|
||||
ad['locationid'] = self.args['locationid']
|
||||
ad['begin_time'] = self.args['begin_time'] or '1999-01-01'
|
||||
ad['end_time'] = self.args['end_time'] or '3000-01-01'
|
||||
|
Loading…
x
Reference in New Issue
Block a user