Commit cced2960 by 庄冰

template

parent 79298d8e
......@@ -5,7 +5,7 @@ var cacheBaseComp = null;
class TemplateinfoCtl extends CtlBase {
constructor() {
super("templateinfomag", CtlBase.getServiceName(TemplateinfoCtl));
super("template", CtlBase.getServiceName(TemplateinfoCtl));
this.templateinfoSve = system.getObject('service.template.templateinfoSve');
}
/**
......
......@@ -5,21 +5,11 @@ var cacheBaseComp = null;
class TemplatelinkCtl extends CtlBase {
constructor() {
super("templateinfomag", CtlBase.getServiceName(TemplatelinkCtl));
super("template", CtlBase.getServiceName(TemplatelinkCtl));
this.templatelinkSve = system.getObject('service.template.templatelinkSve');
}
/**
* 重写查询方法
* @param pobj
* @returns {Promise<{msg: string, data: *, bizmsg: string, status: number}>}
*/
async findAndCountAll(pobj) {
let result = await this.templatelinkSve.findAndCountAll(pobj);
return result;
}
/**
* 重写保存方法
* @param pobj
* @returns {Promise<void>}
......@@ -34,7 +24,8 @@ class TemplatelinkCtl extends CtlBase {
* @param {*} pobj
*/
async updateLaunchStatus(pobj){
let result = await this.templatelinkSve.updateLaunchStatus(pobj);
var a=9;
var result = await this.service.updateLaunchStatus(pobj);
return result;
}
......
......@@ -48,7 +48,7 @@ class TemplatelinkService extends ServiceBase {
return system.getResultFail(-101,"模板id不能为空");
}
var res = await this.dao.findAndCountAll(obj);
return system.getResultSuccess(res);
return res;
}
/**
* 校验封装参数
......@@ -56,18 +56,23 @@ class TemplatelinkService extends ServiceBase {
* @param {*} xctx
*/
async checkAndPackageParams(ab,xctx){
var codeParams={};
if(!ab.channel_code){
return system.getResultFail(-101,"渠道主体编码不能为空");
}
codeParams.channel_code = ab.channel_code;
if(!ab.business_type_code){
return system.getResultFail(-102,"业务类型编码不能为空");
}
codeParams.business_type_code = ab.business_type_code;
if(!ab.lauch_type_code){
return system.getResultFail(-103,"投放方式编码不能为空");
}
codeParams.lauch_type_code = ab.lauch_type_code;
if(!ab.marketing_subject_code){
return system.getResultFail(-104,"营销主体编码不能为空");
}
codeParams.marketing_subject_code = ab.marketing_subject_code;
if(!ab.channel_name){
return system.getResultFail(-105,"渠道主体名称不能为空");
}
......@@ -92,6 +97,10 @@ class TemplatelinkService extends ServiceBase {
if(!ab.name){
return system.getResultFail(-112,"任务名称不能为空");
}
var checkCodeRes = await this.checkLinkCodeParams(codeParams);
if(checkCodeRes && checkCodeRes.status && checkCodeRes.status<0){
return checkCodeRes;
}
if(!ab.code){//新增
ab.code = await this.getBusUid("tl");
ab.user_id=ab.userid;
......@@ -218,12 +227,24 @@ class TemplatelinkService extends ServiceBase {
if(ab.is_enabled!==0 && ab.is_enabled!==1){
return system.getResultFail(-103,"投放状态参数错误");
}
var linkinfo = await this.dao.model.findOne({
where:{code:ab.code},raw:true
});
if(!linkinfo || !linkinfo.id){
return system.getResultFail(-300,"未知链接");
}
if(ab.is_enabled===1){
var checkLinkCodeParamsObj={
channel_code:linkinfo.channel_code,
lauch_type_code:linkinfo.lauch_type_code,
marketing_subject_code:linkinfo.marketing_subject_code
};
var checkLinkCodeParamsRes = await this.checkLinkCodeParams(checkLinkCodeParamsObj);
if(checkLinkCodeParamsRes && checkLinkCodeParamsRes.status && checkLinkCodeParamsRes.status<0){
return checkLinkCodeParamsRes;
}
}
await this.dao.update({id:linkinfo.id,is_enabled:ab.is_enabled});
return system.getResultSuccess();
}
......@@ -324,5 +345,32 @@ class TemplatelinkService extends ServiceBase {
return system.getResultSuccess(resultObj);
}
//校验链接编码参数
async checkLinkCodeParams(obj){
var channelinfo = await this.launchchannelDao.model.findOne({
attributes:["id"],
where:{code:obj.channel_code},raw:true
});
if(!channelinfo || !channelinfo.id){
return system.getResultFail(-120,"操作失败,渠道不存在或已被修改");
}
var lauchtype = await this.launchtypeDao.model.findOne({
attributes:["id"],
where:{code:obj.lauch_type_code},raw:true
});
if(!lauchtype || !lauchtype.id){
return system.getResultFail(-121,"操作失败,投放类型不存在或已被修改");
}
var marketingsubject = await this.marketingsubjectDao.model.findOne({
attributes:["id"],
where:{code:obj.marketing_subject_code},raw:true
});
if(!marketingsubject || !marketingsubject.id){
return system.getResultFail(-121,"操作失败,投放主体不存在或已被修改");
}
return system.getResultSuccess();
}
}
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