<?php

namespace app\model;

use app\model\Base;
/**
 * @property integer $id 主键(ID) - 无注释
 * @property integer $user_id 用户ID
 * @property float $deduction_amount 提现金额
 * @property float $recive_amount 到账金额
 * @property float $fee 后续费
 * @property string $title 姓名
 * @property string $network 方式
 * @property string $address 地址
 * @property integer $transfer_at 转账时间
 * @property string $txid 凭证
 * @property string $memo 备注
 * @property integer $created_at 创建时间
 * @property integer $updated_at 更新时间
 * @property integer $status 状态
 */
class Withdrawl extends Base
{
    
    protected function getOptions(): array 
    {
        // 所有的参数配置统一返回
        return array_merge(parent::getOptions(),[
            'append'    =>  ['status_text']
        ]);
    }
    function getStatusTextAttr($v,$row){
        if($v){
            return \app\enum\WithdrawlStatus::tryFromValue($row['status'])->getDescription();
        }
    }
    function setTransferAtAttr($v){
        if($v && strpos($v,'-')){
            return strtotime($v);
        }
    }
    
    function setCreatedAtAttr($v){
        if($v && strpos($v,'-')){
            return strtotime($v);
        }
    }
    function setUpdatedAtAttr($v){
        if($v && strpos($v,'-')){
            return strtotime($v);
        }
    }
    function getNetworkList(){
        return [
            "BEP-20"=>"BEP-20",
            "TRC-20"=>"TRC-20",
            "WECHAT"=>"微信",
            "ALIPAY"=>"支付宝"
        ];
    }
    function getStatusList(){
        return \app\enum\WithdrawlStatus::toArray();
    } 
    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id');//->setEagerlyType(0);
    }
    
    
}
