Backflow.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Models;
  3. /**
  4. * @property $date
  5. * @property $recharge_amount
  6. * @property $withdrawal_amount
  7. * @property $status
  8. * @property $backflow_ratio
  9. * @property $member_id
  10. * @property $amount
  11. * @property $grant_time
  12. *
  13. */
  14. class Backflow extends BaseModel
  15. {
  16. const STATUS_PENDING = 0; // 未发放
  17. const STATUS_GRANTED = 1; // 已发放(月份已结束并发完)
  18. const STATUS_PARTIAL = 2; // 部分发放(当月提前发放,仍在累计,可继续发放差额)
  19. const OPEN_STATUSES = [self::STATUS_PENDING, self::STATUS_PARTIAL];
  20. protected $table = 'backflow';
  21. protected $fillable = ['date', 'member_id', 'grant_time', 'recharge_amount', 'withdrawal_amount', 'backflow_ratio', 'amount', 'status',
  22. 'loss_amount', 'details', 'need_flow', 'granted_amount', 'granted_need_flow'];
  23. protected $casts = ['details' => 'array'];
  24. function user()
  25. {
  26. return $this->belongsTo(User::class, 'member_id', 'member_id')
  27. ->select(['id', 'member_id', 'username', 'first_name', 'admin_note', 'status', 'phone', 'visitor_id', 'register_ip']);
  28. }
  29. protected function getGrantTimeAttribute($value): string
  30. {
  31. if ($value > 0) return date('Y-m-d H:i', $value);
  32. return "";
  33. }
  34. }