Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이정민
/
OPproject
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
서예진
2019-12-03 19:39:19 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
088dcf93ff52a2fbce5c57409a2991c1bf5bd27c
088dcf93
1 parent
809ec494
checkAuction.js
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
checkAuction.js
checkAuction.js
0 → 100644
View file @
088dcf9
const
{
Good
,
Auction
,
User
,
sequelize
}
=
require
(
'./models'
);
module
.
exports
=
async
()
=>
{
try
{
const
yesterday
=
new
Date
();
yesterday
.
setDate
(
yesterday
.
getDate
()
-
1
);
const
targets
=
await
Good
.
findAll
({
where
:
{
soldId
:
null
,
createdAt
:
{
$lte
:
yesterday
},
},
});
targets
.
forEach
(
async
(
target
)
=>
{
const
success
=
await
Auction
.
find
({
where
:
{
goodId
:
target
.
id
},
order
:
[[
'bid'
,
'DESC'
]],
});
await
Good
.
update
({
soldId
:
success
.
userId
},
{
where
:
{
id
:
target
.
id
}
});
await
User
.
update
({
money
:
sequelize
.
literal
(
`money -
${
success
.
bid
}
`
),
},
{
where
:
{
id
:
success
.
userId
},
});
});
}
catch
(
error
)
{
console
.
error
(
error
);
}
};
Please
register
or
login
to post a comment