mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 03:57:27 +08:00
chore: code style and type declaration improvements
This commit is contained in:
@@ -172,7 +172,8 @@ class GiftCardCode extends Model
|
||||
public static function generateCode(string $prefix = 'GC'): string
|
||||
{
|
||||
do {
|
||||
$code = $prefix . strtoupper(substr(md5(uniqid(mt_rand(), true)), 0, 12));
|
||||
$safePrefix = (string) $prefix;
|
||||
$code = $safePrefix . strtoupper(substr(md5(uniqid($safePrefix . mt_rand(), true)), 0, 12));
|
||||
} while (self::where('code', $code)->exists());
|
||||
|
||||
return $code;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Dflydev\DotAccessData\Data;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
@@ -200,7 +201,7 @@ class GiftCardTemplate extends Model
|
||||
|
||||
if (isset($festivalConfig['start_time']) && isset($festivalConfig['end_time'])) {
|
||||
if ($now >= $festivalConfig['start_time'] && $now <= $festivalConfig['end_time']) {
|
||||
$bonus = (float) ($festivalConfig['festival_bonus'] ?? 1.0);
|
||||
$bonus = data_get($festivalConfig, 'festival_bonus', 1.0);
|
||||
if ($bonus > 1.0) {
|
||||
foreach ($actualRewards as $key => &$value) {
|
||||
if (is_numeric($value)) {
|
||||
@@ -240,7 +241,7 @@ class GiftCardTemplate extends Model
|
||||
->orderBy('created_at', 'desc')
|
||||
->first();
|
||||
|
||||
if ($lastUsage) {
|
||||
if ($lastUsage && isset($lastUsage->created_at)) {
|
||||
$cooldownTime = $lastUsage->created_at + ($conditions['cooldown_hours'] * 3600);
|
||||
if (time() < $cooldownTime) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user