This commit is contained in:
hujiabin 2023-11-06 17:07:25 +08:00
parent 855c07b379
commit 5113f30ec4
4 changed files with 78 additions and 72 deletions

View File

@ -107,10 +107,10 @@ class ComputingPower(object):
] ]
}, },
{ {
'name': 'exchangeUplimitNew', 'name': 'exchangeCrystalInfo',
'desc': '晶体兑换上限', 'desc': '晶体兑换信息',
'group': 'ComputingPower', 'group': 'ComputingPower',
'url': 'webapp/index.php?c=ComputingPower&a=exchangeUplimitNew', 'url': 'webapp/index.php?c=ComputingPower&a=exchangeCrystalInfo',
'params': [ 'params': [
_common.ReqHead(), _common.ReqHead(),
], ],

View File

@ -351,7 +351,7 @@ class ComputingPowerController extends BaseAuthedController
)); ));
} }
public function exchangeUplimitNew(){ public function exchangeCrystalInfo(){
$hashRateService = new \services\HashRateService(); $hashRateService = new \services\HashRateService();
$crystalInfo = $hashRateService->getCrystalValue(); $crystalInfo = $hashRateService->getCrystalValue();
$this->_rspData(array( $this->_rspData(array(
@ -460,8 +460,11 @@ class ComputingPowerController extends BaseAuthedController
} }
public function test(){ public function test(){
print_r(\mt\HashRateTask::getMetaList()); $hashRateService = new \services\HashRateService();
$crystalInfo = $hashRateService->getCrystalValue();
$this->_rspData(array(
'crystalInfo' => $crystalInfo
));
} }

View File

@ -1,66 +1,67 @@
<?php <?php
namespace models; namespace models;
use mt; use mt;
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
class CrystalRecord extends BaseModel class CrystalRecord extends BaseModel
{ {
public static function getCrystalRecordList($cb){ public static function getCrystalRecordList($cb){
SqlHelper::ormSelect( SqlHelper::ormSelect(
myself()->_getSelfMysql(), myself()->_getSelfMysql(),
't_crystal_exchange_record', 't_crystal_exchange_record',
array( array(
'account_id'=>myself()->_getAccountId() 'account_id'=>myself()->_getAccountId(),
), 'item_id'=>ComputingPower::CRYSTAL_NEW,
function ($row) use($cb) { ),
$cb($row); function ($row) use($cb) {
} $cb($row);
); }
} );
}
public static function getCrystalNum($item_id){
$rows = SqlHelper::ormSelect( public static function getCrystalNum($item_id){
myself()->_getSelfMysql(), $rows = SqlHelper::ormSelect(
't_crystal_exchange_record', myself()->_getSelfMysql(),
array( 't_crystal_exchange_record',
'account_id'=>myself()->_getAccountId(), array(
'item_id' => $item_id 'account_id'=>myself()->_getAccountId(),
) 'item_id' => $item_id
); )
);
$crystalNum = 0;
if ($rows){ $crystalNum = 0;
foreach ($rows as $row){ if ($rows){
$crystalNum += $row['item_num']; foreach ($rows as $row){
} $crystalNum += $row['item_num'];
} }
return $crystalNum; }
} return $crystalNum;
}
public static function addCrystalRecord($itemId,$itemNum){
SqlHelper::insert( public static function addCrystalRecord($itemId,$itemNum){
myself()->_getSelfMysql(), SqlHelper::insert(
't_crystal_exchange_record', myself()->_getSelfMysql(),
array( 't_crystal_exchange_record',
'account_id'=>myself()->_getAccountId(), array(
'address'=>myself()->_getAddress(), 'account_id'=>myself()->_getAccountId(),
'item_id'=>$itemId, 'address'=>myself()->_getAddress(),
'item_num' => $itemNum, 'item_id'=>$itemId,
'createtime'=>myself()->_getNowTime(), 'item_num' => $itemNum,
'modifytime'=>myself()->_getNowTime(), '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"; public static function getNewestRecordOne($itemId){
$rows = myself()->_getMysql('')->execQuery($sql,array( $sql = "select * from t_crystal_exchange_record where `account_id` = :account_id and item_id = :item_id order by idx desc limit 1";
'account_id' =>myself()->_getAccountId(), $rows = myself()->_getMysql('')->execQuery($sql,array(
'item_id' =>$itemId, 'account_id' =>myself()->_getAccountId(),
)); 'item_id' =>$itemId,
return count($rows) > 0 ? $rows[0] : array(); ));
} return count($rows) > 0 ? $rows[0] : array();
}
} }

View File

@ -167,8 +167,10 @@ class HashRateService extends BaseService
$hashRateDb = HashRateTask::findByTaskIdOrSeason($metaTask['id'],$seasonMeta['id']); $hashRateDb = HashRateTask::findByTaskIdOrSeason($metaTask['id'],$seasonMeta['id']);
$userDb = myself()->_safeGetOrmUserInfo(); $userDb = myself()->_safeGetOrmUserInfo();
$rankMeta = Rank::getRankById($userDb['rank']); $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']; $finalVal = ($rankMeta['rank_order2'] - $hashRateDb['claim_total']) * $metaTask['reward'];
} }
} else { } else {
$hashRateDb = HashRateTask::findByTaskId($metaTask['id']); $hashRateDb = HashRateTask::findByTaskId($metaTask['id']);