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
2d13addb
Commit
2d13addb
authored
Mar 06, 2019
by
姜登
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gjj
parent
d62dd15d
Pipeline
#4067
passed with stage
in 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
21 deletions
+28
-21
order.js
app/controller/order.js
+17
-3
order.js
app/service/order.js
+11
-18
No files found.
app/controller/order.js
View file @
2d13addb
...
...
@@ -50,13 +50,27 @@ class OrderController extends Controller {
const
uuid
=
require
(
'node-uuid'
);
ctx
.
validate
(
this
.
createRule
);
let
{
appKey
,
userId
,
notifyUrl
,
backUrl
,
orderId
}
=
ctx
.
request
.
body
;
orderId
=
orderId
||
uuid
.
v1
();
await
service
.
order
.
update
({
if
(
orderId
)
{
await
service
.
order
.
update
({
orderId
,
taskId
:
''
,
userId
:
userId
||
''
,
cityId
:
''
,
notifyUrl
:
(
ctx
.
app
.
notifyMap
.
get
(
appKey
)
&&
ctx
.
app
.
notifyMap
.
get
(
appKey
).
notifyUrl
)
||
''
,
backUrl
:
backUrl
||
''
,
appKey
:
appKey
,
status
:
'init'
,
})
ctx
.
success
({
orderId
});
return
}
orderId
=
uuid
.
v1
();
await
service
.
order
.
create
({
orderId
,
taskId
:
''
,
userId
:
userId
||
''
,
cityId
:
''
,
notifyUrl
:
notifyUrl
||
(
ctx
.
app
.
notifyMap
.
get
(
appKey
)
&&
ctx
.
app
.
notifyMap
.
get
(
appKey
).
notifyUrl
)
||
''
,
notifyUrl
:
notifyUrl
||
''
,
backUrl
:
backUrl
||
''
,
appKey
:
appKey
,
status
:
'init'
,
...
...
app/service/order.js
View file @
2d13addb
...
...
@@ -20,40 +20,33 @@ class OrderService extends Service {
async
create
(
params
)
{
const
{
ctx
}
=
this
;
// const order = await ctx.model.TaskStatus.findOne({
// where: { orderId: params.orderId },
// });
// if (order) {
// ctx.throw(400, { message: 'already have order' });
// }
await
ctx
.
model
.
TaskStatus
.
create
(
params
);
return
;
}
async
update
(
params
)
{
const
{
ctx
}
=
this
;
const
order
=
await
ctx
.
model
.
TaskStatus
.
find
One
({
const
order
=
await
ctx
.
model
.
TaskStatus
.
find
All
({
where
:
{
orderId
:
params
.
orderId
},
order
:
[[
'
updateDate'
,
'DESC'
]]
order
:
[[
'
createDate'
,
'DESC'
]],
});
if
(
!
order
)
{
if
(
order
.
length
===
0
)
{
ctx
.
throw
(
400
,
{
message
:
'no order'
});
return
;
}
if
(
params
.
orderId
)
{
const
success
=
await
ctx
.
model
.
TaskStatus
.
findOne
({
where
:
{
orderId
:
params
.
orderId
,
status
:
'success'
},
});
if
(
success
)
{
ctx
.
throw
(
400
,
{
message
:
'order success'
});
for
(
const
item
of
order
)
{
if
(
item
.
status
===
'success'
)
{
ctx
.
throw
(
400
,
{
message
:
'orderId success'
});
return
;
}
}
const
{
appKey
,
taskId
,
notifyUrl
,
backUrl
,
userId
}
=
order
;
const
{
appKey
,
taskId
,
notifyUrl
,
backUrl
,
userId
}
=
order
[
0
]
;
if
(
taskId
)
{
await
ctx
.
model
.
TaskStatus
.
create
({
appKey
,
status
:
'init'
,
notifyUrl
,
backUrl
,
userId
,
...
params
})
}
else
{
await
order
.
update
(
params
);
await
order
[
0
]
.
update
(
params
);
}
return
order
;
return
order
[
0
]
;
}
}
...
...
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