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
d029281e
Commit
d029281e
authored
Sep 16, 2020
by
linboxuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
needBatchUpload
parent
35699442
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
36 deletions
+61
-36
center-channel/app/base/service/impl/utilsSve/utilsNeedSve.js
+60
-35
center-channel/app/base/utils/aliyunClient.js
+1
-1
No files found.
center-channel/app/base/service/impl/utilsSve/utilsNeedSve.js
View file @
d029281e
...
...
@@ -617,6 +617,10 @@ class UtilsNeedService extends AppServiceBase {
async
needBatchUpload
(
pobj
,
actionBody
)
{
var
BizIds
=
""
;
var
demands
=
[];
// 声明两个数组 用来走后四步用
var
npobj
=
[];
var
spobj
=
[];
// 遍历生成阿里需求 并把bizId 填充进数组
for
(
var
i
=
0
;
i
<
actionBody
.
demands
.
length
;
i
++
)
{
// 第一步
// 地区转换
...
...
@@ -633,29 +637,18 @@ class UtilsNeedService extends AppServiceBase {
Channel
:
"gsb"
,
Token
:
"gsb"
,
}
// 4.1 提交阿里需求
var
aliResult
=
await
this
.
aliclient
.
reqbyget
({
action
:
"SubmitIcpIntention"
,
reqbody
:
obj
,
apiVersion
:
"2019-05-08"
});
console
.
log
(
"needBatchUpload-aliResult"
,
aliResult
)
if
(
aliResult
.
status
!=
0
)
{
// 统计失败次数
}
// 第二步
// 创建企服通需求单
var
objString
=
JSON
.
stringify
(
pobj
);
var
npobj
=
JSON
.
parse
(
objString
);
npobj
.
actionBody
=
{
intentionBizId
:
aliResult
.
data
.
BizId
,
type
:
this
.
bizTypeChange
(
actionBody
.
demands
[
i
].
type
),
description
:
actionBody
.
demands
[
i
].
description
,
mobile
:
actionBody
.
demands
[
i
].
contactMobile
}
var
opResult
=
await
this
.
submitNeed
(
npobj
,
npobj
.
actionBody
);
console
.
log
(
"needBatchUpload-opResult"
,
opResult
)
// 第三步
// 提交Icp注册方案
var
sobjString
=
JSON
.
stringify
(
pobj
);
var
spobj
=
JSON
.
parse
(
sobjString
);
spobj
.
actionType
=
"submitIcpProgramme"
;
spobj
.
actionBody
=
{
// 整合前端需要的数据1
BizIds
+=
aliResult
.
data
.
BizId
+
","
;
npobj
.
push
({
"intentionBizId"
:
aliResult
.
data
.
BizId
,
"type"
:
this
.
bizTypeChange
(
actionBody
.
demands
[
i
].
type
),
"description"
:
actionBody
.
demands
[
i
].
description
,
"mobile"
:
actionBody
.
demands
[
i
].
contactMobile
})
spobj
.
push
({
"needNo"
:
aliResult
.
data
.
BizId
,
//渠道需求号
"solutionContent"
:{
// submitIcpProgramme需要的类型转换 ICP许可证 = icpsq/EDI许可证 = edisq
...
...
@@ -668,44 +661,63 @@ class UtilsNeedService extends AppServiceBase {
"Note"
:
actionBody
.
demands
[
i
].
description
}
}
})
if
(
aliResult
.
status
!=
0
)
{
// 统计失败次数
}
var
subRes
=
await
this
.
qcCenterOrderSve
.
submitIcpProgramme
(
spobj
);
}
// 判断数据是否符合 执行后四步 的条件
if
(
npobj
.
length
!=
actionBody
.
demands
.
length
||
spobj
.
length
!=
actionBody
.
demands
.
length
)
{
return
system
.
getResultFail
(
-
5018
,
"提交阿里需求失败"
);
}
// 睡3秒 意义:等待阿里异步分配成功。如果不等待则提交方案会失败 无法生成支付链接,需求状态错误
await
this
.
sleep
(
3000
)
// 遍历 执行后面步骤 创建企服需求单(提交方案需要)。提交方案。需求沟通提交
for
(
var
i
=
0
;
i
<
actionBody
.
demands
.
length
;
i
++
)
{
// 第二步
// 创建企服通需求单
var
objString1
=
JSON
.
stringify
(
pobj
);
var
obj1
=
JSON
.
parse
(
objString1
);
obj1
.
actionBody
=
npobj
[
i
];
var
opResult
=
await
this
.
submitNeed
(
obj1
,
obj1
.
actionBody
);
console
.
log
(
"needBatchUpload-opResult"
,
opResult
)
// 第三步
// 提交Icp注册方案
// 程序执行比异步分配需求快,所以写成两个循环
var
objString2
=
JSON
.
stringify
(
pobj
);
var
obj2
=
JSON
.
parse
(
objString2
);
obj2
.
actionType
=
"submitIcpProgramme"
;
obj2
.
actionBody
=
spobj
[
i
];
var
subRes
=
await
this
.
qcCenterOrderSve
.
submitIcpProgramme
(
obj2
);
console
.
log
(
"----------------------------------start"
);
console
.
log
(
"needBatchUpload-res"
,
subRes
)
console
.
log
(
"----------------------------------end"
);
// 第四步
// 需求沟通记录接口
var
writeRes
=
await
this
.
writeCommunicationLog
({
actionBody
:{
intentionBizId
:
"20200804200124000001"
,
note
:
"测试反馈"
}});
var
writeRes
=
await
this
.
writeCommunicationLog
({
actionBody
:{
intentionBizId
:
npobj
[
i
].
intentionBizId
,
note
:
"测试反馈"
}});
console
.
log
(
"needBatchUpload-writeRes"
,
writeRes
)
// 整合前端需要的数据
// BizIds.push(aliResult.data.BizId)
BizIds
+=
aliResult
.
data
.
BizId
+
","
;
// 整合前端需要的数据2
demands
.
push
({
uniqueCode
:
actionBody
.
demands
[
i
].
uniqueCode
,
demandCode
:
opResult
.
data
.
needNo
})
}
BizIds
=
BizIds
.
substr
(
0
,
BizIds
.
length
-
1
);
// 第五步 用户需求确认
// 首先切割掉BizId最后一位 是,
BizIds
=
BizIds
.
substr
(
0
,
BizIds
.
length
-
1
);
var
aliConfirmResult
=
await
this
.
aliclient
.
reqbyget
({
action
:
"ConfirmIcpIntention"
,
reqbody
:
{
BizIds
:
BizIds
},
apiVersion
:
"2019-05-08"
});
console
.
log
(
"needBatchUpload-aliConfirmResult"
,
aliConfirmResult
)
// 获取链接失败
if
(
aliConfirmResult
.
status
!=
0
)
{
var
res
=
{
paymentLink
:
"www.baidu.com"
,
batchNumber
:
actionBody
.
batchNumber
,
demands
:
demands
}
return
system
.
getResultFail
(
-
5018
,
"confirmIcpIntention fail"
);
// return system.getResultRedisSuccess(res);
}
var
res
=
{
paymentLink
:
aliConfirmResult
.
data
.
ConfirmUrl
,
batchNumber
:
actionBody
.
batchNumber
,
demands
:
demands
}
// 2020 0916 lin 新增返回格式 成功status为1
return
system
.
getResultRedisSuccess
(
res
);
// 2020 0916 lin 新增返回格式 成功status为1
因为queue判断成功请求的条件为status1
return
system
.
getResultRedis
Queue
Success
(
res
);
}
async
testsymq
(
pobj
)
{
var
a
=
null
;
...
...
@@ -808,6 +820,11 @@ class UtilsNeedService extends AppServiceBase {
return
"edisq"
}
}
sleep
(
t
)
{
return
new
Promise
(
res
=>
setTimeout
(
res
,
t
))
}
urlSplit
(
url
)
{
var
arr
=
url
.
split
(
"?"
)[
1
];
//根据?跟个url
var
arr2
=
arr
[
1
].
split
(
"&"
);
//根据&重新分割参数
...
...
@@ -817,6 +834,11 @@ class UtilsNeedService extends AppServiceBase {
}
return
jsonarr
;
}
// async test() {
// var aliConfirmResult = await this.aliclient.reqbyget({ action: "ConfirmIcpIntention", reqbody: {BizIds:"20200916170117000001,20200916170117000002,20200916170117000003,20200916170118000001,20200916170118000002,20200916170118000003,20200916170119000001,20200916170119000002,20200916170120000001,20200916170120000002,20200916170120000003,20200916170121000001,20200916170121000002,20200916170121000003,20200916170122000001,20200916170122000002,20200916170122000003,20200916170123000001,20200916170123000002"}, apiVersion: "2019-05-08" });
// console.log("needBatchUpload-aliConfirmResult",aliConfirmResult)
// }
// async test1() {
// var a = await this.aliclient.reqbyget({ action: "CloseIntention", reqbody: { BizId: "20200416125415000001", Note: "测试需求关闭" }, apiVersion: "2019-05-08" });
...
...
@@ -838,4 +860,7 @@ module.exports = UtilsNeedService;
// var a = new UtilsNeedService();
// a.queryTradeIntentionUserList({ actionBody: { intentionBizId: "20200803095203000001", userFeedBack: true } });
// var a = new UtilsNeedService();
// a.test();
center-channel/app/base/utils/aliyunClient.js
View file @
d029281e
...
...
@@ -53,7 +53,7 @@ class aliyunClient {
reqAliclient
.
apiVersion
=
obj
.
apiVersion
;
}
var
res
=
await
reqAliclient
.
request
(
action
,
reqbody
,
{
timeout
:
3000
,
// default 3000 ms
timeout
:
10000
,
// default 3000 ms 2020 0916 lin修改3000为10000,原因ConfirmIcpIntention BizIds 超过5条会超时
formatAction
:
true
,
// default true, format the action to Action
formatParams
:
true
,
// default true, format the parameter name to first letter upper case
method
:
'GET'
,
// set the http method, default is GET
...
...
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