Commit f2e6bb61 by 庄冰

producttype

parent c9a8a2e4
...@@ -6,6 +6,7 @@ class NeedinfoService extends ServiceBase { ...@@ -6,6 +6,7 @@ class NeedinfoService extends ServiceBase {
constructor() { constructor() {
super("aggregation", ServiceBase.getDaoName(NeedinfoService)); super("aggregation", ServiceBase.getDaoName(NeedinfoService));
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
// this.launchchannelDao = system.getObject("dao.configmag.launchchannelDao");
} }
//推送聚合页需求至蜂擎 //推送聚合页需求至蜂擎
async pushAggregationNeedInfo2fq(ab){ async pushAggregationNeedInfo2fq(ab){
...@@ -43,7 +44,92 @@ class NeedinfoService extends ServiceBase { ...@@ -43,7 +44,92 @@ class NeedinfoService extends ServiceBase {
await this.dao.update({id:needinfo.id,push_status:2}); await this.dao.update({id:needinfo.id,push_status:2});
} }
} }
async getChannelDataStatistic(pobj){
// var channelList = await this.launchchannelDao.model.findAll
}
async getbrowsingrecordlist(obj){
try {
var queryObj={
"query": {
"bool": {
"must": [],
"must_not": [],
"should": []
}
},
"from": 0,
"size": 20,
"sort": [{
"created_date": {
"order": "desc"
}
}],
"aggs": {}
};
if(obj.channel_code){
queryObj.query.bool.must.push({
"term": {
"channel_code": obj.channel_code
}
});
}
if(obj.start_date){
var st = new Date(obj.start_date);
if(st){
st = st.getTime();
queryObj.query.bool.must.push({
"range": {
"created_date": {
"gte": st
}
}
})
}
}
if(obj.end_date){
var et = new Date(obj.end_date);
if(et){
et = et.getTime();
queryObj.query.bool.must.push({
"range": {
"created_date": {
"lte": et
}
}
})
}
}
if(obj.from){
queryObj.from=obj.from
}
if(obj.size){
queryObj.size=obj.size
}
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);
return res;
}
return null;
} catch (e) {
console.log(e)
return null;
}
}
} }
module.exports = NeedinfoService; module.exports = NeedinfoService;
\ No newline at end of file // var task = new NeedinfoService();
// var obj={
// channel_code:"iqiyi",
// start_date:"2020-09-07 08:03:08",
// end_date:"2020-09-07 08:03:08",
// from:0,
// size:100
// };
// task.getbrowsingrecordlist(obj).then(d=>{
// console.log(JSON.stringify(d),"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
// });
\ No newline at end of file
...@@ -8,6 +8,7 @@ class ProducttypeService extends ServiceBase { ...@@ -8,6 +8,7 @@ class ProducttypeService extends ServiceBase {
async create(pobj) { async create(pobj) {
let code = await this.getBusUid("mmc"); let code = await this.getBusUid("mmc");
pobj.code = code; pobj.code = code;
delete pobj.id;
if (!pobj.code) { if (!pobj.code) {
return system.getResultFail(-101, "编码不能为空"); return system.getResultFail(-101, "编码不能为空");
} }
...@@ -17,19 +18,27 @@ class ProducttypeService extends ServiceBase { ...@@ -17,19 +18,27 @@ class ProducttypeService extends ServiceBase {
if (!pobj.sequence) { if (!pobj.sequence) {
return system.getResultFail(-103, "排序不能为空"); return system.getResultFail(-103, "排序不能为空");
} }
if (!pobj.jump_link_type && !pobj.jump_link) {
return system.getResultFail(-104, "连接不能为空"); if (!pobj.name) {
}
if (pobj.name) {
return system.getResultFail(-105, "名称不能为空"); return system.getResultFail(-105, "名称不能为空");
} }
if (pobj.name && pobj.name.length > 3) { if (pobj.name && pobj.name.length > 4) {
return system.getResultFail(-106, "名称最多4位字符"); return system.getResultFail(-106, "名称最多4位字符");
} }
if(pobj.p_code){
var p_type = await this.dao.model.findOne({
where:{code:pobj.p_code,p_id:0},raw:true
});
if(!p_type){
return system.getResultFail(-300,"产品一类不存在");
}
pobj.p_id = p_type.id;
pobj.p_name = p_type.name;
}else if (!pobj.jump_link_type || !pobj.jump_link) {
return system.getResultFail(-104, "连接不能为空");
}
return system.getResultSuccess(this.dao.create(pobj)); return system.getResultSuccess(this.dao.create(pobj));
} }
async update(pobj) { async update(pobj) {
if (!pobj.pic_url) { if (!pobj.pic_url) {
return system.getResultFail(-101, "图标不能为空"); return system.getResultFail(-101, "图标不能为空");
...@@ -37,16 +46,17 @@ class ProducttypeService extends ServiceBase { ...@@ -37,16 +46,17 @@ class ProducttypeService extends ServiceBase {
if (!pobj.sequence) { if (!pobj.sequence) {
return system.getResultFail(-102, "排序不能为空"); return system.getResultFail(-102, "排序不能为空");
} }
if (!pobj.jump_link_type && !pobj.jump_link) { // if (!pobj.jump_link_type || !pobj.jump_link) {
return system.getResultFail(-104, "连接不能为空"); // return system.getResultFail(-104, "连接不能为空");
} // }
if (pobj.name) { if (!pobj.name) {
return system.getResultFail(-105, "名称不能为空"); return system.getResultFail(-105, "名称不能为空");
} }
if (pobj.name && pobj.name.length > 3) { if (pobj.name && pobj.name.length > 4) {
return system.getResultFail(-106, "名称最多4位字符"); return system.getResultFail(-106, "名称最多4位字符");
} }
return system.getResultSuccess(this.dao.update(pobj)); return system.getResultSuccess(this.dao.update(pobj));
} }
} }
module.exports = ProducttypeService; module.exports = ProducttypeService;
\ 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