This commit is contained in:
aozhiwei 2022-06-06 19:28:32 +08:00
parent cb70c63e06
commit ebe315a759
4 changed files with 107 additions and 64 deletions

View File

@ -298,56 +298,10 @@ class MissionController extends BaseAuthedController {
break;
case mt\Task::OFFER_REWARD_MISSON_TYPE:
{
//PVE角色NFT每日获得极限CEG+PVE武器NFT每日获得极限CEG*90%/悬赏任务数量
$totalHeroUpLimit = 0;
$totalGunUpLimit = 0;
$count = $this->missionService-> getOfferRewardMissionCount();
$this->propertyChgService->addUserChg();
foreach ($missionDto['objects'] as $obj) {
switch ($obj['type']) {
case 0:
{
//weapon
$gunDb = Gun::find($obj['id']);
if ($gunDb) {
$gunDto = Gun::toDto($gunDb);
$totalGunUpLimit += $gunDto['raw_pve_ceg_uplimit'];
Gun::Update
($obj['id'],
array(
'lock_type' => 0,
'unlock_time' => 0
));
}
}
break;
case 1:
{
//hero
$heroDb = Hero::find($obj['id']);
if ($heroDb) {
$heroDto = Hero::toDto($heroDb);
$totalHeroUpLimit += $heroDto['raw_pve_ceg_uplimit'];
Hero::Update
($obj['id'],
array(
'lock_type' => 0,
'unlock_time' => 0
));
}
}
break;
default:
{
}
break;
}
}//end foreach
if ($count > 0) {
$ceg = ($totalHeroUpLimit + $totalGunUpLimit) * 0.9/ $count;
myself()->_addVirtualItem(V_ITEM_GOLD, round($gold));
$this->awardService->addItem(V_ITEM_GOLD, round($gold));
}
$this->missionService->receiveOfferRewardMission
($missionDto['mission_id'],
$this->awardService,
$this->propertyChgService);
}
break;
default:

View File

@ -334,4 +334,23 @@ class Gun extends BaseModel {
return $finalyAddGold;
}
public static function pveGainGold($gunDto, $count)
{
if ($count <= 0) {
return 0;
}
$newGold = min($gunDto['pve_ceg_uplimit'],
$gunDto['today_pve_get_ceg'] +
round($gunDto['pve_ceg_uplimit'] / $count));
$finalyAddGold = max(0, $newGold - $gunDto['today_pve_get_ceg']);
if ($finalyAddGold > 0) {
self::update($gunDto['gun_uniid'],
array(
'today_pve_get_ceg' => $newGold,
'last_pve_get_ceg_time' => myself()->_getNowTime()
));
}
return $finalyAddGold;
}
}

View File

@ -168,7 +168,7 @@ class Hero extends BaseModel {
'today_get_gold' => $todayGetGold,
'last_get_gold_time' => $lastGetGoldTime,
'today_pve_get_ceg' => $todayPveGetCeg,
'last_pve_get_gold_ceg' => $lastPveGetCegTime,
'last_pve_get_ceg_time' => $lastPveGetCegTime,
'unlock_trade_time' => $row['unlock_trade_time'],
);
$dto['ceg_uplimit'] = FormulaService::getHeroPvpDailyCegUpLimit($dto);
@ -375,4 +375,23 @@ class Hero extends BaseModel {
return $finalyAddGold;
}
public static function pveGainGold($heroDto, $count)
{
if ($count <= 0) {
return 0;
}
$newGold = min($heroDto['pve_ceg_uplimit'],
$heroDto['today_pve_get_ceg'] +
round($heroDto['pve_ceg_uplimit'] / $count));
$finalyAddGold = max(0, $newGold - $heroDto['today_pve_get_ceg']);
if ($finalyAddGold > 0) {
self::update($heroDto['hero_uniid'],
array(
'today_pve_get_ceg' => $newGold,
'last_pve_get_ceg_time' => myself()->_getNowTime()
));
}
return $finalyAddGold;
}
}

View File

@ -842,9 +842,13 @@ class MissionService extends BaseService {
myself()->_rspErr(10, 'server internal error:' . $missionMeta['reward']);
return;
}
myself()->_scatterDrop('mission:' . $missionId, $dropMeta, $awardService, $propertyChgService);
$this->updateOfferRewardMission($missionId);
$this->saveOfferRewardMission();
myself()->_scatterDrop('mission:' . $missionId,
$dropMeta,
$awardService,
$propertyChgService);
$this->receiveOfferRewardMission($missionId,
$awardService,
$propertyChgService);
myself()->_rspData(array(
'award' => $awardService->toDto(),
));
@ -866,24 +870,71 @@ class MissionService extends BaseService {
private function saveOfferRewardMission()
{
BigData::setData(BigData::OFFER_REWARD_MISSION_TYPE, json_encode($this->offerRewartdMission));
BigData::setData(BigData::OFFER_REWARD_MISSION_TYPE,
json_encode($this->offerRewartdMission));
}
public function commitOfferRewardMission($missionMeta)
public function receiveOfferRewardMission($missionId,
$awardService,
$propertyChgService)
{
$missionId = $missionMeta['mission_id'];
$mission = &$this->getOfferRewardMissionById($missionId);
if (!$mission) {
myself()->_rspErr(1, 'mission_id parameter error');
$idx = 0;
$mission = null;
if (!$this->getOfferRewardMissionById($missionId, $mission, $idx)) {
return;
}
if ($mission['sendtime'] > 0) {
myself()->_rspErr(1, 'mission_id parameter error2');
return;
//PVE角色NFT每日获得极限CEG+PVE武器NFT每日获得极限CEG*90%/悬赏任务数量
$totalHeroUpLimit = 0;
$totalGunUpLimit = 0;
$count = $this->getOfferRewardMissionCount();
$propertyChgService->addUserChg();
foreach ($mission['objects'] as $obj) {
switch ($obj['type']) {
case 0:
{
//weapon
$gunDb = Gun::find($obj['id']);
if ($gunDb) {
$gunDto = Gun::toDto($gunDb);
$totalGunUpLimit += Gun::pveGainGold($gunDto, $count);
Gun::Update
($obj['id'],
array(
'lock_type' => 0,
'unlock_time' => 0
));
}
}
break;
case 1:
{
//hero
$heroDb = Hero::find($obj['id']);
if ($heroDb) {
$heroDto = Hero::toDto($heroDb);
$totalHeroUpLimit += Hero::pveGainGold($heroDto, $count);
Hero::Update
($obj['id'],
array(
'lock_type' => 0,
'unlock_time' => 0
));
}
}
break;
default:
{
}
break;
}
}//end foreach
$ceg = $totalHeroUpLimit + $totalGunUpLimit;
if ($count > 0 && $ceg > 0) {
myself()->_addVirtualItem(V_ITEM_GOLD, round($ceg));
$awardService->addItem(V_ITEM_GOLD, round($ceg));
}
$this->updateOfferRewardMission($missionId);
$this->saveOfferRewardMission();
myself()->_rspOk();
}
public function getOfferRewardMissionCount()