SoftCodeService.php 599 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace app\common\service;
  3. use app\common\model\soft\Codes as SoftCodes;
  4. use think\Cache;
  5. use think\Exception;
  6. use app\common\traits\ServiceTrait;
  7. class SoftCodeService
  8. {
  9. use ServiceTrait;
  10. /** @var SoftCodes */
  11. public static $Model = SoftCodes::class;
  12. /**
  13. * 获取可用激活码
  14. * @throws \Exception
  15. */
  16. public static function getAvailableCode()
  17. {
  18. $res = self::getOne(['status' => CommonService::NO]);
  19. if (!$res) {
  20. exception('激活码不足,请手动生成');
  21. }
  22. return $res->activate_code;
  23. }
  24. }