It's simple. For this kind of economic problems, grasp this core view: there are only two participants, and the loss of one is the gain of the other. We just need to figure out how much money the villain made.
The scoundrel got the sugar and his change because he came empty-handed. The shopkeeper gave him 50-0.8* 17=36.4. The value of the sugar he got was 0.85 * 0.8 *17 =11.56. So the rogue earned 36.4+ 1 1.56 = 46. The shopkeeper lost 47.96 yuan.