| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\common\model;
- use fast\Asset;
- use fast\Http;
- use fast\Random;
- use think\Cache;
- use think\Log;
- use think\Model;
- use think\Request;
- class EtcWithdrawRecordModel extends Model
- {
- protected $name = "etc_withdraw_record";
- /*
- * 获取ETC的USDT价格
- */
- public function getEtcPrice(){
- $etc_price = Cache::remember('etc_price', function(){
- $etc_usdt_price = 16;
- $url = "https://www.binance.com/api/v1/klines?symbol=ETCUSDT&limit=1&interval=3m";
- $body = Http::get($url);
- if (empty($body)) {
- dump('获取ETC价格接口返回为空');
- Log::info('拨币时:获取ETC价格接口返回为空');
- return "获取ETC价格接口返回为空";
- }
- // 转成数组
- $rsArr = json_decode($body, true);
- $etc_usdt_price = $rsArr[0][2];
- return $etc_usdt_price;
- }, 36000);
- if(empty($etc_price)){
- $etc_price = 16;
- }
- return $etc_price;
- }
- }
|