1. 优化代码,把特殊处理的代码从两处变为一处

main
RogerWork 3 months ago
parent d0991cac01
commit c108d68073
  1. 4
      dspt_api/util/api/seat_lock.py
  2. 3
      dspt_api/util/random_params.py

@ -20,10 +20,6 @@ class ApiSeatLock:
if result_play and result_seat: if result_play and result_seat:
play_data = random.choice(redis_data_play) play_data = random.choice(redis_data_play)
seat_data = random.choice(redis_data_seat) seat_data = random.choice(redis_data_seat)
seat_id = ''
if isinstance(seat_data, dict):
seat_id = seat_data['cineSeatId']
if isinstance(seat_data, list):
seat_id = ','.join([seat['cineSeatId'] for seat in seat_data]) seat_id = ','.join([seat['cineSeatId'] for seat in seat_data])
return [{'param': 'play_id', 'value': play_data['id'], 'is_checked': True, 'result': True}, return [{'param': 'play_id', 'value': play_data['id'], 'is_checked': True, 'result': True},
{'param': 'play_update_time', 'value': play_data['cineUpdateTime'], 'is_checked': True, {'param': 'play_update_time', 'value': play_data['cineUpdateTime'], 'is_checked': True,

@ -25,6 +25,9 @@ def random_params(_user_info, _handle_data):
else: else:
_user_data = _handle_data['res']['data'] _user_data = _handle_data['res']['data']
if len(_user_data) > 0: if len(_user_data) > 0:
if _user_info["api"] == 'play/seat-status':
data['user_data'] = [[random.choice(_user_data)]]
else:
data['user_data'] = [random.choice(_user_data)] data['user_data'] = [random.choice(_user_data)]
redis_conn.set(redis_key_api, json.dumps(data)) redis_conn.set(redis_key_api, json.dumps(data))
else: else:

Loading…
Cancel
Save