UserRechargeLog.php 675 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace app\weixin\model;
  3. use app\weixin\service\PRedis;
  4. use think\Model;
  5. class UserRechargeLog extends Model
  6. {
  7. protected $table = 'sg_user_recharge_log';
  8. /**
  9. * 用户是否充值过
  10. * @param $userId
  11. * @param $type
  12. * @return bool
  13. */
  14. public static function check($userId, $type){
  15. $cacheKey = "caches:recharge:check:{$userId}_{$type}";
  16. if(PRedis::get($cacheKey)){
  17. return true;
  18. }
  19. if($id = UserRechargeLog::where(['user_id'=> $userId,'type'=> $type,'status'=>2])->value('id')){
  20. PRedis::set($cacheKey, $id, rand(10, 30));
  21. }
  22. return $id? true : false;
  23. }
  24. }