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

This commit is contained in:
aozhiwei 2024-08-07 15:22:33 +08:00
commit 567d5c2489
10 changed files with 116 additions and 72 deletions

View File

@ -10,7 +10,7 @@ class AAMarket(object):
'desc': '获取上架出售的NFTs(瀑布流式api) jwtheader为可选参数',
'group': '!AAMarket',
'url': 'https://market-test.kingsome.cn/api/market/product/list/:net_id',
'headers': _common.JwtHeader,
'headers': _common.MaybeJwtHeader,
'is_json_params': True,
'request_params': [
[':net_id', 0, '链id'],
@ -295,13 +295,14 @@ class AAMarket(object):
'name': '/api/user/:account_address',
'desc': '获取用户信息',
'group': '!AAMarket',
'headers': _common.MaybeJwtHeader,
'url': 'https://market-test.kingsome.cn/api/user/:account_address',
'params': [
],
'response': [
_common.RspHead(),
['nickname', '', '昵称'],
['email', '', 'email'],
['email', '', 'email(因为隐私问题jwt关联的地址和:account_address相等时才返回email)'],
['contribution_point', 0, '贡献点'],
['gold', '', '金币数'],
['diamond', '', '钻石数'],

View File

@ -26,6 +26,10 @@ JwtHeader = [
'Authorization Bearer {JwtToken}'
]
MaybeJwtHeader = [
'Authorization Bearer {JwtToken} 可选参数'
]
LoginRequired = 'login required'
class Union(object):

View File

@ -67,11 +67,11 @@ class BigwheelController extends BaseAuthedController {
}
$priceInfo = $this->getPriceInfo($data['drawed_times']);
if (empty($priceInfo)) {
myself()->_rspErr(500, 'server internal error');
myself()->_rspErr(500, 'server internal error1');
return;
}
if ($priceInfo['cost_item_id'] != V_ITEM_DIAMOND) {
myself()->_rspErr(500, 'server internal error');
myself()->_rspErr(500, 'server internal error2');
return;
}
$costItemNum = 0;
@ -280,8 +280,15 @@ class BigwheelController extends BaseAuthedController {
)
));
}
$this->sendNotify($drop1[0]['item_id']);
$this->sendNotify($drop2[0]['item_id']);
myself()->_fireEvent('Bigwheel', 'onWinPrize',
array(
'info' => $grid1,
'drop' => $drop1
),
array(
'info' => $grid2,
'drop' => $drop2
));
}
public function buyS()
@ -437,47 +444,4 @@ class BigwheelController extends BaseAuthedController {
return $priceInfo;
}
private function sendNotify($itemId)
{
$itemMeta = myself()->_callMtStatic('Item', 'get', $itemId);
if (empty($itemMeta)) {
return;
}
$elements = array();
array_push($elements, array(
'ele_type' => 2,
'color' => '#ffffff',
'lang_key' => 'Marquee_rewards_get_1',
'lang_params' => array(),
));
array_push($elements, array(
'ele_type' => 1,
//'color' => '#',
'text' => myself()->_getUserInfo(array('name'))['name'],
));
array_push($elements, array(
'ele_type' => 2,
'color' => '#ffffff',
'lang_key' => 'Marquee_rewards_get_2',
'lang_params' => array(),
));
array_push($elements, array(
'ele_type' => 2,
'color' => '#ff3f3f',
'lang_key' => $itemMeta['name'],
'lang_params' => array(),
));
array_push($elements, array(
'ele_type' => 2,
'color' => '#ffffff',
'lang_key' => 'Marquee_rewards_get_3',
'lang_params' => array(),
));
error_log(json_encode($elements));
$content = myself()->_callServiceStatic('NoticeService', 'buildCustom', $elements);
$loop = 1;
$interval = 1;
myself()->_callServiceStatic('NoticeService', 'send', $content, $loop, $interval);
}
}

View File

@ -132,12 +132,12 @@ class HashRateController extends BaseAuthedController
$rewardNum = $reward[0]['item_num'];
HashRate::add($taskMeta['id'],$currentPeriod['id']);
HashRate::rewardAdd($currentPeriod['id'],$rewardNum);
//刷新任务
$refreshTimes = myself()->_getDailyV(TN_HASH_DAILY_REFRESH_TIMES,0);
$refreshTimesMax = \mt\Parameter::getVal('economy_account_compute_refresh_max',5);
if ($taskMeta['is_refresh'] == \mt\AchievementsPower::REFRESH_STATE && $refreshTimes < $refreshTimesMax){
$this->hashRateService->refreshHashRateTask($taskMeta,$currentPeriod['id']);
}
// //刷新任务
// $refreshTimes = myself()->_getDailyV(TN_HASH_DAILY_REFRESH_TIMES,0);
// $refreshTimesMax = \mt\Parameter::getVal('economy_account_compute_refresh_max',5);
// if ($taskMeta['is_refresh'] == \mt\AchievementsPower::REFRESH_STATE && $refreshTimes < $refreshTimesMax){
// $this->hashRateService->refreshHashRateTask($taskMeta,$currentPeriod['id']);
// }
$this->_rspData(array(
'award' => $reward,
));

