import time from dspt_api.util.general.handle_redis import get_data_from_redis class ApiEcardDetail: def __init__(self, **kwargs): self.member_type = kwargs.get('member_type') self.api = kwargs.get('api') self.ip = kwargs.get('ip') self.env = kwargs.get('env') self.cid = kwargs.get('cid') self.pid = kwargs.get('pid') def get_suggestion(self): _now = int(time.time() * 1000) # ecard_number request_api_ec_1 = {'name': '3.4.4 获取联名卡详情', 'path': 'ecard/detail'} redis_key_api_ec_1 = f'dspt_api_{self.ip}_{self.env}_{self.member_type}_{self.pid}_{self.cid}_{request_api_ec_1["path"]}' request_api_ec_2 = {'name': '3.4.2 联名卡开卡', 'path': 'ecard/regist'} redis_key_api_ec_2 = f'dspt_api_{self.ip}_{self.env}_{self.member_type}_{self.pid}_{self.cid}_{request_api_ec_2["path"]}' result_ec_1, _format_ec_1, redis_data_ec_1, _timestamp_ec_1 = get_data_from_redis(redis_key_api_ec_1) result_ec_2, _format_ec_2, redis_data_ec_2, _timestamp_ec_2 = get_data_from_redis(redis_key_api_ec_2) ecard_number_result = False ecard_number = False if result_ec_2: print('redis_data_ec_2', redis_data_ec_2) ecard_number_ec_2 = {'param': 'ecard_number', 'value': redis_data_ec_2['ecardNumber'], 'is_checked': True, 'result': True, 'timestamp': _timestamp_ec_2} ecard_number = ecard_number_ec_2 ecard_number_result = True if result_ec_1: ecard_number_ec_1 = {'param': 'ecard_number', 'value': redis_data_ec_1['ecardNumber'], 'is_checked': True, 'result': True, 'timestamp': _timestamp_ec_1} ecard_number = ecard_number_ec_1 ecard_number_result = True if result_ec_1 and result_ec_2: ecard_number = ecard_number_ec_1 if _timestamp_ec_1 >= _timestamp_ec_2 else ecard_number_ec_2 if ecard_number_result: return [ecard_number] else: return [{'param': 'ecard_number', 'value': redis_data_ec_1 + request_api_ec_1["name"], 'is_checked': True, 'result': True, 'timestamp': _now},] def get_timestamp(self): return int(time.time() * 1000)