| | |
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | import org.jsoup.nodes.Document;
|
| | | import org.jsoup.nodes.Element;
|
| | | import org.jsoup.select.Elements;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.dataoke.DingDongQiangDTO;
|
| | | import com.yeshi.fanli.dto.dataoke.DingDongTime;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoHead;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | "🕚", // 十一点
|
| | | "🕦",// 十一点半
|
| | | };
|
| | |
|
| | | static final String[] evaluateEmojis = new String[] { "💟", "🌸", "🍸", "🍺", "📢", "❤", "💝", "💋", "👛", "🐾",
|
| | | "🌹", "🔥", "🎉", "🎁", "🍥", "🍭", "🌺", "👑", "✨", "💫", "🍻", "🎈", "💥", "💕", "💞", "💰", "💌", "💭",
|
| | | "🌼", "🍀" };
|
| | |
|
| | | public static List<GoodsClass> goodsClasses;
|
| | | static {
|
| | |
| | | return couponList;
|
| | | }
|
| | |
|
| | | private static List<DaTaoKeDetail> parseCurrent(String url) {
|
| | | private static List<DaTaoKeDetailV2> parseCurrent(String url) {
|
| | |
|
| | | List<DaTaoKeDetail> list = new ArrayList<>();
|
| | | List<DaTaoKeDetailV2> list = new ArrayList<>();
|
| | | try {
|
| | | Document doc = Jsoup.connect(url)
|
| | | .userAgent(
|
| | |
| | | .getElementsByTag("b").get(0).text();
|
| | |
|
| | | System.out.println(id + "-" + currentSale);
|
| | | DaTaoKeDetail detail = new DaTaoKeDetail();
|
| | | DaTaoKeDetailV2 detail = new DaTaoKeDetailV2();
|
| | | detail.setId(id);
|
| | | detail.setSalesNum(Integer.parseInt(currentSale));
|
| | | detail.setMonthSales(Integer.parseInt(currentSale));
|
| | | list.add(detail);
|
| | |
|
| | | }
|
| | |
| | | * @param cid
|
| | | * @return
|
| | | */
|
| | | public static List<DaTaoKeDetail> getCurrentSalesRank(Integer cid) {
|
| | | public static List<DaTaoKeDetailV2> getCurrentSalesRank(Integer cid) {
|
| | | String url = null;
|
| | | if (cid == null)
|
| | | url = "http://www.dataoke.com/top_sell";
|
| | |
| | | * @param cid
|
| | | * @return
|
| | | */
|
| | | public static List<DaTaoKeDetail> getCurrentDaySalesRank(Integer cid) {
|
| | | public static List<DaTaoKeDetailV2> getCurrentDaySalesRank(Integer cid) {
|
| | | String url = null;
|
| | | if (cid == null)
|
| | | url = "http://www.dataoke.com/top_all";
|
| | |
| | | * @param cid
|
| | | * @return
|
| | | */
|
| | | public static List<DaTaoKeDetail> getCurrentHotSalesRank() {
|
| | | public static List<DaTaoKeDetailV2> getCurrentHotSalesRank() {
|
| | | String url = "http://www.dataoke.com/top_tui";
|
| | | return parseCurrent(url);
|
| | | }
|
| | |
|
| | | private static String getRandomCommonEmoji() {
|
| | | public static String getRandomCommonEmoji() {
|
| | | return commonEmojis[(int) (Math.random() * commonEmojis.length)];
|
| | | }
|
| | |
|
| | | public static String getDesc(DaTaoKeDetail detail) {
|
| | | public static String getEvaluateEmojis() {
|
| | | return evaluateEmojis[(int) (Math.random() * evaluateEmojis.length)];
|
| | | }
|
| | |
|
| | | public static String getDesc(DaTaoKeDetailV2 detail) {
|
| | |
|
| | | // 标题+券后价+包邮+描述
|
| | | String desc = detail.getdTitle();
|
| | | String desc = detail.getDtitle();
|
| | | desc += "\n";
|
| | | desc += String.format("券后价%s【%s元】包邮秒杀 ", Math.random() > 0.5 ? "💰" : "",
|
| | | MoneyBigDecimalUtil.getWithNoZera(detail.getPrice()).toString())
|
| | | MoneyBigDecimalUtil.getWithNoZera(detail.getActualPrice()).toString())
|
| | | + (Math.random() > 0.5 ? getRandomCommonEmoji() : "");
|
| | | desc += "\n";
|
| | | // desc += detail.getIntroduce();
|
| | | String introduce = detail.getIntroduce().replace(",", ",").replace("。", ",").replace("!", ",").replace(",",
|
| | | ",");
|
| | | String introduce = detail.getDesc().replace(",", ",").replace("。", ",").replace("!", ",").replace(",", ",");
|
| | | introduce = introduce.replace(",,,", ",").replace(",,", ",");
|
| | |
|
| | | String[] sts = introduce.split(",");
|
| | |
| | | return desc;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetail detail) {
|
| | | if (detail != null && goods != null) {
|
| | | public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 v2,
|
| | | boolean filterCouponInfo) {
|
| | | if (v2 != null && goods != null) {
|
| | | // 重新设置标题与券价格
|
| | | goods.setTitle(detail.getdTitle());
|
| | | if (!StringUtil.isNullOrEmpty(detail.getPic()))
|
| | | goods.setPictUrlWhite(detail.getPic());
|
| | | goods.setTitle(v2.getDtitle());
|
| | | if (!StringUtil.isNullOrEmpty(v2.getMainPic()))
|
| | | goods.setPictUrlWhite(v2.getMainPic());
|
| | | // 如果没有券信息,则提供券信息
|
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo()) && v2 != null
|
| | | && !StringUtil.isNullOrEmpty(v2.getCouponLink())) {
|
| | | try {
|
| | | long time = System.currentTimeMillis();
|
| | | // 券在有效期内并且还有剩余券
|
| | | if (time >= TimeUtil.convertToTimeTemp(v2.getCouponStartTime(), "yyyy-MM-dd HH:mm:ss")
|
| | | && time <= TimeUtil.convertToTimeTemp(v2.getCouponEndTime(), "yyyy-MM-dd HH:mm:ss")
|
| | | && (v2.getCouponTotalNum() - v2.getCouponReceiveNum()) > 0) {
|
| | | goods.setCouponStartFee(v2.getOriginalPrice());
|
| | |
|
| | | goods.setCouponEffectiveEndTime(TimeUtil.getGernalTime(
|
| | | TimeUtil.convertToTimeTemp(v2.getCouponEndTime(), "yyyy-MM-dd HH:mm:ss"),
|
| | | "yyyy-MM-dd"));
|
| | | goods.setCouponEffectiveStartTime(TimeUtil.getGernalTime(
|
| | | TimeUtil.convertToTimeTemp(v2.getCouponStartTime(), "yyyy-MM-dd HH:mm:ss"),
|
| | | "yyyy-MM-dd"));
|
| | |
|
| | | goods.setCouponAmount(v2.getCouponPrice());
|
| | | goods.setCouponInfo(
|
| | | String.format("满%s元减%s元", v2.getOriginalPrice() + "", v2.getCouponPrice() + ""));
|
| | | goods.setCouponLeftCount(v2.getCouponTotalNum() - v2.getCouponReceiveNum());
|
| | | goods.setCouponLink(v2.getCouponLink());
|
| | | goods.setCouponTotalCount(v2.getCouponTotalNum());
|
| | | goods.setShopCoupon(true);
|
| | | goods.setZkPrice(v2.getOriginalPrice());
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | return goods;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 detail) {
|
| | | if (detail != null && goods != null) {
|
| | | // 重新设置标题与券价格
|
| | | goods.setTitle(detail.getDtitle());
|
| | | if (!StringUtil.isNullOrEmpty(detail.getMainPic()))
|
| | | goods.setPictUrlWhite(detail.getMainPic());
|
| | | }
|
| | | return goods;
|
| | | public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 v2) {
|
| | | return filterTaoBaoGoods(goods, v2, false);
|
| | | }
|
| | |
|
| | | public static DaTaoKeDetail filterDaTaoKe(TaoBaoGoodsBrief goods, DaTaoKeDetail detail) {
|
| | | public static DaTaoKeDetailV2 filterDaTaoKe(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 detail) {
|
| | | if (goods != null) {
|
| | | BigDecimal price = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | detail.setOrgPrice(goods.getZkPrice());
|
| | | detail.setPrice(price);
|
| | | detail.setOriginalPrice(goods.getZkPrice());
|
| | | detail.setActualPrice(price);
|
| | | if (goods.getCouponStartFee() != null)
|
| | | detail.setQuanCondition(goods.getCouponStartFee() + "");
|
| | | detail.setQuanId(goods.getCouponActivityId());
|
| | | detail.setQuanPrice(goods.getCouponAmount());
|
| | | detail.setCouponConditions(goods.getCouponStartFee() + "");
|
| | | detail.setCouponPrice(goods.getCouponAmount());
|
| | | return detail;
|
| | | }
|
| | |
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | // 获取推广文案
|
| | | public static void getPublishDoc(String id) {
|
| | | String url = String.format("http://www.dataoke.com/detailtpl?gid=%s&type=1", id);
|
| | | String response = HttpUtil.get(url);
|
| | | try {
|
| | | JSONObject json = JSONObject.fromObject(new String(response.getBytes("ISO-8859-1"), "UTF-8"));
|
| | | JSONObject data = json.optJSONObject("data");
|
| | | String tpl2 = data.optString("tpl2");
|
| | | tpl2 = tpl2.substring(0, tpl2.indexOf("---------"));
|
| | | System.out.println(tpl2.replace("</br>", "\n").trim());
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|