Merge branch 'james_bc' of git.kingsome.cn:server/game2006api into james_bc

This commit is contained in:
hujiabin 2022-11-25 15:47:12 +08:00
commit dd60a987cd
4 changed files with 148 additions and 3 deletions

View File

@ -8,7 +8,8 @@ function add(name) {
function init() {
add('fragment');
add('damping');
add('season');
//add('season');
add('feeback');
}
exports.init = init;

View File

@ -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;

View File

@ -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`),

View File

@ -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)