WalletLogModel.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\Models;
  12. use App\Services\RedisService;
  13. /**
  14. * 平台钱包交易记录-模型
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * @package App\Models
  18. */
  19. class WalletLogModel extends BaseModel
  20. {
  21. // 设置数据表
  22. protected $table = 'wallet_log';
  23. /**
  24. * 验证记录是否已经存在
  25. * @param $hash
  26. * @return array|bool
  27. */
  28. public static function checkExists($hash)
  29. {
  30. $cacheKey = "caches:wallet:checkLog:{$hash}";
  31. $check = RedisService::get($cacheKey);
  32. if($check){
  33. return true;
  34. }
  35. $info = WalletLogModel::where(['hash'=> $hash,'status'=>1,'mark'=>1])->first();
  36. $info = $info? $info->toArray() : [];
  37. if($info){
  38. RedisService::set($cacheKey, $info, rand(3600,7200));
  39. }
  40. return $info;
  41. }
  42. }