admin
2019-11-12 0cf8c0bf5649b0b7269f78f6eae7c09cffea75cd
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java
@@ -14,6 +14,7 @@
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD.FloatADTypeEnum;
import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.entity.common.JumpDetailV2;
@@ -79,8 +80,7 @@
   @Resource
   private RedPackWinNewUserService redPackWinNewUserService;
   /**
    * s 首页配置信息
    * 
@@ -145,7 +145,6 @@
      out.print(JsonUtil.loadTrueResult(data));
   }
   /**
    * s 首页配置信息
    * 
@@ -156,42 +155,61 @@
   public void getHomeConfigNew(AcceptData acceptData, Long uid, PrintWriter out) {
      if (uid != null && uid == 0L)
         uid = null;
      // 活动弹框
      List<FloatAD> listAD = null;
      if (redPackWinNewUserService.verifyHasReward(uid)) {
         listAD = floatADService.getValidByPosition(FloatAD.POSITION_INDEX);
      } else {
         listAD = floatADService.getValidCommonByPosition(FloatAD.POSITION_INDEX);
      }
      List<FloatAD> listAD = new ArrayList<FloatAD>();
      List<FloatImgDetailVO> listVO = new ArrayList<FloatImgDetailVO>();
      if (listAD != null && !listAD.isEmpty()) {
         for (FloatAD floatAD: listAD) {
            JumpDetailV2 jumpDetail = floatAD.getJumpDetail();
            if (jumpDetail != null) {
               jumpDetail = jumpDetailV2Service.selectByPrimaryKey(jumpDetail.getId());
               if (jumpDetail != null) {
                  jumpDetail.setNeedLogin(floatAD.isJumpNeedLogin());
               }
            }
            FloatImgDetailVO floatImgVO = new FloatImgDetailVO();
            floatImgVO.setId(floatAD.getId().toString());
            floatImgVO.setImg(floatAD.getPicture());
            floatImgVO.setParams(floatAD.getParams());
            floatImgVO.setJumpDetail(jumpDetail);
            floatImgVO.setShowTime(floatAD.getShowMode());
            floatImgVO.setAccountLogin(floatAD.isJumpNeedLogin());
            listVO.add(floatImgVO);
         }
      }
      
      List<FloatAD> list = floatADService.getValidByPosition(FloatAD.POSITION_INDEX);
      if (list != null && !list.isEmpty())
         listAD.addAll(list);
      for (int i = 0; i < listAD.size(); i++) {
         FloatAD floatAD = listAD.get(i);
         FloatADTypeEnum typeEnum = floatAD.getTypeEnum();
         if (typeEnum == FloatADTypeEnum.newUserRedPack && !redPackWinNewUserService.verifyHasReward(uid)) {
            listAD.remove(i);
            i--;
         }
         JumpDetailV2 jumpDetail = floatAD.getJumpDetail();
         if (jumpDetail != null) {
            jumpDetail = jumpDetailV2Service.selectByPrimaryKey(jumpDetail.getId());
            if (jumpDetail != null) {
               jumpDetail.setNeedLogin(floatAD.isJumpNeedLogin());
            }
         }
         FloatImgDetailVO floatImgVO = new FloatImgDetailVO();
         floatImgVO.setId(floatAD.getId().toString());
         floatImgVO.setImg(floatAD.getPicture());
         floatImgVO.setParams(floatAD.getParams());
         floatImgVO.setJumpDetail(jumpDetail);
         floatImgVO.setShowTime(floatAD.getShowMode());
         floatImgVO.setAccountLogin(floatAD.isJumpNeedLogin());
         if (floatAD.getPlaySound() != null)
            floatImgVO.setPlaySound(floatAD.getPlaySound());// 默认都播放音效
         else
            floatImgVO.setPlaySound(false);
         listVO.add(floatImgVO);
      }
      JSONObject data = new JSONObject();
      data.put("listAD", JsonUtil.getApiCommonGson().toJson(listVO));
      // 领券帮助链接,1.5.2后生效
      String couponHelp = configService.get("taobao_coupon_help");
      data.put("couponHelpUrl", couponHelp);
      // 判断新老用户 显示热门功能按钮滑动
      UserActiveLog da = null;
      if (uid != null)
         da = userActiveLogService.getFirstActiveInfo(uid);
      // 新人
      if (da == null || (System.currentTimeMillis() - da.getCreateTime().getTime()) <= 1000 * 60 * 60 * 24 * 15L) {
         data.put("userTimeType", 0);
      } else {// 老人
         data.put("userTimeType", 1);
      }
      // 是否显示热门功能按钮
      String platform = acceptData.getPlatform();
@@ -199,8 +217,7 @@
            configService.getByVersion("hot_function_url", platform, Integer.parseInt(acceptData.getVersion())));
      out.print(JsonUtil.loadTrueResult(data));
   }
   /**
    * 消息中心弹框
    * 
@@ -303,14 +320,15 @@
         data.put("baichuan", false);// 不需要采用阿里百川的方式加载webview
         data.put("goodsDetail", false);// 不需要拦截商品详情
      }
//TODO 前端需要处理
//      if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
//         JSONObject js = new JSONObject();
//         String jsStr = configService.get("url_extract_id");
//         String md5 = StringUtil.Md5(jsStr);
//         js.put("md5", md5);
//         data.put("js", js);
//      }
      // TODO 前端需要处理
      // if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(),
      // acceptData.getVersion())) {
      // JSONObject js = new JSONObject();
      // String jsStr = configService.get("url_extract_id");
      // String md5 = StringUtil.Md5(jsStr);
      // js.put("md5", md5);
      // data.put("js", js);
      // }
      out.print(JsonUtil.loadTrueResult(data));
   }