| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Models;
- /**
- * @property $date
- * @property $recharge_amount
- * @property $withdrawal_amount
- * @property $status
- * @property $backflow_ratio
- * @property $member_id
- * @property $amount
- * @property $grant_time
- *
- */
- class Backflow extends BaseModel
- {
- const STATUS_PENDING = 0; // 未发放
- const STATUS_GRANTED = 1; // 已发放(月份已结束并发完)
- const STATUS_PARTIAL = 2; // 部分发放(当月提前发放,仍在累计,可继续发放差额)
- const OPEN_STATUSES = [self::STATUS_PENDING, self::STATUS_PARTIAL];
- protected $table = 'backflow';
- protected $fillable = ['date', 'member_id', 'grant_time', 'recharge_amount', 'withdrawal_amount', 'backflow_ratio', 'amount', 'status',
- 'loss_amount', 'details', 'need_flow', 'granted_amount', 'granted_need_flow'];
- protected $casts = ['details' => 'array'];
- function user()
- {
- return $this->belongsTo(User::class, 'member_id', 'member_id')
- ->select(['id', 'member_id', 'username', 'first_name', 'admin_note', 'status', 'phone', 'visitor_id', 'register_ip']);
- }
- protected function getGrantTimeAttribute($value): string
- {
- if ($value > 0) return date('Y-m-d H:i', $value);
- return "";
- }
- }
|