Merge branch 'hjb' of git.kingsome.cn:server/game2006api into hjb
This commit is contained in:
commit
855c07b379
@ -106,18 +106,44 @@ class ComputingPower(object):
|
|||||||
['pending_rewards', '', '剩余总计'],
|
['pending_rewards', '', '剩余总计'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
#
|
{
|
||||||
# {
|
'name': 'exchangeUplimitNew',
|
||||||
# 'name': 'getExchangePowerHistorys',
|
'desc': '晶体兑换上限',
|
||||||
# 'desc': '获取兑换算力历史',
|
'group': 'ComputingPower',
|
||||||
# 'group': 'ComputingPower',
|
'url': 'webapp/index.php?c=ComputingPower&a=exchangeUplimitNew',
|
||||||
# 'url': 'webapp/index.php?c=ComputingPower&a=getExchangePowerHistorys',
|
'params': [
|
||||||
# 'params': [
|
_common.ReqHead(),
|
||||||
# _common.ReqHead(),
|
],
|
||||||
# ],
|
'response': [
|
||||||
# 'response': [
|
_common.RspHead(),
|
||||||
# _common.RspHead(),
|
['totalNum', 0, '可领取的总晶体'],
|
||||||
# ['info', _common.ComputingPower(), '算力信息']
|
['!playing', [Info()], '游戏行为'],
|
||||||
# ]
|
['!staking', [Info()], '质押行为'],
|
||||||
# },
|
['!consuming', [Info()], '支出行为'],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'claimCrystal',
|
||||||
|
'desc': '一键领取晶体',
|
||||||
|
'group': 'ComputingPower',
|
||||||
|
'url': 'webapp/index.php?c=ComputingPower&a=claimCrystal',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['award', _common.Award(), '奖励信息'],
|
||||||
|
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class Info(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.fields = [
|
||||||
|
['task_id', 0, 'task_id'],
|
||||||
|
['uplimit', '', '上限数量 -1为无上限'],
|
||||||
|
['chaim_num', 0, '可领取数量'],
|
||||||
]
|
]
|
@ -1584,7 +1584,7 @@ CREATE TABLE `t_power_exchange_record` (
|
|||||||
-- Table structure for table `t_computing_power_period`
|
-- Table structure for table `t_computing_power_period`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `t_computing_power_period`;
|
DROP TABLE IF EXISTS `t_hash_rate_reward`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `t_hash_rate_reward` (
|
CREATE TABLE `t_hash_rate_reward` (
|
||||||
@ -1694,3 +1694,17 @@ CREATE TABLE `t_avatar` (
|
|||||||
UNIQUE KEY `hero_idx_type` (`hero_idx`, `item_type`)
|
UNIQUE KEY `hero_idx_type` (`hero_idx`, `item_type`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
CREATE TABLE `t_hash_rate_task` (
|
||||||
|
`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 '配置表HashRateTask',
|
||||||
|
`season` int(11) NOT NULL DEFAULT '0' COMMENT 'taskId 为10003可用',
|
||||||
|
`record_total` int(64) NOT NULL DEFAULT '0' COMMENT '记录总数据',
|
||||||
|
`claim_day` int(64) NOT NULL DEFAULT '0' COMMENT '当天领取数据',
|
||||||
|
`claim_total` 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_task_id` (`account_id`, `task_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
19
sql/gamedb2006_migrate_231027_01.sql
Normal file
19
sql/gamedb2006_migrate_231027_01.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
begin;
|
||||||
|
|
||||||
|
CREATE TABLE `t_hash_rate_task` (
|
||||||
|
`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 '配置表HashRateTask',
|
||||||
|
`season` int(11) NOT NULL DEFAULT '0' COMMENT 'taskId 为10003可用',
|
||||||
|
`record_total` int(64) NOT NULL DEFAULT '0' COMMENT '记录总数据',
|
||||||
|
`claim_day` int(64) NOT NULL DEFAULT '0' COMMENT '当天领取数据',
|
||||||
|
`claim_total` 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_task_id` (`account_id`, `task_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
insert into version (version) values(2023092001);
|
||||||
|
|
||||||
|
commit;
|
@ -16,6 +16,7 @@ require_once('models/Parachute.php');
|
|||||||
require_once('models/Chip.php');
|
require_once('models/Chip.php');
|
||||||
require_once('models/Pass.php');
|
require_once('models/Pass.php');
|
||||||
require_once('models/Avatar.php');
|
require_once('models/Avatar.php');
|
||||||
|
require_once('models/HashRateTask.php');
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/RankSeason.php');
|
require_once('mt/RankSeason.php');
|
||||||
require_once('mt/LevelUp.php');
|
require_once('mt/LevelUp.php');
|
||||||
@ -38,6 +39,7 @@ use models\UserSeasonRing;
|
|||||||
use models\Chip;
|
use models\Chip;
|
||||||
use models\Pass;
|
use models\Pass;
|
||||||
use models\Avatar;
|
use models\Avatar;
|
||||||
|
use models\HashRateTask;
|
||||||
use services\LogService;
|
use services\LogService;
|
||||||
|
|
||||||
class BaseAuthedController extends BaseController {
|
class BaseAuthedController extends BaseController {
|
||||||
@ -417,6 +419,7 @@ class BaseAuthedController extends BaseController {
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
$this->_incDailyV(TN_DAILY_GET_STAR_NUM, 0,$itemNum);
|
$this->_incDailyV(TN_DAILY_GET_STAR_NUM, 0,$itemNum);
|
||||||
|
HashRateTask::incRecordNum(HashRateTask::STAR_TYPE,$itemNum);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -12,6 +12,7 @@ require_once('models/User.php');
|
|||||||
require_once('models/Parachute.php');
|
require_once('models/Parachute.php');
|
||||||
require_once('models/ChipPage.php');
|
require_once('models/ChipPage.php');
|
||||||
require_once('models/Battle.php');
|
require_once('models/Battle.php');
|
||||||
|
require_once('models/HashRateTask.php');
|
||||||
require_once('services/BattleDataService.php');
|
require_once('services/BattleDataService.php');
|
||||||
require_once('services/TameBattleDataService.php');
|
require_once('services/TameBattleDataService.php');
|
||||||
require_once('services/FormulaService.php');
|
require_once('services/FormulaService.php');
|
||||||
@ -29,6 +30,7 @@ use models\User;
|
|||||||
use models\Parachute;
|
use models\Parachute;
|
||||||
use models\ChipPage;
|
use models\ChipPage;
|
||||||
use models\Battle;
|
use models\Battle;
|
||||||
|
use models\HashRateTask;
|
||||||
|
|
||||||
class BattleController extends BaseAuthedController {
|
class BattleController extends BaseAuthedController {
|
||||||
|
|
||||||
@ -124,6 +126,7 @@ class BattleController extends BaseAuthedController {
|
|||||||
// $ranked = getReqVal('pvp_personal_rank', 0);
|
// $ranked = getReqVal('pvp_personal_rank', 0);
|
||||||
$teamBattleDataService = new services\TameBattleDataService();
|
$teamBattleDataService = new services\TameBattleDataService();
|
||||||
$teamBattleDataService->calStarNum();
|
$teamBattleDataService->calStarNum();
|
||||||
|
HashRateTask::setRankedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function teamReport()
|
public function teamReport()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('mt/HashRate.php');
|
require_once('mt/HashRate.php');
|
||||||
require_once('mt/HashRateCommon.php');
|
require_once('mt/HashRateCommon.php');
|
||||||
|
require_once('mt/HashRateTask.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('services/HashRateService.php');
|
require_once('services/HashRateService.php');
|
||||||
@ -12,11 +13,13 @@ require_once('models/ComputingPower.php');
|
|||||||
require_once('models/CrystalRecord.php');
|
require_once('models/CrystalRecord.php');
|
||||||
require_once('models/RewardsCec.php');
|
require_once('models/RewardsCec.php');
|
||||||
require_once('models/Staking.php');
|
require_once('models/Staking.php');
|
||||||
|
require_once('models/HashRateTask.php');
|
||||||
|
|
||||||
use models\ComputingPower;
|
use models\ComputingPower;
|
||||||
use models\CrystalRecord;
|
use models\CrystalRecord;
|
||||||
use models\RewardsCec;
|
use models\RewardsCec;
|
||||||
use models\Staking;
|
use models\Staking;
|
||||||
|
use models\HashRateTask;
|
||||||
use mt\HashRate;
|
use mt\HashRate;
|
||||||
use mt\Parameter;
|
use mt\Parameter;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
@ -348,6 +351,80 @@ class ComputingPowerController extends BaseAuthedController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function exchangeUplimitNew(){
|
||||||
|
$hashRateService = new \services\HashRateService();
|
||||||
|
$crystalInfo = $hashRateService->getCrystalValue();
|
||||||
|
$this->_rspData(array(
|
||||||
|
'crystalInfo' => $crystalInfo
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function claimCrystal(){
|
||||||
|
$hashRateService = new \services\HashRateService();
|
||||||
|
$crystalInfo = $hashRateService->getCrystalValue();
|
||||||
|
if ($crystalInfo['totalNum'] < 1){
|
||||||
|
$this->_rspErr(1, 'No crystals available at this time');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
foreach ($crystalInfo['playing'] as $val){
|
||||||
|
if ($val['chaim_num'] < 1){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$hashRateMt = \mt\HashRateTask::find($val['task_id']);
|
||||||
|
switch ($val['task_id']){
|
||||||
|
case HashRateTask::RANK_TYPE :{
|
||||||
|
$chaimUpTotal = $val['chaim_num'] / $hashRateMt['reward'];
|
||||||
|
HashRateTask::updateKv($val['task_id'],array(
|
||||||
|
'claim_total' => function () use($chaimUpTotal) {
|
||||||
|
return "claim_total + ${chaimUpTotal}";
|
||||||
|
},
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default : {
|
||||||
|
|
||||||
|
if ($val['task_id'] == HashRateTask::BATTLE_TIME_TYPE){
|
||||||
|
$chaimTotal = $val['chaim_num'] / $hashRateMt['reward'] * $hashRateMt['target'] * 1000;
|
||||||
|
}else{
|
||||||
|
$chaimTotal = $val['chaim_num'] / $hashRateMt['reward'] * $hashRateMt['target'];
|
||||||
|
}
|
||||||
|
HashRateTask::incDailyReward($val['task_id'],$val['chaim_num'],$chaimTotal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($crystalInfo['staking'] as $val){
|
||||||
|
if ($val['chaim_num'] > 0){
|
||||||
|
HashRateTask::updateKv($val['task_id'],array(
|
||||||
|
'claim_day' => 1,
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($crystalInfo['consuming'] as $val){
|
||||||
|
if ($val['chaim_num'] > 0){
|
||||||
|
$hashRateMt = \mt\HashRateTask::find($val['task_id']);
|
||||||
|
$chaimTotal = $val['chaim_num'] / $hashRateMt['reward'] * $hashRateMt['target'] * \services\HashRateService::EXCHANGE_RATE;
|
||||||
|
myself()->_incV(TN_TOTAL_DIAMOND_CONSUME,-1,$chaimTotal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$items = array(
|
||||||
|
array(
|
||||||
|
'item_id' => ComputingPower::CRYSTAL_NEW,
|
||||||
|
'item_num' => $crystalInfo['totalNum'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$awardService = new services\AwardService();
|
||||||
|
$this->_addItems($items,$awardService,$propertyChgService);
|
||||||
|
CrystalRecord::addCrystalRecord(ComputingPower::CRYSTAL_NEW,$crystalInfo['totalNum']);
|
||||||
|
$this->_rspData(array(
|
||||||
|
'award' => $awardService->toDto(),
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
private function _verificationCeiling($period,$meta,$num1,$num2,$num3,$num4){
|
private function _verificationCeiling($period,$meta,$num1,$num2,$num3,$num4){
|
||||||
$list = ComputingPower::findByPeriod($period);
|
$list = ComputingPower::findByPeriod($period);
|
||||||
switch ($meta['item_id']){
|
switch ($meta['item_id']){
|
||||||
@ -382,6 +459,10 @@ class ComputingPowerController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test(){
|
||||||
|
print_r(\mt\HashRateTask::getMetaList());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ class ComputingPower extends BaseModel
|
|||||||
const CRYSTAL2 = 260002;
|
const CRYSTAL2 = 260002;
|
||||||
const CRYSTAL3 = 260003;
|
const CRYSTAL3 = 260003;
|
||||||
const CRYSTAL4 = 260004;
|
const CRYSTAL4 = 260004;
|
||||||
|
const CRYSTAL_NEW = 260010;
|
||||||
|
|
||||||
//获取我的算力
|
//获取我的算力
|
||||||
public static function getOwnedBH($period,$account = null){
|
public static function getOwnedBH($period,$account = null){
|
||||||
|
175
webapp/models/HashRateTask.php
Normal file
175
webapp/models/HashRateTask.php
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
require_once('mt/Rank.php');
|
||||||
|
require_once('mt/RankSeason.php');
|
||||||
|
|
||||||
|
use mt\Rank;
|
||||||
|
use mt\RankSeason;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class HashRateTask extends BaseModel
|
||||||
|
{
|
||||||
|
const KILL_TYPE = 10001;
|
||||||
|
const STAR_TYPE = 10002;
|
||||||
|
const RANK_TYPE = 10003;
|
||||||
|
const BATTLE_TIME_TYPE = 10004;
|
||||||
|
const BATTLE_WIN_TYPE = 10005;
|
||||||
|
const VS_FOUR_BATTLE_WIN_TYPE = 10006;
|
||||||
|
const DAMAGE_TYPE = 10007;
|
||||||
|
|
||||||
|
public static function find(){
|
||||||
|
$rows = SqlHelper::ormSelect(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (count($rows) < 1){
|
||||||
|
$rows = array();
|
||||||
|
}
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function toDto($row){
|
||||||
|
array(
|
||||||
|
'task_id' => $row['task_id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function findByTaskId($taskId){
|
||||||
|
return SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function incRecordNum($taskId,$num){
|
||||||
|
SqlHelper::upsert
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'record_total' => function () use($num) {
|
||||||
|
return "record_total + ${num}";
|
||||||
|
},
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
'record_total' => $num,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDailyReward($taskId){
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$modifytime = $row ? $row['modifytime'] : myself()->_getNowTime();
|
||||||
|
$num = $row ? $row['claim_day'] : 0;
|
||||||
|
|
||||||
|
if (myself()->_getDaySeconds($modifytime) < myself()->_getNowDaySeconds()) {
|
||||||
|
$num = 0;
|
||||||
|
}
|
||||||
|
return $num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function incDailyReward($taskId,$val,$total){
|
||||||
|
$oldVal = self::getDailyReward($taskId);
|
||||||
|
$val += $oldVal;
|
||||||
|
SqlHelper::upsert
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'claim_day' => $val,
|
||||||
|
'claim_total' => function () use($total) {
|
||||||
|
return "claim_total + ${total}";
|
||||||
|
},
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
'claim_day' => $val,
|
||||||
|
'claim_total' => $total,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function updateKv($taskId,$fieldKv){
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
),
|
||||||
|
$fieldKv
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setRankedData(){
|
||||||
|
$SeasonMeta = RankSeason::getCurrentSeason();
|
||||||
|
if (!$SeasonMeta){
|
||||||
|
error_log("当前赛季结束");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (! self::findByTaskIdOrSeason(self::RANK_TYPE,$SeasonMeta['id'])){
|
||||||
|
$userDb = myself()->_safeGetOrmUserInfo();
|
||||||
|
$rankMeta = Rank::getRankById($userDb['rank']);
|
||||||
|
SqlHelper::insert
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => self::RANK_TYPE,
|
||||||
|
'season' => $SeasonMeta['id'],
|
||||||
|
'record_total' => $rankMeta['rank_order2'],
|
||||||
|
'claim_total' => $rankMeta['rank_order2'],
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function findByTaskIdOrSeason($taskId,$season){
|
||||||
|
return SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
'season' => $season,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
40
webapp/mt/HashRateTask.php
Normal file
40
webapp/mt/HashRateTask.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace mt;
|
||||||
|
|
||||||
|
use phpcommon;
|
||||||
|
|
||||||
|
class HashRateTask {
|
||||||
|
const PLAYING = 1;
|
||||||
|
const STAKING = 2;
|
||||||
|
const TRADING = 3;
|
||||||
|
const CONSUMING = 4;
|
||||||
|
const COMMUNITY = 5;
|
||||||
|
const NFT = 6;
|
||||||
|
public static function find($id){
|
||||||
|
return getXVal(self::getMetaList(), $id, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getListByType($type){
|
||||||
|
$mateList = array();
|
||||||
|
foreach (self::getMetaList() as $mate){
|
||||||
|
if ($mate['type'] == $type){
|
||||||
|
array_push($mateList,$mate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $mateList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function getMetaList()
|
||||||
|
{
|
||||||
|
if (!self::$metaList) {
|
||||||
|
self::$metaList = getMetaTable('HashRateTask@HashRateTask.php');
|
||||||
|
}
|
||||||
|
return self::$metaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static $metaList;
|
||||||
|
|
||||||
|
}
|
@ -4,15 +4,22 @@
|
|||||||
namespace services;
|
namespace services;
|
||||||
require_once('mt/HashRate.php');
|
require_once('mt/HashRate.php');
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
|
require_once('mt/HashRateTask.php');
|
||||||
|
require_once('mt/Rank.php');
|
||||||
|
require_once('mt/RankSeason.php');
|
||||||
require_once('models/Bag.php');
|
require_once('models/Bag.php');
|
||||||
require_once('models/CrystalRecord.php');
|
require_once('models/CrystalRecord.php');
|
||||||
require_once('models/Staking.php');
|
require_once('models/Staking.php');
|
||||||
|
require_once('models/HashRateTask.php');
|
||||||
|
|
||||||
use models\Bag;
|
use models\Bag;
|
||||||
use models\CrystalRecord;
|
use models\CrystalRecord;
|
||||||
use models\Staking;
|
use models\Staking;
|
||||||
|
use models\HashRateTask;
|
||||||
use mt\HashRate;
|
use mt\HashRate;
|
||||||
use mt\Parameter;
|
use mt\Parameter;
|
||||||
|
use mt\Rank;
|
||||||
|
use mt\RankSeason;
|
||||||
|
|
||||||
class HashRateService extends BaseService
|
class HashRateService extends BaseService
|
||||||
{
|
{
|
||||||
@ -100,4 +107,147 @@ class HashRateService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCrystalValue(){
|
||||||
|
$chaimNum = 0;
|
||||||
|
$playing = array();
|
||||||
|
$staking = array();
|
||||||
|
$trading = array();
|
||||||
|
$consuming = array();
|
||||||
|
$nft = array();
|
||||||
|
// $hashRateMt = \mt\HashRateTask::getListByType(\mt\HashRateTask::PLAYING);
|
||||||
|
// foreach ($hashRateMt as $meta){
|
||||||
|
// $finalVal = 0;
|
||||||
|
// $uplimit = $meta['upperlimit'] ;
|
||||||
|
// if ($meta['id'] == HashRateTask::RANK_TYPE){
|
||||||
|
// $seasonMeta = RankSeason::getCurrentSeason();
|
||||||
|
// if (!$seasonMeta){
|
||||||
|
// $seasonMeta = RankSeason::getLastSeason();
|
||||||
|
// }
|
||||||
|
// $hashRateDb = HashRateTask::findByTaskIdOrSeason($meta['id'],$seasonMeta['id']);
|
||||||
|
// $userDb = myself()->_safeGetOrmUserInfo();
|
||||||
|
// $rankMeta = Rank::getRankById($userDb['rank']);
|
||||||
|
// if ($rankMeta['rank_order2'] > $hashRateDb['record_total']){
|
||||||
|
// $finalVal = ($rankMeta['rank_order2'] - $hashRateDb['claim_total']) * $meta['reward'];
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// $hashRateDb = HashRateTask::findByTaskId($meta['id']);
|
||||||
|
// $targetVal = 0;
|
||||||
|
// if ($hashRateDb){
|
||||||
|
// $total = $hashRateDb['record_total'] - $hashRateDb['claim_total'];
|
||||||
|
// if ($hashRateDb['task_id'] == HashRateTask::BATTLE_TIME_TYPE){
|
||||||
|
// $targetVal = max(0,floor($total / 1000 / $meta['target'])) * $meta['reward'];
|
||||||
|
// }else{
|
||||||
|
// $targetVal = max(0,floor($total / $meta['target'])) * $meta['reward'];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// $claim_day = HashRateTask::getDailyReward($meta['id']);
|
||||||
|
// $uplimit = $meta['upperlimit'] - $claim_day;
|
||||||
|
// $finalVal = min($targetVal , $uplimit);
|
||||||
|
// }
|
||||||
|
// $chaimNum += $finalVal;
|
||||||
|
// array_push($detail,array(
|
||||||
|
// 'task_id' => $meta['id'],
|
||||||
|
// 'uplimit' => $uplimit,
|
||||||
|
// 'chaim_num' => $finalVal
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
$hashRateTask = \mt\HashRateTask::getMetaList();
|
||||||
|
foreach ($hashRateTask as $metaTask){
|
||||||
|
$finalVal = 0;
|
||||||
|
$uplimit = $metaTask['upperlimit'] ;
|
||||||
|
switch ($metaTask['type']){
|
||||||
|
case \mt\HashRateTask::PLAYING :{
|
||||||
|
if ($metaTask['id'] == HashRateTask::RANK_TYPE){
|
||||||
|
$seasonMeta = RankSeason::getCurrentSeason();
|
||||||
|
if (!$seasonMeta){
|
||||||
|
$seasonMeta = RankSeason::getLastSeason();
|
||||||
|
}
|
||||||
|
$hashRateDb = HashRateTask::findByTaskIdOrSeason($metaTask['id'],$seasonMeta['id']);
|
||||||
|
$userDb = myself()->_safeGetOrmUserInfo();
|
||||||
|
$rankMeta = Rank::getRankById($userDb['rank']);
|
||||||
|
if ($rankMeta['rank_order2'] > $hashRateDb['record_total']){
|
||||||
|
$finalVal = ($rankMeta['rank_order2'] - $hashRateDb['claim_total']) * $metaTask['reward'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$hashRateDb = HashRateTask::findByTaskId($metaTask['id']);
|
||||||
|
$targetVal = 0;
|
||||||
|
if ($hashRateDb){
|
||||||
|
$total = $hashRateDb['record_total'] - $hashRateDb['claim_total'];
|
||||||
|
if ($hashRateDb['task_id'] == HashRateTask::BATTLE_TIME_TYPE){
|
||||||
|
$targetVal = max(0,floor($total / 1000 / $metaTask['target'])) * $metaTask['reward'];
|
||||||
|
}else{
|
||||||
|
$targetVal = max(0,floor($total / $metaTask['target'])) * $metaTask['reward'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$claim_day = HashRateTask::getDailyReward($metaTask['id']);
|
||||||
|
$uplimit = $metaTask['upperlimit'] - $claim_day;
|
||||||
|
$finalVal = min($targetVal , $uplimit);
|
||||||
|
}
|
||||||
|
$chaimNum += $finalVal;
|
||||||
|
array_push($playing,array(
|
||||||
|
'task_id' => $metaTask['id'],
|
||||||
|
'uplimit' => $uplimit,
|
||||||
|
'chaim_num' => $finalVal
|
||||||
|
));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case \mt\HashRateTask::STAKING :{
|
||||||
|
//质押价值
|
||||||
|
$stakingVal = Staking::getStakingTotalValue();
|
||||||
|
$targetVal = max(0,floor($stakingVal / $metaTask['target']) * $metaTask['reward']);
|
||||||
|
$claim_day = HashRateTask::getDailyReward($metaTask['id']);
|
||||||
|
if ($claim_day){
|
||||||
|
$finalVal = 0;
|
||||||
|
}else{
|
||||||
|
$finalVal = $targetVal;
|
||||||
|
}
|
||||||
|
$chaimNum += $finalVal;
|
||||||
|
array_push($staking,array(
|
||||||
|
'task_id' => $metaTask['id'],
|
||||||
|
'uplimit' => $uplimit,
|
||||||
|
'chaim_num' => $finalVal
|
||||||
|
));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// case \mt\HashRateTask::TRADING : {
|
||||||
|
// $consumeCost = myself()->_getV(TN_TOTAL_CEG_CONSUME,0);
|
||||||
|
// $consumeCostEd = myself()->_getV(TN_TOTAL_CEG_CONSUME,-1);
|
||||||
|
// $total = $consumeCost - $consumeCostEd ;
|
||||||
|
// $finalVal = max(0,floor($total / self::EXCHANGE_RATE / $metaTask['target']) * $metaTask['reward']);
|
||||||
|
// $chaimNum += $finalVal;
|
||||||
|
// array_push($trading,array(
|
||||||
|
// 'task_id' => $metaTask['id'],
|
||||||
|
// 'uplimit' => $uplimit,
|
||||||
|
// 'chaim_num' => $finalVal
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
case \mt\HashRateTask::CONSUMING : {
|
||||||
|
$consumeCost = myself()->_getV(TN_TOTAL_DIAMOND_CONSUME,0);
|
||||||
|
$consumeCostEd = myself()->_getV(TN_TOTAL_DIAMOND_CONSUME,-1);
|
||||||
|
$total = $consumeCost - $consumeCostEd;
|
||||||
|
$finalVal = max(0,floor($total / self::EXCHANGE_RATE / $metaTask['target']) * $metaTask['reward']);
|
||||||
|
$chaimNum += $finalVal;
|
||||||
|
array_push($consuming,array(
|
||||||
|
'task_id' => $metaTask['id'],
|
||||||
|
'uplimit' => $uplimit,
|
||||||
|
'chaim_num' => $finalVal
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array(
|
||||||
|
'totalNum' => $chaimNum,
|
||||||
|
'playing'=>$playing,
|
||||||
|
'staking'=>$staking,
|
||||||
|
'consuming'=>$consuming,
|
||||||
|
'nft'=>$nft,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -31,6 +31,7 @@ require_once('models/NftActive.php');
|
|||||||
require_once('models/FragmentRecord.php');
|
require_once('models/FragmentRecord.php');
|
||||||
require_once('models/BattleSettlement.php');
|
require_once('models/BattleSettlement.php');
|
||||||
require_once('models/RankBattle.php');
|
require_once('models/RankBattle.php');
|
||||||
|
require_once('models/HashRateTask.php');
|
||||||
|
|
||||||
require_once('services/RankActivityService.php');
|
require_once('services/RankActivityService.php');
|
||||||
require_once('services/FormulaService.php');
|
require_once('services/FormulaService.php');
|
||||||
@ -42,6 +43,7 @@ require_once('services/LogService.php');
|
|||||||
use models\BattleSettlement;
|
use models\BattleSettlement;
|
||||||
use models\Chip;
|
use models\Chip;
|
||||||
use models\FragmentRecord;
|
use models\FragmentRecord;
|
||||||
|
use models\HashRateTask;
|
||||||
use models\Nft;
|
use models\Nft;
|
||||||
use models\NftActive;
|
use models\NftActive;
|
||||||
use models\RankBattle;
|
use models\RankBattle;
|
||||||
@ -112,8 +114,8 @@ class TameBattleDataService extends BaseService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//录入战斗记录
|
//记录算力系统有效行为
|
||||||
// $this->saveBattleHistory();
|
$this->_addHashRateTask();
|
||||||
|
|
||||||
switch ($matchMode) {
|
switch ($matchMode) {
|
||||||
//PVP模式
|
//PVP模式
|
||||||
@ -739,6 +741,7 @@ class TameBattleDataService extends BaseService {
|
|||||||
}else{
|
}else{
|
||||||
$finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]);
|
$finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($finalNum > 0){
|
if ($finalNum > 0){
|
||||||
array_push($reward['items'],array(
|
array_push($reward['items'],array(
|
||||||
'item_id'=> V_ITEM_STAR,
|
'item_id'=> V_ITEM_STAR,
|
||||||
@ -1223,4 +1226,20 @@ class TameBattleDataService extends BaseService {
|
|||||||
$battleData[$key] = max(getXVal($battleData, $key, 0), $val);
|
$battleData[$key] = max(getXVal($battleData, $key, 0), $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _addHashRateTask(){
|
||||||
|
error_log("_addHashRateTask");
|
||||||
|
//击杀
|
||||||
|
HashRateTask::incRecordNum(HashRateTask::KILL_TYPE,getXVal($this->battleInfo,'kills', 0));
|
||||||
|
//存活时间、战斗时长
|
||||||
|
HashRateTask::incRecordNum(HashRateTask::BATTLE_TIME_TYPE,getXVal($this->battleInfo,'alive_time', 0));
|
||||||
|
//吃鸡、4v4吃鸡
|
||||||
|
$ranked = getXVal($this->battleInfo,'pvp_team_rank', 0);
|
||||||
|
if ($ranked == 1){
|
||||||
|
HashRateTask::incRecordNum(HashRateTask::BATTLE_WIN_TYPE,1);
|
||||||
|
// HashRateTask::incRecordNum(HashRateTask::VS_FOUR_BATTLE_WIN_TYPE,1);
|
||||||
|
}
|
||||||
|
//承伤
|
||||||
|
HashRateTask::incRecordNum(HashRateTask::DAMAGE_TYPE,getXVal($this->battleInfo,'damage_in', 0));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user