| 123456789101112131415161718192021222324252627282930 |
- <?php
- namespace app\weixin\model;
- use app\weixin\service\PRedis;
- use think\Model;
- class UserRechargeLog extends Model
- {
- protected $table = 'sg_user_recharge_log';
- /**
- * 用户是否充值过
- * @param $userId
- * @param $type
- * @return bool
- */
- public static function check($userId, $type){
- $cacheKey = "caches:recharge:check:{$userId}_{$type}";
- if(PRedis::get($cacheKey)){
- return true;
- }
- if($id = UserRechargeLog::where(['user_id'=> $userId,'type'=> $type,'status'=>2])->value('id')){
- PRedis::set($cacheKey, $id, rand(10, 30));
- }
- return $id? true : false;
- }
- }
|