Unfortunately for the Chinese government, the sex business is very closely related with corruption, so the ongoing "war against corruption" really makes it difficult for the sex industry to get a foothold in China.
Shanghai used to be one of the few places, where it was still relatively easy to find any fun. However in the end of 2017, police has closed off a lot of businesses making it, once again, extremely difficult to find decent places.
So, when looking for your relief, keep in mind that some activities include a high risk to get caught by the law enforcement. You will always be at a certain level of risk, when visiting a Sauna or Massage parlor, that the Police will 'raid' the place unexpectedly and arrest you for buying services from a prostitute.
Any kind of paid sexual services is against the Chinese law and will be seriously fined. This can range from a few thousand RMB, up to 20 days jail and a retraction of your current visa and being blacklisted from getting a visa in the future. An escort girl, if she get's arrested, can also receive a fine and end up in jail for up to two weeks. Guys and girls who help introduce prostitutes to customers, can receive around five years of jail time, while people who actively organize prostitution can receive up to ten years of jailtime.
If you are looking for the safest option to still be able to enjoy these kind of services, it would be to request the services from an Independent Outcall Escort. These escort girls might be a bit pricier than going to the Bar or Sauna, but you will be doing your activities in the comfort of your own hotel or apartment. Hotel employees don't really care about what you do in your room, as long as you do not break things, be extremely noisy or leave a huge mess. They don't want to have any form of trouble.