Rebate.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Models;
  3. /**
  4. * @property $id
  5. * @property $effective_betting_amount
  6. * @property $date
  7. * @property $rebate_ratio
  8. * @property $member_id
  9. * @property $status
  10. * @property $amount
  11. * @property $audited_by
  12. * @property $grant_time
  13. */
  14. class Rebate extends BaseModel
  15. {
  16. protected $table = 'rebates';
  17. protected $fillable = ['date', 'member_id', 'betting_amount', 'rebate_ratio',
  18. 'amount', 'status', 'first_name', 'username', 'audited_by',
  19. 'profit', 'huishui_percentage', 'huishui_restriction', 'huishui_amount',
  20. 'effective_betting_amount', 'grant_time', 'details', 'need_flow', 'granted_amount', 'granted_need_flow'
  21. ];
  22. protected $casts = ['details' => 'array'];
  23. const STATUS_WEI_FAN_YONG = 0;//未返佣
  24. const STATUS_FAN_YONG = 1; //已返佣
  25. const STATUS_PARTIAL = 2; // 当天已发放一部分,后续可补发差额
  26. const OPEN_STATUSES = [self::STATUS_WEI_FAN_YONG, self::STATUS_PARTIAL];
  27. public function member()
  28. {
  29. return $this->belongsTo(User::class, 'member_id', 'member_id')
  30. ->select(['id', 'member_id', 'username', 'account', 'first_name', 'admin_note', 'status', 'phone', 'visitor_id', 'register_ip']);
  31. }
  32. protected function getGrantTimeAttribute($value): string
  33. {
  34. if ($value > 0) return date('Y-m-d H:i', $value);
  35. return "";
  36. }
  37. }