Commit 1f0745c1 authored by 吴贤德's avatar 吴贤德

中心接口:增量媒资列表接口、增量媒资推送接口改造(修复多表联查问题),增加媒资拉取日志

中心服务:增加媒拉取日子记录
parent fbb7fcd5
......@@ -44,4 +44,3 @@ func (this *WasuChecker) check() {
}
}
......@@ -31,10 +31,12 @@ type Media struct {
Spid string `json:"spid"`
PushMode string `json:"push_mode"` //是否自动转推:0手动,1自动
JsonUrl string `json:"jsonUrl"`
//Md5 string `json:"md5"`
//NewsId string `json:"newsId"`
//NewsName string `json:"newsName"`
//PlayUrl string `json:"playUrl"`
NewsId string `json:"newsId"`
NewsName string `json:"newsName"`
NodeId string `json:"nodeId"`
NodeName string `json:"nodeName"`
// Md5 string `json:"md5"`
// PlayUrl string `json:"playUrl"`
}
type MediaList struct {
......@@ -116,7 +118,9 @@ func (this *MediaListModel) UpdateMedia(media *Media) bool {
b := false
if ok {
inData, _ := json.Marshal(media)
//fmt.Printf("****** media_info : %v",media)
data, err := Request.Post(center_api_media_update.(string), *(*string)(unsafe.Pointer(&inData)))
//data, err := Request.Post(center_api_media_update.(string), string(inData))
if err == nil {
if data == "true" {
b = true
......
......@@ -39,7 +39,7 @@ func (this *SpModel) pull() {
mediaModel.Config = this.Config
mediaModel.Spid = this.Spid
date := DateTime.Format("YYYYMMDD", time.Now())
//date:="20190627"
//date:="20190901"
mediaList := mediaModel.FetchList(date, 1)
ok := mediaModel.UpdateMediaList(mediaList)
if !ok {
......@@ -59,3 +59,5 @@ func (this *SpModel) pull() {
}
}
}
......@@ -5,3 +5,7 @@ log_path = ./
log_filename = center_service.log
[release]
api_conf_sys = http://api.hotel.wasu.tv/api/center/conf_sys #系统配置接口
api_conf_sps = http://api.hotel.wasu.tv/api/center/conf_sps #合作方配置接口
log_path = ./
log_filename = center_service.log
\ No newline at end of file
......@@ -50,10 +50,14 @@ class CenterAction extends Action
/*
* 媒资实时下线接口(华数经纬cms调用,下线媒资,同时需要下线所有酒店片库中相应媒资)
* GET /api/center/media_offline?spid=1&mid=33431345
* GET /api/center/media_offline?spid=1&mid=33431345&sw_time=1523345555&sw_sign=xxxxxx
* 参数说明:
* spid : 合作方标识(我们提供,每个合作方标识不一样)
* mid : 媒资标识代码(经纬cms中的媒资id)
* sw_time : 请求时间戳
* sw_sign : 请求签名 md5(uri+key) 如:
* uri :/api/center/media_offline?spid=1&mid=33431345&sw_time=1523345555
* key : 我们提供(每个spid对应不同的key)
* 返回说明:
* {"code":0,"msg":"ok"}
* code : 0-成功,1001-传入的媒资参数有问题,2001-下线失败
......@@ -105,10 +109,10 @@ class CenterAction extends Action
public function media_update(){
$rawData = @file_get_contents("php://input");
//echo $rawData."\n";
$json = json_decode($rawData,true);
$spid=$json["spid"];
$pushMode = $json["push_mode"]; //
$url = $json["jsonUrl"];
$inputJson = json_decode($rawData,true);
$spid=$inputJson["spid"];
$pushMode = $inputJson["push_mode"]; //
$url = $inputJson["jsonUrl"];
$content = file_get_contents($url);
$json = json_decode($content,true);
......@@ -132,6 +136,7 @@ class CenterAction extends Action
$data["programType"]=$json["programType"];
$data["nodeId"]=intval($json["nodeId"]);
$data["sp_id"]=intval($spid);
$data["nodeName"]=$this->null2str($json["nodeName"]);
$model = D("Media");
$where["code"]=$data["code"];
......@@ -139,6 +144,7 @@ class CenterAction extends Action
$tmp = $model->field("id")->where($where)->find();
$id= $tmp["id"];
// var_dump($tmp);exit;
$code=0;
if($id){
$data['id'] = $id;
$data["updatetime"]=date('Y-m-d H:i:s');
......@@ -148,22 +154,40 @@ class CenterAction extends Action
echo 'true';
}else{
echo 'false';
$code=1001;
}
}else{
$id = $model->add($data);
$data["id"]=$id;
if($id){
echo 'true';
$b=true;
}else{
echo 'false';
$code=1002;
}
}
if ($pushMode=="1") {
$this->media_auto_push($data);
}
if ($code){ //更新媒资失败: 记录拉取失败日志
$this->log_pull_failture($code,$inputJson);
}
exit;
}
function log_pull_failture($code,&$json){
$data["sp_id"]=intval($json["spid"]);
$data["push_mode"]=intval($json["push_mode"]);
$data["jsonUrl"]=$json["jsonUrl"];
$data["newsId"]=$json["newsId"];
$data["newsName"]=$json["newsName"];
$data["nodeId"]=$json["nodeId"];
$data["nodeName"]=$json["nodeName"];
$data["code"]=$code;
D("PullLog")->add($data);
}
function null2str($str){
if (is_null($str)){
$str="";
......@@ -234,11 +258,17 @@ class CenterAction extends Action
}
$page_num = ceil($total/$page_size);
$limit_from = ($page-1)*$page_size;
// $sql = "SELECT mw.code id,mw.title,mw.description,mw.programType,mw.url_pic picUrl"
// . ",mw.year,mw.type,mw.score,mw.region,mw.actor,mw.director"
// . ",hm.hotel_id hotelId,hm.status,hm.status_inject statusInject"
// . " FROM (SELECT media_id,hotel_id,status,status_inject FROM sh_hotel_media_map_$spid"
// . " WHERE updatetime BETWEEN '$start' AND '$end' ORDER BY updatetime,media_id ASC LIMIT $limit_from,$page_size) hm"
// . " JOIN sh_media_wasu mw ON mw.id=hm.media_id";
$sql = "SELECT mw.code id,mw.title,mw.description,mw.programType,mw.url_pic picUrl"
. ",mw.year,mw.type,mw.score,mw.region,mw.actor,mw.director"
. ",hm.hotel_id hotelId,hm.status,hm.status_inject statusInject"
. " FROM (SELECT media_id,hotel_id,status,status_inject FROM sh_hotel_media_map_$spid"
. " WHERE updatetime BETWEEN'$start' AND '$end' ORDER BY updatetime,media_id ASC LIMIT $limit_from,$page_size) hm"
. ",hm.code hotelId,hm.status,hm.status_inject statusInject"
. " FROM (SELECT hm.media_id,h.code,hm.status,hm.status_inject FROM sh_hotel_media_map_$spid hm,sh_hotel h"
. " WHERE hm.updatetime BETWEEN '$start' AND '$end' AND h.id=hm.hotel_id ORDER BY hm.updatetime,hm.media_id ASC LIMIT $limit_from,$page_size) hm"
. " JOIN sh_media_wasu mw ON mw.id=hm.media_id";
// echo $sql;exit;
......@@ -330,11 +360,10 @@ class CenterAction extends Action
$limit_from = ($page - 1) * $page_size;
$sql = "SELECT mw.code id,mw.title,mw.description,mw.programType,mw.url_pic picUrl"
. ",mw.year,mw.type,mw.score,mw.region,mw.actor,mw.director"
. ",h.code hotelId,hm.status,hm.status_inject statusInject"
. " FROM (SELECT media_id,hotel_id,status,status_inject FROM sh_hotel_media_map_$spid"
. " WHERE updatetime BETWEEN'$start' AND '$end' ORDER BY updatetime,media_id ASC LIMIT $limit_from,$page_size) hm"
. " JOIN sh_media_wasu mw ON mw.id=hm.media_id"
. " JOIN sh_hotel h ON h.id=hm.hotel_id";
. ",hm.code hotelId,hm.status,hm.status_inject statusInject"
. " FROM (SELECT hm.media_id,h.code,hm.status,hm.status_inject FROM sh_hotel_media_map_$spid hm,sh_hotel h"
. " WHERE hm.updatetime BETWEEN '$start' AND '$end' AND h.id=hm.hotel_id ORDER BY hm.updatetime,hm.media_id ASC LIMIT $limit_from,$page_size) hm"
. " JOIN sh_media_wasu mw ON mw.id=hm.media_id";
// echo $sql;exit;
$list = M("")->query($sql);//获取增量媒资列表
......@@ -381,7 +410,7 @@ class CenterAction extends Action
$log["req_json"]=$rawData;
$log["resp_json"]=$data;
$log["code"]=$result["code"];
D("LogPush")->add($log);
D("PushLog")->add($log);
}
echo json_encode($result);
exit;
......
<?php
class PullLogModel extends RelationModel{
protected $tableName = 'sh_log_pull'; //重新定义表名
}
\ No newline at end of file
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