BalanceLogModel.php 2.6 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\Models;
  12. use App\Services\RedisService;
  13. /**
  14. * 余额充值提现订单管理-模型
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * Class BalanceLogModel
  18. * @package App\Models
  19. */
  20. class BalanceLogModel extends BaseModel
  21. {
  22. // 设置数据表
  23. protected $table = 'balance_logs';
  24. /**
  25. * 验证记录是否已经存在
  26. * @param $hash
  27. * @return array|bool
  28. */
  29. public static function checkExists($hash)
  30. {
  31. $cacheKey = "caches:wallet:balanceLog:{$hash}";
  32. $check = RedisService::get($cacheKey);
  33. if(RedisService::exists($cacheKey)){
  34. return $check;
  35. }
  36. $info = BalanceLogModel::where(['hash'=> $hash,'mark'=>1])->first();
  37. $info = $info? $info->toArray() : [];
  38. if($info){
  39. RedisService::set($cacheKey, $info, rand(600,1200));
  40. }
  41. return $info;
  42. }
  43. /**
  44. * 用户
  45. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  46. */
  47. public function member()
  48. {
  49. return $this->hasOne(MemberModel::class, 'id','user_id')
  50. ->where(['mark'=>1])
  51. ->select(['id','nickname','username','realname','balance','trc_url','usdt','avatar','status']);
  52. }
  53. /**
  54. * 承兑商
  55. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  56. */
  57. public function acceptor()
  58. {
  59. return $this->hasOne(AcceptorModel::class, 'id','user_id')
  60. ->where(['mark'=>1])
  61. ->select(['id','name as nickname','user_id','mobile']);
  62. }
  63. /**
  64. * 商家
  65. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  66. */
  67. public function merchant()
  68. {
  69. return $this->hasOne(MerchantModel::class, 'id','user_id')
  70. ->where(['mark'=>1])
  71. ->select(['id','name as nickname','user_id','mobile']);
  72. }
  73. /**
  74. * 账号信息
  75. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  76. */
  77. public function payment()
  78. {
  79. return $this->hasOne(MemberBankModel::class, 'id','payment_id')
  80. ->where(['mark'=>1]);
  81. }
  82. }