Commit ef97503f by 王勇飞

Merge branch 'ic-deliver' of gitlab.gongsibao.com:jiangyong/zhichan into ic-deliver

parents f5ca7847 948f0918
...@@ -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 {
......
...@@ -128,6 +128,7 @@ class BizOptCtl extends CtlBase { ...@@ -128,6 +128,7 @@ class BizOptCtl extends CtlBase {
async insertInfo(pobj,qobj,req){ async insertInfo(pobj,qobj,req){
if (pobj.businessMode && pobj.businessMode != 'undefined' && pobj.businessType && pobj.businessType != 'undefined'){ if (pobj.businessMode && pobj.businessMode != 'undefined' && pobj.businessType && pobj.businessType != 'undefined'){
try{ try{
pobj.currentStatus = "beforeSubmission";//加上当前状态为待提交方案
await this.service.insertInfo(pobj); await this.service.insertInfo(pobj);
return system.getResult("插入成功!"); return system.getResult("插入成功!");
......
...@@ -198,8 +198,8 @@ class SchemeCtl extends CtlBase { ...@@ -198,8 +198,8 @@ class SchemeCtl extends CtlBase {
try{ try{
pobj.currentStatus = "beforeConfirmation";//同时把方案的状态也更新为待确认 pobj.currentStatus = "beforeConfirmation";//同时把方案的状态也更新为待确认
//修改方案的时候,需要把修改的方案传给商城 //修改方案的时候,需要把修改的方案传给商城
var mobj = pobj; var ttype = pobj.businessType;
mobj.businessType = appconfig.pdict.fdyDict[pobj.businessType]; pobj.businessType = appconfig.pdict.fdyDict[pobj.businessType];
var rc = system.getObject("util.execClient"); var rc = system.getObject("util.execClient");
var requrl = this.receiveUrl; var requrl = this.receiveUrl;
var params = { var params = {
...@@ -207,12 +207,13 @@ class SchemeCtl extends CtlBase { ...@@ -207,12 +207,13 @@ class SchemeCtl extends CtlBase {
"actionBody":{ "actionBody":{
"needNum": pobj.businessMode, "needNum": pobj.businessMode,
"solutionNum":pobj.schemeNumber, "solutionNum":pobj.schemeNumber,
"solutionContent": mobj "solutionContent": pobj
} }
} }
var rtn = await rc.execPost(params, requrl); var rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout); var j = JSON.parse(rtn.stdout);
if (j.status == 1){ if (j.status == 1){
pobj.businessType = ttype;
var retn = await this.service.updateInfoByDemandCode(pobj);//更新方案详情 var retn = await this.service.updateInfoByDemandCode(pobj);//更新方案详情
var bobj = {"businessMode":pobj.businessMode,"currentStatus":"beforeConfirmation"};//同时把商机状态更新回待确认 var bobj = {"businessMode":pobj.businessMode,"currentStatus":"beforeConfirmation"};//同时把商机状态更新回待确认
await this.bizoptService.updateStatusByDemandCode(bobj); await this.bizoptService.updateStatusByDemandCode(bobj);
...@@ -269,8 +270,9 @@ class SchemeCtl extends CtlBase { ...@@ -269,8 +270,9 @@ class SchemeCtl extends CtlBase {
//pobj.statusReason = businessInfo.close_reason;//状态原因 //pobj.statusReason = businessInfo.close_reason;//状态原因
} }
//调商城的接口,把商机详情返回给商城 //调商城的接口,把商机详情返回给商城
var mobj = pobj; var btype = pobj.businessType;
mobj.businessType = appconfig.pdict.fdyDict[pobj.businessType]; pobj.businessType = appconfig.pdict.fdyDict[pobj.businessType];
var rc = system.getObject("util.execClient"); var rc = system.getObject("util.execClient");
var requrl = this.receiveUrl; var requrl = this.receiveUrl;
var params = { var params = {
...@@ -278,15 +280,16 @@ class SchemeCtl extends CtlBase { ...@@ -278,15 +280,16 @@ class SchemeCtl extends CtlBase {
"actionBody":{ "actionBody":{
"needNum": pobj.businessMode, "needNum": pobj.businessMode,
"solutionNum":"", "solutionNum":"",
"solutionContent": mobj "solutionContent": pobj
} }
} }
var rtn = await rc.execPost(params, requrl); var rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout); var j = JSON.parse(rtn.stdout);
if (j.status == 1){ if (j.status == 1){
pobj.schemeNumber = j.data; pobj.schemeNumber = j.data;
await this.bizoptService.updateStatusByDemandCode(pobj);//先修改商机状态 pobj.businessType = btype;
await this.service.insertInfo(pobj); await this.service.insertInfo(pobj);
await this.bizoptService.updateStatusByDemandCode(pobj);//先修改商机状态
return system.getResult("操作成功!"); return system.getResult("操作成功!");
} }
else{ else{
...@@ -295,6 +298,7 @@ class SchemeCtl extends CtlBase { ...@@ -295,6 +298,7 @@ class SchemeCtl extends CtlBase {
} }
catch(error){ catch(error){
console.log(error);
return system.getResultError(error); return system.getResultError(error);
} }
} }
...@@ -312,9 +316,8 @@ class SchemeCtl extends CtlBase { ...@@ -312,9 +316,8 @@ class SchemeCtl extends CtlBase {
module.exports = SchemeCtl; module.exports = SchemeCtl;
// var task = new SchemeCtl(); // var task = new SchemeCtl();
// var obj={"businessMode":"202006100012","currentStatus":"beforeSubmission","baseInfo":{"memoInfo":"sfdsff","whetherType":"individual","creditCode":"1223345455","companyType":"有限公司","companyName":"三个五","establishedTime":"2010-5-6","registeredCapital":"5万元","shareholderName":"2B","businessTerm":"500","businessScope":"sgrgdrgghhh","residenceAddress":"北京市"}}; // var obj={"businessMode":"202006100002","baseInfo":{"memoInfo":"sfdsff","whetherType":"individual","creditCode":"1223345455","companyType":"有限公司","companyName":"三个五","establishedTime":"2010-5-6","registeredCapital":"5万元","shareholderName":"2B","businessTerm":"500","businessScope":"sgrgdrgghhh","residenceAddress":"北京市"}};
// task.insertInfo(obj,{},{}).then(d=>{ // task.insertInfo(obj,{},{}).then(d=>{
// console.log(d); // console.log(d);
// //console.log(d[0].analyse); // //console.log(d[0].analyse)
// }) // })
var system = require("../../../system");
const http = require("http");
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const moment = require('moment');
class StatusLogCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(StatusLogCtl));
}
/*插入缓存信息 */
async insertInfo(pobj,qobj,req){
if (pobj.flowType && pobj.flowType != 'undefined' && pobj.flowId && pobj.flowId != 'undefined'
&& pobj.statusCode && pobj.statusCode != 'undefined'){
try{
var res = await this.service.insertInfo(pobj);
return system.getResult("插入成功!");
}
catch (error){
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
}
}
timeFormat(date) {
let localTime = moment.utc(date).toDate();
localTime = moment(localTime).format("YYYY-MM-DD");
return localTime;
}
}
module.exports = StatusLogCtl;
// var task = new CacheInfoCtl();
// var obj={"demand_code":"30030302992","business_status":"isFinished"};
// task.updateStatusByDemandCode(obj,{},{}).then(d=>{
// console.log(d);
// //console.log(d[0].analyse);
// })
...@@ -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);
} }
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class StatuslogDao extends Dao {
constructor() {
super(Dao.getModelName(StatuslogDao));
}
/*插入状态信息信息*/
async insertInfo(qobj,t){
var obj = {
"flow_type":qobj.flowType,
"flow_id":qobj.flowId,
"status_code":qobj.statusCode,
};
if (qobj.statusDate && qobj.statusDate != 'undefined'){
obj["status_date"] = qobj.statusDate
}
return await this.create(obj,t);
}
}
module.exports = StatuslogDao;
...@@ -187,18 +187,23 @@ module.exports = { ...@@ -187,18 +187,23 @@ module.exports = {
}, },
"ddyDict":{//和庄冰的交付单对应关系 "ddyDict":{//和庄冰的交付单对应关系
"paid":1, "paid":1,
"received":2, "received":20,
"inservice":3, "inservice":30,
"collecting":10, "collecting":100,
"uploading":11, "uploading":110,
"checking":12, "checking":120,
"auditing":13, "auditing":130,
"engraving":14, "engraving":140,
"posting":15, "posting":150,
"signed":16, "signed":160,
"completed":17, "completed":170,
"expired":18, "expired":180,
"closed":19 "closed":190
},
"flowType":{
"BIZ": "BIZ",//商机表
"SCHEME": "SCHEME",//方案表
"DELIVERY": "DELIVERY"//服务单表
} }
} }
} }
......
...@@ -6,49 +6,38 @@ class SchemeService extends ServiceBase { ...@@ -6,49 +6,38 @@ class SchemeService extends ServiceBase {
constructor() { constructor() {
super("bizchance", ServiceBase.getDaoName(SchemeService)); super("bizchance", ServiceBase.getDaoName(SchemeService));
} }
// async findAndCountAll(obj) {
// var self = this;
// const apps = await this.dao.findAndCountAll(obj);
// return apps;
// }
/*根据id获取方案信息*/ async findById(qobj){//根据id获取方案信息
async findById(qobj){
var oid = qobj.id; var oid = qobj.id;
return await this.dao.findById(oid); return await this.dao.findById(oid);
} }
/*根据方案编号获取方案详情*/ async findInfoByDemandCode(qobj){//根据方案编号获取方案详情
async findInfoByDemandCode(qobj){
return await this.dao.findInfoByDemandCode(qobj); return await this.dao.findInfoByDemandCode(qobj);
} }
/* 根据商机编号号更新方案状态及原因 */ async updateStatusByDemandCode(qobj){//根据商机编号号更新方案状态及原因
async updateStatusByDemandCode(qobj){
var self=this; var self=this;
return self.db.transaction(async function (t) { return self.db.transaction(async function (t) {
return await self.dao.updateStatusByDemandCode(qobj,t); return await self.dao.updateStatusByDemandCode(qobj,t);
}); });
} }
/*根据商机编号更新方案详情*/ async updateInfoByDemandCode(qobj){//根据商机编号更新方案详情
async updateInfoByDemandCode(qobj){
var self = this; var self = this;
return self.db.transaction(async function (t) { return self.db.transaction(async function (t) {
return await self.dao.updateInfoByDemandCode(qobj,t); return await self.dao.updateInfoByDemandCode(qobj,t);
}); });
} }
/*根据商机编号更新方案编号*/ async updateSchemeNumberByDemandCode(qobj){//根据商机编号更新方案编号
async updateSchemeNumberByDemandCode(qobj){
var self = this; var self = this;
return self.db.transaction(async function (t) { return self.db.transaction(async function (t) {
return await self.dao.updateSchemeNumberByDemandCode(qobj,t); return await self.dao.updateSchemeNumberByDemandCode(qobj,t);
}); });
} }
/*插入方案信息*/ async insertInfo(qobj){//插入方案信息
async insertInfo(qobj){
var self = this; var self = this;
return await self.db.transaction(async function (t) { return await self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t); return await self.dao.insertInfo(qobj,t);
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class StatusLogService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(StatusLogService));
}
/*插入状态信息*/
async insertInfo(qobj){
var self=this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
});
}
}
module.exports = StatusLogService;
\ No newline at end of file
...@@ -30,7 +30,7 @@ class ExecClient { ...@@ -30,7 +30,7 @@ class ExecClient {
async execPost(subData, url) { async execPost(subData, url) {
let cmd = this.FetchPostCmd(subData, url); let cmd = this.FetchPostCmd(subData, url);
console.log("__________________" + cmd); //console.log("__________________" + cmd);
var result = await this.exec(cmd); var result = await this.exec(cmd);
return result; return result;
} }
......
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