Exemplo n.º 1
0
  /*
   * 保存用户订单信息
   */
  public void saveUserOrderByHtmlparser(
      String content, IPayInfoService payInfoService, String currentUser, String alipayName)
      throws InterruptedException {

    Document doc = Jsoup.parse(content);

    for (int i = 1; i < 21; i++) {
      Element element = doc.select("tr[id=J-item-" + i + "]").first();
      if (element == null) {
        break;
      }

      // 交易号码或者流水号码
      String tradeNo = element.select("a[id=J-tradeNo-" + i + "]").attr("title").trim();
      System.out.println(tradeNo);

      Map map = new HashMap(2);
      map.put("tradeNo", tradeNo);
      map.put("source", Constant.ZHIFUBAO);
      List<PayInfo> list1 = payInfoService.getPayInfoByTradeNoSource(map);
      if (list1 != null && list1.size() > 0) {

      } else {
        // 2014.03.18
        String time_d = element.select("p[class=time-d]").first().text();
        // 09:44
        String time_d_m = element.select("p[class=time-h ft-gray]").first().text();
        time_d = time_d.replaceAll("\\.", "-");
        String payTimeStr = time_d + " " + time_d_m;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Date payTime = null;
        try {
          payTime = sdf.parse(payTimeStr);
        } catch (ParseException e1) {
          // TODO Auto-generated catch block
          logger.info("第598行捕获异常:" + e1.getMessage());
          e1.printStackTrace();
        }
        // 交易类型
        String tradeType = element.select("p[class=consume-title]").first().text();
        // 交易账号类型:流水号 或者 交易号
        String tradeNoType =
            element
                .select("div[id=J-tradeNo-container-" + i + "]")
                .first()
                .text()
                .trim()
                .substring(0, 3);

        String receiverName =
            element.select("td[class=other]").first().select("p[class=name]").text().trim();

        String amount = element.select("td[class=amount]").text().trim();
        BigDecimal payAmount = new BigDecimal(amount);
        String status = element.select("td[class=status]").text().trim();

        try {
          PayInfo payInfo = new PayInfo();
          UUID uuid = UUID.randomUUID();
          payInfo.setId(uuid.toString());
          payInfo.setPayTime(payTime);

          payInfo.setTradeNo(tradeNo);
          payInfo.setTradeNoType(tradeNoType);
          payInfo.setTradeType(tradeType);
          payInfo.setReceiverName(receiverName);
          payInfo.setAmount(payAmount);
          payInfo.setStatus(status);
          payInfo.setSource(Constant.ZHIFUBAO);
          payInfo.setAlipayName(alipayName);
          payInfoService.savePayInfo(payInfo);
        } catch (Exception e) {
          logger.info("第635行捕获异常:", e);
          e.printStackTrace();
        }
      }
    }
  }
Exemplo n.º 2
0
  /** 解析支付宝一年前的 */
  public void anLyzerAlipayOneYear(
      String content, IPayInfoService payInfoService, String currentUser, String alipayName) {
    Document doc = Jsoup.parse(content);
    Elements elements =
        doc.select("table[id=tradeRecordsIndex]").first().select("tbody").select("tr");

    java.text.DateFormat format3 = new java.text.SimpleDateFormat("yyyy.MM.dd HH:mm");

    for (int i = 0; i < elements.size(); i++) {
      Element element = elements.get(i);
      String times = element.select("td[class=time2]").first().text();
      Date payTime = null;
      try {
        payTime = format3.parse(times);
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        logger.info("第250行捕获异常:", e);
        e.printStackTrace();
      }

      String tradeType = element.select("li[class=name fn-claer]").first().text(); // 付款-转账
      String tradeNo = element.select("li[class=J-bizNo]").first().text(); // No
      String receiverName = element.select("td[class=other]").first().text(); // receriverName
      String amount = element.select("td[class=amount]").first().text(); // amount
      BigDecimal payAmount = new BigDecimal(amount);
      String status = element.select("td[class=status]").first().text(); // status

      System.out.println(
          payTime
              + "&&"
              + tradeType
              + "&&"
              + tradeNo
              + "&&"
              + receiverName
              + "&&"
              + payAmount
              + "&&"
              + status);

      Map map = new HashMap(2);
      map.put("tradeNo", tradeNo);
      map.put("source", Constant.ZHIFUBAO);
      List<PayInfo> list1 = payInfoService.getPayInfoByTradeNoSource(map);
      if (list1 != null && list1.size() > 0) {

      } else {
        try {
          String tradeNoType = "交易号";
          PayInfo payInfo = new PayInfo();
          UUID uuid = UUID.randomUUID();
          payInfo.setId(uuid.toString());
          payInfo.setPayTime(payTime);

          payInfo.setTradeNo(tradeNo);
          payInfo.setTradeNoType(tradeNoType);
          payInfo.setTradeType(tradeType);
          payInfo.setReceiverName(receiverName);
          payInfo.setAmount(payAmount);
          payInfo.setStatus(status);
          payInfo.setSource(Constant.ZHIFUBAO);
          payInfo.setAlipayName(alipayName);
          payInfoService.savePayInfo(payInfo);
        } catch (Exception e) {
          logger.info("第635行捕获异常:", e);
          e.printStackTrace();
        }
      }
    }
  }