CoinLogService.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\CoinLogModel;
  13. use App\Services\BaseService;
  14. use App\Services\RedisService;
  15. /**
  16. * 币种明细(提币、存币)-服务类
  17. * Class CoinLogService
  18. * @package App\Services\Common
  19. */
  20. class CoinLogService extends BaseService
  21. {
  22. // 静态对象
  23. protected static $instance = null;
  24. /**
  25. * 构造函数
  26. * @since 2020/11/10
  27. * CoinLogService constructor.
  28. */
  29. public function __construct()
  30. {
  31. $this->model = new CoinLogModel();
  32. }
  33. /**
  34. * 静态入口
  35. * @return static|null
  36. */
  37. public static function make()
  38. {
  39. if (!self::$instance) {
  40. self::$instance = (new static());
  41. }
  42. return self::$instance;
  43. }
  44. /**
  45. * 验证是否存在
  46. * @param \App\Services\字段名 $field
  47. * @param \App\Services\字段值 $value
  48. * @param string $pk
  49. * @return mixed
  50. */
  51. public function checkExists($field, $value, $pk = 'id')
  52. {
  53. $cacheKey = "caches:coinLogs:exists:{$field}_{$value}";
  54. if($result = RedisService::get($cacheKey)){
  55. return $result;
  56. }
  57. $result = parent::checkExists($field, $value, $pk);
  58. if($result){
  59. RedisService::set($cacheKey, $result, rand(3,5));
  60. }
  61. return $result;
  62. }
  63. }