src/Biz/Sign/Service/Impl/SignServiceImpl.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\Sign\Service\Impl;

use Biz\BaseService;
use Biz\Sign\Dao\SignTargetStatisticsDao;
use Biz\Sign\Dao\SignUserLogDao;
use Biz\Sign\Dao\SignUserStatisticsDao;
use Biz\Sign\SignException;
use Biz\User\UserException;
use Codeages\Biz\Framework\Event\Event;
use Biz\Sign\Service\SignService;

class SignServiceImpl extends BaseService implements SignService
{
    public function userSign($userId, $targetType, $targetId)
    {
        $user = $this->getUserService()->getUser($userId);

        if (empty($user)) {
            $this->createNewException(UserException::NOTFOUND_USER());
        }

        $isSignedToday = $this->isSignedToday($userId, $targetType, $targetId);

        if ($isSignedToday) {
            $this->createNewException(SignException::DUPLICATE_SIGN());
        }

        $sign = array();
        $sign['userId'] = $userId;
        $sign['targetId'] = $targetId;
        $sign['targetType'] = $targetType;
        $sign['createdTime'] = time();

        $sign = $this->getSignUserLogDao()->create($sign);
        $statistics = $this->targetSignedNumIncrease($targetType, $targetId, date('Ymd', time()));
        $this->getSignUserLogDao()->update($sign['id'], array('rank' => $statistics['signedNum']));
        $this->refreshKeepDays($userId, $targetType, $targetId);

        $this->dispatchEvent('class.signed', new Event($sign));

        return $sign;
    }

    public function isSignedToday($userId, $targetType, $targetId)
    {
        $startTimeToday = strtotime(date('y-n-d 0:0:0'));
        $endTimeToday = strtotime(date('y-n-d 23:59:59'));

        $signs = $this->getSignUserLogDao()->findSignLogByPeriod($userId, $targetType, $targetId, $startTimeToday, $endTimeToday);

        return empty($signs) ? false : true;
    }

    public function isYestodaySigned($userId, $targetType, $targetId)
    {
        $startTimeToday = strtotime(date('y-n-d 0:0:0', strtotime('-1 days')));
        $endTimeToday = strtotime(date('y-n-d 23:59:59', strtotime('-1 days')));

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。