/**
   * 根据商品编码从表promotion里查询出商品的单品促销信息
   *
   * @param connection 到数据库的连接
   * @param code 商品编码
   * @return 普通促销信息
   * @throws SQLException
   */
  public DiscCriteria getPromotion(Connection connection, String code) throws SQLException {

    DiscCriteria result = null;

    String sql =
        " SELECT vgno, promtype, promprice, "
            + " startdate, enddate, starttime, endtime "
            + "FROM promotion where vgno=?; ";
    PreparedStatement stmt = connection.prepareStatement(sql);
    stmt.setString(1, code);
    ResultSet rs = stmt.executeQuery();
    if (rs.next()) {
      String vgno = Formatter.mytrim(rs.getString("vgno"));
      String promtype = Formatter.mytrim(rs.getString("promtype"));
      double promprice = rs.getDouble("promprice");

      Date startdate = rs.getDate("startdate");
      Date enddate = rs.getDate("enddate");
      Date starttime = rs.getDate("starttime");
      Date endtime = rs.getDate("endtime");

      GregorianCalendar g_start = new GregorianCalendar();
      g_start.setTime(starttime);

      GregorianCalendar g_end = new GregorianCalendar();
      g_end.setTime(endtime);

      result = new Promotion(vgno, (int) (100 * promprice), g_start, g_end);
    }

    return result;
  }
Esempio n. 2
0
 public HashMap getHeader(PosContext context, int index, int total) {
   HashMap paras = new HashMap();
   paras.put("${ShopID}", context.getStoreid());
   paras.put("${PosID}", context.getPosid());
   // createrandomnum randomnum = new createrandomnum();
   // String num = Integer.toString(randomnum.getrandomnum());
   paras.put("${SheetID}", Integer.toString(context.getSheetid()));
   paras.put("${Cashier}", context.getCashierid());
   paras.put("${Date}", Formatter.getDate(new Date()));
   paras.put("${Time}", Formatter.getTime(new Date()));
   paras.put("${DateTime}", Formatter.getDate(new Date()) + " " + Formatter.getTime(new Date()));
   paras.put("${OrderID}", Integer.toString(context.getOrderidOld()));
   paras.put("${PageNo}", String.valueOf(index) + "/" + String.valueOf(total));
   return paras;
 }
  /**
   * 根据商品编码从表promdisc_vip里查询出会员折扣
   *
   * @param connection 到数据库的连接
   * @param code 商品编码
   * @return 普通促销信息
   * @throws SQLException
   */
  public DiscCriteria getDisc4Member(Connection connection, String code) throws SQLException {

    DiscCriteria result = null;

    String sql =
        " SELECT vgno, promlevel, promdisc, "
            + " startdate, enddate, starttime, endtime "
            + " FROM promdisc_vip where vgno=?; ";

    PreparedStatement stmt = connection.prepareStatement(sql);
    stmt.setString(1, code);
    ResultSet rs = stmt.executeQuery();
    if (rs.next()) {
      String vgno = Formatter.mytrim(rs.getString("vgno"));
      int promlevel = rs.getInt("promlevel");
      int promdisc = rs.getInt("promdisc");

      Date startdate = rs.getDate("startdate");
      Date enddate = rs.getDate("enddate");
      Date starttime = rs.getDate("starttime");
      Date endtime = rs.getDate("endtime");

      GregorianCalendar g_start = new GregorianCalendar();
      g_start.setTime(starttime);

      GregorianCalendar g_end = new GregorianCalendar();
      g_end.setTime(endtime);

      result = new Disc4Member(vgno, promdisc, promlevel, g_start, g_end);
    }

    return result;
  }
  /**
   * 根据商品编码在表distitem_vgno里查询商品的单品折扣
   *
   * @param connection 到数据库的连接
   * @param code 商品编码
   * @return 普通促销信息
   * @throws SQLException
   */
  public DiscCriteria getDisc4Goods(Connection connection, String code) throws SQLException {

    DiscCriteria result = null;

    String sql =
        " SELECT vgno, distrate1, distrate2, distrate3, "
            + " min_amount, med_amount, max_amount, "
            + " starttime, endtime "
            + " FROM distitem_vgno where vgno=?; ";
    PreparedStatement stmt = connection.prepareStatement(sql);
    stmt.setString(1, code);
    ResultSet rs = stmt.executeQuery();
    if (rs.next()) {
      String vgno = Formatter.mytrim(rs.getString("vgno"));
      int distrate1 = rs.getInt("distrate1");
      int distrate2 = rs.getInt("distrate2");
      int distrate3 = rs.getInt("distrate3");
      int min_amount = rs.getInt("min_amount");
      int med_amount = rs.getInt("med_amount");
      int max_amount = rs.getInt("max_amount");

      Date starttime = rs.getDate("starttime");
      Date endtime = rs.getDate("endtime");

      GregorianCalendar g_start = new GregorianCalendar();
      g_start.setTime(starttime);

      GregorianCalendar g_end = new GregorianCalendar();
      g_end.setTime(endtime);

      result =
          new Disc4Goods(
              vgno,
              distrate1,
              min_amount,
              distrate2,
              med_amount,
              distrate3,
              max_amount,
              g_start,
              g_end);
    }

    return result;
  }
  /**
   * 根据商品编码从表promotion里查询出商品的单品促销信息
   *
   * @param connection 到数据库的连接
   * @param code 商品编码
   * @return 普通促销信息
   * @throws SQLException
   */
  public DiscCriteria getDISCTIME(Connection connection, String code) throws SQLException {

    DiscCriteria result = null;
    SimpleDateFormat fmt1 = new SimpleDateFormat("HHmmss");

    String sql =
        " SELECT vgno,time1,time2,time3,time4,time5,time6, "
            + " distrate1,distrate2,distrate3,distrate4,distrate5,distrate6 "
            + "FROM vgnodiscount where vgno=? and convert(char(8),getdate(),112) between convert(char(8),startdate,112) and convert(char(8),enddate,112); ";
    PreparedStatement stmt = connection.prepareStatement(sql);
    stmt.setString(1, code);
    ResultSet rs = stmt.executeQuery();
    if (rs.next()) {
      String vgno = Formatter.mytrim(rs.getString("vgno"));
      // int time1 = Integer.parseInt(fmt1.format(Date.valueOf(rs.getString("time1"))));
      int time1 = Integer.parseInt(fmt1.format(rs.getTime("time1")));
      int time2 = Integer.parseInt(fmt1.format(rs.getTime("time2")));
      int time3 = Integer.parseInt(fmt1.format(rs.getTime("time3")));
      int time4 = Integer.parseInt(fmt1.format(rs.getTime("time4")));
      int time5 = Integer.parseInt(fmt1.format(rs.getTime("time5")));
      int time6 = Integer.parseInt(fmt1.format(rs.getTime("time6")));

      int distrate1 = rs.getInt("distrate1");
      int distrate2 = rs.getInt("distrate2");
      int distrate3 = rs.getInt("distrate3");
      int distrate4 = rs.getInt("distrate4");
      int distrate5 = rs.getInt("distrate5");
      int distrate6 = rs.getInt("distrate6");

      result =
          new DiscTime(
              vgno, time1, distrate1, time2, distrate2, time3, distrate3, time4, distrate4, time5,
              distrate5, time6, distrate6);
    }

    return result;
  }