Commit 549a6a39 by 兰国旗

Merge branch 'gsb-marketplat' of gitlab.gongsibao.com:jiangyong/zhichan into gsb-marketplat

parents 3b4ab9c2 ff5c30e0
...@@ -39,6 +39,9 @@ class Template extends APIBase { ...@@ -39,6 +39,9 @@ class Template extends APIBase {
case "editTemplateContent"://修改模板内容 case "editTemplateContent"://修改模板内容
opResult = await this.templateinfoSve.editTemplateContent(pobj); opResult = await this.templateinfoSve.editTemplateContent(pobj);
break; break;
// case "getLinkConfigParams"://获取模板链接配置参数
// opResult = await this.templatelinkSve.getLinkConfigParams(pobj);
// break;
// case "updateSwitchStatus"://修改模板启用状态 // case "updateSwitchStatus"://修改模板启用状态
// opResult = await this.templateinfoSve.updateSwitchStatus(pobj); // opResult = await this.templateinfoSve.updateSwitchStatus(pobj);
// break; // break;
......
const APIBase = require("../../api.base"); const APIBase = require("../../api.base");
const system = require("../../../system"); const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
var db = system.getObject("db.common.connection").getCon();
/** /**
* 用户端调用订单相关接口 * 用户端调用订单相关接口
*/ */
class Templateconfig extends APIBase { class Templateconfig extends APIBase {
constructor() { constructor() {
super(); super();
// this.templateinfoSve = system.getObject("service.template.templateinfoSve"); this.imginfoSve = system.getObject("service.configmag.imginfoSve");
this.forminfoSve = system.getObject("service.configmag.forminfoSve")
this.templateinfoSve = system.getObject("service.template.templateinfoSve.js");
// this.templatelinkSve = system.getObject("service.template.templatelinkSve"); // this.templatelinkSve = system.getObject("service.template.templatelinkSve");
} }
/** /**
...@@ -32,6 +37,19 @@ class Templateconfig extends APIBase { ...@@ -32,6 +37,19 @@ class Templateconfig extends APIBase {
case "test"://测试 case "test"://测试
opResult = system.getResultSuccess("测试接口"); opResult = system.getResultSuccess("测试接口");
break; break;
case "getImgList": // 查询图片
opResult = await this.imginfoSve.getImgList(pobj.actionBody);
break;
case "createImginfo": // 添加图片
opResult = await this.imginfoSve.createImginfo(pobj.actionBody);
break;
case "getTemplateList": // 获取模板列表
opResult = await this.templateinfoSve.getTemplateList(pobj.actionBody);
// opResult = await this.templateinfoSve.findByCompanyId(pobj.actionBody);
break;
case "getFormList": // 获取表单列表
opResult = await this.forminfoSve.getFormList(pobj.actionBody);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -14,9 +14,22 @@ class FormItemCtl extends CtlBase { ...@@ -14,9 +14,22 @@ class FormItemCtl extends CtlBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
// async create(pobj){ async create(pobj){
// let result = this.formitemSve.createItem(pobj);
// } return result;
}
/**
* 重写删除
* @param pobj
* @returns {Promise<void>}
*/
async delete(pobj){
let result = this.formitemSve.deleteItem(pobj);
return result;
}
} }
module.exports = FormItemCtl; module.exports = FormItemCtl;
...@@ -3,12 +3,18 @@ var settings = require("../../../../config/settings"); ...@@ -3,12 +3,18 @@ var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base"); const CtlBase = require("../../ctl.base");
var cacheBaseComp = null; var cacheBaseComp = null;
class FormInfoCtl extends CtlBase { class TemplateinfoCtl extends CtlBase {
constructor() { constructor() {
super("templateinfomag", CtlBase.getServiceName(FormInfoCtl)); super("templateinfomag", CtlBase.getServiceName(TemplateinfoCtl));
this.templateinfoSve = system.getObject('service.template.templateinfoSve'); this.templateinfoSve = system.getObject('service.template.templateinfoSve');
} }
/**
* 创建模板
* @param {*} pobj
*/
async createTemplate(pobj){
return this.templateinfoSve.createTemplate(pobj);
}
/** /**
* 重写查询方法 * 重写查询方法
* @param pobj * @param pobj
...@@ -25,9 +31,9 @@ class FormInfoCtl extends CtlBase { ...@@ -25,9 +31,9 @@ class FormInfoCtl extends CtlBase {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async create(pobj){ async create(pobj){
let result = await this.templateinfoSve.createTemplate(pobj); let result = await this.templateinfoSve.editTemplateTdk(pobj);
return result; return result;
} }
} }
module.exports = FormInfoCtl; module.exports = TemplateinfoCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class TemplatelinkCtl extends CtlBase {
constructor() {
super("templateinfomag", 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>}
*/
async create(pobj){
let result = await this.templatelinkSve.createTemplateLink(pobj);
return result;
}
}
module.exports = TemplatelinkCtl;
const system=require("../../../system");
const Dao=require("../../dao.base");
class ImginfoDao extends Dao{
constructor(){
super(Dao.getModelName(ImginfoDao));
}
// extraWhere(obj,w,qc,linkAttrs){
// w["company_id"]=obj.company_id;
// return w;
// }
}
module.exports=ImginfoDao;
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class LaunchchannelDao extends Dao{
constructor(){
super(Dao.getModelName(LaunchchannelDao));
}
}
module.exports=LaunchchannelDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class LaunchtypeDao extends Dao{
constructor(){
super(Dao.getModelName(LaunchtypeDao));
}
}
module.exports=LaunchtypeDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class MarketingsubjectDao extends Dao{
constructor(){
super(Dao.getModelName(MarketingsubjectDao));
}
}
module.exports=MarketingsubjectDao;
...@@ -25,10 +25,10 @@ module.exports = (db, DataTypes) => { ...@@ -25,10 +25,10 @@ module.exports = (db, DataTypes) => {
type: DataTypes.JSON type: DataTypes.JSON
}, },
is_enabled: {//显示状态 is_enabled: {//显示状态
type: DataTypes.INTEGER type: DataTypes.BOOLEAN
}, },
is_required: {//是否必填 is_required: {//是否必填
type: DataTypes.INTEGER type: DataTypes.BOOLEAN
}, },
sequence: {//次序 sequence: {//次序
type: DataTypes.INTEGER type: DataTypes.INTEGER
......
...@@ -4,38 +4,25 @@ ...@@ -4,38 +4,25 @@
* @param DataTypes * @param DataTypes
* @returns {Model|void|*} * @returns {Model|void|*}
*/ */
const record_status={"1":"未读", "2":"已读", "3":"无效"};
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("formsubmitrecord", { return db.define("formsubmitrecord", {
form_id:DataTypes.INTEGER(11),//表单id template_id: DataTypes.INTEGER(11),///模板id
template_id:DataTypes.INTEGER(11),//表单id templatelink_id: DataTypes.INTEGER(11),//模板链接id
templatelink_id:DataTypes.INTEGER(11),//表单id form_id: DataTypes.INTEGER(11),//表单id
record_status :{//记录状态 1未读 2已读 3无效 record_status: DataTypes.STRING(60),//记录状态 1未读 2已读 3无效
type: DataTypes.STRING, record_status_name: DataTypes.STRING(60),//记录状态名称
set: function (val) { templatelink_snapshot:DataTypes.JSON,//模板链接快照
this.setDataValue("record_status", val); record_content:DataTypes.JSON,//记录内容
this.setDataValue("record_status_name", record_status[val]); }, {
} paranoid: true,//假的删除
},// underscored: true,
record_status_name:DataTypes.STRING(60),//记录状态名称 version: true,
templatelink_snapshot:DataTypes.JSON, freezeTableName: true,
form_snapshot:DataTypes.JSON, timestamps: true,
record_content:DataTypes.JSON, updated_at: true,
tableName: 'c_form_submit_record',
}, { validate: {},
paranoid: true,//假的删除 indexes: []
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updated_at: true,
tableName: 'c_form_submit_record',
validate: {
},
indexes: [
]
}); });
} }
...@@ -14,6 +14,7 @@ module.exports = (db, DataTypes) => { ...@@ -14,6 +14,7 @@ module.exports = (db, DataTypes) => {
allowNull: false, allowNull: false,
type: DataTypes.STRING type: DataTypes.STRING
}, },
pic_size:DataTypes.STRING,
company_id: { company_id: {
allowNull: false, allowNull: false,
type: DataTypes.INTEGER type: DataTypes.INTEGER
......
module.exports = (sequelize, DataType) => {
return sequelize.define("marketingsubject", {
code: DataType.STRING(100),
name: DataType.STRING(100),
notes: DataType.STRING(255),
user_name: DataType.STRING(100),
user_id: DataType.STRING(100),
company_id: DataType.INTEGER,
}, {
// 不添加时间戳属性 (updatedAt, createdAt)
timestamps: true,
// 不删除数据库条目,但将新添加的属性deletedAt设置为当前日期(删除完成时)。
// paranoid 只有在启用时间戳时才能工作
paranoid: true,
// 将自动设置所有属性的字段选项为下划线命名方式。
// 不会覆盖已经定义的字段选项
underscored: true,
// 禁用修改表名; 默认情况下,sequelize将自动将所有传递的模型名称(define的第一个参数)转换为复数。 如果你不想这样,请设置以下内容
freezeTableName: true,
// 定义表的名称
tableName: 'c_marketing_subject',
// 启用乐观锁定。 启用时,sequelize将向模型添加版本计数属性,
// 并在保存过时的实例时引发OptimisticLockingError错误。
// 设置为true或具有要用于启用的属性名称的字符串。
version: true
});
};
\ No newline at end of file
...@@ -26,31 +26,19 @@ class ForminfoService extends ServiceBase { ...@@ -26,31 +26,19 @@ class ForminfoService extends ServiceBase {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async createForm(pobj){ async createForm(pobj){
console.log(pobj)
if(!pobj.name){ if(!pobj.name){
return system.getResult(null,'name can not be empty'); return system.getResult(null,'name can not be empty');
} }
if(!pobj.form_describe){ if(!pobj.form_describe){
return system.getResult(null,'form_describe can not be empty'); return system.getResult(null,'form_describe can not be empty');
} }
let items = '';
// if(!pobj.form_item){
// return 'form_item can not be empty';
// }
const formItem = this.composeItem(items);
if(formItem.status != 0){
return formItem;
}
let code = await this.getBusUid("fm") let code = await this.getBusUid("fm")
let formData = { pobj.code = code;
name:pobj.name, pobj.user_id = pobj.userid;
code:code, pobj.user_name = pobj.username;
form_describe:pobj.form_describe, let result = await this.create(pobj)
form_item:formItem.data, return system.getResult(result);
user_id:pobj.user_id,
user_name:pobj.username
}
let result = await this.create(formData);
return system.getResul(result);
} }
/** /**
* *
...@@ -58,13 +46,17 @@ class ForminfoService extends ServiceBase { ...@@ -58,13 +46,17 @@ class ForminfoService extends ServiceBase {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async updateForm(pobj) { async updateForm(pobj) {
let upData = {
return null; name:pobj.name,
form_describe: pobj.form_describe
}
let result = await this.updateByWhere(upData,{id:pobj.id})
return system.getResult(result);
} }
//表单项 数据重组 async getFormList (pobj) {
async composeItem(obj){ let res = await this.dao.findAndCountAll(pobj);
return system.getResultSuccess(); return system.getResult(res);
} }
} }
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class FormitemService extends ServiceBase {
constructor() {
super("configmag", ServiceBase.getDaoName(FormitemService));
this.forminfoSve = system.getObject("service.configmag.forminfoSve");
}
/**
* 创建表单项
* @param pobj
* @returns {Promise<void>}
*/
async createItem(pobj) {
let code = await this.getBusUid('it');
pobj.item_type_name = pobj.item_type_name;
pobj.code = code;
//获取表单的表单项
let form = await this.forminfoSve.findOne({id:pobj.form_id},['form_items']);
if(!form){
return system.getResult(null,'获取订单信息失败');
}
let form_items = form.form_items ? form.form_items + "、" + pobj.item_type_name : pobj.item_type_name;
//修改表单项字段
this.forminfoSve.updateByWhere({form_items:form_items},{id:pobj.form_id});
//保存表单项
let result = await this.create(pobj);
return system.getResult(result)
}
/**
* 表单项删除
* @param pobj
* @returns {Promise<void>}
*/
async deleteItem(pobj){
let item = await this.findOne({id:pobj.id},['form_id','item_type_name']);
if(!item){
return system.getResult(null,'获取表单项失败');
}
let form = await this.forminfoSve.findOne({id:item.form_id},['form_items']);
if(!form){
return system.getResult(null,'获取表单失败');
}
let form_items = '';
if(form.form_items){
form_items = form.form_items.replace('、'+item.item_type_name,'');
}
this.forminfoSve.updateByWhere({form_items:form_items},{id:item.form_id});
let result = await this.delete(pobj);
return system.getResult(result);
}
/**
* 修改表表单项
* @param pobj
* @returns {Promise<void>}
*/
async updateItem(pobj) {
let upResult = await this.update(pobj);
return system.getResult(upResult);
}
//根据类型获取类型名称
async getTypeName(type) {
let data = {
"phone": "手机号",
"singleBtn": "单选按钮",
"multipleBtn": "多选按钮",
"downOptions": "下拉选项",
"singleText": "单行文本",
"multipleText": "多行文本",
"dateTime": "日期",
"area": "省市"
}
return data[type];
}
}
module.exports = FormitemService;
\ No newline at end of file
...@@ -2,13 +2,13 @@ const system = require("../../../system"); ...@@ -2,13 +2,13 @@ const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
class ForminfoService extends ServiceBase { class FormsubmitrecordService extends ServiceBase {
constructor() { constructor() {
super("configmag", ServiceBase.getDaoName(ForminfoService)); super("configmag", ServiceBase.getDaoName(FormsubmitrecordService));
this.templateinfoDao = system.getObject("db.template.templateinfoDao"); this.templateinfoDao = system.getObject("db.template.templateinfoDao");
this.templatelinkDao = system.getObject("db.template.templatelinkDao"); this.templatelinkDao = system.getObject("db.template.templatelinkDao");
this.forminfoDao = system.getObject("db.form.forminfoDao"); this.forminfoDao = system.getObject("db.configmag.forminfoDao");
this.formitemDao = system.getObject("db.form.formitemDao"); this.formitemDao = system.getObject("db.configmag.formitemDao");
} }
/** /**
...@@ -129,4 +129,4 @@ class ForminfoService extends ServiceBase { ...@@ -129,4 +129,4 @@ class ForminfoService extends ServiceBase {
} }
} }
module.exports = ForminfoService; module.exports = FormsubmitrecordService;
\ No newline at end of file \ No newline at end of file
...@@ -3,9 +3,21 @@ const ServiceBase = require("../../sve.base"); ...@@ -3,9 +3,21 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
class ImginfoService extends ServiceBase { class ImginfoService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(ImginfoService)); super("configmag", ServiceBase.getDaoName(ImginfoService));
}
async getImgList (pobj) {
let res = await this.dao.findAndCountAll(pobj);
return system.getResultSuccess(res);
}
async createImginfo (pobj) {
let code = await this.getBusUid("img");
pobj.imginfo.code = code;
if (pobj.imginfo.company_id === undefined) {
pobj.imginfo.company_id = 10;
}
let res = await this.dao.create(pobj.imginfo);
return system.getResultSuccess(res);
} }
async create(pobj){ async create(pobj){
var code = await this.getBusUid("img"); var code = await this.getBusUid("img");
pobj.code = code; pobj.code = code;
......
...@@ -4,7 +4,7 @@ const settings = require("../../../../config/settings"); ...@@ -4,7 +4,7 @@ const settings = require("../../../../config/settings");
class LaunchchannelService extends ServiceBase { class LaunchchannelService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(LaunchchannelService)); super("configmag", ServiceBase.getDaoName(LaunchchannelService));
} }
/** /**
......
...@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base"); ...@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
class MaininfoService extends ServiceBase { class MaininfoService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(MaininfoService)); super("configmag", ServiceBase.getDaoName(MaininfoService));
} }
async create(pobj){ async create(pobj){
......
...@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base"); ...@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
class PuttypeService extends ServiceBase { class PuttypeService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(PuttypeService)); super("configmag", ServiceBase.getDaoName(PuttypeService));
} }
async create(pobj){ async create(pobj){
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const System = require("../../../system");
class TemplateconfigService extends ServiceBase {
constructor() {
super("template", ServiceBase.getDaoName(TemplateconfigService));
}
async findAndCountAll (obj) {
console.log(JSON.stringify(obj));
let res = await this.dao.findAndCountAll(obj);
return System.getResultSuccess(res);
}
}
module.exports = TemplateconfigService;
\ No newline at end of file
...@@ -19,14 +19,13 @@ class TemplateinfoService extends ServiceBase { ...@@ -19,14 +19,13 @@ class TemplateinfoService extends ServiceBase {
*/ */
async createTemplate(pobj){ async createTemplate(pobj){
var ab = {}; var ab = {};
var xctx = pobj.xctx;
var code = await this.getBusUid("mt");//自动生成模板编码 var code = await this.getBusUid("mt");//自动生成模板编码
var name = "营销模板";//模板名称 var name = "营销模板";//模板名称
ab.code = code; ab.code = code;
ab.name = name; ab.name = name;
ab.user_id=xctx.credid; ab.user_id=pobj.userid;
ab.user_name=xctx.username; ab.user_name=pobj.username;
ab.company_id=xctx.companyid; ab.company_id=pobj.company_id;
ab.is_enabled=0; ab.is_enabled=0;
var res = await this.create(ab); var res = await this.create(ab);
return system.getResultSuccess(res); return system.getResultSuccess(res);
...@@ -112,9 +111,8 @@ class TemplateinfoService extends ServiceBase { ...@@ -112,9 +111,8 @@ class TemplateinfoService extends ServiceBase {
* @param {*} pobj * @param {*} pobj
*/ */
async editTemplateTdk(pobj){ async editTemplateTdk(pobj){
var ab = pobj.actionBody; var ab = pobj;
var updateObj = {}; var updateObj = {};
var xctx = pobj.xctx;
if(!ab){ if(!ab){
return system.getResultFail(-100,"参数错误"); return system.getResultFail(-100,"参数错误");
} }
......
...@@ -7,8 +7,42 @@ class TemplatelinkService extends ServiceBase { ...@@ -7,8 +7,42 @@ class TemplatelinkService extends ServiceBase {
this.templateLinkUrl = settings.templateLinkUrl(); this.templateLinkUrl = settings.templateLinkUrl();
this.templateinfoDao = system.getObject("db.template.templateinfoDao"); this.templateinfoDao = system.getObject("db.template.templateinfoDao");
this.browsingrecordsDao = system.getObject("db.template.browsingrecordsDao"); this.browsingrecordsDao = system.getObject("db.template.browsingrecordsDao");
this.launchchannelDao = system.getObject("db.configmag.launchchannelDao");
this.launchtypeDao = system.getObject("db.configmag.launchtypeDao");
this.marketingsubjectDao = system.getObject("db.configmag.marketingsubjectDao");
} }
/**
* 获取模板链接配置参数
* @param {*} pobj
*/
async getLinkConfigParams(pobj){
var ab = pobj.actionBody;
var xctx = pobj.xctx;
var company_id=xctx.companyid;
var whereObj = {company_id:company_id};
//渠道主体
var launchChannelList = await this.launchchannelDao.model.findAll({
attributes:["id","code","name"],
where:whereObj,raw:true
});
//业务参数
//投放方式
var launchTypeList = await this.launchtypeDao.model.findAll({
attributes:["id","code","name"],
where:whereObj,raw:true
});
//营销主体
var marketingSubjectList = await this.marketingsubjectDao.model.findAll({
attributes:["id","code","name"],
where:whereObj,raw:true
});
var res = {launchChannelList:launchChannelList,launchTypeList:launchTypeList,marketingSubjectList:marketingSubjectList};
return system.getResultSuccess(res);
}
/**
* 链接列表
* @param {*} obj
*/
async findAndCountAll(obj){ async findAndCountAll(obj){
var res = await this.dao.findAndCountAll(obj); var res = await this.dao.findAndCountAll(obj);
return system.getResultSuccess(res); return system.getResultSuccess(res);
......
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