Commit cde66511 by 兰国旗

laolan

parents cc3dbefa 5b0be7e1
......@@ -3,14 +3,14 @@ const system = require("../../../system");
const moment = require('moment');
const ServiceBase = require("../../sve.base");
class RegCenterOrderService extends ServiceBase {
constructor() {
constructor() {
super("reg", ServiceBase.getDaoName(RegCenterOrderService));
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.orderdeliveryDao = system.getObject("db.dbcorder.orderdeliveryDao");
this.db = system.getObject("db.common.connection").getCon()
//工商注册状态
this.regSolutionStatus = {
'RECEIVED': '已接单',//
......@@ -30,8 +30,8 @@ class RegCenterOrderService extends ServiceBase {
'SUCCESS': 705 //已完成
}
}
//----------2.
async submitRegNeed(pobj, actionBody, req) {
//提交需求
async submitRegNeed(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
if (!actionBody.intentionBizId) {
return system.getResultFail(-5001, "intentionBizId不能为空");
......@@ -58,21 +58,20 @@ class RegCenterOrderService extends ServiceBase {
// disposeNotes: actionBody.ext,
typeCode: actionBody.type_code,
typeName: actionBody.type_name,
channelTypeCode: actionBody.channel_type_code,
channelTypeName: actionBody.channel_type_name,
channelTypeCode: actionBody.channel_type_code || "",
channelTypeName: actionBody.channel_type_name || "",
status: "wts",
level: actionBody.level || "",
probability: actionBody.probability || "",
notes: actionBody.notes
notes: actionBody.notes || ""
}
if (nobj.channelTypeCode == "GSREG") {
nobj.province = nobj.city,
nobj.city = "";
if (nobj.channelTypeCode == 7 || nobj.channelTypeCode == 5) {
nobj.province = nobj.city, nobj.city = "";
}
var needInfo = await this.dao.create(nobj);
return system.getResultSuccess(needInfo);
}
//添加业务员信息,用于直接下单的reg订单
async addRegSalesmanInfo(pobj) {
var ab = pobj.actionBody;
......@@ -88,23 +87,23 @@ class RegCenterOrderService extends ServiceBase {
return system.getResultFail(-102, "未知方案");
}
var solutionContent = ns.solutionContent;
solutionContent.salesmanInfo=salesmanObj;
var updateObj = {id:ns.id,solutionContent:JSON.stringify(solutionContent)}
solutionContent.salesmanInfo = salesmanObj;
var updateObj = { id: ns.id, solutionContent: JSON.stringify(solutionContent) }
await this.needsolutionDao.update(updateObj);//方案状态修改
return system.getResultSuccess(solutionContent);
}
//渠道方案号获取需求详情
async getItemByChannelSolutionNo(pobj) {
var i = 0;
var bizIdLength = pobj.actionBody.length;
var bizIdList = [];
for(i=0;i<=bizIdLength;i++){
for (i = 0; i <= bizIdLength; i++) {
bizIdList.push(pobj.actionBody[i].bizId)
}
bizIdListStr = bizIdList.join(",");
// var solutionitem = await this.needsolutionDao.findOne({ channelSolutionNo: pobj.actionBody.bizId });
var sql = "select * from n_need_solution where channelSolutionNo in ("+ bizIdListStr + ")";
var sql = "select * from n_need_solution where channelSolutionNo in (" + bizIdListStr + ")";
var solutionitem = await this.customQuery(sql);
if (solutionitem.length < 1) {
return system.getResult(null, "方案数据为空,30210");
......@@ -113,15 +112,15 @@ class RegCenterOrderService extends ServiceBase {
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
item.solutionProvince = solutionitem[0].solutionContent.solution.Area || solutionitem[0].solutionContent.solution.area ;
item.solutionProvince = solutionitem[0].solutionContent.solution.Area || solutionitem[0].solutionContent.solution.area;
item.solutionContent = solutionitem[0].solutionContent
item.channelSolutionNo = solutionitem[0].channelSolutionNo
return system.getResultSuccess(item);
}
//接收渠道方案状态变更通知
async regOrderStatus(pobj) {
//接收渠道方案状态变更通知
async regOrderStatus(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
......@@ -129,7 +128,7 @@ class RegCenterOrderService extends ServiceBase {
if (!ab.status) {
return system.getResultFail(-102, "方案状态不能为空");
}
if(ab.isDirectBuy && ab.isDirectBuy==1 && ab.status==1){//直接下单,无方案 直接返回
if (ab.isDirectBuy && ab.isDirectBuy == 1 && ab.status == 1) {//直接下单,无方案 直接返回
return system.getResultSuccess();
}
//获取方案信息
......@@ -160,11 +159,11 @@ class RegCenterOrderService extends ServiceBase {
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.status == "1") {//⽤户已支付
var afterStatusList=[//用户支付后的流程状态
var afterStatusList = [//用户支付后的流程状态
"USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED",
"MATERIAL_SUBMITTED","GXB_ACCEPT","GXB_REFUSE","GXB_FAIL","GXB_SUCCESS","CLOSE"
"MATERIAL_SUBMITTED", "GXB_ACCEPT", "GXB_REFUSE", "GXB_FAIL", "GXB_SUCCESS", "CLOSE"
];
if(!solutionContent.status || afterStatusList.indexOf(solutionContent.status)<0){
if (!solutionContent.status || afterStatusList.indexOf(solutionContent.status) < 0) {
solutionFlowList.push({
status: "PAID", statusName: this.icpSolutionStatusReference.PAID, updated_at: new Date()
});
......@@ -337,8 +336,6 @@ class RegCenterOrderService extends ServiceBase {
}
}
/*
返回20位业务订单号
......@@ -386,7 +383,7 @@ class RegCenterOrderService extends ServiceBase {
//根据需求关闭方案(关闭需求后调用)
async regClosePlan(pobj) {
console.log("ncClosePlan+++",pobj)
console.log("ncClosePlan+++", pobj)
var ab = pobj.actionBody;
var app = pobj.appInfo;
if (!app || !app.uapp_id) {
......@@ -416,7 +413,7 @@ class RegCenterOrderService extends ServiceBase {
return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案");
}
var flowStatus = ns.solutionContent && ns.solutionContent.status ? ns.solutionContent.status : "";
if (flowStatus && ["NOT_ACCEPTED","CLOSE"].indexOf(flowStatus) < 0) {
if (flowStatus && ["NOT_ACCEPTED", "CLOSE"].indexOf(flowStatus) < 0) {
return system.getResultFail(-104, "⽅案状态为关闭或不予受理才可关闭需求");
}
}
......@@ -434,14 +431,14 @@ class RegCenterOrderService extends ServiceBase {
var uappId = {};
uappId['uapp_id'] = needinfo.uapp_id;
ns = ns ? ns : {};
ns = Object.assign(ns,uappId)
console.log('guanbi ns +++',ns)
ns = Object.assign(ns, uappId)
console.log('guanbi ns +++', ns)
return system.getResultSuccess(ns);
// return system.getResultSuccess();
})
}
//交付商关闭交付单
async ncCloseOrderDelivery(pobj) {
var ab = pobj.actionBody;
......@@ -536,17 +533,17 @@ class RegCenterOrderService extends ServiceBase {
var solutionType = [];
var solutionContent;
var needsolutions = [];//最后返回结果用
if(ab.solutionList){
if (ab.solutionList) {
var solutionListLength = ab.solutionList.length;
}
console.log('ab.solutionList------',ab.solutionList)
for(i=0;i<solutionListLength;i++){
if (!ab.solutionList[i].solutionContent) {
console.log('ab.solutionList------', ab.solutionList)
for (i = 0; i < solutionListLength; i++) {
if (!ab.solutionList[i].solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
solutionContent = ab.solutionList[i].solutionContent
solutionType.push(solutionContent.solution.regType)
console.log('solutionType------',solutionType)
console.log('solutionType------', solutionType)
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
......@@ -570,11 +567,11 @@ class RegCenterOrderService extends ServiceBase {
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
console.log('ns----',ns)
console.log('ns----', ns)
var nsRegType = [];
if(ns){
if (ns) {
var nsLength = ns.length;
for(l=0;l<nsLength;l++){
for (l = 0; l < nsLength; l++) {
nsRegType.push(ns[l].solutionContent.solution.regType)
}
// var flag = nsRegType.indexOf(solutionType);
......@@ -583,13 +580,13 @@ class RegCenterOrderService extends ServiceBase {
// return "该方案已创建";
// }
var diff;
diff = nsRegType.find(item=>solutionType.includes(item))
console.log('diff---',diff)
if(diff != undefined){
diff = nsRegType.find(item => solutionType.includes(item))
console.log('diff---', diff)
if (diff != undefined) {
return system.getResultFail(-207, "该方案中包含已提交过的方案,不能重复提交");
}
}
}
for(j=0;j<solutionListLength;j++){
for (j = 0; j < solutionListLength; j++) {
if (ab.solutionList[j].solutionContent) {
ab.solutionList[j].solutionContent.bizType = bizType;
ab.solutionList[j].solutionContent.typeCode = needinfo.typeCode;
......@@ -607,7 +604,7 @@ class RegCenterOrderService extends ServiceBase {
}
}
// var solution = ab.solutionList[j].solutionContent.solution;
var solutionFlowList = ab.solutionList[j].solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "RECEIVED", statusName: this.regSolutionStatus.RECEIVED, updated_at: new Date()
......@@ -619,7 +616,7 @@ class RegCenterOrderService extends ServiceBase {
// var solutionNo = await this.getBusUid("ns");//chuangjian
var solutionNo = [];//chuangjian
solutionNo[j] = await this.getBusUid("ns")
console.log('solutionNo[j]----',solutionNo[j])
console.log('solutionNo[j]----', solutionNo[j])
ab.solutionList[j]["solutionNo"] = solutionNo[j];
ab.solutionList[j]["status"] = "dqr";
var customerInfo = {//客户信息
......@@ -636,7 +633,7 @@ class RegCenterOrderService extends ServiceBase {
ab.solutionList[j].solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionList[j].solutionContent.solution.solutionPrice = (ab.solutionList[j].solutionContent.solution.solutionPrice) / 100 || "";//分转元
ab.solutionList[j].solutionContent = JSON.stringify(ab.solutionList[j].solutionContent);
console.log('abababab---+++---++',ab)
console.log('abababab---+++---++', ab)
var self = this;
var res = await this.needsolutionDao.db.transaction(async function (t) {
ab.solutionList[j]["needNo"] = needinfo.needNo;
......@@ -668,16 +665,16 @@ class RegCenterOrderService extends ServiceBase {
});
// return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
needsolutions.push(od.dataValues)
console.log('needsolutions-------',needsolutions)
}
console.log('needsolutions-------', needsolutions)
}
// else {
// return system.getResultFail(-302, "提交方案失败");
// }
})
}
}
return system.getResultSuccess({ needinfo: needinfo,needsolutions: needsolutions });
}
return system.getResultSuccess({ needinfo: needinfo, needsolutions: needsolutions });
}
//方案推送baidu后,接收保存方案编号/链接
async saveReginfo(pobj) {
var ab = pobj.actionBody;
......@@ -690,9 +687,9 @@ class RegCenterOrderService extends ServiceBase {
var solutionNos = [];
var infoList = [];
var nsLength = ns.length
for(i=0;i<infosLength;i++){
for (i = 0; i < infosLength; i++) {
var solutionNo = {
solutionNo:ab.infos[i].bizId
solutionNo: ab.infos[i].bizId
}
solutionNos.push(solutionNo)
}
......@@ -711,7 +708,7 @@ class RegCenterOrderService extends ServiceBase {
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
for(j=0;j<nsLength;j++){
for (j = 0; j < nsLength; j++) {
await this.needsolutionDao.model.update({ channelSolutionNo: ab.infos[j].bizId }, { where: { id: ns[j].id } });//修改方案信息
}
return system.getResultSuccess();
......@@ -748,11 +745,11 @@ class RegCenterOrderService extends ServiceBase {
if (updateRes[1]) {
var sql = "select uapp_id from n_need_info where channelNeedNo = :channelNeedNo ";
var where = {
channelNeedNo:pobj.actionBody.intentionBizId
channelNeedNo: pobj.actionBody.intentionBizId
}
var uappIdInfo = await this.customQuery(sql,where);
console.log('uappIdInfo+++',uappIdInfo)
if(uappIdInfo){
var uappIdInfo = await this.customQuery(sql, where);
console.log('uappIdInfo+++', uappIdInfo)
if (uappIdInfo) {
var uappIds = uappIdInfo[0].uapp_id
}
return system.getResultSuccess(uappIds);
......@@ -770,10 +767,10 @@ class RegCenterOrderService extends ServiceBase {
if (updateRes[1]) {
var sql = "select uapp_id from n_need_info where channelNeedNo = :channelNeedNo ";
var where = {
channelNeedNo:pobj.actionBody.intentionBizId
channelNeedNo: pobj.actionBody.intentionBizId
}
var uappIdInfo = await this.customQuery(sql,where);
if(uappIdInfo){
var uappIdInfo = await this.customQuery(sql, where);
if (uappIdInfo) {
var uappIds = uappIdInfo[0].uapp_id
}
return system.getResultSuccess(uappIds);
......@@ -792,10 +789,10 @@ class RegCenterOrderService extends ServiceBase {
// }
var sql = "select uapp_id from n_need_info where channelNeedNo = :channelNeedNo ";
var where = {
channelNeedNo:pobj.actionBody.intentionBizId
channelNeedNo: pobj.actionBody.intentionBizId
}
var uappIdInfo = await this.customQuery(sql,where);
if(uappIdInfo){
var uappIdInfo = await this.customQuery(sql, where);
if (uappIdInfo) {
uappIdInfo = uappIdInfo[0];
return system.getResultSuccess(uappIdInfo);
}
......@@ -852,12 +849,12 @@ class RegCenterOrderService extends ServiceBase {
var ns = await this.needsolutionDao.model.findAll({
where: { needNo: needinfo.needNo, isInvalid: 0 }, raw: true
});
console.log('nnnsss-----',ns)
console.log('nnnsss-----', ns)
var i;
var nsLength = ns.length
if(ns){
for(i=0;i<nsLength;i++){
if(ns[i].id){
if (ns) {
for (i = 0; i < nsLength; i++) {
if (ns[i].id) {
if (ns[i].status == "ywc") {
return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案");
}
......@@ -875,7 +872,7 @@ class RegCenterOrderService extends ServiceBase {
await self.needsolutionDao.model.update({ status: "yzf", isInvalid: 1 }, { where: { id: ns.id }, transaction: t });//方案废弃
// return system.getResultSuccess(ns.orderNo);
ns['uapp_id'] = needinfo.uapp_id;
console.log('guanbi ns +++',ns)
console.log('guanbi ns +++', ns)
})
}
}
......
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