Commit 8963aa90 by sxy

feat: 复购商机init

parent 47a96597
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class FgbusinesschanceAPI extends APIBase {
constructor() {
super();
this.orderinfoSve = system.getObject("service.dbcorder.fgbusinesschanceSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "create": //创建复购商机
opResult = await this.orderinfoSve.create(pobj, pobj.actionBody);
break;
case "getInfo": //获取商机
opResult = await this.orderinfoSve.getInfo(pobj, pobj.actionBody);
break;
case "updateStatus": //更新商机跟进状态 TODO
opResult = await this.orderinfoSve.findByBusinessId(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = FgbusinesschanceAPI;
\ No newline at end of file
...@@ -201,6 +201,22 @@ class Dao { ...@@ -201,6 +201,22 @@ class Dao {
return this.db.query(sql, tmpParas); return this.db.query(sql, tmpParas);
} }
async customInsert(sql, paras, t) {
var tmpParas = null;
if (t && t != 'undefined') {
if (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.UPDATE };
tmpParas.transaction = t;
} else {
tmpParas = { replacements: paras, type: this.db.QueryTypes.INSERT };
tmpParas.transaction = t;
}
} else {
tmpParas = paras == null || paras == 'undefined' ? { type: this.db.QueryTypes.INSERT } : { replacements: paras, type: this.db.QueryTypes.INSERT };
}
return this.db.query(sql, tmpParas);
}
async findCount(whereObj = null) { async findCount(whereObj = null) {
return this.model.count(whereObj, { logging: false }).then(c => { return this.model.count(whereObj, { logging: false }).then(c => {
return c; return c;
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
const ServiceBase = require("../../sve.base");
const uuidv4 = require('uuid/v4');
class FgbusinesschancService extends ServiceBase {
constructor() {
super("dbcorder", "orderinfoDao");
}
//var sql = "select * from c_delivery_official_flow where sourceOrderNo IN(:sourceOrderNo)";
// var paramWhere = { sourceOrderNo: actionBody.sourceOrderNoList };
// var list = await this.customQuery(sql, paramWhere);
// putOrderDelivery(data, orderNo) {//修改交付信息
// var sql = "UPDATE `c_order_delivery` SET deliveryContent ='" + JSON.stringify(data) + "' where sourceOrderNo='" + orderNo + "'";
// sql = sql.replace('\n', '');
// this.customQuery(sql);
// }
async create(req, actionBody) {
var sql = "INSERT INTO `fg_businesschance` (`companyId` ,`companyName`,`businessId`,`status`,`stateName`,`created_at`,`collectContent` ) VALUE (:companyId,:companyName,:businessId,:status,:stateName,:created_at,:collectContent)";
await this.customInsert(sql, {
...actionBody,
"created_at": new Date()
});
return system.getResultSuccess();
};
async getInfo(req, actionBody) {
let sql = "select * from `fg_businesschance` where businessId=:businessId";
var result = system.getResultSuccess();
result.data = await this.customQuery(sql, {
businessId: actionBody.businessId
});
return result
};
async updateStatus(req, actionBody) {
var sql = "UPDATE `fg_businesschance` SET status=:status, stateName=:stateName where businessId=:businessId";
await this.customUpdate(sql, actionBody);
return system.getResultSuccess();
}
}
module.exports = FgbusinesschancService;
\ No newline at end of file
...@@ -5,7 +5,7 @@ const md5 = require("MD5"); ...@@ -5,7 +5,7 @@ const md5 = require("MD5");
class ServiceBase { class ServiceBase {
constructor(gname, daoName) { constructor(gname, daoName) {
this.db = system.getObject("db.common.connection").getCon(); this.db = system.getObject("db.common.connection").getCon();
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.daoName = daoName; this.daoName = daoName;
this.dao = system.getObject("db." + gname + "." + daoName); this.dao = system.getObject("db." + gname + "." + daoName);
this.restS = system.getObject("util.restClient"); this.restS = system.getObject("util.restClient");
...@@ -169,6 +169,12 @@ class ServiceBase { ...@@ -169,6 +169,12 @@ class ServiceBase {
async customQuery(sql, paras, t) { async customQuery(sql, paras, t) {
return this.dao.customQuery(sql, paras, t); return this.dao.customQuery(sql, paras, t);
} }
async customInsert(sql, paras, t) {
return this.dao.customInsert(sql, paras, t);
}
async customUpdate(sql, paras, t) {
return this.dao.customUpdate(sql, paras, t);
}
async findCount(whereObj = null) { async findCount(whereObj = null) {
return this.dao.findCount(whereObj); return this.dao.findCount(whereObj);
} }
...@@ -224,6 +230,6 @@ class ServiceBase { ...@@ -224,6 +230,6 @@ class ServiceBase {
} }
} }
return uuid.join(''); return uuid.join('');
} }
} }
module.exports = ServiceBase; module.exports = ServiceBase;
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"description": "h5framework", "description": "h5framework",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"dev": "nodemon main.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "jy", "author": "jy",
...@@ -56,4 +57,4 @@ ...@@ -56,4 +57,4 @@
"element-theme": "^2.0.1", "element-theme": "^2.0.1",
"element-theme-chalk": "^2.4.0" "element-theme-chalk": "^2.4.0"
} }
} }
\ 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