diff --git a/doc/ComputingPower.py b/doc/ComputingPower.py index 1cc5b037..e2801318 100644 --- a/doc/ComputingPower.py +++ b/doc/ComputingPower.py @@ -107,10 +107,10 @@ class ComputingPower(object): ] }, { - 'name': 'exchangeUplimitNew', - 'desc': '晶体兑换上限', + 'name': 'exchangeCrystalInfo', + 'desc': '晶体兑换信息', 'group': 'ComputingPower', - 'url': 'webapp/index.php?c=ComputingPower&a=exchangeUplimitNew', + 'url': 'webapp/index.php?c=ComputingPower&a=exchangeCrystalInfo', 'params': [ _common.ReqHead(), ], diff --git a/webapp/controller/ComputingPowerController.class.php b/webapp/controller/ComputingPowerController.class.php index 6f38e2cc..c5a740a3 100644 --- a/webapp/controller/ComputingPowerController.class.php +++ b/webapp/controller/ComputingPowerController.class.php @@ -351,7 +351,7 @@ class ComputingPowerController extends BaseAuthedController )); } - public function exchangeUplimitNew(){ + public function exchangeCrystalInfo(){ $hashRateService = new \services\HashRateService(); $crystalInfo = $hashRateService->getCrystalValue(); $this->_rspData(array( @@ -460,8 +460,11 @@ class ComputingPowerController extends BaseAuthedController } public function test(){ - print_r(\mt\HashRateTask::getMetaList()); - + $hashRateService = new \services\HashRateService(); + $crystalInfo = $hashRateService->getCrystalValue(); + $this->_rspData(array( + 'crystalInfo' => $crystalInfo + )); } diff --git a/webapp/models/CrystalRecord.php b/webapp/models/CrystalRecord.php index 78352b02..02f7ea3c 100644 --- a/webapp/models/CrystalRecord.php +++ b/webapp/models/CrystalRecord.php @@ -1,66 +1,67 @@ -_getSelfMysql(), - 't_crystal_exchange_record', - array( - 'account_id'=>myself()->_getAccountId() - ), - function ($row) use($cb) { - $cb($row); - } - ); - } - - public static function getCrystalNum($item_id){ - $rows = SqlHelper::ormSelect( - myself()->_getSelfMysql(), - 't_crystal_exchange_record', - array( - 'account_id'=>myself()->_getAccountId(), - 'item_id' => $item_id - ) - ); - - $crystalNum = 0; - if ($rows){ - foreach ($rows as $row){ - $crystalNum += $row['item_num']; - } - } - return $crystalNum; - } - - public static function addCrystalRecord($itemId,$itemNum){ - SqlHelper::insert( - myself()->_getSelfMysql(), - 't_crystal_exchange_record', - array( - 'account_id'=>myself()->_getAccountId(), - 'address'=>myself()->_getAddress(), - 'item_id'=>$itemId, - 'item_num' => $itemNum, - 'createtime'=>myself()->_getNowTime(), - 'modifytime'=>myself()->_getNowTime(), - ) - ); - } - - public static function getNewestRecordOne($itemId){ - $sql = "select * from t_crystal_exchange_record where `account_id` = :account_id and item_id = :item_id order by idx desc limit 1"; - $rows = myself()->_getMysql('')->execQuery($sql,array( - 'account_id' =>myself()->_getAccountId(), - 'item_id' =>$itemId, - )); - return count($rows) > 0 ? $rows[0] : array(); - } - +_getSelfMysql(), + 't_crystal_exchange_record', + array( + 'account_id'=>myself()->_getAccountId(), + 'item_id'=>ComputingPower::CRYSTAL_NEW, + ), + function ($row) use($cb) { + $cb($row); + } + ); + } + + public static function getCrystalNum($item_id){ + $rows = SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_crystal_exchange_record', + array( + 'account_id'=>myself()->_getAccountId(), + 'item_id' => $item_id + ) + ); + + $crystalNum = 0; + if ($rows){ + foreach ($rows as $row){ + $crystalNum += $row['item_num']; + } + } + return $crystalNum; + } + + public static function addCrystalRecord($itemId,$itemNum){ + SqlHelper::insert( + myself()->_getSelfMysql(), + 't_crystal_exchange_record', + array( + 'account_id'=>myself()->_getAccountId(), + 'address'=>myself()->_getAddress(), + 'item_id'=>$itemId, + 'item_num' => $itemNum, + 'createtime'=>myself()->_getNowTime(), + 'modifytime'=>myself()->_getNowTime(), + ) + ); + } + + public static function getNewestRecordOne($itemId){ + $sql = "select * from t_crystal_exchange_record where `account_id` = :account_id and item_id = :item_id order by idx desc limit 1"; + $rows = myself()->_getMysql('')->execQuery($sql,array( + 'account_id' =>myself()->_getAccountId(), + 'item_id' =>$itemId, + )); + return count($rows) > 0 ? $rows[0] : array(); + } + } \ No newline at end of file diff --git a/webapp/services/HashRateService.php b/webapp/services/HashRateService.php index ded1bd51..0071494a 100644 --- a/webapp/services/HashRateService.php +++ b/webapp/services/HashRateService.php @@ -167,8 +167,10 @@ class HashRateService extends BaseService $hashRateDb = HashRateTask::findByTaskIdOrSeason($metaTask['id'],$seasonMeta['id']); $userDb = myself()->_safeGetOrmUserInfo(); $rankMeta = Rank::getRankById($userDb['rank']); - if ($rankMeta['rank_order2'] > $hashRateDb['record_total']){ +// + if ($hashRateDb && $rankMeta['rank_order2'] > $hashRateDb['record_total']){ $finalVal = ($rankMeta['rank_order2'] - $hashRateDb['claim_total']) * $metaTask['reward']; + } } else { $hashRateDb = HashRateTask::findByTaskId($metaTask['id']);