From 068334f9a0985684c75d1e6f1535195a018dc099 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 6 Jun 2022 21:00:42 +0800 Subject: [PATCH] 1 --- webapp/models/Gun.php | 17 +++++++++++---- webapp/models/Hero.php | 17 +++++++++++---- webapp/services/MissionService.php | 35 +++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 812fbf27..c1126353 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -339,10 +339,7 @@ class Gun extends BaseModel { 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']); + $finalyAddGold = self::calcPveGainGold($gunDto, $count); if ($finalyAddGold > 0) { self::update($gunDto['gun_uniid'], array( @@ -353,4 +350,16 @@ class Gun extends BaseModel { return $finalyAddGold; } + public static function calcPveGainGold($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']); + return $finalyAddGold; + } + } diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 517857b8..481c2c64 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -380,10 +380,7 @@ class Hero extends BaseModel { 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']); + $finalyAddGold = self::calcPveGainGold($gunDto, $count); if ($finalyAddGold > 0) { self::update($heroDto['hero_uniid'], array( @@ -394,4 +391,16 @@ class Hero extends BaseModel { return $finalyAddGold; } + public static function calcPveGainGold($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']); + return $finalyAddGold; + } + } diff --git a/webapp/services/MissionService.php b/webapp/services/MissionService.php index a580a440..90bc1c87 100644 --- a/webapp/services/MissionService.php +++ b/webapp/services/MissionService.php @@ -760,8 +760,41 @@ class MissionService extends BaseService { myself()->_rspErr(1, 'mission_id parameter error'); return; } + $count = $this->getOfferRewardMissionCount(); + $cegNum = 0; + $objects = explode('|', getReqVal('objects', 0)); + foreach ($objects as $val) { + $strings = explode(':', $val); + if (count($strings) < 2) { + continue; + } + $type = $strings[0]; + $id = $strings[1]; + switch ($type) { + case 0: + { + //武器 + $gunDb = Gun::find($id); + if ($gunDb) { + $gunDto = Gun::toDto($gunDb); + $cegNum += Gun::calcPveGainGold($gunDto, $count); + } + } + break; + case 1: + { + //英雄 + $heroDb = Hero::find($id); + if ($heroDb) { + $heroDto = Hero::toDto($heroDb); + $cegNum += Hero::calcPveGainGold($heroDto, $count); + } + } + break; + } + } myself()->_rspData(array( - 'ceg_num' => 0 + 'ceg_num' => $cegNum )); }