Files
hyperf_service/app/Service/Common/Account/AccountOperateInterface.php
2025-04-02 16:05:24 +08:00

67 lines
1.3 KiB
PHP

<?php
/**
* This service file is part of item.
*
* @author ctexthuang
* @contact ctexthuang@qq.com
*/
declare(strict_types=1);
namespace App\Service\Common\Account;
use App\Exception\ErrException;
use App\Model\UserAccount;
use Hyperf\Di\Annotation\Inject;
abstract class AccountOperateInterface
{
/**
* @var UserAccount
*/
#[Inject]
protected UserAccount $userAccountModel;
/**
* 检查num是否正确
* @param $num
* @return void
*/
protected function checkNum($num): void
{
if ($num < 0) throw new ErrException('数值错误');
}
/**
* @param int $userId
* @param string $value
* @param int $businessCode
* @param array $data
* @param string $description
* @return bool
*/
abstract public function inc(
int $userId,
string $value,
int $businessCode,
array $data,
string $description = ''
): bool;
/**
* @param int $userId
* @param string $value
* @param int $businessCode
* @param array $data
* @param string $description
* @return bool
*/
abstract public function dec(
int $userId,
string $value,
int $businessCode,
array $data,
string $description = ''
): bool;
}