From a6ebcc175e9b6a50456779092d2d6222b467ae64 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期四, 28 三月 2019 14:14:52 +0800 Subject: [PATCH] 动态加入时间控制显示 --- fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java | 145 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 138 insertions(+), 7 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java index 9000ddd..5f52b1f 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java @@ -116,8 +116,6 @@ @RequestMapping("api/v1/user") public class RecommendController { - @Resource - private RecommendBannerService recommendService; @Resource private BusinessSystemService businessSystemService; @@ -143,8 +141,6 @@ @Resource private UserInfoService userInfoService; - @Resource - private TaoBaoOrderUtil taoBaoOrderUtil; @Resource private TaoBaoCouponService taoBaoCouponService; @@ -157,9 +153,6 @@ @Resource private CollectionGoodsV2Service collectionGoodsV2Service; - - @Resource - private HongBaoManageMapper hongBaoManageMapper; @Resource private TaoBaoGoodsBriefService taoBaoGoodsBriefService; @@ -1569,6 +1562,144 @@ } + + /** + * 鏂扮増鎺ㄨ崘涓撻绠$悊(1.5.3) + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getRecommendIndex") + public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) { + + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + + // 杞挱鍥� + List<SwiperPicture> swiperList = null; + try { + swiperList = swiperPictureService.getByBannerCard("weex_index"); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + e.printStackTrace(); + } + + if (swiperList == null) { + swiperList = new ArrayList<SwiperPicture>(); + } + + + Special miaoShaSpecial = null; + // 涓よ鍦嗗舰涓撻 + List<Special> arcList = new ArrayList<Special>(); + + // 娲诲姩鍒楄〃 + List<Special> activityList = new ArrayList<Special>(); + + // 鏂瑰潡閮ㄥ垎 + List<Special> blockList = new ArrayList<Special>(); + + + try { + List<Special> listSpecial = specialService.listBySystemAndCard("index", system.getId()); + + if (listSpecial != null && listSpecial.size() > 0) { + for (Special special : listSpecial) { + + if ("闄愭椂绉掓潃".equals(special.getName())) { + miaoShaSpecial = special; + continue; + } + + if (Special.SHOWTYPE_ARC.equals(special.getShowType())) { + // 涓よ鍦嗗舰涓撻 + arcList.add(special); + } else if (Special.SHOWTYPE_BLOCK.equals(special.getShowType())) { + // 鏂瑰潡閮ㄥ垎 + blockList.add(special); + } else if (Special.SHOWTYPE_ACTIVITY.equals(special.getShowType())) { + // 鍔ㄦ�� + activityList.add(special); + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + + + /* 闄愭椂绉掓潃 - 鏃堕棿澶勭悊 */ + JSONObject msJSON = JSONObject.fromObject(new Gson().toJson(miaoShaSpecial)); + if (miaoShaSpecial != null) { + // 鑾峰彇绉掓潃 + int[] hours = new int[] { 0, 9, 12, 14, 16, 20, 22 }; + int hour = -1; + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(Long.parseLong(acceptData.getTime())); + int nowHour = calendar.get(Calendar.HOUR_OF_DAY); + for (int i = 0; i < hours.length - 1; i++) { + if (nowHour >= hours[i] && nowHour < hours[i + 1]) { + hour = hours[i + 1]; + break; + } + } + + if (hour < 0) + hour = 24; + long time = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyy-MM-dd"), + "yyyy-MM-dd") + 1000 * 60 * 60 * hour; + msJSON.put("time", time); + } + + JSONObject root = new JSONObject(); + root.put("swiperList", JsonUtil.getApiCommonGson().toJson(swiperList)); + root.put("arcList", JsonUtil.getApiCommonGson().toJson(arcList)); + root.put("activityList", JsonUtil.getApiCommonGson().toJson(activityList)); + root.put("blockList", JsonUtil.getApiCommonGson().toJson(blockList)); + root.put("miaoSha", msJSON); + + // 澧炲姞閭�璇锋湁濂� + JSONObject invite = new JSONObject(); + JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("invite"); + invite.put("jumpDetail", jumpDetail); + invite.put("picture", configService.get("home_invite_banner")); + + if ("ios".equalsIgnoreCase(acceptData.getPlatform()) + && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) { + // 濡傛灉IOS褰撳墠鐗堟湰澶勪簬瀹℃牳鐘舵�佸氨涓嶈繑鍥� + } else { + + // 鎸夌収鐗堟湰杩斿洖锛岀増鏈鐩栬冻澶熷悗鍙垹闄� + if (("android".equalsIgnoreCase(acceptData.getPlatform()) && Integer.parseInt(acceptData.getVersion()) > 30) + || ("ios".equalsIgnoreCase(acceptData.getPlatform()) + && Integer.parseInt(acceptData.getVersion()) > 37)) { + if (uid != null) { + try { + UserSettingsVO vo = userCustomSettingsService.getMySettings(uid); + if (vo == null || vo.getNoInvitationBonus() == null || vo.getNoInvitationBonus() == 0)// 娌℃湁鍏抽棴閭�璇� + root.put("invite", invite); + } catch (UserCustomSettingsException e) { + e.printStackTrace(); + } + } else + root.put("invite", invite); + } + } + + out.print(JsonUtil.loadTrueResult(root)); + + } + + /** * 鍟嗗搧鍩烘湰璇︽儏 (1.4.0) * -- Gitblit v1.8.0