feat: 實作機台日誌核心功能與 IoT 高併發處理架構
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 36s

This commit is contained in:
2026-03-09 09:43:51 +08:00
parent 21e064ff91
commit c30c3a399d
53 changed files with 2300 additions and 2130 deletions

View File

@@ -0,0 +1,60 @@
<?php
namespace App\Models\Member;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class DepositBonusRule extends Model
{
use HasFactory;
protected $fillable = [
'name',
'min_amount',
'bonus_type',
'bonus_value',
'is_active',
'start_at',
'end_at',
];
protected $casts = [
'min_amount' => 'decimal:2',
'bonus_value' => 'decimal:2',
'is_active' => 'boolean',
'start_at' => 'datetime',
'end_at' => 'datetime',
];
/**
* 取得目前有效的規則
*/
public function scopeActive($query)
{
return $query->where('is_active', true)
->where(function ($q) {
$q->whereNull('start_at')->orWhere('start_at', '<=', now());
})
->where(function ($q) {
$q->whereNull('end_at')->orWhere('end_at', '>=', now());
});
}
/**
* 計算回饋金額
*/
public function calculateBonus(float $depositAmount): float
{
if ($depositAmount < $this->min_amount) {
return 0;
}
if ($this->bonus_type === 'fixed') {
return $this->bonus_value;
}
// percentage
return $depositAmount * ($this->bonus_value / 100);
}
}