This commit is contained in:
aozhiwei 2023-07-26 16:36:44 +08:00
commit 27d713108f
18 changed files with 66609 additions and 25 deletions

View File

@ -279,6 +279,7 @@ class Shop(object):
['idx', 0, '每日精选的索引'],
['grid', 0, '商品在每日精选中的位置索引'],
['count', 0, '购买数量,始终是1'],
['token_type', '', "选用币种,只能选择一种"],
],
'response': [
_common.RspHead(),

View File

@ -450,8 +450,9 @@ class DailySelectionGoods(object):
['goods_num', 0, '商品堆叠数量'],
['shop_icon', "", '商品图标'],
['weight', 0, '权重'],
['discount', 0, '折扣'],
['price', 0, '价格'],
['token_type', '', '代币类型(4|0)'],
['discount', '', '折扣(95|80)'],
['price', '', '价格(100|100000)'],
['pending', 0, '购买中...'],
]

View File

@ -0,0 +1,6 @@
[
{
"host": "127.0.0.1",
"port": 6379
}
]

View File

@ -0,0 +1,3 @@
#!/bin/bash
node ../../game2006tools/app.js

File diff suppressed because it is too large Load Diff

View File

@ -90,10 +90,10 @@ function init() {
'GameRedis'
);
registerMetaClass(configDir + 'rankSeason.json',
'',
'RankSeason'
);
// registerMetaClass(configDir + 'rankSeason.json',
// '',
// 'RankSeason'
// );
load();
{
traverseMetaList('GameDb2006', (dbConf, idx) => {

View File

@ -82,7 +82,7 @@ class Rankings {
//获取用户记录
async getRecords(conn, lastIdx, limit) {
const {err, rows} = await conn.execQuery(
'select idx,account_id,channel,convert(`name` using utf8) as name,head_id,head_frame,rank,history_best_rank,score,history_best_score,createtime, score_modifytime from t_user where idx > ? order by idx LIMIT ?',
'select idx,account_id,channel,convert(`name` using utf8) as name,head_id,head_frame,`rank`,history_best_rank,`score`,history_best_score,createtime, score_modifytime from t_user where idx > ? LIMIT ?',
[
lastIdx,
limit

View File

@ -0,0 +1,13 @@
const utils = require('j7/utils');
const users = utils.readJsonFromFile('tuser.json');
users.forEach(
(user) => {
//console.log(user.account_id, user.activated, user.level, user.exp, user.createtime);
//if (user.level > 1) {
//console.log(user.account_id, user.activated, user.level, user.exp);
//}
const sql = `UPDATE t_user SET level=${user.level}, exp=exp + ${user.exp} where account_id='${user.account_id}';`;
console.log(sql);
}
);

136
server/game2006tools/package-lock.json generated Normal file
View File

@ -0,0 +1,136 @@
{
"name": "game2006tools",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "game2006tools",
"version": "1.0.0",
"dependencies": {
"j7": "file:../../third_party/j7",
"redis": "^3.1.2"
}
},
"../../third_party/j7": {
"version": "1.0.0",
"dependencies": {
"axios": "^0.26.1",
"body-parser": "^1.20.0",
"crc-32": "^1.2.1",
"express": "^4.17.2",
"minimist": "^1.2.6",
"mysql": "~2.18.1",
"node-xlsx": "^0.21.0",
"querystring": "^0.2.1",
"redis": "^4.1.0",
"urlencode": "^1.1.0"
}
},
"node_modules/denque": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz",
"integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==",
"engines": {
"node": ">=0.10"
}
},
"node_modules/j7": {
"resolved": "../../third_party/j7",
"link": true
},
"node_modules/redis": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz",
"integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==",
"dependencies": {
"denque": "^1.5.0",
"redis-commands": "^1.7.0",
"redis-errors": "^1.2.0",
"redis-parser": "^3.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-redis"
}
},
"node_modules/redis-commands": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz",
"integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ=="
},
"node_modules/redis-errors": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz",
"integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==",
"engines": {
"node": ">=4"
}
},
"node_modules/redis-parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
"integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
"dependencies": {
"redis-errors": "^1.0.0"
},
"engines": {
"node": ">=4"
}
}
},
"dependencies": {
"denque": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz",
"integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw=="
},
"j7": {
"version": "file:../../third_party/j7",
"requires": {
"axios": "^0.26.1",
"body-parser": "^1.20.0",
"crc-32": "^1.2.1",
"express": "^4.17.2",
"minimist": "^1.2.6",
"mysql": "~2.18.1",
"node-xlsx": "^0.21.0",
"querystring": "^0.2.1",
"redis": "^4.1.0",
"urlencode": "^1.1.0"
}
},
"redis": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz",
"integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==",
"requires": {
"denque": "^1.5.0",
"redis-commands": "^1.7.0",
"redis-errors": "^1.2.0",
"redis-parser": "^3.0.0"
}
},
"redis-commands": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz",
"integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ=="
},
"redis-errors": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz",
"integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w=="
},
"redis-parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
"integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
"requires": {
"redis-errors": "^1.0.0"
}
}
}
}

