BalanceLogModel.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. 'pay_type',
  22. 'pay_status',
  23. 'pay_at',
  24. 'pay_img',
  25. 'transaction_id',
  26. 'account',
  27. 'account_remark',
  28. 'date',
  29. 'create_time',
  30. 'update_time',
  31. 'confirm_remark',
  32. 'status',
  33. 'mark'
  34. ];
  35. protected $casts = [
  36. 'money' => 'decimal:2',
  37. 'actual_money' => 'decimal:2',
  38. ];
  39. protected $appends = ['time_text'];
  40. // 时间
  41. public function getTimeTextAttribute()
  42. {
  43. return $this->create_time? datetime($this->create_time,'Y-m-d H:i:s') : '';
  44. }
  45. /**
  46. * 关联用户(会员、代理、商家都在 member 表)
  47. */
  48. public function user()
  49. {
  50. return $this->belongsTo(MemberModel::class, 'user_id', 'id');
  51. }
  52. /**
  53. * 关联会员(别名,向后兼容)
  54. */
  55. public function member()
  56. {
  57. return $this->user();
  58. }
  59. /**
  60. * 关联代理(别名,向后兼容)
  61. */
  62. public function agent()
  63. {
  64. return $this->user();
  65. }
  66. /**
  67. * 关联商家(别名,向后兼容)
  68. */
  69. public function store()
  70. {
  71. return $this->user();
  72. }
  73. }