diff --git a/server/game2006service/tasks/factory.js b/server/game2006service/tasks/factory.js index 8345ea4d..688f1f0f 100644 --- a/server/game2006service/tasks/factory.js +++ b/server/game2006service/tasks/factory.js @@ -8,7 +8,8 @@ function add(name) { function init() { add('fragment'); add('damping'); - add('season'); + //add('season'); + add('feeback'); } exports.init = init; diff --git a/server/game2006service/tasks/feeback.js b/server/game2006service/tasks/feeback.js new file mode 100644 index 00000000..14244401 --- /dev/null +++ b/server/game2006service/tasks/feeback.js @@ -0,0 +1,143 @@ +const app = require('j7/app'); +const utils = require('j7/utils'); + +const constant = require('../constant'); + +class FeeBack { + + async start() { + console.log('FeeBack.start'); + while (true) { + await this.backUser(utils.getUtcTime()); + + const nowTime = utils.getUtcTime(); + const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE); + const sleepTime = daySeconds + 3600 * 24 - nowTime; + console.log('FeeBack.sleepTime:' + sleepTime, new Date(), sleepTime / 60); + await utils.sleep(sleepTime * 1000); + } + } + + async backUser(nowTime) { + try { + const {err, conn} = await app.getDbConn("GameDb20060"); + if (err) { + throw err; + } + { + const {err, rows} = await conn.execQuery( + 'SELECT * FROM t_transaction_prefee WHERE done = 0 AND state = 0 AND createtime < ?', + [ + nowTime - 3600 * 24 - 3600 * 6 + ] + ); + await utils.serial( + rows, + async (element) => { + console.log('backUser', element); + await this.procBack(conn, element); + } + ); + } + } catch (err) { + console.log(err); + } + } + + async procBack(conn, row) { + await this.setState(conn, row['trans_id'], 1); + if (row['item_uniid']) { + await conn.update( + 't_bag', + [ + ['account_id', row['account_id']], + ['idx', row['item_uniid']], + ], + [ + ['!item_num', + () => { + return 'item_num + ' + row['item_num'] + }], + ] + ); + } else { + switch (Number(row['item_id'])) { + case 666: + { + await conn.update( + 't_chip', + [ + ['token_id', row['token_id']], + ], + [ + ['!strength', + () => { + return 'GREATEST(0, strength - ' + row['item_num'] + ')' + }], + ] + ); + } + break; + case 10001: + { + //gold + await conn.update( + 't_user', + [ + ['account_id', row['account_id']], + ], + [ + ['!gold', + () => { + return 'gold + ' + row['item_num'] + }], + ] + ); + } + break; + case 10002: + { + //diamond + await conn.update( + 't_user', + [ + ['account_id', row['account_id']], + ], + [ + ['!diamond', + () => { + return 'diamond + ' + row['item_num'] + }], + ] + ); + } + break; + default: + { + console.log('error fee', row); + return; + } + } + } + await this.setState(conn, row['trans_id'], 2); + } + + async setState(conn, transId, state) { + await conn.update( + 't_transaction_prefee', + [ + ['trans_id', transId], + ], + [ + ['state', state] + ] + ); + } + +} + +function init() { + (new FeeBack()).start(); +} + +exports.init = init; diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 567a1064..8209a8c9 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -828,6 +828,7 @@ CREATE TABLE `t_transaction_prefee` ( `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `item_num` double NOT NULL DEFAULT '0' COMMENT '道具数量', `done` int(11) NOT NULL DEFAULT '0' COMMENT 'done', + `state` int(11) NOT NULL DEFAULT '0' COMMENT 'state', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 8f373f4e..7becadd7 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -72,14 +72,14 @@ class BaseAuthedController extends BaseController { die(); } } - if (SERVER_ENV == _ONLINE) { + /*if (SERVER_ENV == _ONLINE) { if (phpcommon\cmpVersion(getReqVal('_version', ''), '0.2.0') > 0) { if (!$this->isWhiteList() || myself()->_getChannel() != BC_CHANNEL) { phpcommon\sendError(1002, ''); die(); } } - } + }*/ } protected function updateSession($accountId, $sessionId)