添加兑换物品 查重修改

This commit is contained in:
yulixing 2019-08-30 14:30:35 +08:00
parent be2bfa3b0e
commit c3065965ad

View File

@ -27,7 +27,8 @@ router.post('/', async (req, res, next) => {
const body = req.body const body = req.body
try { try {
const search = await GameGift.findOne({ const search = await GameGift.findOne({
$or: [{gift_name: body.gift_name}, {gift_id: body.gift_id}], game_id: body.game_id,
gift_id: body.gift_id,
deleted: false, deleted: false,
}) })
if (search) { if (search) {
@ -145,7 +146,7 @@ router.post('/list', async (req, res, next) => {
type: body.type, type: body.type,
time: body.time, time: body.time,
cfg: cfg, cfg: cfg,
extraData: body.extraData extraData: body.extraData,
}) })
const result = await list.save() const result = await list.save()
res.send({ res.send({
@ -184,7 +185,7 @@ router.put('/list', async (req, res, next) => {
type: body.type, type: body.type,
time: body.time, time: body.time,
cfg: cfg, cfg: cfg,
extraData: body.extraData extraData: body.extraData,
} }
) )
res.send({ res.send({
@ -264,8 +265,9 @@ function formatCfg(type, timeStr) {
startTime: startTime:
parseInt(startTimeArr[0]) * 60 * 60 * 1000 + parseInt(startTimeArr[0]) * 60 * 60 * 1000 +
parseInt(startTimeArr[1]) * 60 * 1000, parseInt(startTimeArr[1]) * 60 * 1000,
endTime: parseInt(endTimeArr[0]) * 60 * 60 * 1000 + endTime:
parseInt(endTimeArr[1]) * 60 * 1000, parseInt(endTimeArr[0]) * 60 * 60 * 1000 +
parseInt(endTimeArr[1]) * 60 * 1000,
limit: parseInt(cfg[1]), limit: parseInt(cfg[1]),
}) })
}) })
@ -301,5 +303,4 @@ router.get('/record', async (req, res, next) => {
} }
}) })
export default router export default router