/** * Get the weixin order according to specific extra condition{@link ExtraCond}. * * @param dbCon the database connection * @param staff the staff to perform this action * @param extraCond the extra condition {@link ExtraCond} * @return the result to wx order * @throws SQLException throws if failed to execute any SQL statement */ public static List<WxOrder> getByCond( DBCon dbCon, Staff staff, ExtraCond extraCond, String orderClause) throws SQLException { String sql; sql = " SELECT * FROM " + Params.dbName + ".weixin_order " + " WHERE 1 = 1 " + " AND restaurant_id = " + staff.getRestaurantId() + (extraCond != null ? extraCond.toString() : " ") + (orderClause != null ? orderClause : ""); dbCon.rs = dbCon.stmt.executeQuery(sql); List<WxOrder> result = new ArrayList<WxOrder>(); while (dbCon.rs.next()) { WxOrder wxOrder = new WxOrder(dbCon.rs.getInt("wx_order_id")); wxOrder.setRestaurant(dbCon.rs.getInt("restaurant_id")); wxOrder.setStatus(WxOrder.Status.valueOf(dbCon.rs.getInt("status"))); wxOrder.setType(WxOrder.Type.valueOf(dbCon.rs.getInt("type"))); if (wxOrder.getType() == WxOrder.Type.TAKE_OUT) { TakeoutAddress address = new TakeoutAddress(dbCon.rs.getInt("address_id")); address.setAddress(dbCon.rs.getString("address")); wxOrder.setTakoutAddress(address); } wxOrder.setCode(dbCon.rs.getInt("code")); wxOrder.setOrderId(dbCon.rs.getInt("order_id")); wxOrder.setBirthDate(dbCon.rs.getTimestamp("birth_date").getTime()); wxOrder.setWeixinSerial(dbCon.rs.getString("weixin_serial")); result.add(wxOrder); } dbCon.rs.close(); return result; }