hashRateService = new services\HashRateService(); $this->hashRateService->init(); } public function info(){ $mateList = \mt\AchievementsPower::getMetaList(); $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); $info = array( 'list' => array(), 'obtain_start_time' => 0, 'obtain_end_time' => 0, 'income_start_time' => 0, 'income_end_time' => 0, 'state' => 0, 'myHashRate' => 0, ); if ($currentPeriod){ foreach ($mateList as $mate) { $temp = $this->hashRateService->hashRateTaskDto($mate); array_push($info['list'], $temp); } $obtain_start_time = strtotime($currentPeriod['obtain_start_time']); $obtain_end_time = strtotime($currentPeriod['obtain_end_time']); $income_start_time = strtotime($currentPeriod['income_start_time']); $income_end_time = strtotime($currentPeriod['income_end_time']); $info['obtain_start_time'] = $obtain_start_time; $info['obtain_end_time'] = $obtain_end_time; $info['income_start_time'] = $income_start_time; $info['income_end_time'] = $income_end_time; if(myself()->_getNowTime() >= $obtain_start_time && myself()->_getNowTime() <= $obtain_end_time){ $info['state'] = 1; }elseif (myself()->_getNowTime() >= $income_start_time && myself()->_getNowTime() <= $income_end_time){ $info['state'] = 2; } $info['myHashRate'] = HashRate::getMyHashRate( $currentPeriod['id']); } $this->_rspData($info); } public function taskList(){ $type = getReqVal('type', 1); $taskDtoList1 = array(); $taskDtoList2 = array(); $obtain_start_time = 0; $obtain_end_time = 0; $income_start_time = 0; $income_end_time = 0; $state = 0; $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); if ($currentPeriod){ $mateList = \mt\AchievementsPower::getCustomTypeMetaList($type,$this->hashRateService); foreach ($mateList as $mate) { $taskDb = HashRate::find($mate['id'],$currentPeriod['id']); $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']); $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']); $income_start_time = strtotime($currentPeriod['income_start_time']); $income_end_time = strtotime($currentPeriod['income_end_time']); if(myself()->_getNowTime() >= $obtain_start_time && myself()->_getNowTime() <= $obtain_end_time){ $state = 1; }elseif (myself()->_getNowTime() >= $income_start_time && myself()->_getNowTime() <= $income_end_time){ $state = 2; } } $this->_rspData(array( 'task_list1' => $taskDtoList1, 'task_list2' => $taskDtoList2, 'obtain_start_time' => $obtain_start_time, 'obtain_end_time' => $obtain_end_time, '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, )); } }