Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
45f2656f
Commit
45f2656f
authored
Nov 16, 2020
by
兰国旗
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
laolan
parent
d0bd12e6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1576 additions
and
784 deletions
+1576
-784
center-order/app/base/api/impl/action/need.js
+1
-1
center-order/app/base/api/impl/action/qcapi.js
+54
-18
center-order/app/base/db/impl/dbcorder/orderdeliveryDao.js
+8
-0
center-order/app/base/db/models/dbcorder/orderdeliveryDao.js
+24
-0
center-order/app/base/service/impl/qcutils/baseqcSve.js
+0
-765
center-order/app/base/service/impl/qcutils/ncSve.js
+760
-0
center-order/app/base/service/impl/qcutils/rtSve.js
+729
-0
No files found.
center-order/app/base/api/impl/action/need.js
View file @
45f2656f
...
...
@@ -51,7 +51,7 @@ class IcAPI extends APIBase {
opResult
=
await
this
.
needinfoSve
.
getItemByChannelSolutionNo
(
pobj
,
pobj
.
actionBody
,
req
);
break
;
case
"writeCommunicationLog"
:
//渠道方案号获取需求详情
opResult
=
await
this
.
needinfoSve
.
writeCommunicationLog
(
pobj
,
pobj
.
actionBody
,
req
);
opResult
=
await
this
.
needinfoSve
2
.
writeCommunicationLog
(
pobj
,
pobj
.
actionBody
,
req
);
break
;
case
"submitIcpIntention"
:
// 2020 0827 lin 新增 4.1 提交需求
opResult
=
await
this
.
needinfoSve
.
submitIcpIntention
(
pobj
,
pobj
.
actionBody
,
req
);
...
...
center-order/app/base/api/impl/action/qcapi.js
View file @
45f2656f
...
...
@@ -8,6 +8,8 @@ class QcAPI extends APIBase {
this
.
baiduqcSve
=
system
.
getObject
(
"service.qcutils.baiduqcSve"
);
this
.
baseqcSve
=
system
.
getObject
(
"service.qcutils.baseqcSve"
);
this
.
ncSve
=
system
.
getObject
(
"service.qcutils.ncSve"
);
this
.
rtSve
=
system
.
getObject
(
"service.qcutils.rtSve"
);
}
/**
* 接口跳转-POST请求
...
...
@@ -83,33 +85,67 @@ class QcAPI extends APIBase {
case
"receiveIcpConfirmUrl"
:
//前端关闭ICP需求及方案
opResult
=
await
this
.
aliyunqcSve
.
receiveIcpConfirmUrl
(
pobj
);
break
;
//-----------文网文-----------
case
"serviceSubmitOption"
:
//服务商提交服务操作
opResult
=
await
this
.
aliyunqcSve
.
serviceSubmitOption
(
pobj
);
// --------- 网文 ---------
case
"ncGetNeedList"
:
//查询需求列表(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncGetNeedList
(
pobj
);
break
;
case
"ncSubmitMaterial"
:
//交付材料提交(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncSubmitMaterial
(
pobj
);
break
;
case
"ncNotification"
:
//状态通知(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncNotification
(
pobj
);
break
;
case
"ncSubmitSolution"
:
//提交方案(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncSubmitSolution
(
pobj
);
break
;
case
"ncWriteCommunicationRecord"
:
//提交沟通记录(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncWriteCommunicationRecord
(
pobj
);
break
;
case
"ncGetCommunicationRecord"
:
//查询沟通记录(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncGetCommunicationRecord
(
pobj
);
break
;
case
"
submitWangwenSolution"
:
//提交方案
opResult
=
await
this
.
aliyunqcSve
.
submitWangwenSolution
(
pobj
);
case
"
ncCloseNeed"
:
//关闭需求(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncCloseNeed
(
pobj
);
break
;
case
"
closeNeed"
:
//关闭需求
opResult
=
await
this
.
aliyunqcSve
.
closeNeed
(
pobj
);
case
"
ncClosePlan"
:
//关闭方案(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncClosePlan
(
pobj
);
break
;
case
"
recordLog"
:
//提交沟通记录
opResult
=
await
this
.
aliyunqcSve
.
recordLog
(
pobj
);
case
"
ncCloseOrderDelivery"
:
//关闭交付单(网文)2020-11-11
opResult
=
await
this
.
ncSve
.
ncCloseOrderDelivery
(
pobj
);
break
;
//-----------食品-----------
case
"foodServiceSubmitOption"
:
//服务商提交服务操作
opResult
=
await
this
.
aliyunqcSve
.
foodServiceSubmitOption
(
pobj
);
// --------- 广电 ---------
case
"rtGetNeedList"
:
//查询需求列表(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtGetNeedList
(
pobj
);
break
;
case
"rtSubmitMaterial"
:
//交付材料提交(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtSubmitMaterial
(
pobj
);
break
;
case
"rtNotification"
:
//状态通知(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtNotification
(
pobj
);
break
;
case
"rtSubmitSolution"
:
//提交方案(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtSubmitSolution
(
pobj
);
break
;
case
"rtWriteCommunicationRecord"
:
//提交沟通记录(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtWriteCommunicationRecord
(
pobj
);
break
;
case
"rtGetCommunicationRecord"
:
//查询沟通记录(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtGetCommunicationRecord
(
pobj
);
break
;
case
"
submitFoodSolution"
:
//提交方案
opResult
=
await
this
.
aliyunqcSve
.
submitFoodSolution
(
pobj
);
case
"
rtCloseNeed"
:
//关闭需求(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtCloseNeed
(
pobj
);
break
;
case
"
foodCloseNeed"
:
//关闭需求
opResult
=
await
this
.
aliyunqcSve
.
foodCloseNeed
(
pobj
);
case
"
rtClosePlan"
:
//关闭方案(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtClosePlan
(
pobj
);
break
;
case
"
foodRecordLog"
:
//提交沟通记录
opResult
=
await
this
.
aliyunqcSve
.
foodRecordLog
(
pobj
);
case
"
rtCloseOrderDelivery"
:
//关闭交付单(广电)2020-11-11
opResult
=
await
this
.
rtSve
.
rtCloseOrderDelivery
(
pobj
);
break
;
case
"receiveOrderStatusNotify"
:
//接收订单状态推送 百度icp 2.3
opResult
=
await
this
.
baiduqcSve
.
receiveOrderStatusNotify
(
pobj
);
...
...
center-order/app/base/db/impl/dbcorder/orderdeliveryDao.js
0 → 100644
View file @
45f2656f
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
orderdeliveryDao
extends
Dao
{
constructor
(){
super
(
Dao
.
getModelName
(
orderdeliveryDao
));
}
}
module
.
exports
=
orderdeliveryDao
;
center-order/app/base/db/models/dbcorder/orderdeliveryDao.js
0 → 100644
View file @
45f2656f
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
appKey
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"orderdelivery"
,
{
sourceOrderNo
:
DataTypes
.
STRING
(
128
),
deliveryContent
:
DataTypes
.
JSON
(),
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
timestamps
:
true
,
updated_at
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'c_order_delivery'
,
validate
:
{
},
indexes
:
[
]
});
}
center-order/app/base/service/impl/qcutils/baseqcSve.js
View file @
45f2656f
...
...
@@ -1105,770 +1105,5 @@ class BaseQcService {
}
return
system
.
getResultSuccess
(
new_ns
);
}
// ---------------- 文网文 ----------------
/**
* 服务商提交服务操作
* 服务商通知状态变更
* (交付系统调用)
* (文网文)
*/
async
serviceSubmitOption
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
if
(
!
ab
.
orderNo
)
{
return
system
.
getResultFail
(
-
101
,
"订单号不能为空"
);
}
if
(
!
ab
.
ApplicationStatus
)
{
return
system
.
getResultFail
(
-
102
,
"交付状态不能为空"
);
}
if
(
!
ab
.
channelType
)
{
return
system
.
getResultFail
(
-
103
,
"渠道来源不能为空"
);
}
//获取方案信息
var
orderinfo
=
await
this
.
orderinfoDao
.
model
.
findOne
({
where
:
{
channelOrderNo
:
ab
.
orderNo
},
raw
:
true
});
if
(
orderinfo
){
var
orderNo
=
orderinfo
.
orderNo
;
if
(
orderNo
){
var
needsolutioninfo
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
orderNo
:
orderNo
},
raw
:
true
});
}
}
if
(
!
needsolutioninfo
||
!
needsolutioninfo
.
id
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案"
);
}
if
(
!
needsolutioninfo
.
needNo
)
{
return
system
.
getResultFail
(
-
401
,
"方案需求信息有误"
);
}
var
solutionContent
=
needsolutioninfo
.
solutionContent
;
if
(
!
solutionContent
)
{
return
system
.
getResultFail
(
-
402
,
"方案交付信息有误"
);
}
// if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
// return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
// }
// if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
// return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
// }
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
needsolutioninfo
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"serviceProviderSubmitMateria"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
if
(
ab
.
ApplicationStatus
==
601
)
{
//服务商提交资料
if
(
solutionContent
.
status
==
"USER_UPLOAD_PRODUCE"
||
solutionContent
.
status
==
"USER_REFUSE_PRODUCE"
)
{
solutionContent
.
ApplicationStatus
=
601
;
solutionFlowList
.
push
({
status
:
"PARTNER_SUBMIT_MATERIAL"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
PARTNER_SUBMIT_MATERIAL
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"PARTNER_SUBMIT_MATERIAL"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
PARTNER_SUBMIT_MATERIAL
;
}
else
{
return
system
.
getResultFail
(
-
601
,
"交付流程错误,请先完成账户注册"
);
}
}
if
(
ab
.
ApplicationStatus
==
602
)
{
//完成账户注册
if
(
solutionContent
.
status
!=
"USER_CONFIRM_PRODUCE"
)
{
return
system
.
getResultFail
(
-
602
,
"交付流程错误,用户确认递交⽂件后才能执行此操作"
);
}
solutionFlowList
.
push
({
status
:
"CERT_ACCOUNT_REGISTERED"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_ACCOUNT_REGISTERED
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_ACCOUNT_REGISTERED"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_ACCOUNT_REGISTERED
;
}
if
(
ab
.
ApplicationStatus
==
603
)
{
//服务商完成提交资料到⼯信部
if
(
solutionContent
.
status
!=
"CERT_ACCOUNT_REGISTERED"
)
{
return
system
.
getResultFail
(
-
603
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
status
:
"CERT_MATERIAL_SUBMITTED"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_MATERIAL_SUBMITTED
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_MATERIAL_SUBMITTED"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_MATERIAL_SUBMITTED
;
}
if
(
ab
.
ApplicationStatus
==
604
)
{
//⼯商部已受理
if
(
solutionContent
.
status
!=
"CERT_MATERIAL_SUBMITTED"
)
{
return
system
.
getResultFail
(
-
604
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
status
:
"CERT_GXB_ACCEPT"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_GXB_ACCEPT
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_GXB_ACCEPT"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_GXB_ACCEPT
;
}
if
(
ab
.
ApplicationStatus
==
605
)
{
//⼯商部不予受理
if
(
solutionContent
.
status
!=
"PARTNER_SUBMIT_MATERIAL"
)
{
return
system
.
getResultFail
(
-
605
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
status
:
"CERT_GXB_REFUSE"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_GXB_REFUSE
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_GXB_REFUSE"
;
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_GXB_REFUSE
;
}
if
(
ab
.
ApplicationStatus
==
606
)
{
//⼯商部通过
if
(
solutionContent
.
status
!=
"CERT_GXB_ACCEPT"
)
{
return
system
.
getResultFail
(
-
606
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
solutionFlowList
.
push
({
status
:
"CERT_GXB_SUCCESS"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_GXB_SUCCESS
,
updated_at
:
new
Date
()
});
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
status
=
"CERT_GXB_SUCCESS"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_GXB_SUCCESS
;
}
if
(
ab
.
ApplicationStatus
==
607
)
{
//⼯信部未通过
if
(
solutionContent
.
status
!=
"CERT_GXB_ACCEPT"
)
{
return
system
.
getResultFail
(
-
607
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
solutionFlowList
.
push
({
status
:
"CERT_GXB_FAIL"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_GXB_FAIL
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_GXB_FAIL"
;
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_GXB_FAIL
;
}
solutionContent
.
solutionFlowList
=
solutionFlowList
;
var
applicationStatusList
=
solutionContent
.
applicationStatusList
||
[];
var
statusObj
=
{
"ApplicationStatus"
:
ab
.
ApplicationStatus
,
"ApplicationStatusName"
:
this
.
wangwenSolutionStatusReference
[
ab
.
ApplicationStatus
],
"created_at"
:
new
Date
()
};
applicationStatusList
.
push
(
statusObj
);
solutionContent
.
applicationStatusList
=
applicationStatusList
;
solutionContent
.
applicationStatus
=
ab
.
ApplicationStatus
;
needsolutioninfo
.
solutionContent
=
JSON
.
stringify
(
solutionContent
);
var
self
=
this
;
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
await
self
.
needsolutionDao
.
update
(
needsolutioninfo
,
t
);
statusObj
[
"BizId"
]
=
ab
.
BizId
;
return
system
.
getResultSuccess
(
statusObj
);
})
}
//提交方案
async
submitWangwenSolution
(
pobj
)
{
console
.
log
(
'wangwen提交方案'
,
pobj
)
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
ab
[
"createUserId"
]
=
user
.
id
;
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"渠道需求号不能为空"
);
}
if
(
!
ab
.
solutionContent
)
{
return
system
.
getResultFail
(
-
102
,
"方案信息有误"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能创建方案"
);
}
var
bizType
=
needinfo
.
typeCode
;
//ab.solutionContent.bizType;//业务类型
ab
.
solutionContent
.
bizType
=
bizType
;
if
(
!
bizType
)
{
return
system
.
getResultFail
(
-
205
,
"方案类型错误"
);
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if
(
!
needinfo
.
channelTypeCode
)
{
return
system
.
getResultFail
(
-
206
,
"渠道方案类型错误"
);
}
ab
.
solutionContent
.
typeCode
=
needinfo
.
typeCode
;
ab
.
solutionContent
.
typeName
=
needinfo
.
typeName
;
var
ns
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
,
order
:
[[
"id"
,
'asc'
]]
});
for
(
var
i
=
0
;
i
<
ns
.
length
;
i
++
)
{
var
fa
=
ns
[
i
];
if
(
fa
.
status
==
"dqr"
||
fa
.
status
==
"ywc"
)
{
return
system
.
getResultFail
(
-
207
,
"需求方案已存在,不能重复提交"
);
}
if
(
fa
.
status
==
"ybh"
)
{
ab
.
channelSolutionNo
=
fa
.
channelSolutionNo
;
}
if
(
fa
.
status
==
"yzf"
)
{
ab
.
channelSolutionNo
=
""
;
}
}
var
solution
=
ab
.
solutionContent
.
solution
;
if
(
!
solution
)
{
return
system
.
getResultFail
(
-
103
,
"方案交付信息有误"
);
}
if
(
needinfo
.
channelTypeCode
==
"esp.wangwen"
)
{
//esp.wangwen
ab
.
solutionContent
.
solution
.
IcpType
=
"wangwen"
;
}
else
{
return
system
.
getResultFail
(
-
208
,
"需求业务类型有误"
);
}
if
(
!
solution
.
CompanyName
)
{
return
system
.
getResultFail
(
-
105
,
"企业名称不能为空"
);
}
if
(
!
solution
.
licenseType
)
{
return
system
.
getResultFail
(
-
106
,
"网文类型不能为空"
);
}
if
(
!
solution
.
actionType
)
{
return
system
.
getResultFail
(
-
106
,
"办理类型不能为空"
);
}
if
(
!
solution
.
companyLocation
)
{
return
system
.
getResultFail
(
-
107
,
"区域不能为空"
);
}
if
(
!
solution
.
solutionPrice
)
{
return
system
.
getResultFail
(
-
108
,
"办理价格不能为空"
);
}
else
{
solution
.
solutionPrice
=
solution
.
solutionPrice
/
100
;
}
var
solutionFlowList
=
ab
.
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"SOLUTION_SUBMIT"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
SOLUTION_SUBMIT
,
updated_at
:
new
Date
()
});
ab
.
solutionContent
.
status
=
"SOLUTION_SUBMIT"
;
ab
.
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
SOLUTION_SUBMIT
;
ab
.
solutionContent
.
solutionFlowList
=
solutionFlowList
;
ab
[
"channelNeedNo"
]
=
needinfo
.
channelNeedNo
;
var
solutionNo
=
await
this
.
getBusUid
(
"ns"
);
ab
[
"solutionNo"
]
=
solutionNo
;
ab
[
"status"
]
=
"dqr"
;
var
customerInfo
=
{
//客户信息
"publishName"
:
needinfo
.
publishName
,
"publishMobile"
:
needinfo
.
publishMobile
};
var
salesmanInfo
=
{
//业务员信息
"salesmanName"
:
user
.
channel_username
,
"salesmanMobile"
:
user
.
mobile
,
"salesmanId"
:
user
.
id
,
"salesmanChannelId"
:
user
.
channel_userid
};
ab
.
solutionContent
[
"customerInfo"
]
=
customerInfo
;
ab
.
solutionContent
[
"salesmanInfo"
]
=
salesmanInfo
;
ab
.
solutionContent
=
JSON
.
stringify
(
ab
.
solutionContent
);
var
self
=
this
;
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
ab
[
"needNo"
]
=
needinfo
.
needNo
;
var
od
=
await
self
.
needsolutionDao
.
create
(
ab
,
t
);
if
(
od
&&
od
.
id
)
{
var
needObj
=
{
id
:
needinfo
.
id
};
if
(
!
needinfo
.
followManUserId
)
{
needObj
=
{
id
:
needinfo
.
id
,
followManUserId
:
user
.
id
,
//跟进人id
followManName
:
user
.
channel_username
,
//跟进人姓名
followManMobile
:
user
.
mobile
,
//跟进人手机号(合伙人)
followManOnlyCode
:
user
.
channel_userid
};
}
if
(
!
needinfo
.
followContent
)
{
var
followContent
=
[{
followDate
:
new
Date
(),
content
:
"wangwen提交方案"
}];
followContent
=
JSON
.
stringify
(
followContent
);
needObj
[
"followContent"
]
=
followContent
;
}
await
self
.
needinfoDao
.
update
(
needObj
,
t
);
needinfo
=
await
self
.
needinfoDao
.
model
.
findOne
({
where
:
{
id
:
needinfo
.
id
},
raw
:
true
});
return
system
.
getResultSuccess
({
needinfo
:
needinfo
,
needsolution
:
od
});
}
else
{
return
system
.
getResultFail
(
-
302
,
"提交方案失败"
);
}
})
}
//关闭需求
async
closeNeed
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
app
=
pobj
.
appInfo
;
if
(
!
app
||
!
app
.
uapp_id
)
{
return
system
.
getResultFail
(
-
100
,
"未知渠道"
);
}
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"需求编号不能为空"
);
}
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
106
,
"关闭理由不能为空"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"statusName"
,
"needNo"
],
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
var
updateNeed
=
await
this
.
needinfoDao
.
update
(
needObj
);
//关闭需求
if
(
!
updateNeed
)
{
return
system
.
getResultFail
(
-
203
,
"关闭需求失败"
);
}
else
{
return
system
.
getResultSuccess
();
}
}
//提交沟通记录
async
recordLog
(
pobj
)
{
// 查询需求沟通记录
// 修改channel传过来的参数 为 note/needNo
pobj
.
actionBody
.
Note
=
[
"noteTime"
,
moment
().
format
(
"YYYY-MM-DD HH:mm:ss"
),
"note"
,
pobj
.
actionBody
.
note
];
let
needRes
=
await
this
.
needsolutionDao
.
findOne
({
channelNeedNo
:
pobj
.
actionBody
.
needNo
});
console
.
log
(
'needRes'
,
needRes
)
// 没有需求单直接返回
if
(
!
needRes
)
{
return
system
.
getResult
(
"没有这个需求单"
);
}
// 如果未推送/以推送 修改为已跟进
if
(
needRes
.
status
==
"wts"
||
needRes
.
status
==
"yts"
)
{
var
sql
=
"update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:BizId"
var
paramWhere
=
{
statusName
:
'已跟进'
,
status
:
'ygj'
,
BizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
console
.
log
(
'updateRes'
,
updateRes
)
}
// 有需求单但没有沟通记录 直接set
if
(
!
needRes
.
followContent
)
{
var
sql
=
"update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var
paramWhere
=
{
followContent
:
pobj
.
actionBody
.
Note
,
BizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
if
(
updateRes
[
1
])
{
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
"添加记录失败"
);
// 有需求单有沟通记录 json_array_append
}
else
{
var
sql
=
"update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(pobj.actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +pobj.actionBody.BizId +"\"" +" "
var
paramWhere
=
{
Note
:
pobj
.
actionBody
.
Note
,
BizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
console
.
log
(
'updateRes'
,
updateRes
)
if
(
updateRes
[
1
])
{
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
"添加记录失败"
);
}
}
// ---------------- 食品 ----------------
/**
* 服务商提交服务操作
* 服务商通知状态变更
* (交付系统调用)
* (食品)
*/
async
foodServiceSubmitOption
(
pobj
)
{
console
.
log
(
pobj
)
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
if
(
!
ab
.
orderNo
)
{
return
system
.
getResultFail
(
-
101
,
"订单号不能为空"
);
}
if
(
!
ab
.
ApplicationStatus
)
{
return
system
.
getResultFail
(
-
102
,
"交付状态不能为空"
);
}
if
(
!
ab
.
channelType
)
{
return
system
.
getResultFail
(
-
102
,
"渠道来源不能为空"
);
}
//获取方案信息
var
orderinfo
=
await
this
.
orderinfoDao
.
model
.
findOne
({
where
:
{
channelOrderNo
:
ab
.
orderNo
},
raw
:
true
});
if
(
orderinfo
){
var
orderNo
=
orderinfo
.
orderNo
;
if
(
orderNo
){
var
needsolutioninfo
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
orderNo
:
orderNo
},
raw
:
true
});
}
}
if
(
!
needsolutioninfo
||
!
needsolutioninfo
.
id
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案"
);
}
if
(
!
needsolutioninfo
.
needNo
)
{
return
system
.
getResultFail
(
-
401
,
"方案需求信息有误"
);
}
var
solutionContent
=
needsolutioninfo
.
solutionContent
;
if
(
!
solutionContent
)
{
return
system
.
getResultFail
(
-
402
,
"方案交付信息有误"
);
}
// if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
// return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
// }
// if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
// return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
// }
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
needsolutioninfo
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"serviceProviderSubmitMateria"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
if
(
ab
.
ApplicationStatus
==
601
)
{
//服务商提交资料
if
(
solutionContent
.
status
==
"USER_UPLOAD_PRODUCE"
||
solutionContent
.
status
==
"USER_REFUSE_PRODUCE"
)
{
solutionContent
.
ApplicationStatus
=
601
;
solutionFlowList
.
push
({
status
:
"PARTNER_SUBMIT_MATERIAL"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
PARTNER_SUBMIT_MATERIAL
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"PARTNER_SUBMIT_MATERIAL"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
PARTNER_SUBMIT_MATERIAL
;
}
else
{
return
system
.
getResultFail
(
-
601
,
"交付流程错误,请先完成账户注册"
);
}
}
if
(
ab
.
ApplicationStatus
==
602
)
{
//完成账户注册
if
(
solutionContent
.
status
!=
"USER_CONFIRM_PRODUCE"
)
{
return
system
.
getResultFail
(
-
602
,
"交付流程错误,用户确认递交⽂件后才能执行此操作"
);
}
solutionFlowList
.
push
({
status
:
"CERT_ACCOUNT_REGISTERED"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_ACCOUNT_REGISTERED
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_ACCOUNT_REGISTERED"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_ACCOUNT_REGISTERED
;
}
if
(
ab
.
ApplicationStatus
==
603
)
{
//服务商完成提交资料到⼯信部
if
(
solutionContent
.
status
!=
"CERT_ACCOUNT_REGISTERED"
)
{
return
system
.
getResultFail
(
-
603
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
status
:
"CERT_MATERIAL_SUBMITTED"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_MATERIAL_SUBMITTED
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_MATERIAL_SUBMITTED"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_MATERIAL_SUBMITTED
;
}
if
(
ab
.
ApplicationStatus
==
604
)
{
//⼯商部已受理
if
(
solutionContent
.
status
!=
"CERT_MATERIAL_SUBMITTED"
)
{
return
system
.
getResultFail
(
-
604
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
status
:
"CERT_GXB_ACCEPT"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_GXB_ACCEPT
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_GXB_ACCEPT"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_GXB_ACCEPT
;
}
if
(
ab
.
ApplicationStatus
==
605
)
{
//⼯商部不予受理
if
(
solutionContent
.
status
!=
"PARTNER_SUBMIT_MATERIAL"
)
{
return
system
.
getResultFail
(
-
605
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
status
:
"CERT_GXB_REFUSE"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_GXB_REFUSE
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_GXB_REFUSE"
;
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_GXB_REFUSE
;
}
if
(
ab
.
ApplicationStatus
==
606
)
{
//⼯商部通过
if
(
solutionContent
.
status
!=
"CERT_GXB_ACCEPT"
)
{
return
system
.
getResultFail
(
-
606
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
solutionFlowList
.
push
({
status
:
"CERT_GXB_SUCCESS"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_GXB_SUCCESS
,
updated_at
:
new
Date
()
});
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
status
=
"CERT_GXB_SUCCESS"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_GXB_SUCCESS
;
}
if
(
ab
.
ApplicationStatus
==
607
)
{
//⼯信部未通过
if
(
solutionContent
.
status
!=
"CERT_GXB_ACCEPT"
)
{
return
system
.
getResultFail
(
-
607
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
solutionFlowList
.
push
({
status
:
"CERT_GXB_FAIL"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
CERT_GXB_FAIL
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CERT_GXB_FAIL"
;
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
CERT_GXB_FAIL
;
}
solutionContent
.
solutionFlowList
=
solutionFlowList
;
var
applicationStatusList
=
solutionContent
.
applicationStatusList
||
[];
var
statusObj
=
{
"ApplicationStatus"
:
ab
.
ApplicationStatus
,
"ApplicationStatusName"
:
this
.
wangwenSolutionStatusReference
[
ab
.
ApplicationStatus
],
"created_at"
:
new
Date
()
};
applicationStatusList
.
push
(
statusObj
);
solutionContent
.
applicationStatusList
=
applicationStatusList
;
solutionContent
.
applicationStatus
=
ab
.
ApplicationStatus
;
needsolutioninfo
.
solutionContent
=
JSON
.
stringify
(
solutionContent
);
var
self
=
this
;
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
await
self
.
needsolutionDao
.
update
(
needsolutioninfo
,
t
);
statusObj
[
"BizId"
]
=
ab
.
BizId
;
return
system
.
getResultSuccess
(
statusObj
);
})
}
//提交方案
async
submitFoodSolution
(
pobj
)
{
console
.
log
(
'food提交方案'
,
pobj
)
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
ab
[
"createUserId"
]
=
user
.
id
;
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"渠道需求号不能为空"
);
}
if
(
!
ab
.
solutionContent
)
{
return
system
.
getResultFail
(
-
102
,
"方案信息有误"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能创建方案"
);
}
var
bizType
=
needinfo
.
typeCode
;
//ab.solutionContent.bizType;//业务类型
ab
.
solutionContent
.
bizType
=
bizType
;
if
(
!
bizType
)
{
return
system
.
getResultFail
(
-
205
,
"方案类型错误"
);
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if
(
!
needinfo
.
channelTypeCode
)
{
return
system
.
getResultFail
(
-
206
,
"渠道方案类型错误"
);
}
ab
.
solutionContent
.
typeCode
=
needinfo
.
typeCode
;
ab
.
solutionContent
.
typeName
=
needinfo
.
typeName
;
var
ns
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
,
order
:
[[
"id"
,
'asc'
]]
});
for
(
var
i
=
0
;
i
<
ns
.
length
;
i
++
)
{
var
fa
=
ns
[
i
];
if
(
fa
.
status
==
"dqr"
||
fa
.
status
==
"ywc"
)
{
return
system
.
getResultFail
(
-
207
,
"需求方案已存在,不能重复提交"
);
}
if
(
fa
.
status
==
"ybh"
)
{
ab
.
channelSolutionNo
=
fa
.
channelSolutionNo
;
}
if
(
fa
.
status
==
"yzf"
)
{
ab
.
channelSolutionNo
=
""
;
}
}
var
solution
=
ab
.
solutionContent
.
solution
;
if
(
!
solution
)
{
return
system
.
getResultFail
(
-
103
,
"方案交付信息有误"
);
}
if
(
needinfo
.
channelTypeCode
==
"esp.food"
)
{
//esp.food
ab
.
solutionContent
.
solution
.
IcpType
=
"food"
;
}
else
{
return
system
.
getResultFail
(
-
208
,
"需求业务类型有误"
);
}
if
(
!
solution
.
CompanyName
)
{
return
system
.
getResultFail
(
-
105
,
"企业名称不能为空"
);
}
if
(
!
solution
.
licenseType
)
{
return
system
.
getResultFail
(
-
106
,
"网文类型不能为空"
);
}
if
(
!
solution
.
actionType
)
{
return
system
.
getResultFail
(
-
106
,
"办理类型不能为空"
);
}
if
(
!
solution
.
companyLocation
)
{
return
system
.
getResultFail
(
-
107
,
"区域不能为空"
);
}
if
(
!
solution
.
solutionPrice
)
{
return
system
.
getResultFail
(
-
108
,
"办理价格不能为空"
);
}
else
{
solution
.
solutionPrice
=
solution
.
solutionPrice
/
100
;
}
var
solutionFlowList
=
ab
.
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"SOLUTION_SUBMIT"
,
statusName
:
this
.
wangwenSolutionStatusReference
.
SOLUTION_SUBMIT
,
updated_at
:
new
Date
()
});
ab
.
solutionContent
.
status
=
"SOLUTION_SUBMIT"
;
ab
.
solutionContent
.
statusName
=
this
.
wangwenSolutionStatusReference
.
SOLUTION_SUBMIT
;
ab
.
solutionContent
.
solutionFlowList
=
solutionFlowList
;
ab
[
"channelNeedNo"
]
=
needinfo
.
channelNeedNo
;
var
solutionNo
=
await
this
.
getBusUid
(
"ns"
);
ab
[
"solutionNo"
]
=
solutionNo
;
ab
[
"status"
]
=
"dqr"
;
var
customerInfo
=
{
//客户信息
"publishName"
:
needinfo
.
publishName
,
"publishMobile"
:
needinfo
.
publishMobile
};
var
salesmanInfo
=
{
//业务员信息
"salesmanName"
:
user
.
channel_username
,
"salesmanMobile"
:
user
.
mobile
,
"salesmanId"
:
user
.
id
,
"salesmanChannelId"
:
user
.
channel_userid
};
ab
.
solutionContent
[
"customerInfo"
]
=
customerInfo
;
ab
.
solutionContent
[
"salesmanInfo"
]
=
salesmanInfo
;
ab
.
solutionContent
=
JSON
.
stringify
(
ab
.
solutionContent
);
var
self
=
this
;
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
ab
[
"needNo"
]
=
needinfo
.
needNo
;
var
od
=
await
self
.
needsolutionDao
.
create
(
ab
,
t
);
if
(
od
&&
od
.
id
)
{
var
needObj
=
{
id
:
needinfo
.
id
};
if
(
!
needinfo
.
followManUserId
)
{
needObj
=
{
id
:
needinfo
.
id
,
followManUserId
:
user
.
id
,
//跟进人id
followManName
:
user
.
channel_username
,
//跟进人姓名
followManMobile
:
user
.
mobile
,
//跟进人手机号(合伙人)
followManOnlyCode
:
user
.
channel_userid
};
}
if
(
!
needinfo
.
followContent
)
{
var
followContent
=
[{
followDate
:
new
Date
(),
content
:
"food提交方案"
}];
followContent
=
JSON
.
stringify
(
followContent
);
needObj
[
"followContent"
]
=
followContent
;
}
await
self
.
needinfoDao
.
update
(
needObj
,
t
);
needinfo
=
await
self
.
needinfoDao
.
model
.
findOne
({
where
:
{
id
:
needinfo
.
id
},
raw
:
true
});
return
system
.
getResultSuccess
({
needinfo
:
needinfo
,
needsolution
:
od
});
}
else
{
return
system
.
getResultFail
(
-
302
,
"提交方案失败"
);
}
})
}
//关闭需求
async
foodCloseNeed
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
app
=
pobj
.
appInfo
;
if
(
!
app
||
!
app
.
uapp_id
)
{
return
system
.
getResultFail
(
-
100
,
"未知渠道"
);
}
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"需求编号不能为空"
);
}
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
106
,
"关闭理由不能为空"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"statusName"
,
"needNo"
],
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
var
updateNeed
=
await
this
.
needinfoDao
.
update
(
needObj
);
//关闭需求
if
(
!
updateNeed
)
{
return
system
.
getResultFail
(
-
203
,
"关闭需求失败"
);
}
else
{
return
system
.
getResultSuccess
();
}
}
//提交沟通记录
async
foodRecordLog
(
pobj
)
{
// 查询需求沟通记录
// 修改channel传过来的参数 为 note/needNo
pobj
.
actionBody
.
Note
=
[
"noteTime"
,
moment
().
format
(
"YYYY-MM-DD HH:mm:ss"
),
"note"
,
pobj
.
actionBody
.
note
];
let
needRes
=
await
this
.
needsolutionDao
.
findOne
({
channelNeedNo
:
pobj
.
actionBody
.
needNo
});
console
.
log
(
'needRes'
,
needRes
)
// 没有需求单直接返回
if
(
!
needRes
)
{
return
system
.
getResult
(
"没有这个需求单"
);
}
// 如果未推送/以推送 修改为已跟进
if
(
needRes
.
status
==
"wts"
||
needRes
.
status
==
"yts"
)
{
var
sql
=
"update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:BizId"
var
paramWhere
=
{
statusName
:
'已跟进'
,
status
:
'ygj'
,
BizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
console
.
log
(
'updateRes'
,
updateRes
)
}
// 有需求单但没有沟通记录 直接set
if
(
!
needRes
.
followContent
)
{
var
sql
=
"update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var
paramWhere
=
{
followContent
:
pobj
.
actionBody
.
Note
,
BizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
if
(
updateRes
[
1
])
{
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
"添加记录失败"
);
// 有需求单有沟通记录 json_array_append
}
else
{
var
sql
=
"update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(pobj.actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +pobj.actionBody.BizId +"\"" +" "
var
paramWhere
=
{
Note
:
pobj
.
actionBody
.
Note
,
BizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
console
.
log
(
'updateRes'
,
updateRes
)
if
(
updateRes
[
1
])
{
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
"添加记录失败"
);
}
}
}
module
.
exports
=
BaseQcService
;
center-order/app/base/service/impl/qcutils/ncSve.js
0 → 100644
View file @
45f2656f
const
system
=
require
(
"../../../system"
);
const
moment
=
require
(
'moment'
);
/**
* 网文相关接口(NC)
* laolan
* 2020.11.11
*/
class
NcService
{
constructor
()
{
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
.
ncStatusReference
=
{
507
:
"完成账户注册"
,
508
:
"服务商完成提交资料到⼯信部"
,
509
:
"⼯商部已受理"
,
510
:
"⼯商部不予受理"
,
511
:
"⼯商部通过"
,
512
:
"⼯商部未通过"
};
//网文状态2020-11-11 baidu
this
.
ncSolutionStatus
=
{
"SOLUTION_SUBMIT"
:
"提交服务单"
,
"MATERIAL_UNCONFIRM"
:
"服务商递交⽂件"
,
"REGISTRATION"
:
"完成账户注册"
,
"SUBMITTED"
:
"服务商完成提交资料到⼯信部"
,
"ACCEPTED"
:
"⼯商部已受理"
,
"NOT_ACCEPTED"
:
"⼯商部不予受理"
,
"APPROVED"
:
"⼯商部通过"
,
"NOT_APPROVED"
:
"⼯商部未通过"
,
"CLOSE"
:
"方案关闭"
};
}
//获取需求列表
async
ncGetNeedList
(
pobj
)
{
let
stdate
=
new
Date
(
pobj
.
actionBody
.
Begin
);
let
enddate
=
new
Date
(
pobj
.
actionBody
.
End
);
let
query
=
{
where
:{}};
query
.
where
[
"created_at"
]
=
{
[
this
.
db
.
Op
.
between
]:
[
stdate
,
enddate
]
};
try
{
let
res
=
await
this
.
needinfoDao
.
model
.
findAndCountAll
(
query
);
res
=
res
.
rows
.
map
(
n
=>
n
.
channelNeedNo
);
res
=
pobj
.
actionBody
.
data
.
filter
(
r
=>!
res
.
includes
(
r
.
bizId
));
return
system
.
getResultSuccess
(
res
)
}
catch
(
error
)
{
return
system
.
getResultFail
(
-
1
,
error
.
message
)
}
}
//交付商提交材料信息
async
ncSubmitMaterial
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
console
.
log
(
'ab++'
,
ab
)
if
(
!
ab
.
orderNo
)
{
return
system
.
getResultFail
(
-
101
,
"订单号不能为空"
);
}
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
orderNo
:
ab
.
orderNo
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
301
,
"未知方案"
);
}
ab
[
"bizId"
]
=
ns
.
channelSolutionNo
;
pobj
.
actionBody
=
ab
;
return
this
.
submitNcMaterial
(
pobj
);
}
//提交材料信息
async
submitNcMaterial
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
console
.
log
(
'ababab++'
,
ab
)
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
if
(
!
ab
.
bizId
)
{
return
system
.
getResultFail
(
-
101
,
"渠道方案编号不能为空"
);
}
if
(
!
ab
.
material
)
{
return
system
.
getResultFail
(
-
102
,
"材料信息有误"
);
}
//获取方案信息
var
needsolutioninfo
=
await
this
.
needsolutionDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"needNo"
,
"orderNo"
,
"solutionContent"
],
where
:
{
channelSolutionNo
:
ab
.
bizId
,
isInvalid
:
0
},
raw
:
true
});
console
.
log
(
'needsolutioninfo+++'
,
needsolutioninfo
)
if
(
!
needsolutioninfo
||
!
needsolutioninfo
.
id
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案"
);
}
if
(
!
needsolutioninfo
.
needNo
)
{
return
system
.
getResultFail
(
-
401
,
"方案需求信息有误"
);
}
var
solutionContent
=
needsolutioninfo
.
solutionContent
;
if
(
!
solutionContent
)
{
return
system
.
getResultFail
(
-
402
,
"方案交付信息有误"
);
}
var
orderInfo
=
await
this
.
orderinfoDao
.
model
.
findOne
({
where
:
{
orderNo
:
needsolutioninfo
.
orderNo
},
raw
:
true
})
if
(
orderInfo
){
var
uappId
=
orderInfo
.
uapp_id
}
var
material
=
ab
.
material
;
if
(
!
material
.
businessLicense
.
name
)
{
return
system
.
getResultFail
(
-
101
,
"公司名称不能为空"
);
}
if
(
!
material
.
partnerBusinessLicense
)
{
return
system
.
getResultFail
(
-
103
,
"营业执照不能为空"
);
}
solutionContent
.
material
=
ab
.
material
;
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"MATERIAL_UNCONFIRM"
,
statusName
:
this
.
ncSolutionStatus
.
MATERIAL_UNCONFIRM
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"MATERIAL_UNCONFIRM"
;
solutionContent
.
statusName
=
this
.
ncSolutionStatus
.
MATERIAL_UNCONFIRM
;
needsolutioninfo
.
solutionContent
=
JSON
.
stringify
(
solutionContent
);
let
deliveryContent
=
needsolutioninfo
.
solutionContent
;
let
orderdeliveryData
=
{
sourceOrderNo
:
ab
.
orderNo
,
deliveryContent
:
deliveryContent
,
}
let
orderdeliverySqlData
=
{
sourceOrderNo
:
ab
.
orderNo
}
let
orderdeliverySql
=
"SELECT * FROM `c_order_delivery` WHERE sourceOrderNo = :sourceOrderNo ORDER BY id DESC limit 1"
;
let
orderdeliveryInfo
=
await
this
.
orderdeliveryDao
.
customQuery
(
orderdeliverySql
,
orderdeliverySqlData
)
if
(
!
orderdeliveryInfo
[
0
]){
let
sql
=
"INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUES (:sourceOrderNo,:deliveryContent)"
;
var
orderdelivery
=
await
this
.
orderdeliveryDao
.
customInsert
(
sql
,
orderdeliveryData
);
}
else
{
let
sql
=
"UPDATE `c_order_delivery` SET deliveryContent ='"
+
deliveryContent
+
"' where sourceOrderNo='"
+
ab
.
orderNo
+
"'"
;
var
orderdelivery
=
await
this
.
orderdeliveryDao
.
customInsert
(
sql
);
}
orderdelivery
[
'orderChannelNo'
]
=
orderInfo
.
channelOrderNo
;
orderdelivery
[
'uapp_id'
]
=
uappId
;
console
.
log
(
'nc orderdelivery+++'
,
orderdelivery
)
return
system
.
getResultSuccess
(
orderdelivery
);
}
//提交方案
async
ncSubmitSolution
(
pobj
)
{
console
.
log
(
"pobj++++"
,
pobj
)
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
ab
[
"createUserId"
]
=
user
.
id
;
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"渠道需求号不能为空"
);
}
if
(
!
ab
.
solutionContent
)
{
return
system
.
getResultFail
(
-
102
,
"方案信息有误"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能创建方案"
);
}
var
bizType
=
needinfo
.
typeCode
;
//ab.solutionContent.bizType;//业务类型
ab
.
solutionContent
.
bizType
=
bizType
;
if
(
!
bizType
)
{
return
system
.
getResultFail
(
-
205
,
"方案类型错误"
);
}
if
(
!
needinfo
.
channelTypeCode
)
{
return
system
.
getResultFail
(
-
206
,
"渠道方案类型错误"
);
}
ab
.
solutionContent
.
typeCode
=
needinfo
.
typeCode
;
ab
.
solutionContent
.
typeName
=
needinfo
.
typeName
;
var
ns
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
,
order
:
[[
"id"
,
'asc'
]]
});
for
(
var
i
=
0
;
i
<
ns
.
length
;
i
++
)
{
var
fa
=
ns
[
i
];
if
(
fa
.
status
==
"dqr"
||
fa
.
status
==
"ywc"
)
{
return
system
.
getResultFail
(
-
207
,
"需求方案已存在,不能重复提交"
);
}
if
(
fa
.
status
==
"ybh"
)
{
ab
.
channelSolutionNo
=
fa
.
channelSolutionNo
;
}
if
(
fa
.
status
==
"yzf"
)
{
ab
.
channelSolutionNo
=
""
;
}
}
var
solution
=
ab
.
solutionContent
.
solution
;
if
(
!
solution
)
{
return
system
.
getResultFail
(
-
103
,
"方案交付信息有误"
);
}
if
(
needinfo
.
channelTypeCode
==
"NC"
)
{
ab
.
solutionContent
.
solution
.
icpType
=
"NC"
;
}
else
{
return
system
.
getResultFail
(
-
104
,
"需求业务类型有误"
);
}
if
(
!
solution
.
companyName
)
{
return
system
.
getResultFail
(
-
105
,
"公司名不能为空"
);
}
if
(
!
solution
.
licenseType
)
{
return
system
.
getResultFail
(
-
106
,
"网文类型不能为空"
);
}
if
(
!
solution
.
area
)
{
return
system
.
getResultFail
(
-
107
,
"区域不能为空"
);
}
if
(
!
solution
.
actionType
)
{
return
system
.
getResultFail
(
-
108
,
"办理类型不能为空"
);
}
var
solutionFlowList
=
ab
.
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"SOLUTION_SUBMIT"
,
statusName
:
this
.
ncSolutionStatus
.
SOLUTION_SUBMIT
,
updated_at
:
new
Date
()
});
ab
.
solutionContent
.
status
=
"SOLUTION_SUBMIT"
;
ab
.
solutionContent
.
statusName
=
this
.
ncSolutionStatus
.
SOLUTION_SUBMIT
;
ab
.
solutionContent
.
solutionFlowList
=
solutionFlowList
;
ab
[
"channelNeedNo"
]
=
needinfo
.
channelNeedNo
;
var
solutionNo
=
await
this
.
getBusUid
(
"ns"
);
ab
[
"solutionNo"
]
=
solutionNo
;
ab
[
"status"
]
=
"dqr"
;
var
customerInfo
=
{
//客户信息
"publishName"
:
needinfo
.
publishName
,
"publishMobile"
:
needinfo
.
publishMobile
};
var
salesmanInfo
=
{
//业务员信息
"salesmanName"
:
user
.
channel_username
,
"salesmanMobile"
:
user
.
mobile
,
"salesmanId"
:
user
.
id
,
"salesmanChannelId"
:
user
.
channel_userid
};
ab
.
solutionContent
[
"customerInfo"
]
=
customerInfo
;
ab
.
solutionContent
[
"salesmanInfo"
]
=
salesmanInfo
;
ab
.
solutionContent
=
JSON
.
stringify
(
ab
.
solutionContent
);
var
self
=
this
;
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
ab
[
"needNo"
]
=
needinfo
.
needNo
;
var
od
=
await
self
.
needsolutionDao
.
create
(
ab
,
t
);
if
(
od
&&
od
.
id
)
{
var
needObj
=
{
id
:
needinfo
.
id
};
if
(
!
needinfo
.
followManUserId
)
{
needObj
=
{
id
:
needinfo
.
id
,
followManUserId
:
user
.
id
,
//跟进人id
followManName
:
user
.
channel_username
,
//跟进人姓名
followManMobile
:
user
.
mobile
,
//跟进人手机号(合伙人)
followManOnlyCode
:
user
.
channel_userid
};
}
if
(
!
needinfo
.
followContent
)
{
var
followContent
=
[{
followDate
:
new
Date
(),
content
:
"nc提交方案"
}];
followContent
=
JSON
.
stringify
(
followContent
);
needObj
[
"followContent"
]
=
followContent
;
}
await
self
.
needinfoDao
.
update
(
needObj
,
t
);
needinfo
=
await
self
.
needinfoDao
.
model
.
findOne
({
where
:
{
id
:
needinfo
.
id
},
raw
:
true
});
return
system
.
getResultSuccess
({
needinfo
:
needinfo
,
needsolution
:
od
});
}
else
{
return
system
.
getResultFail
(
-
302
,
"提交方案失败"
);
}
})
}
//交付商通知状态变更
async
ncNotification
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
if
(
!
ab
.
orderNo
)
{
return
system
.
getResultFail
(
-
101
,
"订单号不能为空"
);
}
if
(
!
ab
.
status
)
{
return
system
.
getResultFail
(
-
102
,
"交付状态不能为空"
);
}
else
{
ab
[
"applicationStatus"
]
=
ab
.
status
;
}
if
(
ab
.
officialFileURL
)
{
ab
[
"officialFileURL"
]
=
ab
.
officialFileURL
;
}
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
orderNo
:
ab
.
orderNo
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
301
,
"未知方案"
);
}
ab
[
"bizId"
]
=
ns
.
channelSolutionNo
;
ab
[
"solutionNo"
]
=
ns
.
solutionNo
;
pobj
.
actionBody
=
ab
;
return
this
.
ncAcceptPartnerNotification
(
pobj
);
}
//服务商通知状态变更
async
ncAcceptPartnerNotification
(
pobj
)
{
console
.
log
(
'服务商通知状态变更pobj++++'
,
pobj
)
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
if
(
!
ab
.
solutionNo
)
{
return
system
.
getResultFail
(
-
101
,
"方案编号不能为空"
);
}
if
(
!
ab
.
applicationStatus
)
{
return
system
.
getResultFail
(
-
102
,
"通知状态不能为空"
);
}
//获取方案信息
var
needsolutioninfo
=
await
this
.
needsolutionDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"solutionContent"
,
"needNo"
],
where
:
{
solutionNo
:
ab
.
solutionNo
},
raw
:
true
});
if
(
!
needsolutioninfo
||
!
needsolutioninfo
.
id
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案"
);
}
if
(
!
needsolutioninfo
.
needNo
)
{
return
system
.
getResultFail
(
-
401
,
"方案需求信息有误"
);
}
//获取jiaofu信息
let
orderdeliverySqlData
=
{
sourceOrderNo
:
ab
.
orderNo
}
let
orderdeliverySql
=
"SELECT * FROM `c_order_delivery` WHERE sourceOrderNo = :sourceOrderNo ORDER BY id DESC limit 1"
;
let
orderdeliveryInfo
=
await
this
.
orderdeliveryDao
.
customQuery
(
orderdeliverySql
,
orderdeliverySqlData
)
let
deliveryContent
=
orderdeliveryInfo
[
0
].
deliveryContent
;
console
.
log
(
'nc +++ deliveryContent+++'
,
deliveryContent
)
if
(
!
deliveryContent
)
{
return
system
.
getResultFail
(
-
402
,
"方案交付信息有误"
);
}
if
(
deliveryContent
.
applicationStatus
&&
deliveryContent
.
applicationStatus
>
ab
.
applicationStatus
)
{
return
system
.
getResultFail
(
-
403
,
"操作失败,交付流程未按顺序执行"
);
}
if
(
deliveryContent
.
applicationStatus
&&
deliveryContent
.
applicationStatus
==
ab
.
applicationStatus
)
{
return
system
.
getResultFail
(
-
405
,
"操作失败,该流程状态已提交,不能重复提交"
);
}
var
solutionFlowList
=
deliveryContent
.
solutionFlowList
||
[];
var
orderInfo
=
await
this
.
orderinfoDao
.
model
.
findOne
({
attributes
:[
"uapp_id"
,
"channelOrderNo"
],
where
:
{
orderNo
:
ab
.
orderNo
},
raw
:
true
})
console
.
log
(
"orderInfo+++"
,
orderInfo
)
if
(
orderInfo
){
var
uappId
=
orderInfo
.
uapp_id
;
var
channelOrderNo
=
orderInfo
.
channelOrderNo
}
if
(
ab
.
applicationStatus
==
507
)
{
//完成账户注册
if
(
uappId
==
'18'
){
if
(
deliveryContent
.
status
!=
"USER_CONFIRMED"
)
{
return
system
.
getResultFail
(
-
508
,
"交付流程错误,用户确认递交⽂件后才能执行此操作"
);
}
}
deliveryContent
.
applicationStatus
=
507
;
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"REGISTRATION"
,
statusName
:
this
.
ncSolutionStatus
.
REGISTRATION
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"REGISTRATION"
;
deliveryContent
.
statusName
=
this
.
ncSolutionStatus
.
REGISTRATION
;
}
if
(
ab
.
applicationStatus
==
508
)
{
//"服务商完成提交资料到⼯信部
if
(
deliveryContent
.
status
!=
"REGISTRATION"
)
{
return
system
.
getResultFail
(
-
508
,
"交付流程错误,请先完成账户注册"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"SUBMITTED"
,
statusName
:
this
.
ncSolutionStatus
.
SUBMITTED
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"SUBMITTED"
;
deliveryContent
.
statusName
=
this
.
ncSolutionStatus
.
SUBMITTED
;
}
if
(
ab
.
applicationStatus
==
509
)
{
//⼯商部已受理
if
(
deliveryContent
.
status
!=
"SUBMITTED"
)
{
return
system
.
getResultFail
(
-
509
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"ACCEPTED"
,
statusName
:
this
.
ncSolutionStatus
.
ACCEPTED
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"ACCEPTED"
;
deliveryContent
.
statusName
=
this
.
ncSolutionStatus
.
ACCEPTED
;
}
if
(
ab
.
applicationStatus
==
510
)
{
//⼯商部不予受理
if
(
deliveryContent
.
status
!=
"SUBMITTED"
)
{
return
system
.
getResultFail
(
-
510
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"NOT_ACCEPTED"
,
statusName
:
this
.
ncSolutionStatus
.
NOT_ACCEPTED
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"NOT_ACCEPTED"
;
needsolutioninfo
.
status
=
"ywc"
;
deliveryContent
.
statusName
=
this
.
ncSolutionStatus
.
NOT_ACCEPTED
;
}
if
(
ab
.
applicationStatus
==
511
)
{
//⼯商部通过
if
(
deliveryContent
.
status
!=
"ACCEPTED"
)
{
return
system
.
getResultFail
(
-
511
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"APPROVED"
,
statusName
:
this
.
ncSolutionStatus
.
APPROVED
,
updated_at
:
new
Date
()
});
needsolutioninfo
.
status
=
"ywc"
;
deliveryContent
.
status
=
"APPROVED"
;
deliveryContent
.
statusName
=
this
.
ncSolutionStatus
.
APPROVED
;
}
if
(
ab
.
applicationStatus
==
512
)
{
//⼯信部未通过
if
(
deliveryContent
.
status
!=
"ACCEPTED"
)
{
return
system
.
getResultFail
(
-
512
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"NOT_APPROVED"
,
statusName
:
this
.
ncSolutionStatus
.
NOT_APPROVED
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"NOT_APPROVED"
;
needsolutioninfo
.
status
=
"ywc"
;
deliveryContent
.
statusName
=
this
.
ncSolutionStatus
.
NOT_APPROVED
;
}
deliveryContent
.
solutionFlowList
=
solutionFlowList
;
var
applicationStatusList
=
deliveryContent
.
applicationStatusList
||
[];
var
statusObj
=
{
"officialFileURL"
:
ab
.
officialFileURL
||
""
,
"applicationStatus"
:
ab
.
applicationStatus
,
"applicationStatusName"
:
this
.
ncSolutionStatus
[
ab
.
applicationStatus
],
"created_at"
:
new
Date
()
};
applicationStatusList
.
push
(
statusObj
);
deliveryContent
.
applicationStatusList
=
applicationStatusList
;
deliveryContent
.
applicationStatus
=
ab
.
applicationStatus
;
deliveryContent
=
JSON
.
stringify
(
deliveryContent
);
let
orderdeliveryData
=
{
sourceOrderNo
:
ab
.
orderNo
,
deliveryContent
:
deliveryContent
,
}
if
(
!
orderdeliveryInfo
[
0
]){
let
sql
=
"INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUES (:sourceOrderNo,:deliveryContent)"
;
var
orderdelivery
=
await
this
.
orderdeliveryDao
.
customInsert
(
sql
,
orderdeliveryData
);
}
else
{
let
sql
=
"UPDATE `c_order_delivery` SET deliveryContent ='"
+
deliveryContent
+
"' where sourceOrderNo='"
+
ab
.
orderNo
+
"'"
;
var
orderdelivery
=
await
this
.
orderdeliveryDao
.
customInsert
(
sql
);
}
orderdelivery
[
"bizId"
]
=
ab
.
bizId
;
orderdelivery
[
'uapp_id'
]
=
uappId
;
orderdelivery
[
'channelOrderNo'
]
=
channelOrderNo
;
console
.
log
(
'orderdelivery++'
,
orderdelivery
)
return
system
.
getResultSuccess
(
orderdelivery
);
}
//接收方案编号(方案推送至yun后,接收保存方案信息)
async
ncReceiveProgrammeNo
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
if
(
!
ab
.
solutionBizId
)
{
return
system
.
getResultFail
(
-
101
,
"渠道方案业务编号不能为空"
);
}
if
(
!
ab
.
solutionNo
)
{
return
system
.
getResultFail
(
-
102
,
"方案业务编号不能为空"
);
}
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
solutionNo
:
ab
.
solutionNo
,
isInvalid
:
0
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
103
,
"未知方案"
);
}
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
ns
.
needNo
},
raw
:
true
});
if
(
!
needinfo
)
{
return
system
.
getResultFail
(
-
104
,
"未知方案需求"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
105
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
await
this
.
needsolutionDao
.
model
.
update
({
channelSolutionNo
:
ab
.
solutionBizId
},
{
where
:
{
id
:
ns
.
id
}
});
//修改方案信息
return
system
.
getResultSuccess
();
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async
getBusUid
(
prefix
)
{
prefix
=
(
prefix
||
""
);
if
(
prefix
)
{
prefix
=
prefix
.
toUpperCase
();
}
var
prefixlength
=
prefix
.
length
;
var
subLen
=
8
-
prefixlength
;
var
uidStr
=
""
;
if
(
subLen
>
0
)
{
uidStr
=
await
this
.
getUidInfo
(
subLen
,
60
);
}
var
timStr
=
moment
().
format
(
"YYYYMMDDHHmm"
);
return
prefix
+
timStr
+
uidStr
;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async
getUidInfo
(
len
,
radix
)
{
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
//长度62,到yz长度为长36
var
uuid
=
[],
i
;
radix
=
radix
||
chars
.
length
;
if
(
len
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
}
else
{
var
r
;
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
uuid
[
14
]
=
'4'
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
if
(
!
uuid
[
i
])
{
r
=
0
|
Math
.
random
()
*
16
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
}
}
}
return
uuid
.
join
(
''
);
}
//提交沟通记录
async
ncWriteCommunicationRecord
(
pobj
)
{
// 查询需求沟通记录
pobj
.
actionBody
.
note
=
[
"noteTime"
,
moment
().
format
(
"YYYY-MM-DD HH:mm:ss"
),
"note"
,
pobj
.
actionBody
.
note
];
let
needRes
=
await
this
.
needsolutionDao
.
findOne
({
channelNeedNo
:
pobj
.
actionBody
.
needNo
});
console
.
log
(
'needRes'
,
needRes
)
// 没有需求单直接返回
if
(
!
needRes
)
{
return
system
.
getResult
(
"没有这个需求单"
);
}
// 如果未推送/以推送 修改为已跟进
if
(
needRes
.
status
==
"wts"
||
needRes
.
status
==
"yts"
)
{
var
sql
=
"update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:bizId"
var
paramWhere
=
{
statusName
:
'已跟进'
,
status
:
'ygj'
,
bizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
console
.
log
(
'updateRes'
,
updateRes
)
}
// 有需求单但没有沟通记录 直接set
if
(
!
needRes
.
followContent
)
{
var
sql
=
"update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:bizId"
var
paramWhere
=
{
followContent
:
pobj
.
actionBody
.
note
,
bizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
if
(
updateRes
[
1
])
{
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
"添加记录失败"
);
// 有需求单有沟通记录 json_array_append
}
else
{
var
sql
=
"update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:note)) where channelNeedNo=:bizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(pobj.actionBody.note) + "\""+") where channelNeedNo="+ "\"" +pobj.actionBody.bizId +"\"" +" "
var
paramWhere
=
{
note
:
pobj
.
actionBody
.
note
,
bizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
console
.
log
(
'updateRes'
,
updateRes
)
if
(
updateRes
[
1
])
{
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
"添加记录失败"
);
}
}
//查询沟通记录
async
ncGetCommunicationRecord
(
pobj
){
console
.
log
(
'query++pobj'
,
pobj
)
if
(
!
pobj
.
actionBody
.
intentionBizId
)
{
return
system
.
getResult
(
null
,
"actionBody.intentionBizId can not be empty,100493"
);
}
if
(
pobj
.
appInfo
.
uapp_id
==
18
){
if
(
!
pobj
.
actionBody
.
userFeedBack
)
{
return
system
.
getResult
(
null
,
"actionBody.userFeedBack can not be empty,100494"
);
}
}
var
sql
=
"select uapp_id from n_need_info where channelNeedNo = :channelNeedNo "
;
var
where
=
{
channelNeedNo
:
pobj
.
actionBody
.
intentionBizId
}
var
uappIdInfo
=
await
this
.
customQuery
(
sql
,
where
);
if
(
uappIdInfo
){
uappIdInfo
=
uappIdInfo
[
0
];
return
system
.
getResultSuccess
(
uappIdInfo
);
}
}
//关闭需求
async
ncCloseNeed
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
app
=
pobj
.
appInfo
;
if
(
!
app
||
!
app
.
uapp_id
)
{
return
system
.
getResultFail
(
-
100
,
"未知渠道"
);
}
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"需求编号不能为空"
);
}
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
106
,
"关闭理由不能为空"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"statusName"
,
"needNo"
],
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
var
updateNeed
=
await
this
.
needinfoDao
.
update
(
needObj
);
//关闭需求
if
(
!
updateNeed
)
{
return
system
.
getResultFail
(
-
203
,
"关闭需求失败"
);
}
else
{
return
system
.
getResultSuccess
();
}
}
//根据需求关闭方案(关闭需求后调用)
async
ncClosePlan
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
app
=
pobj
.
appInfo
;
if
(
!
app
||
!
app
.
uapp_id
)
{
return
system
.
getResultFail
(
-
100
,
"未知渠道"
);
}
if
(
!
ab
.
intentionBizId
)
{
return
system
.
getResultFail
(
-
101
,
"需求编号不能为空"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"statusName"
,
"needNo"
,
"uapp_id"
],
//2020-10-29 laolan xinzeng uapp_id
where
:
{
channelNeedNo
:
ab
.
intentionBizId
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
//获取方案信息
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
needNo
:
needinfo
.
needNo
,
isInvalid
:
0
},
raw
:
true
});
if
(
ns
&&
ns
.
id
)
{
if
(
ns
.
status
==
"ywc"
)
{
return
system
.
getResultFail
(
-
103
,
"方案状态错误,不能废弃已完成方案"
);
}
var
flowStatus
=
ns
.
solutionContent
&&
ns
.
solutionContent
.
status
?
ns
.
solutionContent
.
status
:
""
;
if
(
flowStatus
&&
[
"NOT_APPROVED"
,
"CLOSE"
].
indexOf
(
flowStatus
)
<
0
)
{
return
system
.
getResultFail
(
-
104
,
"⽅案状态为关闭或不予受理才可关闭需求"
);
}
}
var
self
=
this
;
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
var
needObj
=
{
id
:
needinfo
.
id
,
status
:
"ygb"
,
notes
:
ab
.
note
};
await
self
.
needinfoDao
.
update
(
needObj
,
t
);
//关闭需求
if
(
ns
&&
ns
.
id
)
{
await
self
.
needsolutionDao
.
model
.
update
({
status
:
"yzf"
,
isInvalid
:
1
},
{
where
:
{
id
:
ns
.
id
},
transaction
:
t
});
//方案废弃
return
system
.
getResultSuccess
(
ns
.
orderNo
);
}
//2020-10-29 laolan
var
uappId
=
{};
uappId
[
'uapp_id'
]
=
needinfo
.
uapp_id
;
ns
=
ns
?
ns
:
{};
ns
=
Object
.
assign
(
ns
,
uappId
)
console
.
log
(
'guanbi ns +++'
,
ns
)
return
system
.
getResultSuccess
(
ns
);
})
}
//交付商关闭交付单
async
ncCloseOrderDelivery
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
if
(
!
ab
.
orderNo
)
{
return
system
.
getResultFail
(
-
101
,
"订单号不能为空"
);
}
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
106
,
"关闭理由不能为空"
);
}
else
{
ab
.
note
=
ab
.
note
;
}
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
orderNo
:
ab
.
orderNo
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
301
,
"未知方案"
);
}
ab
[
"bizId"
]
=
ns
.
channelSolutionNo
;
pobj
.
actionBody
=
ab
;
return
this
.
ncAbolishProgramme
(
pobj
);
}
//服务商作废方案-- ncAbolishProgramme
async
ncAbolishProgramme
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
if
(
!
ab
.
bizId
)
{
return
system
.
getResultFail
(
-
101
,
"渠道方案号不能为空"
);
}
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
106
,
"关闭理由不能为空"
);
}
//获取方案信息
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
channelSolutionNo
:
ab
.
bizId
,
isInvalid
:
0
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
300
,
"未知方案"
);
}
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
ns
.
needNo
},
raw
:
true
});
if
(
!
needinfo
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案需求"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
401
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
// if (ns.status != "dqr") {
// return system.getResultFail(-301, "方案状态错误,只能废弃待确认方案");
// }
var
solutionContent
=
ns
.
solutionContent
;
if
(
!
solutionContent
.
status
||
[
"MATERIAL_UNCONFIRM"
,
"REGISTRATION"
,
"SUBMITTED"
].
indexOf
(
solutionContent
.
status
)
<
0
)
{
return
system
.
getResultFail
(
-
302
,
"方案流程状态错误,不能执行此操作"
);
}
solutionContent
.
serviceProviderNote
=
ab
.
note
;
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"CLOSE"
,
statusName
:
this
.
ncSolutionStatus
.
CLOSE
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CLOSE"
;
solutionContent
.
statusName
=
this
.
ncSolutionStatus
.
CLOSE
;
solutionContent
=
JSON
.
stringify
(
solutionContent
);
await
this
.
needsolutionDao
.
update
({
id
:
ns
.
id
,
status
:
"yzf"
,
isInvalid
:
1
,
solutionContent
:
solutionContent
});
//方案废弃
//获取方案信息
var
new_ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
id
:
ns
.
id
},
raw
:
true
});
return
system
.
getResultSuccess
(
new_ns
);
}
}
module
.
exports
=
NcService
;
center-order/app/base/service/impl/qcutils/rtSve.js
0 → 100644
View file @
45f2656f
const
system
=
require
(
"../../../system"
);
const
moment
=
require
(
'moment'
);
/**
* 广电相关接口(RT)
* laolan
* 2020.11.11
*/
class
RtService
{
constructor
()
{
this
.
needsolutionDao
=
system
.
getObject
(
"db.dbneed.needsolutionDao"
);
this
.
needinfoDao
=
system
.
getObject
(
"db.dbneed.needinfoDao"
);
this
.
orderinfoDao
=
system
.
getObject
(
"db.dbcorder.orderinfoDao"
);
this
.
db
=
system
.
getObject
(
"db.common.connection"
).
getCon
()
this
.
rtStatusReference
=
{
507
:
"完成账户注册"
,
508
:
"服务商完成提交资料到⼯信部"
,
509
:
"⼯商部已受理"
,
510
:
"⼯商部不予受理"
,
511
:
"⼯商部通过"
,
512
:
"⼯商部未通过"
};
//网文状态2020-11-11 baidu
this
.
rtSolutionStatus
=
{
"SOLUTION_SUBMIT"
:
"提交服务单"
,
"MATERIAL_UNCONFIRM"
:
"服务商递交⽂件"
,
"REGISTRATION"
:
"完成账户注册"
,
"SUBMITTED"
:
"服务商完成提交资料到⼯信部"
,
"ACCEPTED"
:
"⼯商部已受理"
,
"NOT_ACCEPTED"
:
"⼯商部不予受理"
,
"APPROVED"
:
"⼯商部通过"
,
"NOT_APPROVED"
:
"⼯商部未通过"
,
"CLOSE"
:
"方案关闭"
};
}
//获取需求列表
async
rtGetNeedList
(
pobj
)
{
let
stdate
=
new
Date
(
pobj
.
actionBody
.
Begin
);
let
enddate
=
new
Date
(
pobj
.
actionBody
.
End
);
let
query
=
{
where
:{}};
query
.
where
[
"created_at"
]
=
{
[
this
.
db
.
Op
.
between
]:
[
stdate
,
enddate
]
};
try
{
let
res
=
await
this
.
needinfoDao
.
model
.
findAndCountAll
(
query
);
res
=
res
.
rows
.
map
(
n
=>
n
.
channelNeedNo
);
res
=
pobj
.
actionBody
.
data
.
filter
(
r
=>!
res
.
includes
(
r
.
bizId
));
return
system
.
getResultSuccess
(
res
)
}
catch
(
error
)
{
return
system
.
getResultFail
(
-
1
,
error
.
message
)
}
}
//交付商提交材料信息
async
rtSubmitMaterial
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
console
.
log
(
'rt ab++'
,
ab
)
if
(
!
ab
.
orderNo
)
{
return
system
.
getResultFail
(
-
101
,
"订单号不能为空"
);
}
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
orderNo
:
ab
.
orderNo
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
301
,
"未知方案"
);
}
ab
[
"bizId"
]
=
ns
.
channelSolutionNo
;
pobj
.
actionBody
=
ab
;
return
this
.
submitRtMaterial
(
pobj
);
}
//提交材料信息
async
submitRtMaterial
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
console
.
log
(
'rt ababab++'
,
ab
)
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
if
(
!
ab
.
bizId
)
{
return
system
.
getResultFail
(
-
101
,
"渠道方案编号不能为空"
);
}
if
(
!
ab
.
material
)
{
return
system
.
getResultFail
(
-
102
,
"材料信息有误"
);
}
//获取方案信息
var
needsolutioninfo
=
await
this
.
needsolutionDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"needNo"
,
"orderNo"
,
"solutionContent"
],
where
:
{
channelSolutionNo
:
ab
.
bizId
,
isInvalid
:
0
},
raw
:
true
});
console
.
log
(
'needsolutioninfo+++'
,
needsolutioninfo
)
if
(
!
needsolutioninfo
||
!
needsolutioninfo
.
id
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案"
);
}
if
(
!
needsolutioninfo
.
needNo
)
{
return
system
.
getResultFail
(
-
401
,
"方案需求信息有误"
);
}
var
solutionContent
=
needsolutioninfo
.
solutionContent
;
if
(
!
solutionContent
)
{
return
system
.
getResultFail
(
-
402
,
"方案交付信息有误"
);
}
var
orderInfo
=
await
this
.
orderinfoDao
.
model
.
findOne
({
where
:
{
orderNo
:
needsolutioninfo
.
orderNo
},
raw
:
true
})
if
(
orderInfo
){
var
uappId
=
orderInfo
.
uapp_id
}
var
material
=
ab
.
material
;
if
(
!
material
.
name
)
{
return
system
.
getResultFail
(
-
101
,
"公司名称不能为空"
);
}
if
(
!
material
.
partnerBusinessLicense
)
{
return
system
.
getResultFail
(
-
103
,
"营业执照不能为空"
);
}
solutionContent
.
material
=
ab
.
material
;
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"MATERIAL_UNCONFIRM"
,
statusName
:
this
.
rtSolutionStatus
.
MATERIAL_UNCONFIRM
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"MATERIAL_UNCONFIRM"
;
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
MATERIAL_UNCONFIRM
;
needsolutioninfo
.
solutionContent
=
JSON
.
stringify
(
solutionContent
);
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
await
this
.
needsolutionDao
.
update
(
needsolutioninfo
,
t
);
var
new_needsolutioninfo
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
id
:
needsolutioninfo
.
id
},
raw
:
true
});
new_needsolutioninfo
[
'orderChannelNo'
]
=
orderInfo
.
channelOrderNo
;
new_needsolutioninfo
[
'uapp_id'
]
=
uappId
;
console
.
log
(
'rt new_needsolutioninfo+++'
,
new_needsolutioninfo
)
return
system
.
getResultSuccess
(
new_needsolutioninfo
);
})
}
//提交方案
async
rtSubmitSolution
(
pobj
)
{
console
.
log
(
"rt pobj++++"
,
pobj
)
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
ab
[
"createUserId"
]
=
user
.
id
;
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"渠道需求号不能为空"
);
}
if
(
!
ab
.
solutionContent
)
{
return
system
.
getResultFail
(
-
102
,
"方案信息有误"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能创建方案"
);
}
var
bizType
=
needinfo
.
typeCode
;
//ab.solutionContent.bizType;//业务类型
ab
.
solutionContent
.
bizType
=
bizType
;
if
(
!
bizType
)
{
return
system
.
getResultFail
(
-
205
,
"方案类型错误"
);
}
if
(
!
needinfo
.
channelTypeCode
)
{
return
system
.
getResultFail
(
-
206
,
"渠道方案类型错误"
);
}
ab
.
solutionContent
.
typeCode
=
needinfo
.
typeCode
;
ab
.
solutionContent
.
typeName
=
needinfo
.
typeName
;
var
ns
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
,
order
:
[[
"id"
,
'asc'
]]
});
for
(
var
i
=
0
;
i
<
ns
.
length
;
i
++
)
{
var
fa
=
ns
[
i
];
if
(
fa
.
status
==
"dqr"
||
fa
.
status
==
"ywc"
)
{
return
system
.
getResultFail
(
-
207
,
"需求方案已存在,不能重复提交"
);
}
if
(
fa
.
status
==
"ybh"
)
{
ab
.
channelSolutionNo
=
fa
.
channelSolutionNo
;
}
if
(
fa
.
status
==
"yzf"
)
{
ab
.
channelSolutionNo
=
""
;
}
}
var
solution
=
ab
.
solutionContent
.
solution
;
if
(
!
solution
)
{
return
system
.
getResultFail
(
-
103
,
"方案交付信息有误"
);
}
if
(
needinfo
.
channelTypeCode
==
"RT"
)
{
ab
.
solutionContent
.
solution
.
icpType
=
"RT"
;
}
else
{
return
system
.
getResultFail
(
-
104
,
"需求业务类型有误"
);
}
if
(
!
solution
.
companyName
)
{
return
system
.
getResultFail
(
-
105
,
"公司名不能为空"
);
}
if
(
!
solution
.
licenseType
)
{
return
system
.
getResultFail
(
-
106
,
"网文类型不能为空"
);
}
if
(
!
solution
.
area
)
{
return
system
.
getResultFail
(
-
107
,
"区域不能为空"
);
}
if
(
!
solution
.
actionType
)
{
return
system
.
getResultFail
(
-
108
,
"办理类型不能为空"
);
}
var
solutionFlowList
=
ab
.
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"SOLUTION_SUBMIT"
,
statusName
:
this
.
rtSolutionStatus
.
SOLUTION_SUBMIT
,
updated_at
:
new
Date
()
});
ab
.
solutionContent
.
status
=
"SOLUTION_SUBMIT"
;
ab
.
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
SOLUTION_SUBMIT
;
ab
.
solutionContent
.
solutionFlowList
=
solutionFlowList
;
ab
[
"channelNeedNo"
]
=
needinfo
.
channelNeedNo
;
var
solutionNo
=
await
this
.
getBusUid
(
"ns"
);
ab
[
"solutionNo"
]
=
solutionNo
;
ab
[
"status"
]
=
"dqr"
;
var
customerInfo
=
{
//客户信息
"publishName"
:
needinfo
.
publishName
,
"publishMobile"
:
needinfo
.
publishMobile
};
var
salesmanInfo
=
{
//业务员信息
"salesmanName"
:
user
.
channel_username
,
"salesmanMobile"
:
user
.
mobile
,
"salesmanId"
:
user
.
id
,
"salesmanChannelId"
:
user
.
channel_userid
};
ab
.
solutionContent
[
"customerInfo"
]
=
customerInfo
;
ab
.
solutionContent
[
"salesmanInfo"
]
=
salesmanInfo
;
ab
.
solutionContent
=
JSON
.
stringify
(
ab
.
solutionContent
);
var
self
=
this
;
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
ab
[
"needNo"
]
=
needinfo
.
needNo
;
var
od
=
await
self
.
needsolutionDao
.
create
(
ab
,
t
);
if
(
od
&&
od
.
id
)
{
var
needObj
=
{
id
:
needinfo
.
id
};
if
(
!
needinfo
.
followManUserId
)
{
needObj
=
{
id
:
needinfo
.
id
,
followManUserId
:
user
.
id
,
//跟进人id
followManName
:
user
.
channel_username
,
//跟进人姓名
followManMobile
:
user
.
mobile
,
//跟进人手机号(合伙人)
followManOnlyCode
:
user
.
channel_userid
};
}
if
(
!
needinfo
.
followContent
)
{
var
followContent
=
[{
followDate
:
new
Date
(),
content
:
"rt提交方案"
}];
followContent
=
JSON
.
stringify
(
followContent
);
needObj
[
"followContent"
]
=
followContent
;
}
await
self
.
needinfoDao
.
update
(
needObj
,
t
);
needinfo
=
await
self
.
needinfoDao
.
model
.
findOne
({
where
:
{
id
:
needinfo
.
id
},
raw
:
true
});
return
system
.
getResultSuccess
({
needinfo
:
needinfo
,
needsolution
:
od
});
}
else
{
return
system
.
getResultFail
(
-
302
,
"提交方案失败"
);
}
})
}
//交付商通知状态变更
async
rtNotification
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
if
(
!
ab
.
orderNo
)
{
return
system
.
getResultFail
(
-
101
,
"订单号不能为空"
);
}
if
(
!
ab
.
status
)
{
return
system
.
getResultFail
(
-
102
,
"交付状态不能为空"
);
}
else
{
ab
[
"applicationStatus"
]
=
ab
.
status
;
}
if
(
ab
.
officialFileURL
)
{
ab
[
"officialFileURL"
]
=
ab
.
officialFileURL
;
}
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
orderNo
:
ab
.
orderNo
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
301
,
"未知方案"
);
}
ab
[
"bizId"
]
=
ns
.
channelSolutionNo
;
ab
[
"solutionNo"
]
=
ns
.
solutionNo
;
pobj
.
actionBody
=
ab
;
return
this
.
rtAcceptPartnerNotification
(
pobj
);
}
//服务商通知状态变更
async
rtAcceptPartnerNotification
(
pobj
)
{
console
.
log
(
'rt 服务商通知状态变更pobj++++'
,
pobj
)
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
if
(
!
ab
.
solutionNo
)
{
return
system
.
getResultFail
(
-
101
,
"方案编号不能为空"
);
}
if
(
!
ab
.
applicationStatus
)
{
return
system
.
getResultFail
(
-
102
,
"通知状态不能为空"
);
}
//获取方案信息
var
needsolutioninfo
=
await
this
.
needsolutionDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"solutionContent"
,
"needNo"
],
where
:
{
solutionNo
:
ab
.
solutionNo
},
raw
:
true
});
if
(
!
needsolutioninfo
||
!
needsolutioninfo
.
id
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案"
);
}
if
(
!
needsolutioninfo
.
needNo
)
{
return
system
.
getResultFail
(
-
401
,
"方案需求信息有误"
);
}
var
solutionContent
=
needsolutioninfo
.
solutionContent
;
if
(
!
solutionContent
)
{
return
system
.
getResultFail
(
-
402
,
"方案交付信息有误"
);
}
if
(
solutionContent
.
applicationStatus
&&
solutionContent
.
applicationStatus
>
ab
.
applicationStatus
)
{
return
system
.
getResultFail
(
-
403
,
"操作失败,交付流程未按顺序执行"
);
}
if
(
solutionContent
.
applicationStatus
&&
solutionContent
.
applicationStatus
==
ab
.
applicationStatus
)
{
return
system
.
getResultFail
(
-
405
,
"操作失败,该流程状态已提交,不能重复提交"
);
}
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
var
orderInfo
=
await
this
.
orderinfoDao
.
model
.
findOne
({
attributes
:[
"uapp_id"
,
"channelOrderNo"
],
where
:
{
orderNo
:
ab
.
orderNo
},
raw
:
true
})
console
.
log
(
"rt orderInfo+++"
,
orderInfo
)
if
(
orderInfo
){
var
uappId
=
orderInfo
.
uapp_id
;
var
channelOrderNo
=
orderInfo
.
channelOrderNo
}
if
(
ab
.
applicationStatus
==
507
)
{
//完成账户注册
solutionContent
.
applicationStatus
=
507
;
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"REGISTRATION"
,
statusName
:
this
.
rtSolutionStatus
.
REGISTRATION
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"REGISTRATION"
;
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
REGISTRATION
;
}
if
(
ab
.
applicationStatus
==
508
)
{
//"服务商完成提交资料到⼯信部
if
(
solutionContent
.
status
!=
"REGISTRATION"
)
{
return
system
.
getResultFail
(
-
508
,
"交付流程错误,请先完成账户注册"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"SUBMITTED"
,
statusName
:
this
.
rtSolutionStatus
.
SUBMITTED
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"SUBMITTED"
;
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
SUBMITTED
;
}
if
(
ab
.
applicationStatus
==
509
)
{
//⼯商部已受理
if
(
solutionContent
.
status
!=
"SUBMITTED"
)
{
return
system
.
getResultFail
(
-
509
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"ACCEPTED"
,
statusName
:
this
.
rtSolutionStatus
.
ACCEPTED
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"ACCEPTED"
;
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
ACCEPTED
;
}
if
(
ab
.
applicationStatus
==
510
)
{
//⼯商部不予受理
if
(
solutionContent
.
status
!=
"SUBMITTED"
)
{
return
system
.
getResultFail
(
-
510
,
"交付流程错误,请先完成资料递交"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"NOT_ACCEPTED"
,
statusName
:
this
.
rtSolutionStatus
.
NOT_ACCEPTED
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"NOT_ACCEPTED"
;
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
NOT_ACCEPTED
;
}
if
(
ab
.
applicationStatus
==
511
)
{
//⼯商部通过
if
(
solutionContent
.
status
!=
"ACCEPTED"
)
{
return
system
.
getResultFail
(
-
511
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"APPROVED"
,
statusName
:
this
.
rtSolutionStatus
.
APPROVED
,
updated_at
:
new
Date
()
});
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
status
=
"APPROVED"
;
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
APPROVED
;
}
if
(
ab
.
applicationStatus
==
512
)
{
//⼯信部未通过
if
(
solutionContent
.
status
!=
"ACCEPTED"
)
{
return
system
.
getResultFail
(
-
512
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
solutionFlowList
.
push
({
file
:
ab
.
officialFileURL
||
""
,
status
:
"NOT_APPROVED"
,
statusName
:
this
.
rtSolutionStatus
.
NOT_APPROVED
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"NOT_APPROVED"
;
needsolutioninfo
.
status
=
"ywc"
;
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
NOT_APPROVED
;
}
solutionContent
.
solutionFlowList
=
solutionFlowList
;
var
applicationStatusList
=
solutionContent
.
applicationStatusList
||
[];
var
statusObj
=
{
"officialFileURL"
:
ab
.
officialFileURL
||
""
,
"applicationStatus"
:
ab
.
applicationStatus
,
"applicationStatusName"
:
this
.
rtSolutionStatus
[
ab
.
applicationStatus
],
"created_at"
:
new
Date
()
};
applicationStatusList
.
push
(
statusObj
);
solutionContent
.
applicationStatusList
=
applicationStatusList
;
solutionContent
.
applicationStatus
=
ab
.
applicationStatus
;
needsolutioninfo
.
solutionContent
=
JSON
.
stringify
(
solutionContent
);
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
await
self
.
needsolutionDao
.
update
(
needsolutioninfo
,
t
);
statusObj
[
"bizId"
]
=
ab
.
bizId
;
statusObj
[
'uapp_id'
]
=
uappId
;
statusObj
[
'channelOrderNo'
]
=
channelOrderNo
;
console
.
log
(
'rt statusObj++'
,
statusObj
)
return
system
.
getResultSuccess
(
statusObj
);
})
}
//接收方案编号(方案推送至yun后,接收保存方案信息)
async
rtReceiveProgrammeNo
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
if
(
!
ab
.
solutionBizId
)
{
return
system
.
getResultFail
(
-
101
,
"渠道方案业务编号不能为空"
);
}
if
(
!
ab
.
solutionNo
)
{
return
system
.
getResultFail
(
-
102
,
"方案业务编号不能为空"
);
}
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
solutionNo
:
ab
.
solutionNo
,
isInvalid
:
0
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
103
,
"未知方案"
);
}
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
ns
.
needNo
},
raw
:
true
});
if
(
!
needinfo
)
{
return
system
.
getResultFail
(
-
104
,
"未知方案需求"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
105
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
await
this
.
needsolutionDao
.
model
.
update
({
channelSolutionNo
:
ab
.
solutionBizId
},
{
where
:
{
id
:
ns
.
id
}
});
//修改方案信息
return
system
.
getResultSuccess
();
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async
getBusUid
(
prefix
)
{
prefix
=
(
prefix
||
""
);
if
(
prefix
)
{
prefix
=
prefix
.
toUpperCase
();
}
var
prefixlength
=
prefix
.
length
;
var
subLen
=
8
-
prefixlength
;
var
uidStr
=
""
;
if
(
subLen
>
0
)
{
uidStr
=
await
this
.
getUidInfo
(
subLen
,
60
);
}
var
timStr
=
moment
().
format
(
"YYYYMMDDHHmm"
);
return
prefix
+
timStr
+
uidStr
;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async
getUidInfo
(
len
,
radix
)
{
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
//长度62,到yz长度为长36
var
uuid
=
[],
i
;
radix
=
radix
||
chars
.
length
;
if
(
len
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
}
else
{
var
r
;
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
uuid
[
14
]
=
'4'
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
if
(
!
uuid
[
i
])
{
r
=
0
|
Math
.
random
()
*
16
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
}
}
}
return
uuid
.
join
(
''
);
}
//提交沟通记录
async
rtWriteCommunicationRecord
(
pobj
)
{
// 查询需求沟通记录
pobj
.
actionBody
.
note
=
[
"noteTime"
,
moment
().
format
(
"YYYY-MM-DD HH:mm:ss"
),
"note"
,
pobj
.
actionBody
.
note
];
let
needRes
=
await
this
.
needsolutionDao
.
findOne
({
channelNeedNo
:
pobj
.
actionBody
.
needNo
});
console
.
log
(
'needRes'
,
needRes
)
// 没有需求单直接返回
if
(
!
needRes
)
{
return
system
.
getResult
(
"没有这个需求单"
);
}
// 如果未推送/以推送 修改为已跟进
if
(
needRes
.
status
==
"wts"
||
needRes
.
status
==
"yts"
)
{
var
sql
=
"update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:bizId"
var
paramWhere
=
{
statusName
:
'已跟进'
,
status
:
'ygj'
,
bizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
console
.
log
(
'updateRes'
,
updateRes
)
}
// 有需求单但没有沟通记录 直接set
if
(
!
needRes
.
followContent
)
{
var
sql
=
"update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:bizId"
var
paramWhere
=
{
followContent
:
pobj
.
actionBody
.
note
,
bizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
if
(
updateRes
[
1
])
{
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
"添加记录失败"
);
// 有需求单有沟通记录 json_array_append
}
else
{
var
sql
=
"update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:note)) where channelNeedNo=:bizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(pobj.actionBody.note) + "\""+") where channelNeedNo="+ "\"" +pobj.actionBody.bizId +"\"" +" "
var
paramWhere
=
{
note
:
pobj
.
actionBody
.
note
,
bizId
:
pobj
.
actionBody
.
needNo
};
var
updateRes
=
await
this
.
orderinfoDao
.
customUpdate
(
sql
,
paramWhere
);
console
.
log
(
'updateRes'
,
updateRes
)
if
(
updateRes
[
1
])
{
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
"添加记录失败"
);
}
}
//查询沟通记录
async
rtGetCommunicationRecord
(
pobj
){
console
.
log
(
'query++pobj'
,
pobj
)
if
(
!
pobj
.
actionBody
.
intentionBizId
)
{
return
system
.
getResult
(
null
,
"actionBody.intentionBizId can not be empty,100493"
);
}
if
(
pobj
.
appInfo
.
uapp_id
==
18
){
if
(
!
pobj
.
actionBody
.
userFeedBack
)
{
return
system
.
getResult
(
null
,
"actionBody.userFeedBack can not be empty,100494"
);
}
}
var
sql
=
"select uapp_id from n_need_info where channelNeedNo = :channelNeedNo "
;
var
where
=
{
channelNeedNo
:
pobj
.
actionBody
.
intentionBizId
}
var
uappIdInfo
=
await
this
.
customQuery
(
sql
,
where
);
if
(
uappIdInfo
){
uappIdInfo
=
uappIdInfo
[
0
];
return
system
.
getResultSuccess
(
uappIdInfo
);
}
}
//关闭需求
async
rtCloseNeed
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
app
=
pobj
.
appInfo
;
if
(
!
app
||
!
app
.
uapp_id
)
{
return
system
.
getResultFail
(
-
100
,
"未知渠道"
);
}
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"需求编号不能为空"
);
}
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
106
,
"关闭理由不能为空"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"statusName"
,
"needNo"
],
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
var
updateNeed
=
await
this
.
needinfoDao
.
update
(
needObj
);
//关闭需求
if
(
!
updateNeed
)
{
return
system
.
getResultFail
(
-
203
,
"关闭需求失败"
);
}
else
{
return
system
.
getResultSuccess
();
}
}
//根据需求关闭方案(关闭需求后调用)
async
rtClosePlan
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
app
=
pobj
.
appInfo
;
if
(
!
app
||
!
app
.
uapp_id
)
{
return
system
.
getResultFail
(
-
100
,
"未知渠道"
);
}
if
(
!
ab
.
intentionBizId
)
{
return
system
.
getResultFail
(
-
101
,
"需求编号不能为空"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"statusName"
,
"needNo"
,
"uapp_id"
],
//2020-10-29 laolan xinzeng uapp_id
where
:
{
channelNeedNo
:
ab
.
intentionBizId
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
//获取方案信息
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
needNo
:
needinfo
.
needNo
,
isInvalid
:
0
},
raw
:
true
});
if
(
ns
&&
ns
.
id
)
{
if
(
ns
.
status
==
"ywc"
)
{
return
system
.
getResultFail
(
-
103
,
"方案状态错误,不能废弃已完成方案"
);
}
var
flowStatus
=
ns
.
solutionContent
&&
ns
.
solutionContent
.
status
?
ns
.
solutionContent
.
status
:
""
;
if
(
flowStatus
&&
[
"NOT_APPROVED"
,
"CLOSE"
].
indexOf
(
flowStatus
)
<
0
)
{
return
system
.
getResultFail
(
-
104
,
"⽅案状态为关闭或不予受理才可关闭需求"
);
}
}
var
self
=
this
;
return
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
var
needObj
=
{
id
:
needinfo
.
id
,
status
:
"ygb"
,
notes
:
ab
.
note
};
await
self
.
needinfoDao
.
update
(
needObj
,
t
);
//关闭需求
if
(
ns
&&
ns
.
id
)
{
await
self
.
needsolutionDao
.
model
.
update
({
status
:
"yzf"
,
isInvalid
:
1
},
{
where
:
{
id
:
ns
.
id
},
transaction
:
t
});
//方案废弃
return
system
.
getResultSuccess
(
ns
.
orderNo
);
}
var
uappId
=
{};
uappId
[
'uapp_id'
]
=
needinfo
.
uapp_id
;
ns
=
ns
?
ns
:
{};
ns
=
Object
.
assign
(
ns
,
uappId
)
console
.
log
(
'rt guanbi ns +++'
,
ns
)
return
system
.
getResultSuccess
(
ns
);
})
}
//交付商关闭交付单
async
rtCloseOrderDelivery
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
if
(
!
ab
.
orderNo
)
{
return
system
.
getResultFail
(
-
101
,
"订单号不能为空"
);
}
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
106
,
"关闭理由不能为空"
);
}
else
{
ab
.
note
=
ab
.
note
;
}
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
orderNo
:
ab
.
orderNo
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
301
,
"未知方案"
);
}
ab
[
"bizId"
]
=
ns
.
channelSolutionNo
;
pobj
.
actionBody
=
ab
;
return
this
.
rtAbolishProgramme
(
pobj
);
}
//服务商作废方案-- rtAbolishProgramme
async
rtAbolishProgramme
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
user
=
pobj
.
userInfo
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知用户"
);
}
if
(
!
ab
.
bizId
)
{
return
system
.
getResultFail
(
-
101
,
"渠道方案号不能为空"
);
}
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
106
,
"关闭理由不能为空"
);
}
//获取方案信息
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
channelSolutionNo
:
ab
.
bizId
,
isInvalid
:
0
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
300
,
"未知方案"
);
}
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
ns
.
needNo
},
raw
:
true
});
if
(
!
needinfo
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案需求"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
401
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
// if (ns.status != "dqr") {
// return system.getResultFail(-301, "方案状态错误,只能废弃待确认方案");
// }
var
solutionContent
=
ns
.
solutionContent
;
if
(
!
solutionContent
.
status
||
[
"MATERIAL_UNCONFIRM"
,
"REGISTRATION"
,
"SUBMITTED"
].
indexOf
(
solutionContent
.
status
)
<
0
)
{
return
system
.
getResultFail
(
-
302
,
"方案流程状态错误,不能执行此操作"
);
}
solutionContent
.
serviceProviderNote
=
ab
.
note
;
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"CLOSE"
,
statusName
:
this
.
rtSolutionStatus
.
CLOSE
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CLOSE"
;
solutionContent
.
statusName
=
this
.
rtSolutionStatus
.
CLOSE
;
solutionContent
=
JSON
.
stringify
(
solutionContent
);
await
this
.
needsolutionDao
.
update
({
id
:
ns
.
id
,
status
:
"yzf"
,
isInvalid
:
1
,
solutionContent
:
solutionContent
});
//方案废弃
//获取方案信息
var
new_ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
id
:
ns
.
id
},
raw
:
true
});
return
system
.
getResultSuccess
(
new_ns
);
}
}
module
.
exports
=
RtService
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment