This study is a prospective, randomized, parallel-controlled, multicenter clinical study. The purpose of this study is to evaluate the efficacy and safety of nanocrystalline megestrol acetate combined with the first-line standard immunochemotherapy regimen compared with the first-line standard immunochemotherapy regimen in the treatment of anorexia and cachexia in advanced gastric and esophageal cancer. Eligible patients with gastric and esophageal cancer will be randomly assigned in a 1:1 ratio to the nanocrystalline megestrol acetate combination group (referred to as the megestrol acetate group for short) or the first-line standard immunochemotherapy group (referred to as the standard control group for short).