Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjh5
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data_server
gjjh5
Commits
32c95433
Commit
32c95433
authored
Mar 06, 2019
by
姜登
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gjj
parent
396d21dc
Pipeline
#4049
passed with stage
in 5 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
10 deletions
+18
-10
order.js
app/controller/order.js
+6
-3
task.js
app/controller/task.js
+2
-2
order.js
app/service/order.js
+10
-5
No files found.
app/controller/order.js
View file @
32c95433
...
...
@@ -7,7 +7,10 @@ class OrderController extends Controller {
super
(
ctx
);
this
.
createRule
=
{
appKey
:
'string'
,
userId
:
'string'
,
userId
:
{
type
:
'string'
,
required
:
false
,
},
orderId
:
{
type
:
'string'
,
required
:
false
,
...
...
@@ -48,10 +51,10 @@ class OrderController extends Controller {
ctx
.
validate
(
this
.
createRule
);
let
{
appKey
,
userId
,
notifyUrl
,
backUrl
,
orderId
}
=
ctx
.
request
.
body
;
orderId
=
orderId
||
uuid
.
v1
();
await
service
.
order
.
cre
ate
({
await
service
.
order
.
upd
ate
({
orderId
,
taskId
:
''
,
userId
:
userId
,
userId
:
userId
||
''
,
cityId
:
''
,
notifyUrl
:
notifyUrl
||
(
ctx
.
app
.
notifyMap
.
get
(
appKey
)
&&
ctx
.
app
.
notifyMap
.
get
(
appKey
).
notifyUrl
)
||
''
,
backUrl
:
backUrl
||
''
,
...
...
app/controller/task.js
View file @
32c95433
...
...
@@ -40,9 +40,9 @@ class TaskController extends Controller {
async
create
()
{
const
{
ctx
,
service
}
=
this
;
ctx
.
validate
(
this
.
createRule
);
const
{
scriptId
,
orderId
,
userId
}
=
ctx
.
request
.
body
;
const
{
scriptId
,
orderId
}
=
ctx
.
request
.
body
;
const
taskId
=
await
service
.
task
.
create
(
scriptId
);
await
service
.
order
.
update
({
orderId
,
cityId
:
scriptId
,
taskId
,
userId
});
await
service
.
order
.
update
({
orderId
,
cityId
:
scriptId
,
taskId
});
await
service
.
cache
.
set
({
key
:
taskId
,
value
:
{
status
:
'init'
,
note
:
{
message
:
'init'
}
},
...
...
app/service/order.js
View file @
32c95433
...
...
@@ -34,17 +34,22 @@ class OrderService extends Service {
const
{
ctx
}
=
this
;
const
order
=
await
ctx
.
model
.
TaskStatus
.
findOne
({
where
:
{
orderId
:
params
.
orderId
},
order
:
[[
'updateDate'
,
'DESC'
]]
});
if
(
!
order
)
{
ctx
.
throw
(
400
,
{
message
:
'no order'
});
}
if
(
params
.
orderId
)
{
const
success
=
await
ctx
.
model
.
TaskStatus
.
findOne
({
where
:
{
orderId
:
params
.
orderId
,
status
:
'success'
},
});
if
(
success
)
{
ctx
.
throw
(
400
,
{
message
:
'order success'
});
}
}
const
{
appKey
,
taskId
,
notifyUrl
,
backUrl
,
userId
}
=
order
;
if
(
taskId
)
{
if
(
params
.
userId
)
{
await
ctx
.
model
.
TaskStatus
.
create
({
appKey
,
status
:
'init'
,
notifyUrl
,
backUrl
,
...
params
})
}
else
{
await
ctx
.
model
.
TaskStatus
.
create
({
appKey
,
status
:
'init'
,
notifyUrl
,
backUrl
,
...
params
,
userId
})
}
await
ctx
.
model
.
TaskStatus
.
create
({
appKey
,
status
:
'init'
,
notifyUrl
,
backUrl
,
userId
,
...
params
})
}
else
{
await
order
.
update
(
params
);
}
...
...
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