| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Models;
- /**
- * 缴费充值套餐模型
- */
- class PayMealsModel extends BaseModel
- {
- protected $table = 'pay_meals';
- protected $fillable = [
- 'product_id',
- 'money',
- 'discount',
- 'remark',
- 'gas_type',
- 'type',
- 'electric_type',
- 'phone_type',
- 'phone_service',
- '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;
- }
- }
|