/** * 颁发勋章,用于完成的自动任务获取的勋章 * * @param int $uid * @param int $medalId */ public function awardTaskMedal($uid, $medalId) { $info = $this->_getMedalDs()->getMedalInfo($medalId); if (!$info) { return false; } $userLog = $this->_getMedalLogDs()->getInfoByUidMedalId($uid, $medalId); Wind::import('SRV:medal.dm.PwMedalLogDm'); $time = Pw::getTime(); if ($userLog && $userLog['award_status'] < 4) { $dm = new PwMedalLogDm($userLog['log_id']); $dm->setAwardStatus(3); $resource = $this->_getMedalLogDs()->updateInfo($dm); } else { $dm = new PwMedalLogDm(); $dm->setMedalid($medalId)->setUid($uid)->setAwardStatus(3)->setCreatedTime($time); $resource = $this->_getMedalLogDs()->replaceMedalLog($dm); } }
/** * 勋章申请批量操作 * */ public function batchPassAction() { $logids = (array) $this->getInput('logids', 'post'); Wind::import('SRV:medal.dm.PwMedalLogDm'); $ds = $this->_getMedalLogDs(); $srv = $this->_getMedalService(); foreach ($logids as $logid) { $log = $ds->getMedalLog($logid); $dm = new PwMedalLogDm($logid); $dm->setAwardStatus(PwMedalLog::STATUS_AWARD); $resource = $ds->updateInfo($dm); if (!$resource instanceof PwError) { $srv->sendNotice($log['uid'], $log['log_id'], $log['medal_id'], 3); } } $this->showMessage("MEDAL:success"); }