['status_text','remaining_sec','usdt_amount'] ]); } function getStatusTextAttr($v,$row){ if($v){ return \app\enum\RechargeStatus::tryFromValue($row['status'])->getDescription(); } } function getRemainingSecAttr($v,$row){ $created_at = $row['created_at']; if(!$created_at){ return 0; } if(false !== strpos($created_at,'-')){ $created_at = strtotime($created_at); } $v = $created_at + 900 -time() ; return $v <=0 ? 0 : $v; } function getUsdtAmountAttr($v,$row){ if(in_array($row['network'],['BEP-20','TRC-20'])){ $amount = bcdiv($row['amount'],Config('site.money_to_usdt_rate'),4); //折扣 $amount = bcmul($amount,Config('site.usdt_recharge_discount'),4); return formatAmount($amount,4); } return 0; } function setTransferAtAttr($v){ if($v && strpos($v,'-')){ return strtotime($v); } return $v; } function setCreatedAtAttr($v){ if($v && strpos($v,'-')){ return strtotime($v); } return $v; } function setUpdatedAtAttr($v){ if($v && strpos($v,'-')){ return strtotime($v); } return $v; } function getStatusList(){ return \app\enum\RechargeStatus::toArray(); } function getNetworkList(){ return [ "BEP-20"=>"BEP-20", "TRC-20"=>"TRC-20" ]; } public function user() { return $this->belongsTo('User', 'user_id', 'id');//->setEagerlyType(0); } }