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

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

@ -20,11 +20,7 @@ class ApiSeatLock:
if result_play and result_seat:
play_data = random.choice(redis_data_play)
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},
{'param': 'play_update_time', 'value': play_data['cineUpdateTime'], 'is_checked': True,
'result': True},

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

Loading…
Cancel
Save