WithDrawalLogModel.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Models\Mysql;
  3. use App\Repositories\ConfigRepoistory;
  4. class WithDrawalLogModel extends BaseMysql
  5. {
  6. protected $table = 'withdrawal_log';
  7. /**
  8. * UUID 键名
  9. * @var string
  10. */
  11. protected $uuidKeyName = 'uid';
  12. /**
  13. * 已拒绝
  14. */
  15. const STATUS_REJECT = 1;
  16. /**
  17. * 申请中
  18. */
  19. const STATUS_APPLYING = 2;
  20. /**
  21. * 已打款
  22. */
  23. const STATUS_PAID = 3;
  24. /**
  25. * 拒绝并扣除
  26. */
  27. const STATUS_REJECT_DEDUCT = 4;
  28. /**
  29. * The "booted" method of the model.
  30. *
  31. * @return void
  32. */
  33. protected static function boot()
  34. {
  35. parent::boot();
  36. self::creating(function ($model) {
  37. $model->{$model->uuidKeyName} = self::generateId($model->uuidKeyName);
  38. });
  39. self::created(function ($model) {
  40. $uuid = hashEncodeId($model->id);
  41. $model->{$model->uuidKeyName} = $uuid;
  42. $model->save();
  43. });
  44. }
  45. public $typeMap = [
  46. 1 => '银行卡',
  47. 2 => 'USDT',
  48. 3 => '支付宝',
  49. ];
  50. protected $appends = ['pay_amount', 'type_name'];
  51. /**
  52. * 提现方式翻译
  53. *
  54. * @param $value
  55. * @return string
  56. */
  57. public function getTypeNameAttribute($value)
  58. {
  59. $value = $this->typeMap[$this->type] ?? '';
  60. return $value;
  61. }
  62. /**
  63. * 实际支付金额
  64. *
  65. * @param $value
  66. * @return int|mixed
  67. */
  68. public function getPayAmountAttribute($value)
  69. {
  70. if ($this->type == 2) {
  71. $payAmount = round($this->amount / $this->usdt_rate);
  72. $value = $payAmount . "($this->amount)";
  73. } else {
  74. $value = $this->amount;
  75. }
  76. return $value;
  77. }
  78. public function agent()
  79. {
  80. return $this->hasOne(AgentModel::class, 'uid', 'agent_uid');
  81. }
  82. }