/** * 积分日志 */ public function logAction() { list($ctype, $timeStart, $timeEnd, $award) = $this->getInput(array('ctype', 'time_start', 'time_end', 'award')); $page = $this->getInput('page'); $page < 1 && ($page = 1); $perpage = 20; list($offset, $limit) = Pw::page2limit($page, $perpage); Wind::import('SRV:credit.srv.PwCreditOperationConfig'); Wind::import('SRV:credit.vo.PwCreditLogSc'); $sc = new PwCreditLogSc(); $url = array(); if ($ctype) { $sc->setCtype($ctype); $url['ctype'] = $ctype; } if ($timeStart) { $sc->setCreateTimeStart(Pw::str2time($timeStart)); $url['time_start'] = $timeStart; } if ($timeEnd) { $sc->setCreateTimeEnd(Pw::str2time($timeEnd)); $url['time_end'] = $timeEnd; } if ($award) { $sc->setAward($award); $url['award'] = $award; } if ($sc->hasData()) { $sc->setUserid($this->loginUser->uid); $count = Wekit::load('credit.PwCreditLog')->countBySearch($sc); $log = Wekit::load('credit.PwCreditLog')->searchLog($sc, $limit, $offset); } else { $count = Wekit::load('credit.PwCreditLog')->countLogByUid($this->loginUser->uid); $log = Wekit::load('credit.PwCreditLog')->getLogByUid($this->loginUser->uid, $limit, $offset); } $this->setOutput($log, 'log'); $this->setOutput(PwCreditBo::getInstance(), 'creditBo'); $this->setOutput(PwCreditOperationConfig::getInstance(), 'coc'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($count, 'count'); $this->setOutput($url, 'url'); $this->setOutput($ctype, 'ctype'); $this->setOutput($timeStart, 'timeStart'); $this->setOutput($timeEnd, 'timeEnd'); $this->setOutput($award, 'award'); $this->setTemplate('profile_credit_log'); }
public static function getInstance() { isset(self::$_instance) || (self::$_instance = new self()); return self::$_instance; }
/** * 记录积分日志 * * @param string $operation 操作类型 * @param array $setv 积分值 array('1' => ??, '2' => ??, ...) * @param object $user 被操作用户 * @param array $log 日志信息描述 * @return void */ public function addLog($operation, $setv, PwUserBo $user, $log = array()) { if (!is_array($setv) || !$setv) { return false; } $log['uid'] = $user->uid; $log['username'] = $user->username; $coc = PwCreditOperationConfig::getInstance(); $_creditAffect = array(); foreach ($setv as $key => $affect) { if (isset($this->cType[$key]) && $this->isLog[$key] && $affect != 0) { $log['cname'] = $this->cType[$key]; $log['affect'] = $affect > 0 ? '+' . $affect : $affect; $descrip = $coc->getDescrip($operation, $log); $dm = new PwCreditLogDm(); $dm->setCtype($key)->setAffect($affect)->setLogtype($operation)->setDescrip($descrip)->setCreatedUser($user->uid, $user->username)->setCreatedTime(Pw::getTime()); $this->_log[] = $dm; $_creditAffect[] = array($log['cname'], $log['affect']); } } //TODO 记录用户的积分变动情况--- //change: judge if the operate is in the "global->credit->strategy" //exists: add user credit log if ($coc->isCreditPop($operation) && $_creditAffect) { $this->_userLog[$user->uid] = array($coc->getName($operation), $_creditAffect); } }
/** * 积分日志页面 */ public function logAction() { list($ctype, $time_start, $time_end, $award, $username, $uid) = $this->getInput(array('ctype', 'time_start', 'time_end', 'award', 'username', 'uid')); $page = $this->getInput('page'); $page < 1 && ($page = 1); $perpage = 20; list($offset, $limit) = Pw::page2limit($page, $perpage); Wind::import('SRV:credit.bo.PwCreditBo'); Wind::import('SRV:credit.vo.PwCreditLogSc'); Wind::import('SRV:credit.srv.PwCreditOperationConfig'); $sc = new PwCreditLogSc(); $url = array(); if ($ctype) { $sc->setCtype($ctype); $url['ctype'] = $ctype; } if ($time_start) { $sc->setCreateTimeStart(Pw::str2time($time_start)); $url['time_start'] = $time_start; } if ($time_end) { $sc->setCreateTimeEnd(Pw::str2time($time_end)); $url['time_end'] = $time_end; } if ($award) { $sc->setAward($award); $url['award'] = $award; } if ($username) { $user = Wekit::load('user.PwUser')->getUserByName($username); $sc->setUserid($user['uid']); // $url['uid'] = $user['uid']; $url['username'] = $username; } if ($uid) { $sc->setUserid($uid); $url['uid'] = $uid; } $count = Wekit::load('credit.PwCreditLog')->countBySearch($sc); $log = Wekit::load('credit.PwCreditLog')->searchLog($sc, $limit, $offset); $this->setCurrentTab('log'); $this->setOutput(PwCreditBo::getInstance(), 'creditBo'); $this->setOutput(PwCreditOperationConfig::getInstance(), 'coc'); $this->setOutput($log, 'log'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($count, 'count'); $this->setOutput($url, 'args'); }