View File

@ -5,12 +5,9 @@ namespace events;
class Bigwheel
{
public static function onWinBigPrize($data)
public static function onWinPrize($grid1, $grid2)
{
//触发(调用)对应对该事件感兴趣的模块
//myself()->_callServiceStatic('A', 'f1', $battleData);
//myself()->_callServiceStatic('B', 'f1', $battleData);
echo json_encode($data);
myself()->_callServiceStatic('BigwheelService', 'onWinPrize', $grid1, $grid2);
}
}

View File

@ -6,12 +6,12 @@ namespace events;
class Upgrade
{
public static function onHeroUpgrade($params){
myself()->_callServiceStatic('HashRateService', 'onUpLvHero', $params);
public static function onHeroUpgrade(){
myself()->_callServiceStatic('HashRateService', 'onUpLvHero');
}
public static function onChipUpgrade($params){
myself()->_callServiceStatic('HashRateService', 'onUpLvChip', $params);
public static function onChipUpgrade(){
myself()->_callServiceStatic('HashRateService', 'onUpLvChip');
}

View File

@ -3,6 +3,9 @@
namespace models;
require_once('mt/AchievementsPower.php');
use mt\AchievementsPower;
use phpcommon\SqlHelper;
class HashRate extends BaseModel
{
@ -32,6 +35,7 @@ class HashRate extends BaseModel
}
public static function getCount($period){
$count = 0;
$rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_hash_rate',
@ -40,7 +44,13 @@ class HashRate extends BaseModel
'period' => $period,
)
);
return count($rows);
foreach ($rows as $row){
$hashMeta = AchievementsPower::find($row['task_id']);
if ($hashMeta['task_type'] != AchievementsPower::TYPE5){
$count += 1;
}
}
return $count;
}

View File

@ -39,13 +39,14 @@ class BattleRandAttribute {
$strs = explode('|', $randMeta['attributeRange']);
foreach ($strs as $str){
$attrStr = explode(':', $str);
if (count($attrStr) == 3){
$rnd = rand($attrStr[1]*100000 , $attrStr[2]*100000) / 100000;
// $val = $attrStr[1] + ($attrStr[2] - $attrStr[1]) * $rnd;
array_push($attrArray,array(
"attr_id" => $attrStr[0],
"val" => $rnd,
));
}
}
return $attrArray;
}

View File

@ -0,0 +1,66 @@
<?php
namespace services;
require_once('mt/Bigwheel.php');
use mt;
class BigwheelService extends BaseService
{
public static function onWinPrize($grid1, $grid2)
{
$grids = array($grid1, $grid2);
foreach ($grids as $grid) {
$gridMeta = mt\Bigwheel::get($grid['info']['grid_id']);
if ($grid['info']['grid_state'] == 1 && $gridMeta['is_grand_reward']) {
self::sendNotify($grid['drop'][0]['item_id']);
}
}
}
private static function sendNotify($itemId)
{
$itemMeta = myself()->_callMtStatic('Item', 'get', $itemId);
if (empty($itemMeta)) {
return;
}
$elements = array();
array_push($elements, array(
'ele_type' => 2,
'color' => '#ffffff',
'lang_key' => 'Marquee_rewards_get_1',
'lang_params' => array(),
));
array_push($elements, array(
'ele_type' => 1,
//'color' => '#',
'text' => myself()->_getUserInfo(array('name'))['name'],
));
array_push($elements, array(
'ele_type' => 2,
'color' => '#ffffff',
'lang_key' => 'Marquee_rewards_get_2',
'lang_params' => array(),
));
array_push($elements, array(
'ele_type' => 2,
'color' => '#ff3f3f',
'lang_key' => $itemMeta['name'],
'lang_params' => array(),
));
array_push($elements, array(
'ele_type' => 2,
'color' => '#ffffff',
'lang_key' => 'Marquee_rewards_get_3',
'lang_params' => array(),
));
error_log(json_encode($elements));
$content = myself()->_callServiceStatic('NoticeService', 'buildCustom', $elements);
$loop = 1;
$interval = 1;
myself()->_callServiceStatic('NoticeService', 'send', $content, $loop, $interval);
}
}

View File

@ -344,7 +344,8 @@ class HashRateService extends BaseService
private function randHashRateTaskList($type){
$metas = AchievementsPower::getListByType($type);
$this->hashRateTask['task'.$type] = array();
foreach (array_rand($metas, 4) as $key) {
$count = count($metas) >= 4 ? 4 : count($metas) ;
foreach (array_rand($metas, $count) as $key) {
$meta = $metas[$key];
if (count($this->hashRateTask['task'.$type]) >=
4) {