From d42ba43782169fc063a486a0392d671b48f238f3 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Fri, 16 Jun 2023 19:10:22 +0800 Subject: [PATCH] 1 --- webapp/controller/PassController.class.php | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index 0352b925..b2cbefa5 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -66,7 +66,7 @@ class PassController extends BaseAuthedController { $passDb = Pass::find($this->currSeasonMeta['id']); $rewards = emptyReplace(json_decode($passDb['data'], true), array()); - $data = $this->_rewardHash($rewards); + $data = $this->_rewardHash($rewards,$type); $items = array(); switch ($type){ case 0 : { @@ -111,10 +111,12 @@ class PassController extends BaseAuthedController { switch ($type){ case 0 : { $data['basic'][$level]['state'] = 1; + $data['basic'] = array_values($data['basic']); } break; case 1 : { $data['platinum'][$level]['state'] = 1; + $data['platinum'] = array_values($data['platinum']); } } Pass::upsert($this->currSeasonMeta['id'],json_encode($data)); @@ -170,16 +172,24 @@ class PassController extends BaseAuthedController { } - private function _rewardHash($reward){ + private function _rewardHash($reward,$type){ if (!$reward){ return array(); } $data = array(); - foreach ($reward['basic'] as $value){ - $data['basic'][$value['level']] = $value; - } - foreach ($reward['platinum'] as $value){ - $data['platinum'][$value['level']] = $value; + switch ($type){ + case 0 : { + foreach ($reward['basic'] as $value){ + $data['basic'][$value['level']] = $value; + } + } + break; + case 1:{ + foreach ($reward['platinum'] as $value){ + $data['platinum'][$value['level']] = $value; + } + } + break; } return $data; }