def __change_head_order(cls, oid, good_id): # 修改开团者订单状态 order = Order.query.filter(Order.oid == oid).first() if order and order.status == 7: order.status = 2 order.is_group = True order.group_time = int(time.time()) order.change_time = int(time.time()) db.session.commit() r.delete(cls.set + good_id + ':' + oid) return True else: return False
def set_cache(cls, data, old_token): # 存入redis if old_token: # 删除旧的token old_token_key = cls.token_set + ':' + old_token r.delete(old_token_key) user = {} user['token'] = data.token user['username'] = data.username user['phoneNum'] = data.phoneNum user['email'] = data.email user['header'] = data.header if data.header else 'default.png' user['timestamp'] = int(time.time()) key = cls.token_set + ':' + user['token'] r.hmset(key, user) # 设置过期时间 r.expire(key, cls.expired_time)
def verify_message(cls, phone, code): # 验证短信验证码是否正确 if not cls.__wrong_count(phone): return 3 else: code_keys = r.keys(pattern=cls.key_set + ':' + str(phone) + ':[0123456789]*') for key in code_keys: code_val = r.hgetall(key) if str(code) == code_val['num']: r.delete(key) return 0 else: code_val['wrong_count'] = str( int(code_val['wrong_count']) + 1) if int(code_val['wrong_count']) >= 3: r.delete(key) fail_key = cls.key_set + ':' + str( phone) + ':fail_count' fail_count = int(r.get(fail_key))\ if(r.get(fail_key)) else 0 r.set(fail_key, str(fail_count + 1)) else: r.hmset(key, code_val)
def _del_cache(cls): # 删除现有活动 if r.keys(pattern='home_act:*'): r.delete(*r.keys(pattern='home_act:*'))
def _del_cache(cls): # 删除现有活动 if r.keys(pattern='lottery:*'): r.delete(*r.keys(pattern='lottery:*'))
def _del_cache(cls): # 删除现有分类 if r.keys(pattern='category:*'): r.delete(*r.keys(pattern='category:*'))
def _del_cache(cls): # 删除现有分类 if r.keys(pattern='mine:*'): r.delete(*r.keys(pattern='mine:*'))
def _del_cache(cls): # 删除现有商品 if r.keys(pattern='group_good:*'): r.delete(*r.keys(pattern='group_good:*'))