Commit 8c9daf58 by 蒋勇

d

parent 6bdb1220
...@@ -53,6 +53,12 @@ class CtlBase { ...@@ -53,6 +53,12 @@ class CtlBase {
opath: req.headers['xopath'], opath: req.headers['xopath'],
ptags: req.headers['xptags'], ptags: req.headers['xptags'],
} }
//添加组织结构路径,如果是上级,取上级
if(req.xctx.ptags && req.xctx.ptags!=""){
pobj.opath=req.xctx.ptags
}else{
pobj.opath=req.xctx.opath
}
if (!req.xctx.appkey) { if (!req.xctx.appkey) {
return [-200, "请求头缺少应用x-app-key"] return [-200, "请求头缺少应用x-app-key"]
} else { } else {
......
...@@ -7,81 +7,95 @@ class BizoptDao extends Dao { ...@@ -7,81 +7,95 @@ class BizoptDao extends Dao {
extraWhere(qobj, qw, qc) {//根据业务员id获取商机信息的组装条件 extraWhere(qobj, qw, qc) {//根据业务员id获取商机信息的组装条件
qc.raw = true; qc.raw = true;
qc.where.business_type = qc.where.business_type || { //检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
[this.db.Op.notIn]: ["ICP", "EDI"] if (qobj.company_id == 1) {
} return qw
if(qobj.bizpath && qobj.bizpath!=""){ } else {
if(qobj.bizpath.indexOf("myChance")>0){//说明是从商机列表过来的 //需要添加公司查询条件
qw["salesman_id"]=qobj.userid; qw["facilitator_id"] = Number(qobj.company_id)
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != "") {
qw["salesman_opcode"] = qobj.opath
} }
} //不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
qc.where.business_type = qc.where.business_type || {
[this.db.Op.notIn]: ["ICP", "EDI"]
}
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("myChance") > 0) {//说明是从商机列表过来的
qw["salesman_id"] = qobj.userid;
}
}
}
}
return qw; return qw;
} }
/*根据商机编号获取商机详情*/ /*根据商机编号获取商机详情*/
async findInfoByDemandCode(qobj){ async findInfoByDemandCode(qobj) {
var qcwhere = {"demand_code":qobj.businessMode}; var qcwhere = { "demand_code": qobj.businessMode };
return await this.findOne(qcwhere); return await this.findOne(qcwhere);
} }
/*更新商机状态*/ /*更新商机状态*/
async updateStatusByDemandCode(qobj,t){ async updateStatusByDemandCode(qobj, t) {
var setobj = {"business_status":qobj.currentStatus}; var setobj = { "business_status": qobj.currentStatus };
if (qobj.statusReason && qobj.statusReason != 'undefined'){ if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj["close_reason"] = qobj.statusReason; setobj["close_reason"] = qobj.statusReason;
} }
var whereobj = {"demand_code":qobj.businessMode}; var whereobj = { "demand_code": qobj.businessMode };
return await this.updateByWhere(setobj,whereobj,t); return await this.updateByWhere(setobj, whereobj, t);
} }
/*插入商机信息*/ /*插入商机信息*/
async insertInfo(qobj,t){ async insertInfo(qobj, t) {
var obj = { var obj = {
"demand_code":qobj.businessMode, "demand_code": qobj.businessMode,
"business_type":qobj.businessType, "business_type": qobj.businessType,
"business_status":"beforeSubmission" "business_status": "beforeSubmission"
}; };
if (qobj.channelSource && qobj.channelSource != 'undefined'){ if (qobj.channelSource && qobj.channelSource != 'undefined') {
obj.source_name = qobj.channelSource; obj.source_name = qobj.channelSource;
} }
if (qobj.sourceNumber && qobj.sourceNumber != 'undefined'){ if (qobj.sourceNumber && qobj.sourceNumber != 'undefined') {
obj.source_number = qobj.sourceNumber; obj.source_number = qobj.sourceNumber;
} }
if (qobj.serviceCode && qobj.serviceCode != 'undefined'){ if (qobj.serviceCode && qobj.serviceCode != 'undefined') {
obj.service_address = qobj.serviceCode; obj.service_address = qobj.serviceCode;
} }
if (qobj.memoInfo && qobj.memoInfo != 'undefined'){ if (qobj.memoInfo && qobj.memoInfo != 'undefined') {
obj.business_info.memoInfo = qobj.memoInfo; obj.business_info.memoInfo = qobj.memoInfo;
} }
if (qobj.statusReason && qobj.statusReason != 'undefined'){ if (qobj.statusReason && qobj.statusReason != 'undefined') {
obj.close_reason = qobj.statusReason; obj.close_reason = qobj.statusReason;
} }
if (qobj.contactsName && qobj.contactsName != 'undefined'){ if (qobj.contactsName && qobj.contactsName != 'undefined') {
obj.business_info.contactsName = qobj.contactsName; obj.business_info.contactsName = qobj.contactsName;
} }
if (qobj.contactsPhone && qobj.contactsPhone != 'undefined'){ if (qobj.contactsPhone && qobj.contactsPhone != 'undefined') {
obj.business_info.contactsPhone = qobj.contactsPhone; obj.business_info.contactsPhone = qobj.contactsPhone;
} }
if (qobj.servicerCode && qobj.servicerCode != 'undefined'){ if (qobj.servicerCode && qobj.servicerCode != 'undefined') {
obj.facilitator_id = qobj.servicerCode; obj.facilitator_id = qobj.servicerCode;
} }
if (qobj.servicerName && qobj.servicerName != 'undefined'){ if (qobj.servicerName && qobj.servicerName != 'undefined') {
obj.facilitator_name = qobj.servicerName; obj.facilitator_name = qobj.servicerName;
} }
if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined'){ if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') {
obj.salesman_opcode = qobj.salesmanOpcode; obj.salesman_opcode = qobj.salesmanOpcode;
} }
if (qobj.salesmanId && qobj.salesmanId != 'undefined'){ if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
obj.salesman_id = qobj.salesmanId; obj.salesman_id = qobj.salesmanId;
} }
if (qobj.clerkName && qobj.clerkName != 'undefined'){ if (qobj.clerkName && qobj.clerkName != 'undefined') {
obj.salesman_name = qobj.clerkName; obj.salesman_name = qobj.clerkName;
} }
if (qobj.clerkPhone && qobj.clerkPhone != 'undefined'){ if (qobj.clerkPhone && qobj.clerkPhone != 'undefined') {
obj.salesman_phone = qobj.salesman_phone; obj.salesman_phone = qobj.salesman_phone;
} }
return await this.create(obj,t); return await this.create(obj, t);
} }
......
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