often times when i trade with a villager, the villager will take my items, but not give me any emeralds back. these villagers have discounts too, but I end up paying the regular price. I believe these two bugs to be related to one another. (speculation) Perhaps the game is trying to charge the full and discounted price at the same time, with the full price winning out. as for the part where they take my item without giving anything in return, I've not the faintest idea of how to explain that.
Related issues
Comments

I'm on my own personal Minecraft realm
Duplicate of MC-148454. The GUI just displays the incorrect price, you actually don't lose any emeralds as opposed to single player mode (even if it looks like it).
Are you playing in singleplayer or on a server?