BalanceLogModel.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 充值/提现记录模型 - 统一余额日志表
  6. * 用于会员的充值和提现记录
  7. */
  8. class BalanceLogModel extends Model
  9. {
  10. protected $table = 'balance_logs';
  11. protected $primaryKey = 'id';
  12. public $timestamps = false;
  13. protected $fillable = [
  14. 'order_no',
  15. 'user_id',
  16. 'type',
  17. 'account_type',
  18. 'realname',
  19. 'money',
  20. 'actual_money',
  21. 'after_money',
  22. 'pay_type',
  23. 'pay_status',
  24. 'pay_at',
  25. 'pay_img',
  26. 'transaction_id',
  27. 'account',
  28. 'account_name',
  29. 'account_remark',
  30. 'date',
  31. 'create_time',
  32. 'update_time',
  33. 'confirm_remark',
  34. 'status',
  35. 'mark'
  36. ];
  37. protected $casts = [
  38. 'money' => 'decimal:2',
  39. 'actual_money' => 'decimal:2',
  40. ];
  41. protected $appends = ['time_text'];
  42. // 时间
  43. public function getTimeTextAttribute()
  44. {
  45. return $this->create_time? datetime($this->create_time,'Y-m-d H:i:s') : '';
  46. }
  47. /**
  48. * 关联用户(会员、代理、商家都在 member 表)
  49. */
  50. public function user()
  51. {
  52. return $this->belongsTo(MemberModel::class, 'user_id', 'id');
  53. }
  54. /**
  55. * 关联会员(别名,向后兼容)
  56. */
  57. public function member()
  58. {
  59. return $this->user();
  60. }
  61. /**
  62. * 关联代理(别名,向后兼容)
  63. */
  64. public function agent()
  65. {
  66. return $this->user();
  67. }
  68. /**
  69. * 关联商家(别名,向后兼容)
  70. */
  71. public function store()
  72. {
  73. return $this->user();
  74. }
  75. }