View File

@ -0,0 +1,11 @@
{
"name": "game2006tools",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {},
"dependencies": {
"j7": "file:../../third_party/j7",
"redis": "^3.1.2"
}
}

View File

@ -0,0 +1,5 @@
UPDATE t_user o JOIN (
SELECT owner_address, item_id, SUM(amount) as t FROM t_market_store WHERE `status`=3 AND item_id=10001 GROUP BY owner_address
) t ON o.address = t.owner_address
SET o.gold = o.gold + t.t;
UPDATE t_market_store SET `status`=1 WHERE `status`=3;

View File

@ -388,10 +388,15 @@ class ShopController extends BaseAuthedController
default:
error_log("buyGoodsDirect--- " . $order_id . " --- " . $status);
$this->_rspErr(1, "status error, status: {$status}");
break;
return;
}
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
SqlHelper::update($conn, 't_shop_buy_order', array('order_id' => $order_id), array('status' => $buyStatus));
if ($buyStatus == 2) {
$this->_rspErr(2, "buyStatus error, buyStatus: {$buyStatus}");
return;
}
// 以下是看商品表中是否配置了充值额外奖励
$goods = mt\ShopGoods::get($id);
@ -411,7 +416,7 @@ class ShopController extends BaseAuthedController
'name' => LogService::RECHARGE_CEBG_BONUS,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
error_log("buyGoodsDirect---" . $address . "---" . $item_id . "---" . $item_num);
@ -622,7 +627,7 @@ class ShopController extends BaseAuthedController
'name' => LogService::RECHARGE_DIAMOND,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_addGoods($address, array(
@ -674,7 +679,7 @@ class ShopController extends BaseAuthedController
'name' => LogService::RECHARGE_DIAMOND,
'val' => -$item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_decGoods($address, array(
@ -1201,6 +1206,16 @@ class ShopController extends BaseAuthedController
return;
}
$token_type = getReqVal('token_type', '4');
switch ($token_type) {
case ShopController::TOKEN_TYPE_GOLD:
case ShopController::TOKEN_TYPE_DIAMOND:
break;
default:
$this->_rspErr(1, "token_type is unsupport, {$token_type}");
return;
}
$conn = $this->_getMysql('');
$row = SqlHelper::selectOne(
@ -1234,17 +1249,32 @@ class ShopController extends BaseAuthedController
$goods = mt\Dailyselection::get($sel_id);
$token_type = $goods['token_type'];
$desired_token_type = $goods['token_type'];
$check_token_type = splitStr1($desired_token_type);
if (!in_array($token_type, $check_token_type)) {
$this->_rspErr(1, "token_type parameter error, desired_token_type: {$desired_token_type}");
return;
}
$token_pos = array_search($token_type, $check_token_type, true);
$price_array = splitStr1($goods['price']);
$discount_array = splitStr1($goods['discount']);
$need_price = $price_array[$token_pos];
$discount = $discount_array[$token_pos];
$costItemId = $this->getCostItemIdByTokenType($token_type);
$costItems = $this->makeCostItems($costItemId, $count * $goods['price']);
$costItems = $this->makeCostItems($costItemId, $count * $need_price);
error_log("buyGoodsDS costItems " . json_encode($costItems));
$lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
return;
}
$item_id = $goods['goods_id'];
$item_num = $goods['goods_num'];
@ -1264,7 +1294,18 @@ class ShopController extends BaseAuthedController
'name' => LogService::SHOP_BUY_ITEM_DAILY,
'val' => $costItems[0]['item_num']
];
LogService::consumeDiamond($event);
switch ($token_type) {
case ShopController::TOKEN_TYPE_GOLD:
LogService::consumeGold($event);
break;
case ShopController::TOKEN_TYPE_DIAMOND:
LogService::consumeDiamond($event);
break;
default:
// 这里不应该出现,出现了说明配置表新增了一种货币,但是这里没有处理
error_log("buyGoodsDS token_type is invalid, token_type: {$token_type}");
return;
}
$goodsDto = array(
'goods_id' => $sel_id,
@ -1275,12 +1316,14 @@ class ShopController extends BaseAuthedController
),
'bought_times' => 0,
'total_buy_times' => 0,
); {
);
{
$priceInfo = mt\Item::getPriceInfo($itemMeta);
if (!empty($priceInfo)) {
$goodsDto['price_info'] = $priceInfo['price_info'];
}
}
$propertyChgService->addUserChg();
$this->_rspData(

View File

@ -173,7 +173,7 @@ class BlockChainService {
private static function getWeb3ServiceUrl()
{
if (SERVER_ENV == _DEBUG) {
return 'https://login-test.kingsome.cn/webapp/index.php';
return 'https://192.144.140.87/webapp/index.php';
}
if (SERVER_ENV == _TEST) {
return 'http://127.0.0.1:7672/webapp/index.php';

View File

@ -87,8 +87,22 @@ class LogService extends BaseService
$logInfo['properties'] = array_merge($data,$param);
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
}
public static function productGoldCallback($base, $event,$param = [])
{
$logInfo = self::goldRecord($base['account_id']);
$data = self::userInfoByAccountId($base['account_id']);
$data['type'] = self::PRODUCT_TYPE;
$data['event_name'] = $event['name'];
$data['event_type'] = self::GOLD_TYPE;
$data['event_product'] = 'gold';
$data['event_product_val'] = $event['val'];
public static function productDiamond($base, $event,$param = [])
$logInfo['properties'] = array_merge($data,$param);
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
}
public static function productDiamondCallback($base, $event,$param = [])
{
$logInfo = self::diamondRecord($base['account_id']);
$data = self::userInfoByAccountId($base['account_id']);

View File

@ -90,7 +90,7 @@ class BuyShopGoodsCbService
'name' => LogService::CEBG_TO_DIAMOND,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_addGoods($address, array(

View File

@ -116,6 +116,7 @@ class GameItemMarketBuyOk
private function buyFromMarket($order, $idx)
{
$address = $order['address'];
$account_id = $this->getAccountId($address);
$goods = $this->getMarketGoods($address, $idx);
$this->markMarketGoodsSold($address, $idx);
@ -126,7 +127,7 @@ class GameItemMarketBuyOk
'name' => LogService::MARKET_BUY_GOLD,
'val' => $goods['amount']
];
LogService::productGold($event, ['account_id' => $address]);
LogService::productGoldCallback(['account_id' => $account_id], $event );
}
}
@ -182,4 +183,17 @@ class GameItemMarketBuyOk
ShopBuyRecord::addWithAddress($address, $id, $goods_num);
}
}
private function getAccountId($address){
$row = SqlHelper::ormSelectOne
(myself()->_getMysql($address),
't_user',
array(
'address' => $address
)
);
return $row['account_id'];
}
}

View File

@ -101,7 +101,12 @@ class ShopBuyGoodsDirect
break;
}
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
SqlHelper::update($conn, 't_shop_buy_order', array('order_id' => $order_id), array('status' => $buyStatus));
if ($buyStatus == 2) {
$this->_rspErr(2, "buyStatus error, buyStatus: {$buyStatus}");
return;
}
// 以下是看商品表中是否配置了充值额外奖励
$goods = ShopGoods::get($id);
@ -121,7 +126,7 @@ class ShopBuyGoodsDirect
'name' => LogService::RECHARGE_CEBG_BONUS,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
error_log("buyGoodsDirect---" . $address . "---" . $item_id . "---" . $item_num);

View File

@ -130,7 +130,7 @@ class ShopInappPurchaseDiamonds
'name' => LogService::RECHARGE_DIAMOND,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_addGoods($address, array(
@ -182,7 +182,7 @@ class ShopInappPurchaseDiamonds
'name' => LogService::RECHARGE_DIAMOND,
'val' => -$item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_decGoods($address, array(