yujian
2019-04-22 b6c37e4bc38db88a360d0f2c6099183f9bb75bdc
fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
@@ -7,7 +7,6 @@
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Resource;
@@ -1572,24 +1571,33 @@
   @RequestMapping(value = "getRecommendIndex")
   public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) {
      try {
         // 专题模块
         JSONObject root = specialService.listCacheSpecialToIndex();
         //  1、专题模块
         JSONObject root = specialService.listCacheSpecialToIndex(acceptData);
         // 顶部轮播图
         // 2、顶部轮播图
         List<SwiperPicture> topPicList = getSwiperByCard("index_top");
         if (topPicList == null) {
            topPicList = new ArrayList<SwiperPicture>();
         }
         root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList));
         
         // 邀请、分享轮播图
         List<SwiperPicture> invitePicList = getInvitePicList(uid, acceptData);
         // 3、邀请有奖
         List<SwiperPicture> invitePicList = null;
         if ("ios".equalsIgnoreCase(acceptData.getPlatform())
               && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
            // 如果IOS当前版本处于审核状态就不返回
         } else {
            invitePicList = getSwiperByCard("index_invite");
         }
         if (invitePicList == null) {
            invitePicList = new ArrayList<SwiperPicture>();
         }
         }
         root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList));
         
         // 底部网页链接
         // 4、IOS的底部网页链接
         String platform = acceptData.getPlatform();
         if ("ios".equalsIgnoreCase(platform)) {
            root.put("htmlLink", configService.get("index_html_link_ios"));
@@ -1621,25 +1629,7 @@
      
      List<SwiperPicture> invitePicList = getSwiperByCard("index_invite");   
      
      if (uid != null) {
         try {
            // 用户自定义:不看邀请有奖
            UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
            if (vo != null  && vo.getNoInvitationBonus() != null && vo.getNoInvitationBonus() == 1
                  && invitePicList != null && invitePicList.size() > 0) {
               Iterator<SwiperPicture> iterator = invitePicList.iterator();
               while (iterator.hasNext()) {
                  SwiperPicture swiperPicture = iterator.next();
                  JumpDetailV2 jumpDetail = swiperPicture.getJumpDetail();
                  if (jumpDetail != null && "invite".equals(jumpDetail.getType())) {
                     iterator.remove();
                  }
               }
            }
         } catch (UserCustomSettingsException e) {
            e.printStackTrace();
         }
      }
      
      return invitePicList;
   }
@@ -1705,16 +1695,24 @@
      nextTime.set(Calendar.SECOND, 0);
      nextTime.set(Calendar.MILLISECOND, 0);
      
      JSONObject root = new JSONObject();
      root.put("time", nextTime.getTimeInMillis());
      JSONArray array = null;
      String timekey = "spikeGoods_hour";
      String cachekey = "spikeGoodsList";
      
      JSONArray array = new JSONArray();
      String cachekey = "spikeGoodsList" ;
      String cacheValue = redisManager.getCommonString(cachekey);
      if (!StringUtil.isNullOrEmpty(cacheValue)) {
         array = JSONArray.fromObject(cacheValue);
      String timeValue = redisManager.getCommonString(timekey);
      if (timeValue == null || !timeValue.equals(hour+"")) {
         redisManager.cacheCommonString(timekey, hour+"", 60 * 30);
      } else {
         String cacheValue = redisManager.getCommonString(cachekey);
         if (!StringUtil.isNullOrEmpty(cacheValue)) {
            array = JSONArray.fromObject(cacheValue);
         }
      }
      if (array == null) {
         array = new JSONArray();
         BigDecimal proportion = manageService.getFanLiRate();
         Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
               .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
@@ -1724,6 +1722,7 @@
         if (listGoods == null) {
            listGoods = new ArrayList<QualityFactory>();
         }
         /* 遍历列表数据 */
         for (QualityFactory qualityFactory : listGoods) {
               
@@ -1733,9 +1732,13 @@
            }
            array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
         }
         // 缓存半个小时
         redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30);
      }
      JSONObject root = new JSONObject();
      root.put("time", nextTime.getTimeInMillis());
      root.put("listgoods", array);
      out.print(JsonUtil.loadTrueResult(root));
   }