Answered by ZUPAN | Nov. 24, 2019 10:58
Your first stop in Shanghai is eligible for 144 hour visa free transit because you have an eligible itinerary:
Bangkok - Shanghai - Japan
Anyway, your second arrival in China, after your cruise is not eligible for 144 hour visa free transit because you plan to have two consecutive stops within mainland China (Shanghai and Beijing) and that is not allowed. You can perform such an itinerary only if your entire itinerary could be done within 24 hours.
If you want to retain actual itinerary you are supposed to obtain a Chinese tourist (L) visa in advance. If you plan to obtain your Chinese visa in Thailand, you need just a single entry visa, but you should be very focused and explain to the Chinese immigration authorities, during your first stop in China, that you will use your single entry visa after you return from the cruise and that you intend to travel on 144 hour visa free transit during your first stay in Shanghai. Otherwise, if you don't explain that upon your arrival, an immigration official could collect your single entry visa and that means that you cannot perform your intended itinerary after your cruise is over.