diff --git a/src/controllers/games/ad.js b/src/controllers/games/ad.js index 2a2fcbc..b239dec 100644 --- a/src/controllers/games/ad.js +++ b/src/controllers/games/ad.js @@ -82,10 +82,15 @@ router.post('/pos', async (req, res, next) => { method: 'post', data: { area: body.area, - type: body.type, - mode: body.mode, - gameid: body.gameid, channelid: body.channelid, + gameid: body.gameid, + ld_property: body.ld_property, + mode: body.mode, + type: body.type, + x: body.x, + y: body.y, + x_offset: body.x_offset, + y_offset: body.y_offset, }, }) const data = addRes.data @@ -129,13 +134,17 @@ router.put('/pos', async (req, res, next) => { url: adApiUrl + '/location', method: 'put', data: { - area: body.area, - type: body.type, - mode: body.mode, id: body.id, - status: body.status, - gameid: body.gameid, + area: body.area, channelid: body.channelid, + gameid: body.gameid, + ld_property: body.ld_property, + mode: body.mode, + type: body.type, + x: body.x, + y: body.y, + x_offset: body.x_offset, + y_offset: body.y_offset, }, }) const data = modifyRes.data @@ -485,14 +494,12 @@ router.post('/uid-ratio', async (req, res, next) => { let cfg = {} if (ratio) { const arr = ratio.split('\n') - console.log(arr) arr.map(item => { const kv = item.split('-') cfg[kv[0]] = kv[1] }) } - console.log(cfg) for (const key in cfg) { if (cfg.hasOwnProperty(key)) { diff --git a/src/controllers/games/data copy.js b/src/controllers/games/data copy.js deleted file mode 100644 index 8348e33..0000000 --- a/src/controllers/games/data copy.js +++ /dev/null @@ -1,231 +0,0 @@ -// 获取单个游戏广告位 -import {Router} from 'express' -import axios from 'axios' -import config from '../../../config/config' - -const router = new Router() - -const gameReportApiUrl = config.game_report - -// 获取游戏日报 -router.get('/report', async (req, res, next) => { - // 权限判断 - const hasPerm = - req.user.permissions.includes(`${req.query.uid}-readable`) || - req.user.permissions.includes(`${req.query.uid}-edit`) || - req.user.permissions.includes(`${req.query.uid}-publish`) || - req.user.permissions.includes(`games-writeable`) - if (!hasPerm) { - res.status(403).send({ - errcode: 1, - errmsg: '用户无此游戏数据查看权限!', - }) - return - } - - const query = req.query - const game_id = parseInt(query.game_id) - const platform_id = parseInt(query.platform_id) - const date = query.date - const isNew = parseInt(query.isNew) - - try { - const categoryRes = await axios({ - url: gameReportApiUrl, - method: 'get', - params: { - c: 'Ops', - a: 'descField', - body: JSON.stringify({ - gameid: game_id, - channel: platform_id, - }), - }, - }) - - if (categoryRes.data.errcode === 0) { - const categoryInfo = categoryRes.data.result - const category = [] - for (const key in categoryInfo) { - if (categoryInfo.hasOwnProperty(key)) { - category.push(key) - } - } - - if (category.length === 0) { - res.send({ - errcode: 404, - errmsg: '暂无数据!', - }) - return - } - - const getDataArr = [] - - category.map(item => { - getDataArr.push( - getCategoryData(item, date, isNew, game_id, platform_id) - ) - }) - - const dataArr = await Promise.all(getDataArr) - const allData = Object.assign(...dataArr) - - const result = {} - - for (const key in categoryInfo) { - if (categoryInfo.hasOwnProperty(key)) { - const cate = categoryInfo[key] - result[key] = [] - - for (let i = 0; i < cate.length; i++) { - const field = cate[i] - const fieldName = field.name - if (fieldName.endsWith('_%')) { - let idx = 1 - let tempName = fieldName.replace(/%/, idx) - while (allData[tempName]) { - const obj = JSON.parse(JSON.stringify(field)) - obj.name = tempName - obj.explan += `_${idx}` - obj.value = allData[tempName] - result[key].push(obj) - idx++ - tempName = fieldName.replace(/%/, idx) - } - } else { - field.value = allData[fieldName] - result[key].push(field) - } - } - } - } - - res.send({ - errcode: 0, - result: result, - }) - } else { - res.send({ - errcode: categoryRes.errcode, - errmsg: categoryRes.errmsg, - }) - return - } - } catch (err) { - next(err) - } -}) - -function getCategoryData(cateName, date, is_new, game_id, platform_id) { - return new Promise(async (resolve, reject) => { - const dataRes = await axios({ - url: gameReportApiUrl, - method: 'get', - params: { - c: 'Ops', - a: 'gameReport', - body: JSON.stringify({ - gameid: game_id, - channel: platform_id, - times: date, - is_new: is_new, - category: cateName, - }), - }, - }) - - if (dataRes.data.errcode === 0) { - const data = dataRes.data.result - resolve(data) - } else { - reject({ - errcode: 404, - errmsg: '数据获取失败,暂无数据!', - }) - } - }) -} - -// 获取游戏数据(画图表用) -router.get('/game-data', async (req, res, next) => { - // 权限判断 - const hasPerm = - req.user.permissions.includes(`${req.query.uid}-readable`) || - req.user.permissions.includes(`${req.query.uid}-edit`) || - req.user.permissions.includes(`${req.query.uid}-publish`) || - req.user.permissions.includes(`games-writeable`) - if (!hasPerm) { - res.status(403).send({ - errcode: 1, - errmsg: '用户无此游戏数据查看权限!', - }) - return - } - const query = req.query - console.log(query) - const gameid = parseInt(query.gameid) - const channelid = parseInt(query.channelid) - const ad_channelid = query.ad_channelid - const method = query.method - const time_partice = parseInt(query.time_partice) - const time_begin = query.isNew - const time_end = query.isNew - - try { - // TODO: 接口对接 - // const searchRes = await axios({ - // url: gameReportApiUrl, - // method: 'get', - // params: { - // c: 'Ops', - // a: 'descField', - // body: JSON.stringify({ - // gameid: game_id, - // channel: platform_id, - // }), - // }, - // }) - - // if (searchRes.data.errcode === 0) { - // res.send({ - // errcode: 0, - // errmsg: '', - // message: { - // totoal: 2, - // result: [ - // { - // '2019-08-01 01:00:00': 100, - // '2019-08-01 02:00:00': 120, - // }, - // ], - // }, - // }) - // } else { - // res.send({ - // errcode: searchRes.errcode, - // errmsg: searchRes.errmsg, - // }) - // } - - - // TODO: 数据示例 - res.send({ - errcode: 0, - errmsg: '', - message: { - totoal: 2, - result: [ - { - '2019-08-01 01:00:00': 100, - '2019-08-01 02:00:00': 120, - }, - ], - }, - }) - } catch (err) { - next(err) - } -}) - -export default router diff --git a/src/controllers/games/gift.js b/src/controllers/games/gift.js index 9512f02..ca14fe0 100644 --- a/src/controllers/games/gift.js +++ b/src/controllers/games/gift.js @@ -46,6 +46,7 @@ router.post('/', async (req, res, next) => { codes: body.codes, used_codes: body.used_codes, type: body.type, + extraData: body.extraData }) const result = await gift.save() res.send({ @@ -79,6 +80,7 @@ router.put('/', async (req, res, next) => { used_codes: body.used_codes, staus: body.staus, type: body.type, + extraData: body.extraData } ) res.send({ diff --git a/src/controllers/games/order.js b/src/controllers/games/order.js index 0f77461..d595ec2 100644 --- a/src/controllers/games/order.js +++ b/src/controllers/games/order.js @@ -25,7 +25,6 @@ router.get('/', async (req, res, next) => { if (query.itemid) opt.itemid = parseInt(query.itemid) if (query.sp_orderid) opt.sp_orderid = query.sp_orderid - console.log(opt) const result = await OrderInfo.findAll({ offset, diff --git a/src/models/admin/GameGift.js b/src/models/admin/GameGift.js index e391688..1484748 100644 --- a/src/models/admin/GameGift.js +++ b/src/models/admin/GameGift.js @@ -15,6 +15,7 @@ const GameGiftSchema = new mongoose.Schema( used_codes: [{type: String}], // 已使用兑换码 status: {type: Number, default: 0}, // 0-正常, 1-停用 deleted: {type: Boolean, default: false}, + extraData: {type: Object, default: {}}, // 用于拓展 }, { collection: 'game_gift', @@ -61,6 +62,7 @@ const GiftRecordSchema = new mongoose.Schema( gift_name: {type: String}, gift_url: {type: String}, type: {type: Number}, + extraData: {type: Object} }, code: {type: String}, used: {type: Boolean, default: false},