| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services\Common;
- use App\Models\ActionLogModel;
- use App\Models\CurrencyModel;
- use App\Models\TickerModel;
- use App\Services\BaseService;
- use App\Services\OkTradeService;
- use App\Services\RedisService;
- /**
- * 币种管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Services\Common
- */
- class CurrencyService extends BaseService
- {
- // 静态对象
- protected static $instance = null;
- /**
- * 构造函数
- * @author laravel开发员
- * @since 2020/11/11
- */
- public function __construct()
- {
- $this->model = new CurrencyModel();
- }
- /**
- * 静态入口
- * @return static|null
- */
- public static function make()
- {
- if (!self::$instance) {
- self::$instance = (new static());
- }
- return self::$instance;
- }
- /**
- * 获取同步列表数据
- * @return array|false|mixed
- */
- public function getSyncList()
- {
- $cacheKey = "caches:currency:sync";
- $datas = RedisService::get($cacheKey);
- if(empty($datas)){
- $datas = $this->model->where(['sync_status'=>1,'status'=>1,'mark'=>1])
- ->select(['id','name','chain','ctAddr','status'])
- ->orderBy('sort','desc')
- ->get();
- $datas = $datas? $datas->toArray() : [];
- if($datas){
- RedisService::set($cacheKey, $datas, rand(3600, 7200));
- }
- }
- return $datas;
- }
- /**
- * 添加会编辑
- * @return array
- * @since 2020/11/11
- * @author laravel开发员
- */
- public function edit()
- {
- // 请求参数
- $data = request()->all();
- ActionLogModel::setTitle("修改币种信息");
- ActionLogModel::record();
- return parent::edit($data); // TODO: Change the autogenerated stub
- }
- }
|