|
|
@ -8,22 +8,48 @@ class ApiSeatLock: |
|
|
|
self.api = kwargs.get('api') |
|
|
|
self.api = kwargs.get('api') |
|
|
|
self.ip = kwargs.get('ip') |
|
|
|
self.ip = kwargs.get('ip') |
|
|
|
|
|
|
|
|
|
|
|
# def get_suggestion(self): |
|
|
|
def get_suggestion(self): |
|
|
|
# # play_id |
|
|
|
# play_id |
|
|
|
# request_api_play = {'name': '3.1.5 获取放映计划列表', 'path': 'cinema/plays'} |
|
|
|
request_api_play = {'name': '3.1.5 获取放映计划列表', 'path': 'cinema/plays'} |
|
|
|
# redis_key_api_play = f'dspt_api_{self.ip}_{self.member_type}_{request_api_play["path"]}' |
|
|
|
redis_key_api_play = f'dspt_api_{self.ip}_{self.member_type}_{request_api_play["path"]}' |
|
|
|
# result_play, _format_play, redis_data_play = get_data_from_redis(redis_key_api_play) |
|
|
|
result_play, _format_play, redis_data_play, _timestamp_play = get_data_from_redis(redis_key_api_play) |
|
|
|
# # seat_id |
|
|
|
# seat_id |
|
|
|
# request_api_seat = {'name': '3.1.8 获取某场次座位状态', 'path': 'play/seat-status'} |
|
|
|
request_api_seat = {'name': '3.1.8 获取某场次座位状态', 'path': 'play/seat-status'} |
|
|
|
# redis_key_api_seat = f'dspt_api_{self.ip}_{self.member_type}_{request_api_seat["path"]}' |
|
|
|
redis_key_api_seat = f'dspt_api_{self.ip}_{self.member_type}_{request_api_seat["path"]}' |
|
|
|
# result_seat, _format_seat, redis_data_seat = get_data_from_redis(redis_key_api_seat) |
|
|
|
result_seat, _format_seat, redis_data_seat, _timestamp_seat = get_data_from_redis(redis_key_api_seat) |
|
|
|
# if result: |
|
|
|
if result_play and result_seat: |
|
|
|
# play_data = random.choice(redis_data) |
|
|
|
play_data = random.choice(redis_data_play) |
|
|
|
# play_id = play_data['id'] |
|
|
|
seat_data = random.choice(redis_data_seat) |
|
|
|
# return [{'param': 'play_id', 'value': play_id, 'is_checked': True, 'result': True}] |
|
|
|
seat_id = '' |
|
|
|
# else: |
|
|
|
if isinstance(seat_data, dict): |
|
|
|
# # 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 |
|
|
|
seat_id = seat_data['cineSeatId'] |
|
|
|
# return [ |
|
|
|
if isinstance(seat_data, list): |
|
|
|
# {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': True}] |
|
|
|
seat_id = ','.join([seat['cineSeatId'] for seat in seat_data]) |
|
|
|
|
|
|
|
return [{'param': 'play_id', 'value': play_data['id'], 'is_checked': True, 'result': True}, |
|
|
|
|
|
|
|
{'param': 'play_update_time', 'value': play_data['cineUpdateTime'], 'is_checked': True, |
|
|
|
|
|
|
|
'result': True}, |
|
|
|
|
|
|
|
{'param': 'seat_id', 'value': seat_id, 'is_checked': True, 'result': True}] |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
# 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 |
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
{'param': 'play_id', 'value': redis_data_play + request_api_play["name"], 'is_checked': True, |
|
|
|
|
|
|
|
'result': True}, |
|
|
|
|
|
|
|
{'param': 'play_update_time', 'value': redis_data_play + request_api_play["name"], 'is_checked': True, |
|
|
|
|
|
|
|
'result': True}, |
|
|
|
|
|
|
|
{'param': 'seat_id', 'value': redis_data_seat + request_api_seat["name"], 'is_checked': True, |
|
|
|
|
|
|
|
'result': True} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_timestamp(self): |
|
|
|
|
|
|
|
# play_id |
|
|
|
|
|
|
|
request_api_play = {'name': '3.1.5 获取放映计划列表', 'path': 'cinema/plays'} |
|
|
|
|
|
|
|
redis_key_api_play = f'dspt_api_{self.ip}_{self.member_type}_{request_api_play["path"]}' |
|
|
|
|
|
|
|
result_play, _format_play, redis_data_play, _timestamp_play = get_data_from_redis(redis_key_api_play) |
|
|
|
|
|
|
|
# seat_id |
|
|
|
|
|
|
|
request_api_seat = {'name': '3.1.8 获取某场次座位状态', 'path': 'play/seat-status'} |
|
|
|
|
|
|
|
redis_key_api_seat = f'dspt_api_{self.ip}_{self.member_type}_{request_api_seat["path"]}' |
|
|
|
|
|
|
|
result_seat, _format_seat, redis_data_seat, _timestamp_seat = get_data_from_redis(redis_key_api_seat) |
|
|
|
|
|
|
|
# 处理混合结果 |
|
|
|
|
|
|
|
if result_play and result_seat: |
|
|
|
|
|
|
|
return _timestamp_play if _timestamp_play > _timestamp_seat else _timestamp_seat |
|
|
|
|
|
|
|
return 0 |
|
|
|