From 9b55262bb45c81c997ab04e55e8de13e14b8ca7d Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 29 十月 2019 15:11:37 +0800 Subject: [PATCH] 商品最高返 --- fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java index 84dcfc2..33a2b3c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java @@ -6,6 +6,7 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.Calendar; +import java.util.Date; import java.util.Iterator; import java.util.List; @@ -387,7 +388,7 @@ ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("javascript"); try { - String js = "function getData(){return JSON.stringify(dataDef);}" + content; + String js = "function getData(){return JSON.stringify(dataDef);} var test1='--';function test2(res){};" + content.replace("$(window).load", "test2").replace("window.location.search.", "test1."); engine.eval(js); if (engine instanceof Invocable) { Invocable in = (Invocable) engine; @@ -579,19 +580,18 @@ return detail; } - public static List<String> getDingDongQiangTime() { + public static List<String> getDingDongQiangTime(Calendar nowDate) { // 鑾峰彇褰撳墠鐨勫皬鏃舵暟 DingDongTime[] times = new DingDongTime[] { new DingDongTime("0", "00:00"), new DingDongTime("8", "08:00"), new DingDongTime("10", "10:00"), new DingDongTime("13", "13:00"), new DingDongTime("15", "15:00"), new DingDongTime("17", "17:00"), new DingDongTime("19", "19:00"), new DingDongTime("20", "20:00"), new DingDongTime("21", "21:00") }; - Calendar nowDate = Calendar.getInstance(); Calendar preDate = Calendar.getInstance(); preDate.setTimeInMillis(nowDate.getTimeInMillis() - 24 * 60 * 60 * 1000L); Calendar nextDate = Calendar.getInstance(); - preDate.setTimeInMillis(nowDate.getTimeInMillis() + 24 * 60 * 60 * 1000L); + nextDate.setTimeInMillis(nowDate.getTimeInMillis() + 24 * 60 * 60 * 1000L); String preDay = (preDate.get(Calendar.DAY_OF_MONTH) + "").length() < 2 ? "0" + preDate.get(Calendar.DAY_OF_MONTH) : preDate.get(Calendar.DAY_OF_MONTH) + ""; @@ -601,7 +601,7 @@ ? "0" + nowDate.get(Calendar.DAY_OF_MONTH) : nowDate.get(Calendar.DAY_OF_MONTH) + ""; int hour = nowDate.get(Calendar.HOUR_OF_DAY); - int pos = 0; + int pos = times.length - 1; for (int i = 0; i < times.length - 1; i++) { if (hour >= Integer.parseInt(times[i].getKey()) && hour < Integer.parseInt(times[i + 1].getKey())) { pos = i; @@ -611,6 +611,7 @@ List<DingDongTime> list = new ArrayList<>(); + //鑾峰彇褰撳墠鏃堕棿涔嬪墠鐨�5涓暟鎹� for (int i = 5; i >= 0; i--) { int p = pos - i < 0 ? (times.length + pos - i) : pos - i; DingDongTime itemData = new DingDongTime(times[p].getKey(), times[p].getValue()); @@ -623,6 +624,7 @@ list.add(itemData); } + //鍚戝悗娣诲姞鍓╀笅鐨� if (pos + 1 < times.length) for (int i = pos + 1; i < times.length; i++) { DingDongTime itemData = new DingDongTime(times[i].getKey(), times[i].getValue()); -- Gitblit v1.8.0