Sure, I can explain the ending.
The 17-year-old Yu Qi (who was in the 27-year-old body) returned to her original body with many of the memories of the 'future' lost. Before that happens, she writes a note to herself saying not to let Yuan Zi eat sweets. They continue on in the original timeline but presumably the future for them will be greatly altered and much happier.
The 27-year-old Yu Qi (who was in the 17-year-old body) returned to her original body with her changes to the timeline permanently in place and all memories of the old timeline lost. This means that she and Yuan Zi met in high school instead of college and Yu Qi insisted she not eat sweets any longer.
So, in both new timelines, both of them are alive and Yuan Zi doesn't develop diabetes presumably (at least not in her early 20s - age is also a large risk factor and with values that high as a teenager, she probably will develop it eventually).
As for the mechanism of messing around with time - we don't know a lot. The only aspect the author explains (mostly through images) is that the 27-year-old Yu Qi can 'stop' the process by intentionally trying to tell somebody the truth (similar to the protagonist of Re:Zero). The first time this happens, she passes out. The second time this happens, with more determination (she wanted it to end now), is when this ending happens.