from Utils.sql_handler import test_env_conn from TestData.inbox.ticketDetail_test_data import ticketDetailData final_chat_select_sql = f'select * from `im_room` where first_send_uid = {ticketDetailData.customerId} and is_ignore = 0 and room_id != {ticketDetailData.roomId} order by last_msg_time desc' final_chat_select_result = test_env_conn.select_many_value(sql=final_chat_select_sql) final_chat_num = len(final_chat_select_result) first_chat = final_chat_select_result[0] first_chat_id = first_chat['room_id'] first_chat_allocation_name = first_chat['allocation_name'] first_chat_allocation_avatar = first_chat['allocation_avatar'] first_chat_allocation_uid = first_chat['allocation_uid'] first_chat_last_msg = first_chat['last_msg_context'] first_chat_close_time = first_chat['close_time'] setattr(ticketDetailData, 'first_chat_id', str(first_chat_id)) setattr(ticketDetailData, 'first_chat_allocation_name', first_chat_allocation_name) setattr(ticketDetailData, 'first_chat_allocation_avatar', first_chat_allocation_avatar) setattr(ticketDetailData, 'first_chat_allocation_uid', first_chat_allocation_uid) setattr(ticketDetailData, 'first_chat_last_msg', first_chat_last_msg) setattr(ticketDetailData, 'first_chat_close_time', str(first_chat_close_time)) setattr(ticketDetailData, 'final_chat_num', final_chat_num)