Commit 7d6813e5 by 庄冰

needinfoSve

parent 8c1e5d04
...@@ -26,6 +26,7 @@ class Mediaaggregation extends APIBase { ...@@ -26,6 +26,7 @@ class Mediaaggregation extends APIBase {
var opResult = null; var opResult = null;
var self = this; var self = this;
pobj.xctx = req.xctx; pobj.xctx = req.xctx;
pobj.clientIp = req.clientIp;
switch (action_type) { switch (action_type) {
case "test"://测试 case "test"://测试
opResult = system.getResultSuccess("测试接口"); opResult = system.getResultSuccess("测试接口");
...@@ -33,6 +34,9 @@ class Mediaaggregation extends APIBase { ...@@ -33,6 +34,9 @@ class Mediaaggregation extends APIBase {
case "submitNeed"://提交需求/线索 case "submitNeed"://提交需求/线索
opResult = this.needinfoSve.submitNeed(pobj); opResult = this.needinfoSve.submitNeed(pobj);
break; break;
case "addbrowsingrecord"://添加页面访问记录
opResult = this.needinfoSve.addbrowsingrecord(pobj);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -7,6 +7,7 @@ class NeedinfoService extends ServiceBase { ...@@ -7,6 +7,7 @@ class NeedinfoService extends ServiceBase {
super("media", ServiceBase.getDaoName(NeedinfoService)); super("media", ServiceBase.getDaoName(NeedinfoService));
this.launchchannelDao = system.getObject("db.configmag.launchchannelDao"); this.launchchannelDao = system.getObject("db.configmag.launchchannelDao");
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
this.mediabrowsingRecordsLogUrl = settings.mediabrowsingRecordsLogUrl();
} }
//提交商机/线索 //提交商机/线索
async submitNeed(pobj){ async submitNeed(pobj){
...@@ -79,6 +80,83 @@ class NeedinfoService extends ServiceBase { ...@@ -79,6 +80,83 @@ class NeedinfoService extends ServiceBase {
console.log(e, "pushMediaNeed2Queue++++++++++++++++++++++++++++++++++++") console.log(e, "pushMediaNeed2Queue++++++++++++++++++++++++++++++++++++")
} }
} }
//添加媒体聚合页浏览记录
async addbrowsingrecord(pobj){
if(pobj && pobj.actionBody){
var addObj=pobj.actionBody ||{};
if(!addObj.channel_code){
addObj.channel_code="未知";
}
if(!addObj.channel_name){
addObj.channel_name="未知";
}
if(!addObj.platform){
addObj.platform="未知";
}
if(!addObj.equipment){
addObj.equipment="未知";
}
if(!addObj.page_code){
addObj.page_code="未知";
}
if(!addObj.page_name){
addObj.page_name="未知";
}
var myDate = new Date();
addObj["created_year"] = myDate.getFullYear();
addObj["created_month"] =myDate.getMonth()+1;
addObj["created_day"] =myDate.getDate();
addObj["created_date"]=myDate.getTime();
if(pobj.clientIp){
addObj.clientIp= pobj.clientIp;
var list = await this.getbrowsingrecordlist(pobj.clientIp,myDate.getTime());
if(list && list.length>=60){
addObj.is_warning=1;
}
}
var res = await this.execClient.execPostEs(addObj, this.mediabrowsingRecordsLogUrl);
}
return system.getResultSuccess();
}
async getbrowsingrecordlist(ip,time){
time = time - 60*1000;
var queryObj={
"query": {
"bool": {
"must": [
{
"term": {
"clientIp": ip
}
},
{
"range": {
"created_date": {
"gte": time
}
}
}
],
"must_not": [],
"should": []
}
},
"from": 0,
"size": 60,
"sort": [],
"aggs": {}
};
var res = await this.execClient.execPostEs(queryObj, "http://43.247.184.94:7200/marketmedia_browsingrecords_log/_search");
if(res && res.stdout){
res = JSON.parse(res.stdout);
if(res.hits && res.hits.hits){
return res.hits.hits;
}
}
return null;
}
} }
module.exports = NeedinfoService; module.exports = NeedinfoService;
\ No newline at end of file
...@@ -31,9 +31,12 @@ var settings = { ...@@ -31,9 +31,12 @@ var settings = {
return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"; return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard";
} }
}, },
browsingRecordsLogUrl: function () { browsingRecordsLogUrl: function () {//落地页访问记录
return "http://43.247.184.94:7200/marketplat_browsingrecords_log/_doc?pretty"; return "http://43.247.184.94:7200/marketplat_browsingrecords_log/_doc?pretty";
}, },
mediabrowsingRecordsLogUrl: function () {//媒体聚合页访问记录
return "http://43.247.184.94:7200/marketmedia_browsingrecords_log/_doc?pretty";
},
templateLinkUrl: function () { templateLinkUrl: function () {
if (this.env == "dev") { if (this.env == "dev") {
return "http://192.168.200.208:8081/tfhref"; return "http://192.168.200.208:8081/tfhref";
......
No preview for this file type
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