admin
2019-08-23 4b3efa82d7b5040e4140e4664d050aaed37c9788
限时抢购时间定义
2个文件已修改
1个文件已添加
109 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/dataoke/DingDongTime.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -53,6 +53,7 @@
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.factory.MonitorFactory;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
@@ -192,7 +193,7 @@
    }
    private JSONObject getSpikeGoodsContent(AcceptData acceptData) {
        List<String> dtoList = daTaoKeGoodsDetailV2Service.getDingDongQiangTime();
        List<String> dtoList =  DaTaoKeUtil.getDingDongQiangTime();
        long nowTime = System.currentTimeMillis();
        int dateNum = Integer.parseInt(TimeUtil.getGernalTime(nowTime, "ddHH"));
        String timeStr = null;
fanli/src/main/java/com/yeshi/fanli/dto/dataoke/DingDongTime.java
New file
@@ -0,0 +1,39 @@
package com.yeshi.fanli.dto.dataoke;
public class DingDongTime {
    private String key;
    private String value;
    private String time;
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    public DingDongTime(String key, String value) {
        this.key = key;
        this.value = value;
    }
    public DingDongTime() {
    }
    public String getKey() {
        return key;
    }
    public void setKey(String key) {
        this.key = key;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
@@ -5,6 +5,7 @@
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
@@ -18,6 +19,7 @@
import org.jsoup.select.Elements;
import com.yeshi.fanli.dto.dataoke.DingDongQiangDTO;
import com.yeshi.fanli.dto.dataoke.DingDongTime;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.taobao.TaoBaoCoupon;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -577,4 +579,69 @@
        return detail;
    }
    public static List<String> getDingDongQiangTime() {
        // 获取当前的小时数
        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);
        String preDay = (preDate.get(Calendar.DAY_OF_MONTH) + "").length() < 2
                ? "0" + preDate.get(Calendar.DAY_OF_MONTH) : preDate.get(Calendar.DAY_OF_MONTH) + "";
        String nextDay = (nextDate.get(Calendar.DAY_OF_MONTH) + "").length() < 2
                ? "0" + nextDate.get(Calendar.DAY_OF_MONTH) : nextDate.get(Calendar.DAY_OF_MONTH) + "";
        String nowDay = (nowDate.get(Calendar.DAY_OF_MONTH) + "").length() < 2
                ? "0" + nowDate.get(Calendar.DAY_OF_MONTH) : nowDate.get(Calendar.DAY_OF_MONTH) + "";
        int hour = nowDate.get(Calendar.HOUR_OF_DAY);
        int pos = 0;
        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;
                break;
            }
        }
        List<DingDongTime> list = new ArrayList<>();
        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());
            if (pos - i < 0)
                itemData.setTime(
                        preDay + "" + (itemData.getKey().length() < 2 ? ("0" + itemData.getKey()) : itemData.getKey()));
            else
                itemData.setTime(
                        nowDay + "" + (itemData.getKey().length() < 2 ? ("0" + itemData.getKey()) : itemData.getKey()));
            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());
                itemData.setTime(
                        nowDay + "" + (itemData.getKey().length() < 2 ? ("0" + itemData.getKey()) : itemData.getKey()));
                list.add(itemData);
            }
        if (times.length - (pos + 1) < 2) {
            DingDongTime itemData = new DingDongTime(times[0].getKey(), times[0].getValue());
            itemData.setTime(
                    nextDay + "" + (itemData.getKey().length() < 2 ? ("0" + itemData.getKey()) : itemData.getKey()));
            list.add(itemData);
        }
        List<String> finalTimeList = new ArrayList<>();
        for (DingDongTime time : list)
            finalTimeList.add(time.getTime());
        return finalTimeList;
    }
}