_rspData(array( 'complete' => 0, 'firstTopupList' => mt\FirstTopup::getGroups(), 'status' => $status, ) ); return; } FirstTopup::adjustStatus($dbInfo); $complete = 1; $this->fillStatus($dbInfo, $status, $complete); $this->_rspData( array( 'complete' => $complete, 'firstTopupList' => mt\FirstTopup::getGroups(), 'status' => $status, ) ); } public function get() { $group = getReqVal('group', 1); if ($group < 1 || $group > 3) { $this->_rspErr(1, "not yet to receive the reward, group: $group"); return; } $dbInfo = FirstTopup::get(); if (!$dbInfo) { $this->_rspErr(1, "not yet to receive the reward, group: $group"); return; } FirstTopup::adjustStatus($dbInfo); if ($dbInfo['status' . $group] == 2) { $this->_rspErr(2, "already received the reward, group: $group"); return; } if ($dbInfo['status' . $group] != 1) { $this->_rspErr(1, "not yet to receive the reward, group: $group"); return; } FirstTopup::update(array( 'status' . $group => 2 )); $dbInfo['status' . $group] = 2; // 发放奖励 $awardService = new services\AwardService(); $propertyChgService = new services\PropertyChgService(); $reward = mt\FirstTopup::getByGroup($group); $awardItems = array(); for ($i = 0; $i < count($reward); $i++) { array_push($awardItems, array( 'item_id' => $reward[$i]['goods_id'], 'item_num' => $reward[$i]['goods_num'], 'is_payed' => 1 )); } myself()->_addItems($awardItems, $awardService, $propertyChgService); $status = array(0, 0, 0); $complete = 1; $this->fillStatus($dbInfo, $status, $complete); myself()->_rspData( array( 'group' => $group, 'status' => $status, 'award' => $awardService->toDto(), 'property_chg' => $propertyChgService->toDto(), ) ); } private function fillStatus($dbInfo, &$status, &$complete) { $complete = 1; for ($i = 1; $i <= 3; ++$i) { if ($dbInfo['status' . $i] != 2) { $complete = 0; } $status[$i - 1] = $dbInfo['status' . $i]; } if ($complete == 1 && myself()->_getV(TN_FIRST_TUPOP_STATUS, 0) == 0) { myself()->_setV(TN_FIRST_TUPOP_STATUS, 0, 1); } } }