This commit is contained in:
aozhiwei 2022-11-11 21:41:26 +08:00
commit 98133e096e
9 changed files with 191 additions and 124 deletions

View File

@ -18,6 +18,19 @@ class BlockChain(object):
['!transactions', [_common.NftTransaction()], '交易列表'] ['!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', 'name': 'reportResult',
'desc': '上报链调用结果', 'desc': '上报链调用结果',

View File

@ -861,8 +861,7 @@ class Fragment(object):
['idx', 0, '主键id'], ['idx', 0, '主键id'],
['token_id', '', 'token id'], ['token_id', '', 'token id'],
['item_id', '', '道具id'], ['item_id', '', '道具id'],
['type', '', '碎片类型 1:英雄碎片 2枪械碎片 3:特殊英雄碎片 4:特殊枪械碎片'], ['balance', '', '数量'],
['parts', '', '碎片部位 0:特殊碎片的部位 1-8:普通部位'],
['createtime', 0, '创建时间'], ['createtime', 0, '创建时间'],
['modifytime', 0, '修改时间'], ['modifytime', 0, '修改时间'],
] ]

View File

@ -554,7 +554,7 @@ class BlockChainController extends BaseAuthedController {
'tokenId' => $tokenId, 'tokenId' => $tokenId,
'tokenType' => Nft::HERO_TYPE, 'tokenType' => Nft::HERO_TYPE,
'itemUniId' => $heroDb['hero_uniid'], 'itemUniId' => $heroDb['hero_uniid'],
'itemId' => $heroDb['item_id'] 'itemId' => $heroDb['hero_id']
) )
); );
@ -617,6 +617,53 @@ class BlockChainController extends BaseAuthedController {
return; 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) { switch ($type) {
case 1: case 1:
{ {
@ -625,51 +672,7 @@ class BlockChainController extends BaseAuthedController {
myself()->_rspErr(101, 'token_id paramater error'); myself()->_rspErr(101, 'token_id paramater error');
return; 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( $this->internalBcCall(
array( array(
'c' => 'BcService', 'c' => 'BcService',
@ -687,8 +690,9 @@ class BlockChainController extends BaseAuthedController {
'tokenId' => $tokenId, 'tokenId' => $tokenId,
'tokenType' => Nft::HERO_TYPE, 'tokenType' => Nft::HERO_TYPE,
'itemUniId' => $heroDb['hero_uniid'], '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, 'tokenType' => Nft::EQUIP_TYPE,
'itemUniId' => $gunDb['gun_uniid'], 'itemUniId' => $gunDb['gun_uniid'],
'itemId' => $gunDb['gun_id'] 'itemId' => $gunDb['gun_id']
) ),
$decFeeCb
); );
} }
break; break;
@ -747,6 +752,24 @@ class BlockChainController extends BaseAuthedController {
myself()->_rspData($data); 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) private function internalActivate721Nft($tokenId, $tokenType, $itemUniId, $itemId)
{ {
$params = array( $params = array(

View File

@ -20,7 +20,7 @@ class FragmentController extends BaseAuthedController
{ {
$fragmentList = array(); $fragmentList = array();
foreach (Fragment::getFragmentList() as $val){ foreach (Fragment::getFragmentList() as $val){
array_push($fragmentList,Fragment::oldToDto($val)); array_push($fragmentList,Fragment::ToDto($val));
} }
$this->_rspData(array( $this->_rspData(array(
'fragment_list' => $fragmentList, 'fragment_list' => $fragmentList,

View File

@ -41,22 +41,22 @@ class MissionController extends BaseAuthedController {
{ {
parent::_handlePre(); parent::_handlePre();
DynData::preload(); DynData::preload();
$this->currRankSeasonMeta = mt\RankSeason::getCurrentSeason(); // $this->currRankSeasonMeta = mt\RankSeason::getCurrentSeason();
if (!$this->currRankSeasonMeta) { // if (!$this->currRankSeasonMeta) {
$this->_rspErr(10, 'server internal error'); // $this->_rspErr(10, 'server internal error');
die(); // die();
} // }
$this->propertyChgService = new services\PropertyChgService(); $this->propertyChgService = new services\PropertyChgService();
$this->userInfo = $this->_safeGetOrmUserInfo(); $this->userInfo = $this->_safeGetOrmUserInfo();
$this->seasonDb = Season::find($this->currRankSeasonMeta['id']); // $this->seasonDb = Season::find($this->currRankSeasonMeta['id']);
if (!$this->seasonDb) { // if (!$this->seasonDb) {
Season::add($this->currRankSeasonMeta['id']); // Season::add($this->currRankSeasonMeta['id']);
$this->seasonDb = Season::find($this->currRankSeasonMeta['id']); // $this->seasonDb = Season::find($this->currRankSeasonMeta['id']);
} // }
if (!$this->seasonDb) { // if (!$this->seasonDb) {
$this->_rspErr(10, 'server internal error'); // $this->_rspErr(10, 'server internal error');
die(); // die();
} // }
$this->awardService = new services\AwardService(); $this->awardService = new services\AwardService();
$this->missionService = new services\MissionService(); $this->missionService = new services\MissionService();
$this->missionService->init($this->userInfo, $this->seasonDb); $this->missionService->init($this->userInfo, $this->seasonDb);

View File

@ -141,7 +141,7 @@ class Chip extends BaseModel
$row['rand_attr'] = $attrs; $row['rand_attr'] = $attrs;
$row['today_get_gold'] = $todayGetGold; $row['today_get_gold'] = $todayGetGold;
$row['last_get_gold_time'] = $lastGetGoldTime; $row['last_get_gold_time'] = $lastGetGoldTime;
$row['belong_to_item_id'] = self::belongsToWhereOld($row); // $row['belong_to_item_id'] = self::belongsToWhereOld($row);
return $row; return $row;
} }
@ -149,10 +149,7 @@ class Chip extends BaseModel
$tokenId = $row['token_id']; $tokenId = $row['token_id'];
$sql = "select * from t_chip_plugin where chip1=:tokenId or chip2=:tokenId or chip3=:tokenId or chip4=:tokenId limit 1"; $sql = "select * from t_chip_plugin where chip1=:tokenId or chip2=:tokenId or chip3=:tokenId or chip4=:tokenId limit 1";
$whereKv =array( $whereKv =array(
'chip1' => $tokenId, 'tokenId' => $tokenId
'chip2' => $tokenId,
'chip3' => $tokenId,
'chip4' => $tokenId,
); );
$ChipPluginDb = myself()->_getMarketMysql()->execQuery($sql,$whereKv); $ChipPluginDb = myself()->_getMarketMysql()->execQuery($sql,$whereKv);
if (!$ChipPluginDb){ if (!$ChipPluginDb){

View File

@ -20,10 +20,10 @@ class ChipPlugin extends BaseModel
) )
); );
if ($row){ if ($row){
$temp = array( $chips = array(
$row['chip1'],$row['chip2'],$row['chip3'],$row['chip4'] $row['chip1'],$row['chip2'],$row['chip3'],$row['chip4']
); );
$chips = array_filter($temp); // $chips = array_filter($temp);
} }
return implode('|',$chips); return implode('|',$chips);
} }

View File

@ -26,7 +26,7 @@ class Fragment extends BaseModel
$dto = array( $dto = array(
// 'owner_address' => $row['owner_address'], // 'owner_address' => $row['owner_address'],
'token_id' => $row['token_id'], 'token_id' => $row['token_id'],
'item_id' => $row['item_id'], 'item_id' => $row['token_id'],
'balance' => $row['balance'], 'balance' => $row['balance'],
'createtime' => $row['createtime'], 'createtime' => $row['createtime'],
'modifytime' => $row['modifytime'], 'modifytime' => $row['modifytime'],

View File

@ -56,36 +56,40 @@ class MissionService extends BaseService {
public function init($userInfo, $seasonDb) public function init($userInfo, $seasonDb)
{ {
$this->userInfo = $userInfo; $this->userInfo = $userInfo;
$this->seasonDb = $seasonDb; // $this->seasonDb = $seasonDb;
$this->hisBattleData = Battle::getMyBattleData(); $this->hisBattleData = Battle::getMyBattleData();
$seasonBattleData = json_decode($this->seasonDb['battle_data'], true); // $seasonBattleData = json_decode($this->seasonDb['battle_data'], true);
if (!isset($seasonBattleData)) { // if (!isset($seasonBattleData)) {
$seasonBattleData = array(); // $seasonBattleData = array();
} // }
$this->seasonBattleData = getXVal($seasonBattleData, 'season_data', array()); // $this->seasonBattleData = getXVal($seasonBattleData, 'season_data', array());
$this->thisWeekBattleData = getXVal($seasonBattleData, 'this_week_data', array()); // $this->thisWeekBattleData = getXVal($seasonBattleData, 'this_week_data', array());
$this->todayBattleData = getXVal($seasonBattleData, 'today_data', array()); // $this->todayBattleData = getXVal($seasonBattleData, 'today_data', array());
if (myself()->_getDaySeconds(getXVal($this->todayBattleData, 'modifytime', 0)) < // if (myself()->_getDaySeconds(getXVal($this->todayBattleData, 'modifytime', 0)) <
myself()->_getNowDaySeconds()) { // myself()->_getNowDaySeconds()) {
$this->todayBattleData = array( // $this->todayBattleData = array(
'createtime' => myself()->_getNowTime(), // 'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(), // 'modifytime' => myself()->_getNowTime(),
); // );
} // }
if (myself()->_getDaySeconds(getXVal($this->thisWeekBattleData, 'modifytime', 0)) < // if (myself()->_getDaySeconds(getXVal($this->thisWeekBattleData, 'modifytime', 0)) <
myself()->_getMondaySeconds()) { // myself()->_getMondaySeconds()) {
$this->thisWeekBattleData = array( // $this->thisWeekBattleData = array(
'createtime' => myself()->_getNowTime(), // 'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(), // 'modifytime' => myself()->_getNowTime(),
); // );
} // }
$this->offerRewartdMission = BigData::getData(BigData::OFFER_REWARD_MISSION_TYPE); $this->offerRewartdMission = BigData::getData(BigData::OFFER_REWARD_MISSION_TYPE);
if (!$this->offerRewartdMission) { if (!$this->offerRewartdMission) {
$this->offerRewartdMission = array( $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) public function getMissionDto($userInfo, $seasonDb, $missionDb, $missionMeta)
@ -558,12 +562,31 @@ class MissionService extends BaseService {
return myself()->_getV($x, $y); 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() private function refreshOfferRewardMission()
{ {
$wantedRefreshMissionNum = mt\Parameter::getVal $wantedRefreshMissionNum = mt\Parameter::getVal
('wanted_refresh_mission_num', 0); ('wanted_refresh_mission_num', 0);
if ($wantedRefreshMissionNum <= if ($wantedRefreshMissionNum <=
count($this->offerRewartdMission['missions'])) { // count($this->offerRewartdMission['missions'])
$this->getMissionsCount()
) {
return; return;
} }
$metas = mt\Task::getOfferRewardMissions $metas = mt\Task::getOfferRewardMissions
@ -572,9 +595,9 @@ class MissionService extends BaseService {
return; return;
} }
foreach (array_rand($metas, count($metas)) as $key) { foreach (array_rand($metas, 5) as $key) {
$meta = $metas[$key]; $meta = $metas[$key];
if (count($this->offerRewartdMission['missions']) >= if ($this->getMissionsCount() >=
$wantedRefreshMissionNum) { $wantedRefreshMissionNum) {
break; 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(); $this->saveOfferRewardMission();
} }
public function updateOfferRewardMission($missionId) public function updateOfferRewardMission($missionId)
{ {
$metas = mt\Task::getOfferRewardMissions foreach ($this->offerRewartdMission['missions'] as $k=>&$mission) {
($this->offerRewartdMission['missions']); if ($mission['mission_id'] == $missionId) {
$selectMeta = null; unset($this->offerRewartdMission['missions'][$k]);
shuffle($metas);
foreach ($metas as $meta) {
if (!$this->inOfferRewardMission($meta['id'])) {
$selectMeta = $meta;
break;
} }
} }
if ($selectMeta) { // print_r(json_encode($this->offerRewartdMission));die;
foreach ($this->offerRewartdMission['missions'] as &$mission) {
if ($mission['mission_id'] == $missionId) { // $metas = mt\Task::getOfferRewardMissions
$mission['mission_id'] = $selectMeta['id']; // ($this->offerRewartdMission['missions']);
$mission['createtime'] = myself()->_getNowTime(); // $selectMeta = null;
$mission['modifytime'] = myself()->_getNowTime(); // shuffle($metas);
$mission['sendtime'] = 0; // foreach ($metas as $meta) {
$mission['objects'] = array(); // if (!$this->inOfferRewardMission($meta['id'])) {
break; // $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() public function &getOfferRewardMissions()
@ -918,12 +952,13 @@ class MissionService extends BaseService {
{ {
$idx = 0; $idx = 0;
$missions = &$this->getOfferRewardMissions(); $missions = &$this->getOfferRewardMissions();
foreach ($missions as &$val) { foreach ($missions as $k=>&$val) {
if ($val['mission_id'] == $missionId) { if ($val['mission_id'] == $missionId) {
$mission = $val; $mission = $val;
$idx = $k;
return true; return true;
} }
++$idx; // ++$idx;
} }
return false; return false;
} }