diff --git a/ad_Readme.md b/ad_Readme.md new file mode 100644 index 0000000..6f7557c --- /dev/null +++ b/ad_Readme.md @@ -0,0 +1,97 @@ +#### 1、返回广告列表信息 + +##### 接口地址 + +http://ad.kingsome.cn/webapp/index.php + +##### 返回格式:json + +##### 请求方式:get + +##### 请求示范 + +http://ad.kingsome.cn/webapp/index.php?c=Ops&a=getAdList&body={"gameid":"1003:6001","locationid":1001} + +##### 请求参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ---- | ---- | ---------------------------------- | +| c | string | 是 | OPS通用接口标志 | +| a | string | 是 | 方法定义 当前为getAdList | +| body | string | 是 | 参数体,JSON格式,gameid,locationid作为key | + +##### 返回参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | -------- | +| errcode | int | 是 | 返回状态 | +| errmsg | string | 是 | 错误信息 | +| ad_title | string | 是 | 广告标题 | +| ad_body | string | 是 | 广告正文 | +| ad_image | string | 是 | 广告图片 | +| ad_sort | int | 是 | 播放优先级 | +| adid | int | 是 | 广告标志ID,用途数据上传统计 | +| name | string | 是 | 广告名称 | +| jump_status | int | 是 | 跳转状态,1=跳转,0=不跳 | +| jump_param | string | 是 | 跳转参数 | + + +##### 返回示例 +{ + "errcode": 0, + "errmsg": "", + "message": { + "totoal": 3, + "result": [ + { + "ad_body": "2", + "ad_image": "https://resource.kingsome.cn//ad/0e04000e-a865-11e9-a181-525400ddcafb_512icon(1)(1).png", + "ad_num": "40", + "ad_sort": "0", + "ad_title": "2", + "ad_url": "sdfd", + "companyid": "1002", + "gameid": "1004", + "adid": "1010", + "locationid": "1001", + "name": "22" + }, + +#### 2、广告播放上报 + +##### 接口地址 + +http://ad.kingsome.cn/webapp/index.php + +##### 返回格式:json + +##### 请求方式:get + +##### 请求示范 + +http://ad.kingsome.cn/webapp/index.php?c=Ops&a=upAdRecording&adid=1009 + +##### 请求参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ---- | ---- | ---------------------------------- | +| c | string | 是 | OPS通用接口标志 | +| a | string | 是 | 方法定义 upAdRecording | +| adid | int | 是 | 广告ID | + +##### 返回参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | -------- | +| errcode | int | 是 | 返回状态 | +| errmsg | string | 是 | 错误信息 | +| message | string | 是 | 返回信息 | + + + +##### 返回示例 +{ + "errcode": 0, + "errmsg": "", + "message": "1002 incr success!" +} \ No newline at end of file diff --git a/ad_interface_tornado.py b/ad_interface_tornado.py index 31baa48..4394877 100644 --- a/ad_interface_tornado.py +++ b/ad_interface_tornado.py @@ -28,7 +28,7 @@ def send_cache_data(): now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") all = [] # 添加无天数限定的记录 - get_full_data = f"select a.id,a.name,a.ad_num,a.ad_title,a.ad_body,a.ad_image,a.ad_url,a.ad_sort,a.companyid,a.locationid,a.gameid,b.appid from ad a,company b where a.companyid=b.id and a.begin_time='{BEGIN}' or a.end_time='{END}'" + 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,a.companyid,a.locationid,a.gameid,b.appid from ad a,company b where a.companyid=b.id and a.begin_time='{BEGIN}' or a.end_time='{END}'" full_data = mydb.query(get_full_data) if full_data: @@ -38,14 +38,14 @@ def send_cache_data(): item = {} try: item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[ - 'ad_url'], item['ad_sort'], item['companyid'], item['locationid'], item['gameid'], item[ + 'jump_param'], item['ad_sort'], item['companyid'], item['locationid'], item['gameid'], item[ 'appid'] = 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.ad_url,a.ad_sort,a.companyid,a.locationid,a.gameid,b.appid from ad a,company b where a.companyid=b.id and '{now}'>a.begin_time and '{now}'a.begin_time and '{now}'