def call_captcha(func, *args, **kwargs): log.info('req captcha func=%s|args=%s|kwargs=%s', func, args, kwargs) client = ThriftClient(CAPTCHA_SERVER, CaptchaServer) client.raise_except = True ret = client.call(func, *args, **kwargs) log.info('req captcha func=%s|ret=%s', func, ret) return ret
def call_fenqi_api(func, *args, **kwargs): log.info('<<<< req fenqi_api func=%s | args=%s | kwargs=%s', func, args, kwargs) client = ThriftClient(FENQI_SERVER, FenqiServer, framed=True) client.raise_except = True ret = client.call(func, *args, **kwargs) log.info('>>>> resp fenqi_api func=%s | result=%s', func, ret) return ret
def start(_ds): now = int(time.time()) userids = [] with get_connection('wxmp_customer') as db: _sql = " select appid,nick_name from `mp_conf` where status = 1 and appid != '' " userids = db.query(_sql) if not userids: return today = datetime.date.today() yesterday = _ds _table_name = "record_%s" % str(str(yesterday).replace("-", ""))[0:6] client = ThriftClient(config.WX_SERVER, QFMP, framed=False) client.raise_except = True #获取微信数据 for xy in userids: try: _data = client.call('access_token', xy['appid']) _token = _data.access_token #总粉丝数 r = Urllib2Client().get( "https://api.weixin.qq.com/cgi-bin/user/get?access_token=%s&next_openid=" % _token) r_j = json.loads(r) xy['allfan'] = r_j["total"] #新增粉丝数 _params = { "begin_date": str(yesterday).replace("-", ''), "end_date": str(yesterday).replace("-", '') } r = Urllib2Client().post_json( "https://api.weixin.qq.com/datacube/getusersummary?access_token=%s" % _token, _params, escape=False) r_j = json.loads(r) newfan = 0 cuser = 0 for gcc in r_j['list']: if gcc['user_source'] == 51: newfan = gcc['new_user'] cuser = gcc['cancel_user'] auser = newfan - cuser xy['newfan'] = newfan xy['cuser'] = cuser xy['auser'] = auser except Exception, e: print e xy['allfan'] = 0 xy['newfan'] = 0 xy['cuser'] = 0 xy['auser'] = 0
def finance_client(func, *args, **kw): try: client = ThriftClient(config.FINANCE_SERVER, Finance) return client.call(func, *args, **kw) except ServerException as e: raise ThirdError(e.error_msg) except: log.warn(traceback.format_exc()) raise ThirdError('第三方服务错误')
def org_client(func, *args, **kw): try: client = ThriftClient(config.ORG_API_SERVER, OrgServer, framed=True) return client.call(func, *args, **kw) except QudaoException as e: raise ThirdError(e.respmsg) except: log.warn(traceback.format_exc()) raise ThirdError('第三方服务错误')
def POST(self): d = self.req.input() userid = d.get('userid', '').strip() type = d.get('type', '').strip() name = d.get('name', '').strip() licensenumber = d.get('licensenumber', '').strip() licensephoto = d.get('licensephoto', '').strip() checkstand = d.get('checkstand', '').strip() checkin = d.get('checkin', '').strip() sls_uid = int(self.user.userid) usertype = d.get('usertype', '').strip() nickname = d.get('nickname', '').strip() shopphoto = d.get('shopphoto', '').strip() if not usertype: usertype = 0 if (not userid) or (not type) or (not name) or (not licensenumber) or \ (not licensephoto) or (not checkstand) or (not checkin) or (not nickname) or (not shopphoto): raise ParamError('参数错误') client = ThriftClient(config.AUDIT_SERVERS, AuditServer) client.raise_except = True ret = client.call('update_sales', userid=int(userid), type=int(type), name=str(name), licensenumber=str(licensenumber), licensephoto=str(licensephoto), checkstand=str(checkstand), checkin=str(checkin), sls_uid=sls_uid, nickname=nickname, usertype=int(usertype), shopphoto=shopphoto) if ret == 0: return self.write(success({})) else: raise ParamError('覆盖商户信息失败')
def thrift_callex_framed(server_config, mod, func, *args, **kwargs): client = ThriftClient(server_config, mod, framed=True) client.raise_except = True return client.call(func, *args, **kwargs)
def GET(self): uname = self.get_cookie('uname') data = {} data['uname'] = uname conf_name = APP_CUSTOM # app_id = 48 # conf_id = 13 # conf_dict = get_app_conf_dict(app_id, conf_id, app_conf=conf_name) # print conf_dict import redis # 连接,可选不同数据库 r = redis.Redis(host='172.100.102.101', port=6379, db=7) data = {'id': '123'} r.hset('rekey', 123, data) all_audits = r.hgetall('rekey') # for (d,x) in all_audits.items(): # print x # ------------------------------------------- # 看信息 #keys = r.keys() #print type(keys) #print r.exists('appcustom_appid12_confid39_dict') #print r.hget('appcustom_appid12_confid39_dict') # with get_connection('qf_core') as db: # profiles = db.select( # table='profile', # fields='userid', # where={'userid': (' = ',10516)} # ) # userids = [i['userid'] for i in profiles or []] # print len(userids) #keys = r.keys() #print type(keys) #[{'addr': ('172.100.101.107', 6900), 'timeout': 2000}, ] #client = ThriftClient([{'addr': ('127.0.0.1',7100), 'timeout': 6000}, ], AuditServer) #client = ThriftClient([{'addr': ('172.100.101.110', 7100), 'timeout': 6000}, ], AuditServer) #client = ThriftClient([{'addr': ('172.100.101.107', 6900), 'timeout': 2000}, ], ApolloServer) _info = '{"usertype":"1","mobile":"18650005057","nickname":"萌宠乐园宠物用品店","licensenumber":"92350205MA2YNJ287E","legalperson":"法人代表","idnumber":"350204199411150028","dishonestyinfo":"0","idnumbertime":"2017-01-01到2017-01-09","src":"签约宝","shoptype":"分店","otherid":"业务员","nickname":"收据名称","mcc":"1005","shop_province":"北京","shop_city":"北京","shop_address":"厦门市沧林东一里573号","telephone":"1231231","email":"*****@*****.**","banktype":"1","bankuser":"******","account_province":"北京","account_city":"北京","headbankname":"北京银行","bankname":"北京银行","bankcode":"12312","channel_type":"合伙人","salesmanname":"你好","salesmanname":"你好","channel_name":"你好","channel_province":"北京","channel_city":"北京","memo":"无","risk_level":"123","risk_level":"123","alipay_ratio": 0.0038,"qqpay_ratio": 0.0038,"tenpay_ratio": 0.0038,"jdpay_ratio": 0.006,"fee_ratio": 0.006,"credit_ratio": 0.006,"bankaccount":6217231510001346967,"cardstart":"2017-03-05","cardend":"2017-05-01","usertags":["123","456"],"salesman_memo":"234","audit_record":[{"operator":"0","audit_result":"自动审核成功","audit_time":"2017-10-01","audit_memo":"自动审核成功"}],"piclist":[{"name":"idcardfront","src":"http://pic.qfpay.com/userprofile/205/2053691/middle_5fb259576ad455e4949f6767f20ca297.jpg"},{"name":"idcardback","src":"http://pic.qfpay.com/userprofile/205/2053691/middle_5fb259576ad455e4949f6767f20ca297.jpg"}]}' #client.raise_except = True #re = client.call('add_audit', Audit(audit_type='signup',userid=10516,groupid=10,info=_info)) _m = '{"nickname":"123","usertags":["777"],"audit_record":{"operator":"123","audit_result":"123","audit_time":"123","audit_memo":"123"}}' #re = client.call('audit_api',id='6366572138127548259',type='4',modify=_m) #re = thrift_callex([{'addr': ('172.100.101.110',7100), 'timeout': 6000}, ], AuditServer, 'ping') #client = ThriftClient([{'addr': ('172.100.108.65',7100), 'timeout': 16000}, ], AuditServer,framed=False) _info = {} _piclist = [] # for i in range(20): # _piclist.append({"name": str('123'), "src": str('至'), "cert_type": str(100)}) # _info["piclist"] = _piclist # _info["nickname"] = '123123你好' # _info["mcc"] = "12313" # _info["src"] = u"12313" # _info["tenpay_ratio"] = "12313" # _info["alipay_ratio"] = "12313" # _info = byteify(_info) # _info = json.dumps(_info,ensure_ascii=False) #测试成都 #101.204.228.105:6221 # from qfcommon.thriftclient.weifutong.ttypes import WechatConf,WechatConfUpdateItem,WechatConfUpdateArg,CHNLCODE # # client = ThriftClient([{'addr':('101.204.228.105',6221),'timeout': 8000},],weifutong,framed=True) # client.raise_except = True # s_list = [] # _wc = WechatConf(jsapipath='["http://123"]',sub_appid='wx087a3fc3f3757766',subscribe_appid='wx087a3fc3f3757766') # _va = WechatConfUpdateItem(userid=21006662,wechat_conf=_wc,chnlcode=9) # s_list.append(_va) # client.call('wechatconf_update',arg=WechatConfUpdateArg(batch_id='1231234567899090123',src='audit.1',wechatconf_list=s_list)) client = ThriftClient([{'addr': ('172.100.101.110', 7100), 'timeout': 8000}, ], AuditServer, framed=False) #client = ThriftClient([{'addr': ('172.100.101.107', 7200), 'timeout': 8000}, ], AuditServer, framed=False) #client = ThriftClient([{'addr': ('127.0.0.1',7100), 'timeout': 6000}, ],AuditServer, framed=False) # client = ThriftClient([{'addr': ('192.10.2.150',7201), 'timeout': 6000}, ], AuditServer, framed=False) # client.raise_except = True list = client.call('app_api',[704263],5) print list #测试威富通通道结果 from qfcommon.thriftclient.weifutong import weifutong from qfcommon.thriftclient.weifutong.ttypes import CHNLCODE, QueryMeta, AddMchntQueryArg TONGDAOS = [CHNLCODE.CITIC, CHNLCODE.ZXWC, CHNLCODE.FUIOU, CHNLCODE.HUIYI, CHNLCODE.HYQK, CHNLCODE.WANGSHANG, CHNLCODE.DAZEPOINT, CHNLCODE.YEEPAY, CHNLCODE.HUITONG, CHNLCODE.WEIXIN, CHNLCODE.FUIOU_LVZHOU, CHNLCODE.HELIBAO ] client = ThriftClient([{'addr': ('192.10.2.150', 6221), 'timeout': 2000}, ], weifutong, framed=True) client.raise_except = True _uids = [2202982] merchant_dic = {} queryMeta = QueryMeta() queryMeta.offset = 0 queryMeta.count = 10 queryMeta.orderby = 'utime desc' addMchntQueryArg = AddMchntQueryArg() addMchntQueryArg.query_meta = queryMeta addMchntQueryArg.userid_list = _uids addMchntQueryArg.chnlcode_list = TONGDAOS record_ids_l = client.call('addmchnt_query', addMchntQueryArg) addMchntRecord_d = client.call('addmchnt_get', record_ids_l) l1 = [] for (key, ve) in addMchntRecord_d.items(): l1.append({'state':ve.state,'errmsg':ve.errmsg,'chnlcode':ve.chnlcode,'ctime':ve.ctime}) l1.sort(key=lambda k: (k.get('ctime', 0)),reverse=True) l4 = [] l4.append(l1[0]) for dict in l1: # print len(l4) k = 0 for item in l4: # print 'item' if dict['chnlcode'] != item['chnlcode']: k = k + 1 # continue else: break if k == len(l4): l4.append(dict) print l1 #print addMchntRecord_d[6389763976217181206].chnlcode #client = ThriftClient([{'addr': ('172.100.101.107', 7200), 'timeout': 8000}, ], AuditServer, framed=False) #client = ThriftClient([{'addr': ('127.0.0.1',7100), 'timeout': 6000}, ], AuditServer, framed=False) #re = client.call('ping') #re = client.call('add_audit', Audit(audit_type='signup', userid=10516, groupid=10,info=_info)) #client = ThriftClient([{'addr':('192.30.2.173', 8001), 'timeout':50000}], QudaoServer, framed=True) #client.raise_except = True #QudaoBaseInfo = client.call('qd_get_hierarchy',[1764616,1778227],1) #list = client.call('app_api',[21006662]) #print list['wx087a3fc3f3757766'].jsapipath #from qfcommon.thriftclient.audit.ttypes import AppInfo #AppInfo = list[0] #print AppInfo.pay_appid #print AppInfo.appid #print AppInfo.jsapipath #print AppInfo.uid # _zhi = {'id': 1, 'type': 123} # # json_data = json.dumps(_zhi) # # r.lpush("1",json_data) # # data1 = r.brpop("1") # # print data1 #r.set("name",'123') # with get_connection('open_user') as db: # userids = db.select( # table='amchnl_bind', # fields='subscribe_appid,ctime') # from qfcommon.thriftclient.qf_wxmp import QFMP # from qfcommon.thriftclient.qf_wxmp.ttypes import WXToken # # weixin_server = [{'addr': ('192.30.2.168', 6150), 'timeout': 8000},] # weixin_server = [{'addr': ('172.100.101.107', 6120), 'timeout': 8000},] # # client = ThriftClient(weixin_server,QFMP,framed=False) # client.raise_except = True # _data = client.call('access_token','wx087a3fc3f3757766') # # print _data.access_token return json.dumps({'data': '123'}, ensure_ascii=False)
def thrift_callex(server, thriftmod, funcname, *args, **kwargs): client = ThriftClient(server, thriftmod) client.raise_except = True return client.call(funcname, *args, **kwargs)
def thrift_call(thriftmod, funcname, server, *args, **kwargs): client = ThriftClient(server, thriftmod) return client.call(funcname, *args, **kwargs)
def GET(self): customer_id = self.get_cid() userid = hids.decode(self.req.input().get('userid')) if not userid: raise ParamError('商户userid为空') userid = userid[0] openid = self.req.input().get('openid', '') ret = dict() # 消费者信息 ret['profile'] = {} profile = get_profile(customer_id) ret['profile']['avatar'] = profile['avatar'] ret['profile']['is_new'] = self.be_member(userid, customer_id) ret['profile']['customer_id'] = hids.encode(customer_id) ret['profile']['is_submit'] = self.get_submit_info(userid, customer_id) # 活动信息 ret['actvs'] = {} ret['actvs']['privilege'] = self.get_privilege(userid) ret['actvs']['balance'] = self.get_balance(userid, customer_id) or 0 card = self.get_actv_card(userid, customer_id) or {} ret['actvs']['card'] = card.get('desc') ret['actvs']['card_actv_id'] = card.get('mp_id') # 店铺信息 bg_urls = config.CARDS_INFO_BG_URLS ret['shopinfo'] = {} ret['shopinfo']['mchnt_id'] = userid ret['shopinfo']['userid'] = hids.encode(int(userid)) ret['shopinfo']['bg_url'] = bg_urls[userid % 10 % len(bg_urls)] user = apcli_ex('findUserBriefById', userid) if user: ret['shopinfo']['address'] = user.address ret['shopinfo']['mobile'] = user.mobile ret['shopinfo']['shopname'] = user.shopname user_ext = apcli_ex('getUserExt', int(userid)) if user_ext: ret['shopinfo']['head_img'] = user_ext.head_img or '' ret['shopinfo']['logo_url'] = user_ext.logo_url or '' ret['shopinfo']['mobile'] = user_ext.contact or user.mobile # 实用门店 ret['shops'] = self.get_shops(userid) ret['shop_num'] = self._shop_num # 是否卡包信息 ret['wxcard'] = self.get_wxcard(userid, customer_id) or {} # 从weixin_card获取此openid,appid对应的卡包里的所有的卡券列表 # 如果cardid在里面则返回1, 不然异常情况或者不在都返回0 appid, card_id = '', '' if ret['wxcard']: appid = ret['wxcard']['appid'] card_id = ret['wxcard']['card_id'] if not appid: is_added = 0 card_code = '' else: # 如果前端没有给传openid,则先获取openid if not openid: try: openid = thrift_callex( config.OPENUSER_SERVER, QFCustomer, 'get_openid_by_wxappid_and_customid', wx_appid=appid, customid=customer_id) except CustomerError: is_added = 0 log.debug(traceback.format_exc()) if not openid: is_added = 0 card_code = '' else: client = ThriftClient(config.WXCARD_SERVERS, WXCard) card_code = client.call("get_cardcode_by_openid", openid=openid, card_id=card_id) try: card_list = client.call("get_card_list", openid, appid) if card_id: if card_id in card_list: is_added = 1 else: is_added = 0 else: is_added = 0 except WXCardError: log.debug(traceback.format_exc()) is_added = 0 ret['wxcard']['is_added'] = is_added # 获取用户领卡时候的code ret['wxcard']['code'] = card_code return self.write(success(ret))
def GET(self): d = self.req.input() page = d.get('page', 0) pagesize = d.get('pagesize', 10) userid = self.user.userid paging = (int(pagesize), int(pagesize) * int(page)) other = 'order by create_time desc limit {} offset {}'.format(*paging) ret = {'records': []} # 查询交易记录和消费品名称 records = [] titles = [] titles_dict = {} with get_connection_exception('qf_marketing') as db: records = db.select( table='record', fields=['customer_id', 'create_time', 'activity_id', 'xx_id'], where={ 'type': RECORD_STATUS_USE, 'xx_type': ACTIVITY_SHARE_TYPE_GOODS_COUPON, 'use_mchnt_id': userid, }, other=other) if not records: return self.write(success(ret)) act_ids = [record.get('activity_id') for record in records] titles = db.select(table='activity', fields=['title', 'id'], where={'id': ('in', act_ids)}) if not titles: raise ParamError('获取兑换商品失败') titles_dict = {title['id']: title['title'] for title in titles} # 查询消费者信息 cids = {i['customer_id'] for i in records} spec = json.dumps({'user_id': list(cids)}) client = ThriftClient(config.OPENUSER_SERVER, OpenUser) client.raise_except = True infos = [] try: infos = client.call('get_profiles', config.OPENUSER_APPID, spec) infos = {i.user_id: i.__dict__ for i in infos} except: log.warn(traceback.format_exc()) raise ThirdError('获取用户信息失败') # 整理信息 for i in records: cust_id = int(i['customer_id']) cust_info = infos.get(cust_id) or {} avatar_str = cust_info.get('avatar') or '' i['avatar_url'] = avatar_str.split(':', 1)[-1] i['gender'] = cust_info.get('gender') or 0 i['nickname'] = cust_info.get('nickname') or '微信支付顾客' i['exchange_time'] = i['create_time'].strftime('%H:%M:%S') i['goods_name'] = titles_dict.get(i.pop('activity_id'), '未知商品') i['exchange_code'] = hids.encode(i.pop('xx_id')) date_records = defaultdict(list) for i in records: t = i.pop('create_time').strftime(DATE_FMT) date_records[t].append(i) # 查询每日的交易数量 sql = ( 'select FROM_UNIXTIME(create_time, "%%Y-%%m-%%d") as date, ' 'count(id) as num from record ' 'where use_mchnt_id=%s and xx_type=%s and type=%d ' 'group by FROM_UNIXTIME(create_time, "%%Y%%m%%d") ' 'order by create_time desc' % (str(userid), ACTIVITY_SHARE_TYPE_GOODS_COUPON, RECORD_STATUS_USE)) data_infos = [] with get_connection('qf_marketing') as db: data_infos = db.query(sql) if not data_infos: raise ParamError('获取消费者数量失败') # 整理返回信息 ret = [] for i in data_infos: date = i['date'] tmp = {} tmp['date'] = i['date'] tmp['use_cnt'] = i['num'] tmp['customers'] = date_records.get(date) or [] ret.append(tmp) return self.write(success({'records': ret}))
def auto_apply(self, userid): data = self._data td, now = time.strftime(DATE_FMT), time.strftime(DATETIME_FMT) #新审核系统预设参数 info = {} #凭证参数 piclist = [] # 字典转码 def byteify(input): if isinstance(input, dict): return { byteify(key): byteify(value) for key, value in input.iteritems() } elif isinstance(input, list): return [byteify(element) for element in input] elif isinstance(input, unicode): return input.encode('utf-8') else: return input # 写入凭证 with get_connection('qf_mis') as db: d = {k: v.strip() for k, v in self.req.input().iteritems()} cert_types = UserDefine.CERT_TYPE for code in UserDefine.CERT_TYPE_LIST: if (code not in d or not d[code] or code not in cert_types): continue insert_data = { 'user_id': userid, 'upgrade_id': 0, 'apply_level': 0, 'cert_type': cert_types[code], 'name': code, 'submit_time': now, 'state': 1, 'input_state': 1, 'typist_user': 0, 'typist_time': now, 'imgname': d[code] } try: piclist.append({ "name": str(code), "src": str(d[code]), "cert_type": str(cert_types[code]) }) db.insert('mis_upgrade_voucher', insert_data) except: log.debug(traceback.format_exc()) info["piclist"] = piclist # 写入审核 version, platform = get_app_info( self.req.environ.get('HTTP_USER_AGENT', '')) src = ''.join([data['src'], platform, version]) idstatdate = (data['idstatdate'] if is_valid_date( data.get('idstatdate')) else td) idenddate = (data['idenddate'] if is_valid_date(data.get('idenddate')) else td) # mcc if data['cate'] == 'saleman' and not data['shoptype_id']: mcc = UserDefine.DEFAULT_SALEMAN_MCC else: mcc = UserUtil.get_mcc(data['shoptype_id']) apply_values = { 'user': int(userid), 'usertype': data['usertype'], 'legalperson': data['legalperson'] or data['bankuser'], 'name': data['name'], 'idnumber': data['idnumber'], 'idstatdate': idstatdate, 'idenddate': idenddate, 'telephone': data['landline'], 'idphoto1': data['idcardfront'], 'idphoto2': data['idcardback'], 'licenseend_date': td, 'licensephoto': '', 'taxenddate': td, 'longitude': covert(data['longitude'], float), 'latitude': covert(data['latitude'], float), 'address': ''.join([data['city'], data['location'], data['address']]), 'city': data['city'], 'province': data['province'], 'mobile': data['username'], 'headbankname': data['headbankname'], 'banktype': (2 if data['banktype'] == '2' else 1), 'bankname': data['bankname'], 'bankuser': data['bankuser'], 'bankProvince': data['bankprovince'], 'bankCity': data['bankcity'], 'bankaccount': data['bankaccount'].replace(' ', ''), 'state': 4, 'brchbank_code': data['bankcode'], 'mcc': mcc, 'nickname': data['shopname'], 'src': src, 'groupid': data['groupid'], 'srctype': UserDefine.SIGNUP_SRCTYPE_TINY, # 先固定为小微商户 'edu': 1, 'monthincome': 0, 'monthexpense': 0, 'tid': '', 'terminalcount': 1, 'last_admin': 0, 'allowarea': 0, 'needauth': 2, 'passcheck': 2, 'last_modify': now, 'post': '', 'provision': '', 'bankmobile': data['bankmobile'], 'monthtradeamount': 1, 'founddate': td, 'area': 100, 'payment_type': 1, 'rent_count': 0, 'pertradeamount': 1, 'rent_total_amt': -1, 'utime': now, 'uploadtime': now, "licensenumber": data.get("licensenumber", "") } # 获取上传费率 apply_values['ratio'] = self.get_ratio() or '' #收集后台需要的字段,摒弃废弃字段,后期只用下面的字段 userid = int(userid) groupid = int(data['groupid']) info["usertype"] = data['usertype'] info["mobile"] = data['username'] info["name"] = data['name'] info["cardstart"] = data['idstatdate'] info["cardend"] = data['idenddate'] info["legalperson"] = data['legalperson'] or data['bankuser'] info["src"] = data['src'] info["licensenumber"] = data['licensenumber'] info["mcc"] = mcc info["risk_level"] = "54" info["telephone"] = data['landline'] info["nickname"] = data['shopname'] info["bankaccount"] = data['bankaccount'].replace(' ', '') info["shop_province"] = data['province'] info["shop_city"] = data['city'] info["shop_address"] = data['address'] info["banktype"] = (2 if data['banktype'] == '2' else 1) info["bankname"] = data['bankname'] info["bankuser"] = data['bankuser'] info["headbankname"] = data['headbankname'] info["bankcode"] = data['bankcode'] fee = self.get_ratio() or '' if fee != '': fee = json.loads(fee) for (k, v) in fee.items(): info[k] = v info = byteify(info) info = json.dumps(info, ensure_ascii=False) #指定的灰度渠道下商户进入新审核逻辑 if groupid in config.NEW_AUDIT_GROUP: client = ThriftClient(config.AUDIT_SERVERS, AuditServer, framed=False) client.raise_except = True re = client.call( 'add_audit', audit_api(audit_type='signup', userid=userid, groupid=groupid, info=info)) #其他渠道的商户继续老的审核系统 else: with get_connection('qf_mis') as db: db.insert('apply', apply_values) self.set_cache_audit(userid, 2)