diff --git a/doc/BlockChain.py b/doc/BlockChain.py index 27bf4a56..0f38918e 100644 --- a/doc/BlockChain.py +++ b/doc/BlockChain.py @@ -18,6 +18,19 @@ class BlockChain(object): ['!transactions', [_common.NftTransaction()], '交易列表'] ] }, + { + 'name': 'getTransactionInfo', + 'desc': '查看链交易状态', + 'group': 'BlockChain', + 'url': 'webapp/index.php?c=BlockChain&a=getTransactionInfo', + 'params': [ + ['trans_id', '', '事务id'], + ], + 'response': [ + _common.RspHead(), + ['data', _common.NftTransaction(), '交易记录'] + ] + }, { 'name': 'reportResult', 'desc': '上报链调用结果', diff --git a/doc/_common.py b/doc/_common.py index 26a7f24a..f9e440d7 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -861,8 +861,7 @@ class Fragment(object): ['idx', 0, '主键id'], ['token_id', '', 'token id'], ['item_id', '', '道具id'], - ['type', '', '碎片类型 1:英雄碎片 2:枪械碎片 3:特殊英雄碎片 4:特殊枪械碎片'], - ['parts', '', '碎片部位 0:特殊碎片的部位 1-8:普通部位'], + ['balance', '', '数量'], ['createtime', 0, '创建时间'], ['modifytime', 0, '修改时间'], ] diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 0a742e13..8eb22252 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -554,7 +554,7 @@ class BlockChainController extends BaseAuthedController { 'tokenId' => $tokenId, 'tokenType' => Nft::HERO_TYPE, 'itemUniId' => $heroDb['hero_uniid'], - 'itemId' => $heroDb['item_id'] + 'itemId' => $heroDb['hero_id'] ) ); @@ -617,6 +617,53 @@ class BlockChainController extends BaseAuthedController { return; } + //CEG扣除 + { + $costSum = 0; + foreach ($chipIds as $chipId){ + $chipDb = Chip::getChipByTokenId($chipId); + if ($chipDb){ + $tiliDiff = $chipDb['strength_max'] - $chipDb['strength']; + $costSum += \services\FormulaService::Chip_Demount_Mint($tiliDiff); + } + } + $decFeeCb = null; + if ($costSum > 0){ + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $costSum + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $decFeeCb = function ($transId) use ($costItems, $chipIds){ + myself()->_decItems($costItems); + error_log(json_encode($costItems)); + foreach ($costItems as $costItem){ + TransactionPrefee::add($transId,$costItem); + } + + foreach ($chipIds as $chipId){ + $chipDb = Chip::getChipByTokenId($chipId); + $items = array( + 'token_id' => $chipDb['token_id'], + 'token_type' => $chipDb['chip_type'], + 'item_id' => self::TEST_ITEM_ID, + 'item_num' => $chipDb['strength_max'] - $chipDb['strength'] + ); + Chip::update($chipId,array( + 'strength'=>$chipDb['strength_max'] + )); + TransactionPrefee::add($transId,$items); + } + }; + } + } + switch ($type) { case 1: { @@ -625,51 +672,7 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(101, 'token_id paramater error'); return; } - //CEG扣除 -// { -// $costSum = 0; -// foreach ($chipIds as $chipId){ -// $chipDb = Chip::getChipByTokenId($chipId); -// if ($chipDb){ -// $tiliDiff = $chipDb['strength_max'] - $chipDb['strength']; -// $costSum += \services\FormulaService::Chip_Demount_Mint($tiliDiff); -// } -// } -// if ($costSum > 0){ -// $costItems = array( -// array( -// 'item_id' => V_ITEM_GOLD, -// 'item_num' => $costSum -// ), -// ); -// $lackItem = null; -// if (!$this->_hasEnoughItems($costItems, $lackItem)) { -// $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); -// return; -// } -// $decFeeCb = function ($transId) use ($costItems){ -// myself()->_decItems($costItems); -// foreach ($costItems as $costItem){ -// TransactionPrefee::add($transId,$costItem); -// } -// }; -// foreach ($chipIds as $chipId){ -// $chipDb = Chip::getChipByTokenId($chipId); -// $items = array( -// 'token_id' => $chipDb['token_id'], -// 'token_type' => $chipDb['chip_type'], -// 'item_id' => self::TEST_ITEM_ID, -// 'item_num' => $chipDb['strength_max'] - $chipDb['strength'] -// ); -// Chip::update($chipId,array( -// 'strength'=>$chipDb['strength_max'] -// )); -// $decFeeCb = function ($transId) use ($items){ -// TransactionPrefee::add($transId,$items); -// }; -// } -// } -// } + $this->internalBcCall( array( 'c' => 'BcService', @@ -687,8 +690,9 @@ class BlockChainController extends BaseAuthedController { 'tokenId' => $tokenId, 'tokenType' => Nft::HERO_TYPE, 'itemUniId' => $heroDb['hero_uniid'], - 'itemId' => $heroDb['item_id'] - ) + 'itemId' => $heroDb['hero_id'] + ), + $decFeeCb ); } @@ -719,7 +723,8 @@ class BlockChainController extends BaseAuthedController { 'tokenType' => Nft::EQUIP_TYPE, 'itemUniId' => $gunDb['gun_uniid'], 'itemId' => $gunDb['gun_id'] - ) + ), + $decFeeCb ); } break; @@ -747,6 +752,24 @@ class BlockChainController extends BaseAuthedController { myself()->_rspData($data); } + public function getTransactionInfo(){ + $transId = getReqVal('trans_id', ''); + if (!$transId){ + myself()->_rspErr(101, 'trans_id paramater error'); + return; + } + $tranDb= Transaction::find($transId); + myself()->_rspData(array( + 'data' => array( + 'trans_id' => $tranDb['trans_id'], + 'item_id' => $tranDb['item_id'], + 'action' => Transaction::getActionDesc($tranDb), + 'status' => Transaction::getStatusDesc($tranDb), + 'time' => $tranDb['createtime'], + ) + )); + } + private function internalActivate721Nft($tokenId, $tokenType, $itemUniId, $itemId) { $params = array( diff --git a/webapp/controller/FragmentController.class.php b/webapp/controller/FragmentController.class.php index dc640a20..114a2a25 100644 --- a/webapp/controller/FragmentController.class.php +++ b/webapp/controller/FragmentController.class.php @@ -20,7 +20,7 @@ class FragmentController extends BaseAuthedController { $fragmentList = array(); foreach (Fragment::getFragmentList() as $val){ - array_push($fragmentList,Fragment::oldToDto($val)); + array_push($fragmentList,Fragment::ToDto($val)); } $this->_rspData(array( 'fragment_list' => $fragmentList, diff --git a/webapp/controller/MissionController.class.php b/webapp/controller/MissionController.class.php index 543da6ce..72aaf56c 100644 --- a/webapp/controller/MissionController.class.php +++ b/webapp/controller/MissionController.class.php @@ -41,22 +41,22 @@ class MissionController extends BaseAuthedController { { parent::_handlePre(); DynData::preload(); - $this->currRankSeasonMeta = mt\RankSeason::getCurrentSeason(); - if (!$this->currRankSeasonMeta) { - $this->_rspErr(10, 'server internal error'); - die(); - } +// $this->currRankSeasonMeta = mt\RankSeason::getCurrentSeason(); +// if (!$this->currRankSeasonMeta) { +// $this->_rspErr(10, 'server internal error'); +// die(); +// } $this->propertyChgService = new services\PropertyChgService(); $this->userInfo = $this->_safeGetOrmUserInfo(); - $this->seasonDb = Season::find($this->currRankSeasonMeta['id']); - if (!$this->seasonDb) { - Season::add($this->currRankSeasonMeta['id']); - $this->seasonDb = Season::find($this->currRankSeasonMeta['id']); - } - if (!$this->seasonDb) { - $this->_rspErr(10, 'server internal error'); - die(); - } +// $this->seasonDb = Season::find($this->currRankSeasonMeta['id']); +// if (!$this->seasonDb) { +// Season::add($this->currRankSeasonMeta['id']); +// $this->seasonDb = Season::find($this->currRankSeasonMeta['id']); +// } +// if (!$this->seasonDb) { +// $this->_rspErr(10, 'server internal error'); +// die(); +// } $this->awardService = new services\AwardService(); $this->missionService = new services\MissionService(); $this->missionService->init($this->userInfo, $this->seasonDb); diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 4d6820ff..4d2992ca 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -141,7 +141,7 @@ class Chip extends BaseModel $row['rand_attr'] = $attrs; $row['today_get_gold'] = $todayGetGold; $row['last_get_gold_time'] = $lastGetGoldTime; - $row['belong_to_item_id'] = self::belongsToWhereOld($row); +// $row['belong_to_item_id'] = self::belongsToWhereOld($row); return $row; } @@ -149,10 +149,7 @@ class Chip extends BaseModel $tokenId = $row['token_id']; $sql = "select * from t_chip_plugin where chip1=:tokenId or chip2=:tokenId or chip3=:tokenId or chip4=:tokenId limit 1"; $whereKv =array( - 'chip1' => $tokenId, - 'chip2' => $tokenId, - 'chip3' => $tokenId, - 'chip4' => $tokenId, + 'tokenId' => $tokenId ); $ChipPluginDb = myself()->_getMarketMysql()->execQuery($sql,$whereKv); if (!$ChipPluginDb){ diff --git a/webapp/models/ChipPlugin.php b/webapp/models/ChipPlugin.php index 26fa7cbb..3ffaf2e6 100644 --- a/webapp/models/ChipPlugin.php +++ b/webapp/models/ChipPlugin.php @@ -20,10 +20,10 @@ class ChipPlugin extends BaseModel ) ); if ($row){ - $temp = array( + $chips = array( $row['chip1'],$row['chip2'],$row['chip3'],$row['chip4'] ); - $chips = array_filter($temp); +// $chips = array_filter($temp); } return implode('|',$chips); } diff --git a/webapp/models/Fragment.php b/webapp/models/Fragment.php index 92ebe238..373ddd4a 100644 --- a/webapp/models/Fragment.php +++ b/webapp/models/Fragment.php @@ -26,7 +26,7 @@ class Fragment extends BaseModel $dto = array( // 'owner_address' => $row['owner_address'], 'token_id' => $row['token_id'], - 'item_id' => $row['item_id'], + 'item_id' => $row['token_id'], 'balance' => $row['balance'], 'createtime' => $row['createtime'], 'modifytime' => $row['modifytime'], diff --git a/webapp/services/MissionService.php b/webapp/services/MissionService.php index 6ae666eb..a98cbdc6 100644 --- a/webapp/services/MissionService.php +++ b/webapp/services/MissionService.php @@ -56,36 +56,40 @@ class MissionService extends BaseService { public function init($userInfo, $seasonDb) { $this->userInfo = $userInfo; - $this->seasonDb = $seasonDb; +// $this->seasonDb = $seasonDb; $this->hisBattleData = Battle::getMyBattleData(); - $seasonBattleData = json_decode($this->seasonDb['battle_data'], true); - if (!isset($seasonBattleData)) { - $seasonBattleData = array(); - } - $this->seasonBattleData = getXVal($seasonBattleData, 'season_data', array()); - $this->thisWeekBattleData = getXVal($seasonBattleData, 'this_week_data', array()); - $this->todayBattleData = getXVal($seasonBattleData, 'today_data', array()); - if (myself()->_getDaySeconds(getXVal($this->todayBattleData, 'modifytime', 0)) < - myself()->_getNowDaySeconds()) { - $this->todayBattleData = array( - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime(), - ); - } - if (myself()->_getDaySeconds(getXVal($this->thisWeekBattleData, 'modifytime', 0)) < - myself()->_getMondaySeconds()) { - $this->thisWeekBattleData = array( - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime(), - ); - } +// $seasonBattleData = json_decode($this->seasonDb['battle_data'], true); +// if (!isset($seasonBattleData)) { +// $seasonBattleData = array(); +// } +// $this->seasonBattleData = getXVal($seasonBattleData, 'season_data', array()); +// $this->thisWeekBattleData = getXVal($seasonBattleData, 'this_week_data', array()); +// $this->todayBattleData = getXVal($seasonBattleData, 'today_data', array()); +// if (myself()->_getDaySeconds(getXVal($this->todayBattleData, 'modifytime', 0)) < +// myself()->_getNowDaySeconds()) { +// $this->todayBattleData = array( +// 'createtime' => myself()->_getNowTime(), +// 'modifytime' => myself()->_getNowTime(), +// ); +// } +// if (myself()->_getDaySeconds(getXVal($this->thisWeekBattleData, 'modifytime', 0)) < +// myself()->_getMondaySeconds()) { +// $this->thisWeekBattleData = array( +// 'createtime' => myself()->_getNowTime(), +// 'modifytime' => myself()->_getNowTime(), +// ); +// } $this->offerRewartdMission = BigData::getData(BigData::OFFER_REWARD_MISSION_TYPE); if (!$this->offerRewartdMission) { $this->offerRewartdMission = array( - 'missions' => array() + 'missions' => array(), + 'refreshtime' => 0 ); } - $this->refreshOfferRewardMission(); +// print_r($this->offerRewartdMission);die; + if (myself()->_getDaySeconds(myself()->_getNowTime()) - $this->offerRewartdMission['refreshtime'] >= 86400){ + $this->refreshOfferRewardMission(); + } } public function getMissionDto($userInfo, $seasonDb, $missionDb, $missionMeta) @@ -558,12 +562,31 @@ class MissionService extends BaseService { return myself()->_getV($x, $y); } + private function getMissionsCount(){ + $num = 0; + $missionHash = Mission::allToHash(); + if (count($this->offerRewartdMission['missions'])){ + foreach ($this->offerRewartdMission['missions'] as $val){ + $missionDb = getXVal($missionHash, $val['mission_id'], null); + $missionMeta = mt\Task::get($val['mission_id']); + $missionDto = $this->getMissionDto($this->userInfo, $this->seasonDb, $missionDb, $missionMeta); + if ($missionDto['state'] != 0){ + $num+=1; + } + } + } + return $num; + } + private function refreshOfferRewardMission() { $wantedRefreshMissionNum = mt\Parameter::getVal ('wanted_refresh_mission_num', 0); + if ($wantedRefreshMissionNum <= - count($this->offerRewartdMission['missions'])) { +// count($this->offerRewartdMission['missions']) + $this->getMissionsCount() + ) { return; } $metas = mt\Task::getOfferRewardMissions @@ -572,9 +595,9 @@ class MissionService extends BaseService { return; } - foreach (array_rand($metas, count($metas)) as $key) { + foreach (array_rand($metas, 5) as $key) { $meta = $metas[$key]; - if (count($this->offerRewartdMission['missions']) >= + if ($this->getMissionsCount() >= $wantedRefreshMissionNum) { break; } @@ -593,35 +616,46 @@ class MissionService extends BaseService { )); } } - $this->offerRewartdMission['refreshtime'] = myself()->_getNowTime(); +// unset($this->offerRewartdMission['missions']); +// print_r($this->offerRewartdMission['missions']);die; + $this->offerRewartdMission['refreshtime'] = myself()->_getDaySeconds(myself()->_getNowTime()); $this->saveOfferRewardMission(); } public function updateOfferRewardMission($missionId) { - $metas = mt\Task::getOfferRewardMissions - ($this->offerRewartdMission['missions']); - $selectMeta = null; - shuffle($metas); - foreach ($metas as $meta) { - if (!$this->inOfferRewardMission($meta['id'])) { - $selectMeta = $meta; - break; + foreach ($this->offerRewartdMission['missions'] as $k=>&$mission) { + if ($mission['mission_id'] == $missionId) { + unset($this->offerRewartdMission['missions'][$k]); } } - if ($selectMeta) { - foreach ($this->offerRewartdMission['missions'] as &$mission) { - if ($mission['mission_id'] == $missionId) { - $mission['mission_id'] = $selectMeta['id']; - $mission['createtime'] = myself()->_getNowTime(); - $mission['modifytime'] = myself()->_getNowTime(); - $mission['sendtime'] = 0; - $mission['objects'] = array(); - break; - } - } - } +// print_r(json_encode($this->offerRewartdMission));die; + +// $metas = mt\Task::getOfferRewardMissions +// ($this->offerRewartdMission['missions']); +// $selectMeta = null; +// shuffle($metas); +// foreach ($metas as $meta) { +// if (!$this->inOfferRewardMission($meta['id'])) { +// $selectMeta = $meta; +// break; +// } +// } +// +// if ($selectMeta) { +// foreach ($this->offerRewartdMission['missions'] as $k=>&$mission) { +// if ($mission['mission_id'] == $missionId) { +// $mission['mission_id'] = $selectMeta['id']; +// $mission['createtime'] = myself()->_getNowTime(); +// $mission['modifytime'] = myself()->_getNowTime(); +// $mission['sendtime'] = 0; +// $mission['objects'] = array(); +// break; +// } +// } +// } + } public function &getOfferRewardMissions() @@ -918,12 +952,13 @@ class MissionService extends BaseService { { $idx = 0; $missions = &$this->getOfferRewardMissions(); - foreach ($missions as &$val) { + foreach ($missions as $k=>&$val) { if ($val['mission_id'] == $missionId) { $mission = $val; + $idx = $k; return true; } - ++$idx; +// ++$idx; } return false; }