From bd670ab483e6a039ff3668099ace6f4fd0727a7f Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 30 Jul 2024 14:46:52 +0800 Subject: [PATCH 1/6] marqueeNotice --- .../controller/TempToolsController.class.php | 1 + .../controller/UnitTestController.class.php | 44 ++++++++++ webapp/services/NoticeService.php | 80 +++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 webapp/controller/UnitTestController.class.php create mode 100644 webapp/services/NoticeService.php diff --git a/webapp/controller/TempToolsController.class.php b/webapp/controller/TempToolsController.class.php index f95f61a8..9138eba5 100644 --- a/webapp/controller/TempToolsController.class.php +++ b/webapp/controller/TempToolsController.class.php @@ -7,6 +7,7 @@ require_once('models/InGameMall.php'); require_once('services/MailApiService.php'); + use phpcommon\SqlHelper; use models\InGameMall; diff --git a/webapp/controller/UnitTestController.class.php b/webapp/controller/UnitTestController.class.php new file mode 100644 index 00000000..4a680219 --- /dev/null +++ b/webapp/controller/UnitTestController.class.php @@ -0,0 +1,44 @@ +1, + "elements"=> $elements, + ]; + return json_encode($data); + } + + public static function send($content, $loop, $interval) { + $appkey = "YOUME1838B3633FF1410BDC9124BBD806F245B9D2E5AC"; + $identifier="admin"; + $appsecret="q6B570yTyj/00Nk4mYZtgDwyew5v05t13V1vo4mxpEuAaWUiinAyVxG41sNu3vsFe8sipOLfKfIVYGhzpQrqzvj5sId3mrBfj/s65a2gp36yDrI/nX5BnUAJB317SEosR6xLoPuhBvHU+/1DWI7nKSKaRNxnQiC46PJKFc2kX50BAAE="; + + $data = [ + "Notice"=>[ + "ChannelID"=>"world_room_1",//频道 ID,app 内唯一,字符串 + "NoticeType"=>1,//1 为跑马灯公告,2 为聊天框公告,3 为置顶公告,整数 + "LoopType"=>1,// 公告循环类型,1 为一次性公告,2 为周期性公告,整数 + "Title"=>"",// 公告标题,字符串 + "Content"=>$content,//"testtttttt222",// 公告内容,字符串 + "LinkKeyWords"=>"",// 链接关键字,字符串 + "LinkAddr"=>"",// 链接地址,字符串 + "Creator"=>"",// 公告添加人,字符串 + "EnableStatus"=>2,// 公告启用状态,1 为停用,2 为启用,整数 + + "SendStartTime"=>"",// 公告发送时间,格式为 HH:MM:SS,字符串 + "SendInstantly"=>1,// 是否即时发送,也属于公告 json 里的字段。1 是,0 否,不指定则不起作用 + "SendTimes"=>$loop,// 公告发送次数,整数(需要传入) + "SendInterval"=>$interval,// 公告发送多次时,每次的间隔,单位秒,整数(需要传入) + ] + ]; + + $url = "https://sgapi.youme.im/v1/im/add_notice"; + $curtime = time(); + + $params = array( + "appkey" => $appkey, + "identifier"=> $appkey, + "curtime"=> $curtime, + "checksum"=> strtolower(sha1($appsecret.$curtime)), + ); + + $response = ''; + phpcommon\HttpClient::postContentEx($url, $params, json_encode($data), $response, ['Content-Type: application/json']); + + if (SERVER_ENV != _ONLINE) { + error_log($response); + } + } +} \ No newline at end of file From cdcde709dc0c9f9ce7cb2957df9bff0b0a954a5b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 17:07:10 +0800 Subject: [PATCH 2/6] 1 --- doc/AAMarket.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/_common.py | 16 +++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/doc/AAMarket.py b/doc/AAMarket.py index 79f3ad0e..db2f4b42 100644 --- a/doc/AAMarket.py +++ b/doc/AAMarket.py @@ -377,4 +377,59 @@ class AAMarket(object): ['!rows', [_common.ChainActivity()], '数据'], ] }, + { + 'method': 'GET', + 'name': '/api/recharge/goods', + 'desc': '充值-商品列表', + 'group': '!AAMarket', + 'url': 'https://market-test.kingsome.cn/api/recharge/goods', + 'is_json_params': False, + 'request_params': [ + ], + 'params': [ + ], + 'response': [ + _common.RspHead(), + ['!rows', [_common.RechargeGoods()], '数据'], + ] + }, + { + 'method': 'POST', + 'name': '/api/recharge/buy', + 'desc': '充值-购买', + 'group': '!AAMarket', + 'url': 'https://market-test.kingsome.cn/api/recharge/buy', + 'headers': _common.JwtHeader, + 'is_json_params': True, + 'request_params': [ + ], + 'params': [ + ['net_id', 0, '链id'], + ['goods_id', '', '商品id'], + ['account_address', '', '钱包地址(一般为小狐狸)'], + ], + 'response': [ + _common.RspHead(), + ['calls', _common.NftTransaction(), '合约调用'] + ] + }, + { + 'method': 'POST', + 'name': '/api/recharge/history', + 'desc': '充值-历史', + 'group': '!AAMarket', + 'url': 'https://market-test.kingsome.cn/api/recharge/history', + 'headers': _common.JwtHeader, + 'is_json_params': True, + 'request_params': [ + ], + 'params': [ + ['net_id', 0, '链id'], + ], + 'response': [ + _common.RspHead(), + ['page', _common.StreamPage(), '分页信息'], + ['!rows', [_common.RechargeHistory()], '数据'], + ] + }, ] diff --git a/doc/_common.py b/doc/_common.py index dfcdcee8..68dda865 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1828,5 +1828,19 @@ class RechargeGoods(object): def __init__(self): self.fields = [ ['goods_id', '', '商品id(购买时用)'], - ['goods_meta', '', '配置表信息(和excel完全一样)'], + ['diamond', 0, '充值所得钻石'], + ['currency', '', '货币地址'], + ['price', '', '价格'], + ] + +class RechargeHistory(object): + + def __init__(self): + self.fields = [ + ['order_id', '', '订单id'], + ['txhash', '', 'txhash'], + ['net_id', 0, '链id'], + ['currency', '', '货币地址'], + ['amount', '', '货币数'], + ['createtime', 0, '成交时间'], ] From 1992f163434a55407dbed4f95da771c3fcc39aaf Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 17:11:11 +0800 Subject: [PATCH 3/6] 1 --- doc/AAMarket.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/AAMarket.py b/doc/AAMarket.py index db2f4b42..de0fd897 100644 --- a/doc/AAMarket.py +++ b/doc/AAMarket.py @@ -410,7 +410,10 @@ class AAMarket(object): ], 'response': [ _common.RspHead(), - ['calls', _common.NftTransaction(), '合约调用'] + ['!calls', [ + ['trans_id', '', '事务id'], + ['trans_req', _common.MFTransactionRequest(), '调用合约参数'], + ], '合约调用'] ] }, { From d28b8d155a70a5417a8ce0af6b4d4019c5efb6fa Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 31 Jul 2024 17:55:44 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=AE=97=E5=8A=9B=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/HashRate.py | 7 ++- doc/_common.py | 1 + sql/gamedb.sql | 19 +++++++- sql/gamedb2006_migrate_240722_01.sql | 28 +++++++++++ webapp/bootstrap/constant.php | 1 + .../controller/HashRateController.class.php | 48 +++++++++++++++++-- webapp/models/ChipPage.php | 1 + webapp/models/HashRate.php | 44 +++++++++++++++-- webapp/models/Hero.php | 2 + webapp/models/User.php | 13 +++++ webapp/mt/AchievementsPower.php | 17 ++++++- webapp/services/HashRateService.php | 46 ++++++++++++++++-- 12 files changed, 213 insertions(+), 14 deletions(-) diff --git a/doc/HashRate.py b/doc/HashRate.py index 6af018d7..dcf757e6 100644 --- a/doc/HashRate.py +++ b/doc/HashRate.py @@ -11,15 +11,18 @@ class HashRate(object): 'url': 'webapp/index.php?c=HashRate&a=info', 'params': [ _common.ReqHead(), + ['type', 0, '1:战斗任务 2:英雄任务 3:行为任务 4:充值消费任务'], ], 'response': [ _common.RspHead(), - ['!list', [HashRateList()], '行为列表'], + ['!task_list1', [HashRateList()], '任务列表1'], + ['!task_list2', [HashRateList()], '任务列表2'], ['obtain_start_time', 0, '获得期开始时间'], ['obtain_end_time', 0, '获得期结束时间'], ['income_end_time', 0, '盈利期结束时间'], ['state', 0, '0:未开始 1:获得期 2:盈利期'], ['myHashRate', 0, '我的算力'], + ['refresh_times', 0, '今日刷新次数'], ] }, ] @@ -32,5 +35,5 @@ class HashRateList(object): ['task_id', 0, '任务id'], ['current', 0, '当前进度'], ['target', 0, '目标进度'], - ['state', 0, '1:完成 0:未完成'], + ['state', 0, '2:完成(已领取) 1:完成(未领取) 0:未完成'], ] \ No newline at end of file diff --git a/doc/_common.py b/doc/_common.py index dfcdcee8..c966ecec 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1114,6 +1114,7 @@ class ChipPageSlot(object): ['state', 0, '0:未解锁 1:已解锁'], ['chip_id', '', '芯片唯一id'], ['item_id', '', '芯片itemId'], + ['quality', '', '芯片品阶'], ] class HeroPreset(object): diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 2f143928..b52b1123 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1697,13 +1697,30 @@ CREATE TABLE `t_hash_rate` ( `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `task_id` int(11) NOT NULL COMMENT '配置表id', `period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数', - `reward` int(64) NOT NULL DEFAULT '0' COMMENT '奖励', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), UNIQUE KEY `account_period_task_id` (`account_id`,`period`, `task_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +-- +-- Table structure for table `t_hash_rate_reward` +-- + +DROP TABLE IF EXISTS `t_hash_rate_reward`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_hash_rate_reward` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数', + `reward` int(64) NOT NULL DEFAULT '0' COMMENT '奖励', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_period` (`account_id`,`period`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + -- -- Table structure for table `t_hash_rate_battle_data` -- diff --git a/sql/gamedb2006_migrate_240722_01.sql b/sql/gamedb2006_migrate_240722_01.sql index 14d51d08..45495841 100644 --- a/sql/gamedb2006_migrate_240722_01.sql +++ b/sql/gamedb2006_migrate_240722_01.sql @@ -15,6 +15,34 @@ CREATE TABLE `t_emoji` ( UNIQUE KEY `account_item_id` (`account_id`, `item_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +DROP TABLE IF EXISTS `t_hash_rate`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_hash_rate` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `task_id` int(11) NOT NULL COMMENT '配置表id', + `period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_period_task_id` (`account_id`,`period`, `task_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +DROP TABLE IF EXISTS `t_hash_rate_reward`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_hash_rate_reward` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数', + `reward` int(64) NOT NULL DEFAULT '0' COMMENT '奖励', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_period` (`account_id`,`period`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + insert into version (version) values(2024052101); commit; diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index d0ecffc5..6e215811 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -88,6 +88,7 @@ define('TN_HASH_RATE_SYN_CHIP_TIMES', 50004); define('TN_HASH_RATE_SYN_SKIN_TIMES', 50005); define('TN_HASH_RATE_UP_HERO_TIMES', 50006); define('TN_HASH_RATE_UP_CHIP_TIMES', 50007); +define('TN_HASH_DAILY_REFRESH_TIMES', 50008); define('SHOP_BUY_MODE_NORMAL', 0); define('SHOP_BUY_MODE_DAILY_SELECTION', 1); diff --git a/webapp/controller/HashRateController.class.php b/webapp/controller/HashRateController.class.php index 1e3010f9..a7ac613d 100644 --- a/webapp/controller/HashRateController.class.php +++ b/webapp/controller/HashRateController.class.php @@ -1,8 +1,10 @@ hashRateService); foreach ($mateList as $mate) { $taskDb = HashRate::find($mate['id'],$currentPeriod['id']); - $temp = $this->hashRateService->hashRateTaskDto($mate,$taskDb); - array_push($taskDtoList1, $temp); + $taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb); + array_push($taskDtoList1, $taskDto); } $mateList2 = \mt\AchievementsPower::getListByType(0); foreach ($mateList2 as $mate) { $taskDb = HashRate::find($mate['id'],$currentPeriod['id']); - $temp = $this->hashRateService->hashRateTaskDto($mate,$taskDb); - array_push($taskDtoList2, $temp); + $taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb); + array_push($taskDtoList2, $taskDto); } $obtain_start_time = strtotime($currentPeriod['obtain_start_time']); $obtain_end_time = strtotime($currentPeriod['obtain_end_time']); @@ -94,16 +96,54 @@ class HashRateController extends BaseAuthedController 'income_start_time' => $income_start_time, 'income_end_time' => $income_end_time, 'state' => $state, + 'refresh_times' => myself()->_getDailyV(TN_HASH_DAILY_REFRESH_TIMES,0), + 'myHashRate' => 0, )); } public function commitTask(){ + $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); + if (! $currentPeriod){ + $this->_rspErr(1, 'Already ended'); + return; + } $taskId = getReqVal('task_id', 0); $taskMeta = \mt\AchievementsPower::find($taskId); if (!$taskMeta) { $this->_rspErr(1, 'task_id error'); return; } + $taskDb = HashRate::find($taskMeta['id'],$currentPeriod['id']); + $taskDto = $this->hashRateService->hashRateTaskDto($taskMeta,$taskDb); + + if (!$taskDto) { + $this->_rspErr(10, 'server internal error'); + return; + } + if ($taskDto['state'] == \services\HashRateService::RECEIVED_STATE) { + $this->_rspErr(2, "Can't get it again"); + return; + } +// if ($taskDto['state'] == \services\HashRateService::NOT_FINISHED_STATE) { +// $this->_rspErr(3, 'task not achieved'); +// return; +// } + $lootIndex = $taskMeta['Reward_Loot']; + $reward = \services\LootService::dropOutItem($lootIndex); + $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']); + } + $this->_rspData(array( + 'award' => $reward, + )); } + + } \ No newline at end of file diff --git a/webapp/models/ChipPage.php b/webapp/models/ChipPage.php index fff563f2..c32c65a2 100644 --- a/webapp/models/ChipPage.php +++ b/webapp/models/ChipPage.php @@ -85,6 +85,7 @@ class ChipPage extends BaseModel if ($value['chip_id']){ $chipDb = Chip::find($value['chip_id']); $newData[$key]['item_id'] = $chipDb['item_id']; + $newData[$key]['quality'] = $chipDb['quality']; $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array()); foreach ($rand_attr as $val){ array_push($attrs,$val); diff --git a/webapp/models/HashRate.php b/webapp/models/HashRate.php index 7d0a9b9e..b7f4d3d1 100644 --- a/webapp/models/HashRate.php +++ b/webapp/models/HashRate.php @@ -47,11 +47,25 @@ class HashRate extends BaseModel } - public static function add($fieldKv){ - SqlHelper::insert( + public static function add($taskId,$period){ + SqlHelper::upsert( myself()->_getSelfMysql(), 't_hash_rate', - $fieldKv + array( + 'account_id' => myself()->_getAccountId(), + 'period' => $period, + 'task_id' => $taskId + ), + array( + 'modifytime' => myself()->_getNowTime() + ), + array( + 'account_id' => myself()->_getAccountId(), + 'period' => $period, + 'task_id' => $taskId, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) ); } @@ -91,4 +105,28 @@ class HashRate extends BaseModel return $totalHashRate; } + public static function rewardAdd($period,$reward){ + SqlHelper::upsert( + myself()->_getSelfMysql(), + 't_hash_rate_reward', + array( + 'account_id' => myself()->_getAccountId(), + 'period' => $period, + ), + array( + 'reward' => function () use($reward) { + return "reward + ${reward}"; + }, + 'modifytime' => myself()->_getNowTime() + ), + array( + 'account_id' => myself()->_getAccountId(), + 'period' => $period, + 'reward' => $reward, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + } \ No newline at end of file diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 8c07f65c..f90dd9be 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -198,6 +198,7 @@ class Hero extends BaseModel { $heroAtteMeta = \mt\EconomyAttribute::findByGrade($heroMeta['relationship'],$row['quality']); $unsealTime = $row['unseal_time'] ? $row['unseal_time'] : $row['createtime']; $validTime = $unsealTime + 86400 * $heroAtteMeta['validTime'] ; + $skinDb = HeroSkin::find($row['skin_id']); $dto = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -206,6 +207,7 @@ class Hero extends BaseModel { 'hero_lv' => $row['hero_lv'], 'hero_tili' => $row['hero_tili'], 'state' => $row['state'], + 'skin_id' => $skinDb?$skinDb['skin_id']:0, 'quality' => $row['quality'], 'skill_lv1' => $row['skill_lv1'], 'skill_lv2' => $row['skill_lv2'], diff --git a/webapp/models/User.php b/webapp/models/User.php index 8c7a3fef..8407ae84 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -11,6 +11,7 @@ require_once('models/Hero.php'); require_once('models/HeroPreset.php'); require_once('models/SignLog.php'); require_once('models/UserHonor.php'); +require_once('models/HeroSkin.php'); use mt; use phpcommon; @@ -74,6 +75,11 @@ class User extends BaseModel { $heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']); $heroUniid = $heroDb ? $row['hero_id'] : 0; $heroId = $heroDb ? $heroDb['hero_id'] : 0; + $skinId = 0; + if ($heroDb){ + $skinDb = HeroSkin::find($heroDb['skin_id']); + $skinId = $skinDb ? $skinDb['skin_id']:0; + } $honorInfo = array(); if ($row['address']){ $honorInfo = UserHonor::info($row['address']); @@ -98,6 +104,7 @@ class User extends BaseModel { 'diamond' => cecFormat($row['diamond']), 'hero_uniid' => $heroUniid, 'hero_id' => $heroId, + 'skin_id' => $skinId, 'first_fight' => $row['first_fight'], 'already_guide' => $row['already_guide'], 'pve_instance_id' => $row['pve_instance_id'], @@ -125,6 +132,11 @@ class User extends BaseModel { $heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']); $heroUniid = $heroDb ? $row['hero_id'] : 0; $heroId = $heroDb ? $heroDb['hero_id'] : 0; + $skinId = 0; + if ($heroDb){ + $skinDb = HeroSkin::find($heroDb['skin_id']); + $skinId = $skinDb ? $skinDb['skin_id']:0; + } $honorInfo = array(); if ($row['address']){ $honorInfo = UserHonor::info($row['address']); @@ -149,6 +161,7 @@ class User extends BaseModel { 'diamond' => cecFormat($row['diamond']), 'hero_uniid' => $heroUniid, 'hero_id' => $heroId, + 'skin_id' => $skinId, 'first_fight' => $row['first_fight'], 'already_guide' => $row['already_guide'], 'head_list' => self::getHeadList($row), diff --git a/webapp/mt/AchievementsPower.php b/webapp/mt/AchievementsPower.php index ba50e4f4..ee4d7856 100644 --- a/webapp/mt/AchievementsPower.php +++ b/webapp/mt/AchievementsPower.php @@ -37,6 +37,9 @@ class AchievementsPower { const TYPE3 = 3; const TYPE4 = 4; + const REFRESH_STATE = 1; + const NOT_REFRESH_STATE = 0; + public static function find($id){ return getXVal(self::getMetaList(), $id, null); } @@ -55,13 +58,25 @@ class AchievementsPower { public static function getListByType($type){ $mateList = array(); foreach (self::getMetaList() as $mate){ - if ($mate['scene'] == $type){ + if ($mate['task_type'] == $type){ array_push($mateList,$mate); } } return $mateList; } + public static function getAvailableTasks($type,$excludeMetas){ + $metas = array(); + foreach (self::getListByType($type) as $meta) { + if (!array_find($excludeMetas, function($val) use($meta) { + return $val['task_id'] == $meta['id']; + })) { + array_push($metas, $meta); + } + } + return $metas; + } + public static function getMetaList() diff --git a/webapp/services/HashRateService.php b/webapp/services/HashRateService.php index 455f52be..406aa7db 100644 --- a/webapp/services/HashRateService.php +++ b/webapp/services/HashRateService.php @@ -105,9 +105,17 @@ class HashRateService extends BaseService ); if ($taskDb){ - $taskDto['current'] = $taskDto['target']; - $taskDto['state'] = self::RECEIVED_STATE; - return $taskDto; + if ($taskMate['scene'] > 0){ + if (myself()->_getDaySeconds($taskDb['modifytime']) == myself()->_getNowDaySeconds()) { + $taskDto['current'] = $taskDto['target']; + $taskDto['state'] = self::RECEIVED_STATE; + return $taskDto; + } + }else{ + $taskDto['current'] = $taskDto['target']; + $taskDto['state'] = self::RECEIVED_STATE; + return $taskDto; + } } switch ($taskMate['Completion_type']){ @@ -338,6 +346,38 @@ class HashRateService extends BaseService json_encode($this->hashRateTask)); } + public function refreshHashRateTask($taskMate,$period){ + $taskList = $this->getHashRateTasks($taskMate['task_type']); + $metas = AchievementsPower::getAvailableTasks($taskMate['task_type'],$taskList); + if (count($metas)<1) { + return; + } + $randMetas = array(); + foreach ($metas as $meta){ + $taskDb = HashRate::find($meta['id'],$period); + if (!$taskDb || myself()->_getDaySeconds($taskDb['modifytime']) < myself()->_getNowDaySeconds()){ + array_push($randMetas,$meta); + } + } + if (count($randMetas)<1) { + return; + } + $key = array_rand($randMetas,1); + foreach ($taskList as $k=>$task){ + if ($task['task_id'] == $taskMate['id']){ + $taskList[$k] = array( + 'task_id' => $metas[$key]['id'], + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ); + } + } + $this->hashRateTask['task'.$taskMate['task_type']] = $taskList; + $this->saveHashRateTask(); + myself()->_incDailyV(TN_HASH_DAILY_REFRESH_TIMES,0,1); + } + + public function serverTaskDto($taskMate){ $taskDto = array( From 658603e0a09e40545109d4848bb820fdcea77e04 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 31 Jul 2024 17:58:48 +0800 Subject: [PATCH 5/6] 1 --- doc/HashRate.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/HashRate.py b/doc/HashRate.py index dcf757e6..63ce307e 100644 --- a/doc/HashRate.py +++ b/doc/HashRate.py @@ -5,10 +5,10 @@ class HashRate(object): def __init__(self): self.apis = [ { - 'name': 'info', + 'name': 'taskList', 'desc': '获取算力信息', 'group': 'HashRate', - 'url': 'webapp/index.php?c=HashRate&a=info', + 'url': 'webapp/index.php?c=HashRate&a=taskList', 'params': [ _common.ReqHead(), ['type', 0, '1:战斗任务 2:英雄任务 3:行为任务 4:充值消费任务'], @@ -24,6 +24,19 @@ class HashRate(object): ['myHashRate', 0, '我的算力'], ['refresh_times', 0, '今日刷新次数'], ] + },{ + 'name': 'commitTask', + 'desc': '获取算力信息', + 'group': 'HashRate', + 'url': 'webapp/index.php?c=HashRate&a=commitTask', + 'params': [ + _common.ReqHead(), + ['task_id', 0, '任务id'], + ], + 'response': [ + _common.RspHead(), + ['!award', [_common.AwardItem()], '奖励'], + ] }, ] From 559c18cd98619b5cf2419e99ecdb95c53ce87bd5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 19:06:53 +0800 Subject: [PATCH 6/6] 1 --- webapp/controller/BaseController.class.php | 6 +++--- webapp/controller/UnitTestController.class.php | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 376e3e6e..b521ca20 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -276,14 +276,14 @@ class BaseController { return $channel == "0000"; } - public function callService($serviceName, $funcName) + public function _callServiceStatic($serviceName, $funcName, ...$args) { if (!array_key_exists($serviceName, $this->serviceHash)) { require_once('services/' . $serviceName . '.php'); $this->serviceHash[$serviceName] = $this->_getNowTime(); } - $method = new ReflectionMethod($serviceName . 'Service', $funcName); - $ret = $method->invoke(null); + $method = new ReflectionMethod('services\\' . $serviceName, $funcName); + $ret = $method->invoke(null, ...$args); return $ret; } diff --git a/webapp/controller/UnitTestController.class.php b/webapp/controller/UnitTestController.class.php index 4a680219..33e9756b 100644 --- a/webapp/controller/UnitTestController.class.php +++ b/webapp/controller/UnitTestController.class.php @@ -1,7 +1,5 @@ _callServiceStatic('NoticeService', 'send', $content, $loop, $interval); + //services\NoticeService::send($content, $loop, $interval); } catch (Exception $e){ error_log($e); } } - + }