Commit c942cfb0 by 庄冰

埋点

parent ec8b67df
...@@ -8,6 +8,7 @@ class Template extends APIBase { ...@@ -8,6 +8,7 @@ class Template extends APIBase {
constructor() { constructor() {
super(); super();
this.templateinfoSve = system.getObject("service.template.templateinfoSve"); this.templateinfoSve = system.getObject("service.template.templateinfoSve");
this.templatelinkSve = system.getObject("service.template.templatelinkSve");
} }
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
...@@ -25,6 +26,7 @@ class Template extends APIBase { ...@@ -25,6 +26,7 @@ class Template extends APIBase {
async opActionProcess(pobj, action_type, req) { async opActionProcess(pobj, action_type, req) {
var opResult = null; var opResult = null;
var self = this; var self = this;
pobj.clientIp = req.clientIp;
pobj.xctx = req.xctx; pobj.xctx = req.xctx;
switch (action_type) { switch (action_type) {
case "test"://测试 case "test"://测试
...@@ -49,6 +51,9 @@ class Template extends APIBase { ...@@ -49,6 +51,9 @@ class Template extends APIBase {
case "editTemplateTdk"://编辑模板TDK case "editTemplateTdk"://编辑模板TDK
opResult = await this.templateinfoSve.editTemplateTdk(pobj); opResult = await this.templateinfoSve.editTemplateTdk(pobj);
break; break;
case "getTemplateAndLinkInfo"://根据链接参数获取模板链接信息
opResult = await this.templatelinkSve.getTemplateAndLinkInfo(pobj);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class BrowsingrecordsDao extends Dao{
constructor(){
super(Dao.getModelName(BrowsingrecordsDao));
}
}
module.exports=BrowsingrecordsDao;
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
/**
* 模板信息表
*/
module.exports = (db, DataTypes) => {
return db.define("browsingrecords", {
template_id: DataTypes.INTEGER,
link_code: DataTypes.STRING,
link_name: DataTypes.STRING,
else_channel_param:DataTypes.STRING,
channel_name: DataTypes.STRING,
channel_code: DataTypes.STRING,
business_type_code: DataTypes.STRING,
business_type_name: DataTypes.STRING,
lauch_type_code: DataTypes.STRING,
lauch_type_name: DataTypes.STRING,
marketing_subject_code: DataTypes.STRING,
marketing_subject_name: DataTypes.STRING,
device: DataTypes.STRING,
client_ip: DataTypes.STRING
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'b_browsing_records',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
...@@ -16,7 +16,7 @@ module.exports = (db, DataTypes) => { ...@@ -16,7 +16,7 @@ module.exports = (db, DataTypes) => {
// business_type_id: DataTypes.INTEGER, // business_type_id: DataTypes.INTEGER,
// lauch_type_id: DataTypes.INTEGER, // lauch_type_id: DataTypes.INTEGER,
// marketing_subject_id: DataTypes.INTEGER, // marketing_subject_id: DataTypes.INTEGER,
template_name: DataTypes.STRING, // template_name: DataTypes.STRING,
channel_name: DataTypes.STRING, channel_name: DataTypes.STRING,
business_type_name: DataTypes.STRING, business_type_name: DataTypes.STRING,
lauch_type_name: DataTypes.STRING, lauch_type_name: DataTypes.STRING,
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class BrowsingrecordsService extends ServiceBase {
constructor() {
super("template", ServiceBase.getDaoName(BrowsingrecordsService));
}
}
module.exports = BrowsingrecordsService;
\ No newline at end of file
...@@ -146,5 +146,6 @@ class TemplateinfoService extends ServiceBase { ...@@ -146,5 +146,6 @@ class TemplateinfoService extends ServiceBase {
return system.getResultSuccess(); return system.getResultSuccess();
} }
} }
module.exports = TemplateinfoService; module.exports = TemplateinfoService;
\ No newline at end of file
...@@ -5,6 +5,8 @@ class TemplatelinkService extends ServiceBase { ...@@ -5,6 +5,8 @@ class TemplatelinkService extends ServiceBase {
constructor() { constructor() {
super("template", ServiceBase.getDaoName(TemplatelinkService)); super("template", ServiceBase.getDaoName(TemplatelinkService));
this.templateLinkUrl = settings.templateLinkUrl(); this.templateLinkUrl = settings.templateLinkUrl();
this.templateinfoDao = system.getObject("db.template.templateinfoDao");
this.browsingrecordsDao = system.getObject("db.template.browsingrecordsDao");
} }
async findAndCountAll(obj){ async findAndCountAll(obj){
...@@ -214,5 +216,78 @@ class TemplatelinkService extends ServiceBase { ...@@ -214,5 +216,78 @@ class TemplatelinkService extends ServiceBase {
await this.dao.delete({id:linkinfo.id}); await this.dao.delete({id:linkinfo.id});
return system.getResultSuccess(); return system.getResultSuccess();
} }
/**
* 根据链接参数获取模板链接信息
* @param {*} pobj
*/
async getTemplateAndLinkInfo(pobj){
var ab = pobj.actionBody;
var xctx = pobj.xctx;
if(!ab){
return system.getResultFail(-100,"参数错误");
}
if(!ab.channel_code){
return system.getResultFail(-101,"渠道主体编码不能为空");
}
if(!ab.business_type_code){
return system.getResultFail(-102,"业务类型编码不能为空");
}
if(!ab.lauch_type_code){
return system.getResultFail(-103,"投放方式编码不能为空");
}
if(!ab.marketing_subject_code){
return system.getResultFail(-104,"营销主体编码不能为空");
}
if(!ab.else_channel_param){
return system.getResultFail(-110,"其它渠道参数不能为空");
}
if(!ab.template_id){
return system.getResultFail(-111,"模板参数不能为空");
}
if(!ab.device){
return system.getResultFail(-112,"投放终端参数不能为空");
}
var linkObj = {
template_id:ab.template_id,channel_code:ab.channel_code,else_channel_param:ab.else_channel_param,
business_type_code:ab.business_type_code,lauch_type_code:ab.lauch_type_code,
marketing_subject_code:ab.marketing_subject_code
};
//获取链接数据
var linkinfo = await this.dao.model.findOne({
where:linkObj,raw:true
});
if(!linkinfo || !linkinfo.id){
return system.getResultFail(-300,"未知链接");
}
if(!linkinfo.is_enabled || linkinfo.is_enabled!==1){
return system.getResultFail(-301,"无效链接,该链接未投放");
}
var tempObj={id:ab.template_id};
var templateinfo = await this.templateinfoDao.model.findOne({
where:tempObj,raw:true
});
if(!templateinfo || !templateinfo.id){
return system.getResultFail(-400,"未知模板");
}
if(!templateinfo.is_enabled || templateinfo.is_enabled!==1){
return system.getResultFail(-401,"无效模板,该模板未启用");
}
var resultObj = {
templateinfo:templateinfo,linkinfo:linkinfo
};
var addObj = {
...ab,
link_code:linkinfo.code,link_name:linkinfo.name,
channel_name:linkinfo.channel_name,business_type_name:linkinfo.business_type_name,
lauch_type_name:linkinfo.lauch_type_name,marketing_subject_name:linkinfo.marketing_subject_name,
client_ip:pobj.clientIp
};
this.browsingrecordsDao.create(addObj);//添加链接浏览记录
return system.getResultSuccess(resultObj);
}
} }
module.exports = TemplatelinkService; module.exports = TemplatelinkService;
\ 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