Files
hyperf_service/app/Service/Api/Salesman/BaseSalesmanService.php
2025-04-01 14:59:08 +08:00

59 lines
1.4 KiB
PHP

<?php
/**
* This service file is part of item.
*
* @author ctexthuang
* @contact ctexthuang@qq.com
*/
declare(strict_types=1);
namespace App\Service\Api\Salesman;
use App\Constants\Common\RoleCode;
use App\Exception\ErrException;
use App\Model\AdminUser;
use App\Service\Api\BaseService;
use App\Service\ServiceTrait\Common\CycleTrait;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Model;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
abstract class BaseSalesmanService extends BaseService
{
use CycleTrait;
/**
* @var int
*/
protected int $cycleId;
/**
* @var Builder|Model|AdminUser|null
*/
protected AdminUser|null|Builder|Model $adminInfo;
/**
* @var AdminUser
*/
#[Inject]
protected AdminUser $adminUserModel;
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __construct()
{
parent::__construct();
$this->cycleId = $this->initTodayCycleId();
$this->adminInfo = $this->adminUserModel->getAdminInfoByBindUserId($this->userId);
if ($this->adminInfo->role_id != RoleCode::SALESMAN) throw new ErrException('暂无权限,请联系客服并提供相关信息绑定账号');
}
abstract public function handle();
}