| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Models\Mysql;
- use App\Repositories\ConfigRepoistory;
- class WithDrawalLogModel extends BaseMysql
- {
- protected $table = 'withdrawal_log';
- /**
- * UUID 键名
- * @var string
- */
- protected $uuidKeyName = 'uid';
- /**
- * 已拒绝
- */
- const STATUS_REJECT = 1;
- /**
- * 申请中
- */
- const STATUS_APPLYING = 2;
- /**
- * 已打款
- */
- const STATUS_PAID = 3;
- /**
- * 拒绝并扣除
- */
- const STATUS_REJECT_DEDUCT = 4;
- /**
- * The "booted" method of the model.
- *
- * @return void
- */
- protected static function boot()
- {
- parent::boot();
- self::creating(function ($model) {
- $model->{$model->uuidKeyName} = self::generateId($model->uuidKeyName);
- });
- self::created(function ($model) {
- $uuid = hashEncodeId($model->id);
- $model->{$model->uuidKeyName} = $uuid;
- $model->save();
- });
- }
- public $typeMap = [
- 1 => '银行卡',
- 2 => 'USDT',
- 3 => '支付宝',
- ];
- protected $appends = ['pay_amount', 'type_name'];
- /**
- * 提现方式翻译
- *
- * @param $value
- * @return string
- */
- public function getTypeNameAttribute($value)
- {
- $value = $this->typeMap[$this->type] ?? '';
- return $value;
- }
- /**
- * 实际支付金额
- *
- * @param $value
- * @return int|mixed
- */
- public function getPayAmountAttribute($value)
- {
- if ($this->type == 2) {
- $payAmount = round($this->amount / $this->usdt_rate);
- $value = $payAmount . "($this->amount)";
- } else {
- $value = $this->amount;
- }
- return $value;
- }
- public function agent()
- {
- return $this->hasOne(AgentModel::class, 'uid', 'agent_uid');
- }
- }
|