yujian
2020-05-06 a338d86bcaf17f2ba9296a601cdbda4d3e9baae0
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java
@@ -2,24 +2,22 @@
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.help.AppPageNotification;
import com.yeshi.fanli.service.inter.help.AppPageNotificationService;
import com.yeshi.fanli.service.manger.AppUpdateManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.VersionUtil;
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.JsonUtil;
@Controller
@RequestMapping("api/v1/help")
@@ -27,6 +25,9 @@
   @Resource
   private AppPageNotificationService appPageNotificationService;
   @Resource
   private AppUpdateManager appUpdateManager;
   /**
    * 获取app页面的通知
@@ -42,9 +43,12 @@
         return;
      }
      AppPageNotification ap = appPageNotificationService.getAppPageNotificationByTypeCache(type);
      if ("home".equalsIgnoreCase(type)
            && VersionUtil.smallerThan_1_5_1(acceptData.getPlatform(), acceptData.getVersion()) && ap != null) {
      String platform = acceptData.getPlatform();
      String version = acceptData.getVersion();
      AppPageNotification ap = appPageNotificationService.getValidNotificationByTypeCache(type, platform,
            Integer.parseInt(version));
      if ("home".equalsIgnoreCase(type) && VersionUtil.smallerThan_1_5_1(platform, version) && ap != null) {
         AppPageNotification no = new AppPageNotification();
         no.setContentUrl("");
         no.setMd5("111111111111111111");
@@ -53,7 +57,7 @@
         no.setType(ap.getType());
         no.setUpdateTime(ap.getUpdateTime());
         no.setCanClose(false);
         no.setContent("尊敬的用户,为更加准确高效的为你返利、省钱,请升级到返利券最新版本");
         no.setContent(String.format("尊敬的用户,为更加准确高效的为你返利、省钱,请升级到%s最新版本", Constant.getAppName(platform, version)));
         Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
         out.print(JsonUtil.loadTrueResult(gson.toJson(no)));
         return;
@@ -70,40 +74,9 @@
   @RequestMapping(value = "updateApp")
   public void updateApp(AcceptData acceptData, PrintWriter out) {
      Map<String, String> params = new HashMap<>();
      if ("android".equalsIgnoreCase(acceptData.getPlatform())) {// android更新
         acceptData.setVersion("10");
         params.put("method", "update");
         params.put("Platform", "Android");
         params.put("Version", acceptData.getVersion());
         params.put("device  ", acceptData.getDevice());
         params.put("time", System.currentTimeMillis() + "");
         params.put("Package", acceptData.getPackages());
         params.put("device", acceptData.getDevice());
         params.put("platform", "Android");
         params.put("key", "a3f390d88e4c41f2747bfa2f1b5f87db");
         params.put("versionCode", acceptData.getVersion() + "");
         String url = "http://update.yeshitv.com:8090/update/update";
         String result = HttpUtil.post(url, params, null);
         try {
            out.print(new String(result.getBytes("ISO-8859-1"), "UTF-8"));
         } catch (UnsupportedEncodingException e) {
            out.print(result);
         }
      } else {// IOS更新
         params.put("method", "update");
         params.put("Platform", "IOS");
         params.put("Version", acceptData.getVersion());
         params.put("device  ", acceptData.getDevice());
         params.put("time", System.currentTimeMillis() + "");
         params.put("Package", acceptData.getPackages());
         params.put("device", acceptData.getDevice());
         params.put("platform", "IOS");
         params.put("key", "32bb90e8976aab5298d5da10fe66f21d");
         params.put("versionCode", acceptData.getVersion() + "");
      }
      String url = "http://update.yeshitv.com:8090/update/update";
      String result = HttpUtil.post(url, params, null);
      if (Constant.IS_TEST)
         acceptData.setVersion("20");
      String result = appUpdateManager.getUpdateInfoCache(acceptData);
      try {
         out.print(new String(result.getBytes("ISO-8859-1"), "UTF-8"));
      } catch (UnsupportedEncodingException e) {