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
3c9aeb12
Commit
3c9aeb12
authored
Dec 20, 2020
by
兰国旗
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
laolan
parent
8ccd9019
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
505 additions
and
449 deletions
+505
-449
center-order/app/base/api/impl/action/regapi.js
+10
-4
center-order/app/base/db/impl/reg/regcenterorderDao.js
+74
-0
center-order/app/base/db/models/reg/regcenterorder.js
+56
-0
center-order/app/base/service/impl/dbcorder/orderinfoSve.js
+9
-0
center-order/app/base/service/impl/qcutils/regCenterOrderSve.js
+356
-445
No files found.
center-order/app/base/api/impl/action/regapi.js
View file @
3c9aeb12
...
...
@@ -34,16 +34,19 @@ class RegAPI extends APIBase {
case
"receiveSolutionPayInfoNew"
:
//接收reg方案状态及支付信息(方案支付后创建订单时调用)
opResult
=
await
this
.
regCenterOrderSve
.
receiveSolutionPayInfoNew
(
pobj
);
break
;
// case "receiveOrderStatusNotify"://接收订单状态推送 百度reg 2.3
// opResult = await this.regCenterOrderSve.receiveOrderStatusNotify(pobj);
// break;
case
"getItemByChannelSolutionNo"
:
//渠道方案号获取需求详情
opResult
=
await
this
.
regCenterOrderSve
.
getItemByChannelSolutionNo
(
pobj
,
pobj
.
actionBody
,
req
);
break
;
case
"
getR
egOrderStatus"
:
//接收订单状态推送 百度reg 2.3
opResult
=
await
this
.
regCenterOrderSve
.
getR
egOrderStatus
(
pobj
);
case
"
r
egOrderStatus"
:
//接收订单状态推送 百度reg 2.3
opResult
=
await
this
.
regCenterOrderSve
.
r
egOrderStatus
(
pobj
);
break
;
case
"addRegSalesmanInfo"
:
//添加业务员信息,用于直接下单的reg订单
opResult
=
await
this
.
regCenterOrderSve
.
addRegSalesmanInfo
(
pobj
);
break
;
case
"submitRegNeed"
:
//提交需求
case
"submitRegNeed"
:
//提交需求
2.1
opResult
=
await
this
.
regCenterOrderSve
.
submitRegNeed
(
pobj
,
pobj
.
actionBody
,
req
);
break
;
...
...
@@ -59,9 +62,12 @@ class RegAPI extends APIBase {
case
"updateRegOrdertatus"
:
//提交交付信息/修改订单状态
opResult
=
await
this
.
regCenterOrderSve
.
updateRegOrdertatus
(
pobj
);
break
;
case
"closeRegNeed"
:
//
需求关闭
case
"closeRegNeed"
:
//
前端关闭reg需求及方案
opResult
=
await
this
.
regCenterOrderSve
.
closeRegNeed
(
pobj
);
break
;
case
"getRegInfoByChannelNeedNo"
:
//获取需求方案列表
opResult
=
await
this
.
regCenterOrderSve
.
reqCenterOrderApi
(
pobj
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
...
...
center-order/app/base/db/impl/reg/regcenterorderDao.js
0 → 100644
View file @
3c9aeb12
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
RegCenterorderDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
RegCenterorderDao
));
}
async
getItemByNeedNo
(
needNo
)
{
return
await
this
.
model
.
findOne
({
where
:
{
needNo
:
needNo
},
attributes
:
[
"id"
,
"uapp_id"
,
"needNo"
,
"channelNeedNo"
,
"channelUserId"
,
"followManUserId"
,
"followManMobile"
,
"city"
,
"province"
,
"publishContent"
,
"publishName"
,
"publishMobile"
,
"notes"
,
"followContent"
,
"disposeNotes"
,
"status"
,
"statusName"
,
"typeCode"
,
"typeName"
,
"channelTypeCode"
,
"channelTypeName"
,
"publisherOnlyCode"
,
"followManName"
,
"followManOnlyCode"
,
"created_at"
],
raw
:
true
});
}
async
getItemByChannelNeedNo
(
channelNeedNo
)
{
return
await
this
.
model
.
findOne
({
where
:
{
channelNeedNo
:
channelNeedNo
},
attributes
:
[
"id"
,
"uapp_id"
,
"needNo"
,
"channelNeedNo"
,
"channelUserId"
,
"followManUserId"
,
"followManMobile"
,
"city"
,
"province"
,
"publishContent"
,
"publishName"
,
"publishMobile"
,
"notes"
,
"followContent"
,
"disposeNotes"
,
"status"
,
"typeCode"
,
"typeName"
,
"channelTypeCode"
,
"channelTypeName"
,
"publisherOnlyCode"
,
"followManName"
,
"followManOnlyCode"
],
raw
:
true
});
}
}
module
.
exports
=
RegCenterorderDao
;
center-order/app/base/db/models/reg/regcenterorder.js
0 → 100644
View file @
3c9aeb12
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
appKey
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"regcenterorder"
,
{
uapp_id
:
DataTypes
.
INTEGER
,
channelNeedNo
:
DataTypes
.
STRING
(
128
),
//渠道需求号(页面中列表中显示该需求号)
needNo
:
DataTypes
.
STRING
(
128
),
//需求号--用于服务商或需求表中创建订单
channelUserId
:
DataTypes
.
INTEGER
,
//发布者id
publishName
:
DataTypes
.
STRING
,
//发布者姓名
publisherOnlyCode
:
DataTypes
.
STRING
(
50
),
//发布者唯一码
publishContent
:
DataTypes
.
STRING
,
//发布内容
publishMobile
:
DataTypes
.
STRING
,
//发布者手机号
followManUserId
:
DataTypes
.
INTEGER
,
//跟进人id
followManName
:
DataTypes
.
STRING
,
//跟进人姓名
followManMobile
:
DataTypes
.
STRING
,
//跟进人手机号(合伙人)
followManOnlyCode
:
DataTypes
.
STRING
(
50
),
//跟进者唯一码
followContent
:
DataTypes
.
JSON
,
//跟进内容
productOneType_id
:
DataTypes
.
STRING
,
//产品大类Id
productType_id
:
DataTypes
.
STRING
,
//产品类型Id
notes
:
DataTypes
.
STRING
,
//备注
disposeNotes
:
DataTypes
.
STRING
,
//处理的备注
statusName
:
DataTypes
.
STRING
,
status
:
{
//wts未推送,yts已推送,ygj已跟进,ycd已成单
type
:
DataTypes
.
ENUM
,
values
:
Object
.
keys
(
uiconfig
.
config
.
pdict
.
push_chance_type
),
set
:
function
(
val
)
{
this
.
setDataValue
(
"status"
,
val
);
this
.
setDataValue
(
"statusName"
,
uiconfig
.
config
.
pdict
.
push_chance_type
[
val
]);
}
},
city
:
DataTypes
.
STRING
(
50
),
// 城市
province
:
DataTypes
.
STRING
(
50
),
// 省份
typeCode
:
DataTypes
.
STRING
(
50
),
//产品类型编码',
typeName
:
DataTypes
.
STRING
(
50
),
//类型产品名称',
channelTypeCode
:
DataTypes
.
STRING
(
50
),
//渠道产品类型编码',
channelTypeName
:
DataTypes
.
STRING
(
255
),
//渠道产品类型名称',
level
:
DataTypes
.
STRING
(
20
),
//商机等级
probability
:
DataTypes
.
STRING
(
20
),
//商机概率
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'n_need_info'
,
validate
:
{
},
indexes
:
[
]
});
}
center-order/app/base/service/impl/dbcorder/orderinfoSve.js
View file @
3c9aeb12
...
...
@@ -992,6 +992,15 @@ class OrderInfoService extends ServiceBase {
await
this
.
dao
.
delOrderByOrderNo
(
actionBody
.
orderNo
,
pobj
.
appInfo
.
uapp_id
,
pobj
.
userInfo
.
channel_userid
);
return
system
.
getResultSuccess
();
}
//reg关闭订单 2020-12-20
async
delOrders
(
pobj
,
actionBody
)
{
//删除订单
var
i
;
var
len
=
actionBody
.
orderNo
.
length
for
(
i
=
0
;
i
<
len
;
i
++
){
await
this
.
dao
.
delOrderByOrderNo
(
actionBody
.
orderNo
[
i
],
pobj
.
appInfo
.
uapp_id
,
pobj
.
userInfo
.
channel_userid
);
}
return
system
.
getResultSuccess
();
}
// 2020 0918 lin 新增 根据OrderStatus查询订单
async
queryVOrderByOrderStatusAndItemCode
(
pobj
,
actionBody
)
{
var
sql
=
"select `id`,`isSolution`,`orderNo`,`channelServiceNo`,`channelOrderNo`,`channelUserId`,`ownerUserId`,`payTime`,`quantity`,`serviceQuantity`,`orderStatusName`,`orderStatus`,`totalSum`,`payTotalSum`,`refundSum`,"
...
...
center-order/app/base/service/impl/qcutils/regCenterOrderSve.js
View file @
3c9aeb12
//工商注册
const
system
=
require
(
"../../../system"
);
const
moment
=
require
(
'moment'
);
class
regCenterOrderService
{
constructor
()
{
const
ServiceBase
=
require
(
"../../sve.base"
);
class
RegCenterOrderService
extends
ServiceBase
{
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"
);
...
...
@@ -36,8 +37,8 @@ class regCenterOrderService {
// "CLOSE": "方案关闭"
};
}
//----------2.
//添加业务员信息,用于直接下单的reg订单
async
addRegSalesmanInfo
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
...
...
@@ -86,7 +87,7 @@ class regCenterOrderService {
}
//接收渠道方案状态变更通知
async
getR
egOrderStatus
(
pobj
)
{
async
r
egOrderStatus
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
if
(
!
ab
.
BizId
)
{
return
system
.
getResultFail
(
-
101
,
"渠道方案号不能为空"
);
...
...
@@ -98,14 +99,14 @@ class regCenterOrderService {
return
system
.
getResultSuccess
();
}
//获取方案信息
var
ns
=
await
this
.
needsolutionDao
.
model
.
find
One
({
var
ns
=
await
this
.
needsolutionDao
.
model
.
find
All
({
where
:
{
channelSolutionNo
:
ab
.
BizId
,
isInvalid
:
0
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
if
(
!
ns
)
{
return
system
.
getResultFail
(
-
102
,
"未知方案"
);
}
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
ns
.
needNo
},
raw
:
true
where
:
{
needNo
:
ns
[
0
]
.
needNo
},
raw
:
true
});
if
(
!
needinfo
)
{
return
system
.
getResultFail
(
-
104
,
"未知方案需求"
);
...
...
@@ -213,105 +214,188 @@ class regCenterOrderService {
});
return
system
.
getResultSuccess
(
ns
);
}
//交付商提交材料信息
async
ncSubmitMaterial
(
pobj
)
{
/*
返回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
regClosePlan
(
pobj
)
{
console
.
log
(
"ncClosePlan+++"
,
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
,
"需求编号不能为空"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"status"
,
"statusName"
,
"needNo"
,
"uapp_id"
],
//2020-10-29 laolan xinzeng uapp_id
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
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
needNo
:
needinfo
.
needNo
,
isInvalid
:
0
},
raw
:
true
});
// var newFlowStatus = [];
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_ACCEPTED"
,
"CLOSE"
].
indexOf
(
flowStatus
)
<
0
)
{
return
system
.
getResultFail
(
-
104
,
"⽅案状态为关闭或不予受理才可关闭需求"
);
}
}
var
self
=
this
;
return
await
self
.
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
);
// return system.getResultSuccess();
})
}
//交付商关闭交付单
async
ncCloseOrderDelivery
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
console
.
log
(
'ab++'
,
ab
)
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
.
submitNcMaterial
(
pobj
);
return
this
.
ncAbolishProgramme
(
pobj
);
}
//
提交材料信息
async
submitNcMaterial
(
pobj
)
{
//
服务商作废方案-- ncAbolishProgramme
async
ncAbolishProgramme
(
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
,
"渠道方案
编
号不能为空"
);
return
system
.
getResultFail
(
-
101
,
"渠道方案号不能为空"
);
}
if
(
!
ab
.
material
)
{
return
system
.
getResultFail
(
-
10
2
,
"材料信息有误
"
);
if
(
!
ab
.
note
)
{
return
system
.
getResultFail
(
-
10
6
,
"关闭理由不能为空
"
);
}
//获取方案信息
var
needsolutioninfo
=
await
this
.
needsolutionDao
.
model
.
findOne
({
attributes
:
[
"id"
,
"needNo"
,
"orderNo"
,
"solutionContent"
],
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
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
productType
=
solutionContent
.
solution
;
if
(
productType
&&
productType
.
IcpType
){
productType
=
productType
.
IcpType
}
//----
var
orderInfo
=
await
this
.
orderinfoDao
.
model
.
findOne
({
where
:
{
orderNo
:
needsolutioninfo
.
orderNo
},
raw
:
true
})
if
(
orderInfo
){
var
uappId
=
orderInfo
.
uapp_id
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
(
!
ab
.
material
.
businessLicense
.
name
)
{
return
system
.
getResultFail
(
-
101
,
"公司名称不能为空
"
);
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
401
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作
"
);
}
if
(
!
ab
.
material
.
partnerBusinessLicense
)
{
return
system
.
getResultFail
(
-
103
,
"营业执照不能为空"
);
// 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
,
"方案流程状态错误,不能执行此操作"
);
}
console
.
log
(
'solutionContent++++++---------------'
,
solutionContent
)
solutionContent
.
material
=
ab
.
material
;
solutionContent
.
serviceProviderNote
=
ab
.
note
;
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"
MATERIAL_UNCONFIRM"
,
statusName
:
this
.
regSolutionStatus
.
MATERIAL_UNCONFIRM
,
updated_at
:
new
Date
()
status
:
"
CLOSE"
,
statusName
:
this
.
regSolutionStatus
.
CLOSE
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"MATERIAL_UNCONFIRM"
;
solutionContent
.
statusName
=
this
.
regSolutionStatus
.
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
);
}
needsolutioninfo
[
'orderChannelNo'
]
=
orderInfo
.
channelOrderNo
;
needsolutioninfo
[
'uapp_id'
]
=
uappId
;
needsolutioninfo
[
'productType'
]
=
productType
;
console
.
log
(
'nc orderdelivery+++'
,
needsolutioninfo
)
return
system
.
getResultSuccess
(
needsolutioninfo
);
solutionContent
.
status
=
"CLOSE"
;
solutionContent
.
statusName
=
this
.
regSolutionStatus
.
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
);
}
//提交方案
//------------3.
//提交方案 yiwancheng
async
submitRegSolution
(
pobj
)
{
console
.
log
(
"pobj++submitRegSolution++"
,
pobj
)
var
ab
=
pobj
.
actionBody
;
...
...
@@ -323,14 +407,24 @@ class regCenterOrderService {
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"渠道需求号不能为空"
);
}
var
i
=
0
;
var
i
;
var
j
;
var
k
;
var
l
;
var
solutionType
=
[];
var
solutionContent
;
var
needsolutions
=
[];
//最后返回结果用
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
)
{
return
system
.
getResultFail
(
-
102
,
"方案信息有误"
);
}
solutionContent
=
ab
.
solutionList
[
i
].
solutionContent
solutionType
.
push
(
solutionContent
.
solution
.
regType
)
console
.
log
(
'solutionType------'
,
solutionType
)
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
...
...
@@ -349,18 +443,35 @@ class regCenterOrderService {
if
(
!
needinfo
.
channelTypeCode
)
{
return
system
.
getResultFail
(
-
206
,
"渠道方案类型错误"
);
}
var
needsolutions
=
[];
//最后返回结果用
var
j
=
0
;
//查询对应类型方案是否有提交,提交过的不能重复提交
var
ns
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
,
order
:
[[
"id"
,
'asc'
]]
});
console
.
log
(
'ns----'
,
ns
)
var
nsRegType
=
[];
if
(
ns
){
var
nsLength
=
ns
.
length
;
for
(
l
=
0
;
l
<
nsLength
;
l
++
){
nsRegType
.
push
(
ns
[
l
].
solutionContent
.
solution
.
regType
)
}
// var flag = nsRegType.indexOf(solutionType);
// console.log('flag---',flag)
// if(flag > 0){
// return "该方案已创建";
// }
var
diff
;
diff
=
nsRegType
.
find
(
item
=>
solutionType
.
includes
(
item
))
console
.
log
(
'diff---'
,
diff
)
if
(
diff
!=
undefined
){
return
system
.
getResultFail
(
-
207
,
"该方案中包含已提交过的方案,不能重复提交"
);
}
}
for
(
j
=
0
;
j
<
solutionListLength
;
j
++
){
if
(
ab
.
solutionList
[
j
].
solutionContent
)
{
ab
.
solutionList
[
j
].
solutionContent
.
bizType
=
bizType
;
ab
.
solutionList
[
j
].
solutionContent
.
typeCode
=
needinfo
.
typeCode
;
ab
.
solutionList
[
j
].
solutionContent
.
typeName
=
needinfo
.
typeName
;
var
ns
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
channelNeedNo
:
ab
.
needNo
},
raw
:
true
,
order
:
[[
"id"
,
'asc'
]]
});
var
k
=
0
;
for
(
k
=
0
;
k
<
ns
.
length
;
k
++
)
{
var
fa
=
ns
[
k
];
// if (fa.status == "dqr" || fa.status == "ywc") {
...
...
@@ -443,226 +554,34 @@ class regCenterOrderService {
})
}
}
return
system
.
getResultSuccess
({
needinfo
:
needinfo
,
needsolutions
:
needsolutions
});
}
//交付商通知状态变更
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
)
}
//方案推送baidu后,接收保存方案编号/链接
async
saveReginfo
(
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
)
if
(
orderdeliveryInfo
[
0
]
&&
orderdeliveryInfo
[
0
].
deliveryContent
){
var
deliveryContent
=
orderdeliveryInfo
[
0
].
deliveryContent
;
}
console
.
log
(
'nc +++ deliveryContent+++'
,
deliveryContent
)
if
(
!
deliveryContent
)
{
return
system
.
getResultFail
(
-
402
,
"方案交付信息有误"
);
}
if
(
this
.
regNumberStatus
[
deliveryContent
.
status
]
&&
this
.
regNumberStatus
[
deliveryContent
.
status
]
>
ab
.
ApplicationStatus
)
{
return
system
.
getResultFail
(
-
403
,
"操作失败,交付流程未按顺序执行"
);
}
if
(
this
.
regNumberStatus
[
deliveryContent
.
ApplicationStatus
]
&&
this
.
regNumberStatus
[
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(-507, "交付流程错误,用户确认递交⽂件后才能执行此操作");
// }
// }
deliveryContent
[
'ApplicationStatus'
]
=
507
;
solutionFlowList
.
push
({
file
:
ab
.
OfficialFileURL
||
""
,
status
:
"REGISTRATION"
,
statusName
:
this
.
regSolutionStatus
.
REGISTRATION
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"REGISTRATION"
;
deliveryContent
.
statusName
=
this
.
regSolutionStatus
.
REGISTRATION
;
}
if
(
ab
.
ApplicationStatus
==
508
)
{
//"服务商完成提交资料到⼯信部
if
(
deliveryContent
.
status
!=
"REGISTRATION"
)
{
return
system
.
getResultFail
(
-
508
,
"交付流程错误,请先完成账户注册"
);
}
deliveryContent
[
'ApplicationStatus'
]
=
508
;
solutionFlowList
.
push
({
file
:
ab
.
OfficialFileURL
||
""
,
status
:
"SUBMITTED"
,
statusName
:
this
.
regSolutionStatus
.
SUBMITTED
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"SUBMITTED"
;
deliveryContent
.
statusName
=
this
.
regSolutionStatus
.
SUBMITTED
;
}
if
(
ab
.
ApplicationStatus
==
509
)
{
//⼯商部已受理
if
(
deliveryContent
.
status
!=
"SUBMITTED"
)
{
return
system
.
getResultFail
(
-
509
,
"交付流程错误,请先完成资料递交"
);
}
deliveryContent
[
'ApplicationStatus'
]
=
509
;
solutionFlowList
.
push
({
file
:
ab
.
OfficialFileURL
||
""
,
status
:
"ACCEPTED"
,
statusName
:
this
.
regSolutionStatus
.
ACCEPTED
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"ACCEPTED"
;
deliveryContent
.
statusName
=
this
.
regSolutionStatus
.
ACCEPTED
;
}
if
(
ab
.
ApplicationStatus
==
510
)
{
//⼯商部不予受理
if
(
deliveryContent
.
status
!=
"SUBMITTED"
)
{
return
system
.
getResultFail
(
-
510
,
"交付流程错误,请先完成资料递交"
);
}
deliveryContent
[
'ApplicationStatus'
]
=
510
;
solutionFlowList
.
push
({
file
:
ab
.
OfficialFileURL
||
""
,
status
:
"NOT_ACCEPTED"
,
statusName
:
this
.
regSolutionStatus
.
NOT_ACCEPTED
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"NOT_ACCEPTED"
;
needsolutioninfo
.
status
=
"ywc"
;
deliveryContent
.
statusName
=
this
.
regSolutionStatus
.
NOT_ACCEPTED
;
}
if
(
ab
.
ApplicationStatus
==
511
)
{
//⼯商部通过
if
(
deliveryContent
.
status
!=
"ACCEPTED"
)
{
return
system
.
getResultFail
(
-
511
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
if
(
!
ab
.
infos
)
{
return
system
.
getResultFail
(
-
101
,
"渠道信息不能为空"
);
}
var
i
;
var
j
;
var
infosLength
=
ab
.
infos
.
length
var
solutionNos
=
[];
var
infoList
=
[];
var
nsLength
=
ns
.
length
for
(
i
=
0
;
i
<
infosLength
;
i
++
){
var
solutionNo
=
{
solutionNo
:
ab
.
infos
[
i
].
bizId
}
deliveryContent
[
'ApplicationStatus'
]
=
511
;
solutionFlowList
.
push
({
file
:
ab
.
OfficialFileURL
||
""
,
status
:
"APPROVED"
,
statusName
:
this
.
regSolutionStatus
.
APPROVED
,
updated_at
:
new
Date
()
});
needsolutioninfo
.
status
=
"ywc"
;
deliveryContent
.
status
=
"APPROVED"
;
deliveryContent
.
statusName
=
this
.
regSolutionStatus
.
APPROVED
;
solutionNos
.
push
(
solutionNo
)
}
if
(
ab
.
ApplicationStatus
==
512
)
{
//⼯信部未通过
if
(
deliveryContent
.
status
!=
"ACCEPTED"
)
{
return
system
.
getResultFail
(
-
512
,
"交付流程错误,⼯信部已受理后才能执行此操作"
);
}
deliveryContent
[
'ApplicationStatus'
]
=
512
;
solutionFlowList
.
push
({
file
:
ab
.
OfficialFileURL
||
""
,
status
:
"NOT_APPROVED"
,
statusName
:
this
.
regSolutionStatus
.
NOT_APPROVED
,
updated_at
:
new
Date
()
});
deliveryContent
.
status
=
"NOT_APPROVED"
;
needsolutioninfo
.
status
=
"ywc"
;
deliveryContent
.
statusName
=
this
.
regSolutionStatus
.
NOT_APPROVED
;
}
deliveryContent
.
solutionFlowList
=
solutionFlowList
;
var
applicationStatusList
=
deliveryContent
.
applicationStatusList
||
[];
var
statusObj
=
{
"OfficialFileURL"
:
ab
.
OfficialFileURL
||
""
,
"ApplicationStatus"
:
ab
.
ApplicationStatus
,
"ApplicationStatusName"
:
this
.
regSolutionStatus
[
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
);
}
let
orderdeliveryQuery
=
"SELECT * from `c_order_delivery` where sourceOrderNo='"
+
ab
.
orderNo
+
"'"
;
let
QueryDatas
=
{
sourceOrderNo
:
ab
.
orderNo
}
orderdelivery
=
await
this
.
orderdeliveryDao
.
customQuery
(
orderdeliveryQuery
,
QueryDatas
)
console
.
log
(
'orderdelivery++orderdelivery++++++'
,
orderdelivery
)
if
(
orderdelivery
){
orderdelivery
=
orderdelivery
[
0
]
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
var
ns
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
solutionNo
:
{
[
this
.
db
.
Op
.
in
]:
solutionNos
},
isInvalid
:
0
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
if
(
!
ns
)
{
return
system
.
getResultFail
(
-
103
,
"未知方案"
);
}
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
ns
.
needNo
},
raw
:
true
where
:
{
needNo
:
ns
[
0
]
.
needNo
},
raw
:
true
});
if
(
!
needinfo
)
{
return
system
.
getResultFail
(
-
104
,
"未知方案需求"
);
...
...
@@ -670,184 +589,176 @@ class regCenterOrderService {
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
}
});
//修改方案信息
for
(
j
=
0
;
j
<
nsLength
;
j
++
){
await
this
.
needsolutionDao
.
model
.
update
({
channelSolutionNo
:
ab
.
infos
[
j
].
bizId
},
{
where
:
{
id
:
ns
[
j
].
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
];
//回写沟通记录
async
writeRegCommunicationLog
(
pobj
)
{
console
.
log
(
'actionBody------'
,
pobj
)
// 查询需求沟通记录
pobj
.
actionBody
.
Note
=
[
"noteTime"
,
moment
().
format
(
"YYYY-MM-DD HH:mm:ss"
),
"note"
,
pobj
.
actionBody
.
note
];
let
needRes
=
await
this
.
findOne
({
channelNeedNo
:
pobj
.
actionBody
.
intentionBizId
});
// 没有需求单直接返回
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
.
intentionBizId
};
var
updateRes
=
await
this
.
customUpdate
(
sql
,
paramWhere
);
}
// 有需求单但没有沟通记录 直接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
.
intentionBizId
};
var
updateRes
=
await
this
.
customUpdate
(
sql
,
paramWhere
);
if
(
updateRes
[
1
])
{
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
);
console
.
log
(
'uappIdInfo+++'
,
uappIdInfo
)
if
(
uappIdInfo
){
var
uappIds
=
uappIdInfo
[
0
].
uapp_id
}
return
system
.
getResultSuccess
(
uappIds
);
}
return
system
.
getResult
(
"添加记录失败"
);
// 有需求单有沟通记录 json_array_append
}
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
];
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(actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +actionBody.BizId +"\"" +" "
var
paramWhere
=
{
Note
:
pobj
.
actionBody
.
Note
,
BizId
:
pobj
.
actionBody
.
intentionBizId
};
var
updateRes
=
await
this
.
customUpdate
(
sql
,
paramWhere
);
if
(
updateRes
[
1
])
{
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
){
var
uappIds
=
uappIdInfo
[
0
].
uapp_id
}
return
system
.
getResultSuccess
(
uappIds
);
}
return
system
.
getResult
(
"添加记录失败"
);
}
}
//新增查询需求沟通记录
async
queryExpertRegCommunicationLogs
(
pobj
){
console
.
log
(
'query++pobj'
,
pobj
)
if
(
!
pobj
.
actionBody
.
intentionBizId
)
{
return
system
.
getResult
(
null
,
"actionBody.intentionBizId can not be empty,100493"
);
}
// 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
);
}
return
uuid
.
join
(
''
);
}
//根据需求关闭NC方案(关闭需求后调用)
async
ncClosePlan
(
pobj
)
{
console
.
log
(
"ncClosePlan+++"
,
pobj
)
//根据需求查看方案列表
async
getRegInfoByChannelNeedNo
(
pobj
)
{
var
ab
=
pobj
.
actionBody
;
var
app
=
pobj
.
app
Info
;
if
(
!
app
||
!
app
.
uapp_
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知
渠道
"
);
var
user
=
pobj
.
user
Info
;
if
(
!
user
||
!
user
.
id
)
{
return
system
.
getResultFail
(
-
100
,
"未知
用户
"
);
}
ab
[
"createUserId"
]
=
user
.
id
;
if
(
!
ab
.
needNo
)
{
return
system
.
getResultFail
(
-
101
,
"需求
编
号不能为空"
);
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
.
needNo
},
raw
:
true
});
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
return
system
.
getResultFail
(
-
102
,
"未知需求信息"
);
}
//获取方案信息
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
needNo
:
needinfo
.
needNo
,
isInvalid
:
0
},
raw
:
true
var
ns
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
needNo
:
needinfo
.
needNo
},
raw
:
true
,
attributes
:
[
"needNo"
,
"solutionNo"
,
"channelSolutionNo"
,
"orderNo"
,
"solutionContent"
,
"status"
,
"statusName"
]
});
// var newFlowStatus = [];
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_ACCEPTED"
,
"CLOSE"
].
indexOf
(
flowStatus
)
<
0
)
{
return
system
.
getResultFail
(
-
104
,
"⽅案状态为关闭或不予受理才可关闭需求"
);
}
}
var
self
=
this
;
return
await
self
.
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
);
// return system.getResultSuccess();
})
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
)
{
//根据需求关闭reg需求/方案
async
closeRegNeed
(
pobj
)
{
console
.
log
(
"abolishRegProgrammeByNeed+++"
,
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
app
=
pobj
.
appInfo
;
if
(
!
app
||
!
app
.
uapp_id
)
{
return
system
.
getResultFail
(
-
100
,
"未知渠道"
);
}
//获取方案信息
var
ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
channelSolutionNo
:
ab
.
bizId
,
isInvalid
:
0
},
raw
:
true
});
if
(
!
ns
||
!
ns
.
id
)
{
return
system
.
getResultFail
(
-
300
,
"未知方案"
);
if
(
!
ab
.
intentionBizId
)
{
return
system
.
getResultFail
(
-
101
,
"需求编号不能为空"
);
}
//获取需求信息
var
needinfo
=
await
this
.
needinfoDao
.
model
.
findOne
({
where
:
{
needNo
:
ns
.
needNo
},
raw
:
true
attributes
:
[
"id"
,
"status"
,
"statusName"
,
"needNo"
,
"uapp_id"
],
where
:
{
channelNeedNo
:
ab
.
intentionBizId
},
raw
:
true
});
if
(
!
needinfo
)
{
return
system
.
getResultFail
(
-
400
,
"未知方案需求"
);
}
if
(
needinfo
.
status
==
"ycd"
||
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
401
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
if
(
!
needinfo
||
!
needinfo
.
id
)
{
return
system
.
getResultFail
(
-
201
,
"未知需求信息"
);
}
// 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
,
"方案流程状态错误,不能执行此操作"
);
if
(
needinfo
.
status
==
"ygb"
)
{
return
system
.
getResultFail
(
-
202
,
"该方案需求状态为"
+
needinfo
.
statusName
+
",不能执行此操作"
);
}
solutionContent
.
serviceProviderNote
=
ab
.
note
;
var
solutionFlowList
=
solutionContent
.
solutionFlowList
||
[];
solutionFlowList
.
push
({
status
:
"CLOSE"
,
statusName
:
this
.
regSolutionStatus
.
CLOSE
,
updated_at
:
new
Date
()
});
solutionContent
.
status
=
"CLOSE"
;
solutionContent
.
statusName
=
this
.
regSolutionStatus
.
CLOSE
;
solutionContent
=
JSON
.
stringify
(
solutionContent
);
await
this
.
needsolutionDao
.
update
({
id
:
ns
.
id
,
status
:
"yzf"
,
isInvalid
:
1
,
solutionContent
:
solutionContent
});
//方案废弃
//获取方案信息
var
n
ew_ns
=
await
this
.
needsolutionDao
.
model
.
findOne
({
where
:
{
id
:
ns
.
id
},
raw
:
true
var
n
s
=
await
this
.
needsolutionDao
.
model
.
findAll
({
where
:
{
needNo
:
needinfo
.
needNo
,
isInvalid
:
0
},
raw
:
true
});
return
system
.
getResultSuccess
(
new_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
[
i
].
status
==
"ywc"
)
{
return
system
.
getResultFail
(
-
103
,
"方案状态错误,不能废弃已完成方案"
);
}
var
flowStatus
=
ns
[
i
].
solutionContent
&&
ns
[
i
].
solutionContent
.
status
?
ns
[
i
].
solutionContent
.
status
:
""
;
if
(
flowStatus
&&
[
"GXB_REFUSE"
,
"CLOSE"
].
indexOf
(
flowStatus
)
<
0
)
{
return
system
.
getResultFail
(
-
104
,
"⽅案状态为关闭或不予受理才可关闭需求"
);
}
var
self
=
this
await
this
.
needsolutionDao
.
db
.
transaction
(
async
function
(
t
)
{
var
needObj
=
{
id
:
needinfo
.
id
,
status
:
"ygb"
,
notes
:
ab
.
note
};
await
self
.
needinfoDao
.
update
(
needObj
,
t
);
//关闭需求
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
)
})
}
}
}
return
system
.
getResultSuccess
(
ns
);
}
}
module
.
exports
=
r
egCenterOrderService
;
module
.
exports
=
R
egCenterOrderService
;
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