| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Models;
- /**
- * 缴费充值套餐模型
- */
- class PayMealsModel extends BaseModel
- {
- protected $table = 'pay_meals';
- protected $fillable = [
- 'product_id',
- 'money',
- 'discount',
- 'remark',
- 'type',
- 'sort',
- 'create_time',
- 'update_time',
- 'status',
- 'mark'
- ];
- /**
- * 获取类型文本
- */
- public function getTypeTextAttribute()
- {
- $typeMap = [
- 1 => '话费充值',
- 2 => '电费充值',
- 3 => '燃气充值'
- ];
- return $typeMap[$this->type] ?? '未知';
- }
- /**
- * 获取状态文本
- */
- public function getStatusTextAttribute()
- {
- return $this->status == 1 ? '有效' : '无效';
- }
- /**
- * 获取折扣
- */
- public function getDiscountAttribute($value)
- {
- return floatval($value);
- }
- /**
- * 获取实付金额
- */
- public function getPayMoneyAttribute()
- {
- if ($this->discount > 0) {
- return round($this->money * $this->discount / 100, 2);
- }
- return $this->money;
- }
- }
|