CurrencyService.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\ActionLogModel;
  13. use App\Models\CurrencyModel;
  14. use App\Models\TickerModel;
  15. use App\Services\BaseService;
  16. use App\Services\OkTradeService;
  17. use App\Services\RedisService;
  18. /**
  19. * 币种管理-服务类
  20. * @author laravel开发员
  21. * @since 2020/11/11
  22. * @package App\Services\Common
  23. */
  24. class CurrencyService extends BaseService
  25. {
  26. // 静态对象
  27. protected static $instance = null;
  28. /**
  29. * 构造函数
  30. * @author laravel开发员
  31. * @since 2020/11/11
  32. */
  33. public function __construct()
  34. {
  35. $this->model = new CurrencyModel();
  36. }
  37. /**
  38. * 静态入口
  39. * @return static|null
  40. */
  41. public static function make()
  42. {
  43. if (!self::$instance) {
  44. self::$instance = (new static());
  45. }
  46. return self::$instance;
  47. }
  48. /**
  49. * 获取同步列表数据
  50. * @return array|false|mixed
  51. */
  52. public function getSyncList()
  53. {
  54. $cacheKey = "caches:currency:sync";
  55. $datas = RedisService::get($cacheKey);
  56. if(empty($datas)){
  57. $datas = $this->model->where(['sync_status'=>1,'status'=>1,'mark'=>1])
  58. ->select(['id','name','chain','ctAddr','status'])
  59. ->orderBy('sort','desc')
  60. ->get();
  61. $datas = $datas? $datas->toArray() : [];
  62. if($datas){
  63. RedisService::set($cacheKey, $datas, rand(3600, 7200));
  64. }
  65. }
  66. return $datas;
  67. }
  68. /**
  69. * 添加会编辑
  70. * @return array
  71. * @since 2020/11/11
  72. * @author laravel开发员
  73. */
  74. public function edit()
  75. {
  76. // 请求参数
  77. $data = request()->all();
  78. ActionLogModel::setTitle("修改币种信息");
  79. ActionLogModel::record();
  80. return parent::edit($data); // TODO: Change the autogenerated stub
  81. }
  82. }