/** * 根据服务id和pageid 查询出订单id,查出订单是否存在(page编辑页面 服务) * * @author 侯杨 * @date 2014-05-07 * @param data * @return */ public String getOrderState(OrderProductData data) { // 根据服务id 和pageid 查询订单服务中间表 String msg = "0"; String hql = "from OrderProductData op where op.pageId=? and op.productId= ?"; OrderProductData orderProductData = null; List<OrderProductData> list = new ArrayList<OrderProductData>(); if (data != null) { list = orderProductPersistence.search(hql, new Object[] {data.getPageId(), data.getProductId()}); if (list.size() > 0) { orderProductData = list.get(0); } } // 如果查询的出来的订单服务中间表不为空,查询出订单信息,是否存在 OrderData orderData = null; if (orderProductData != null) { orderData = orderPersistence.retrieve(orderProductData.getOrderId()); } // 如果订单状态不存在,返回1,不然返回0 if (orderData == null) { msg = "1"; } else if (orderData.getState() == 3) { // 如果订单状态已付款且开通 msg = "2"; } else { msg = "0"; } return msg; }
/** * 查看page在订单里面的订单里面所有未付款的订单的中间表的集合(0,1) dlm * * @param pageid * @return */ public List<OrderProductData> getOrdersByPage(String pageid) { String ordproHql = " from OrderProductData op where op.pageId=? "; // 先查询中间表 List<OrderProductData> oplist1 = new ArrayList<OrderProductData>(); List<OrderProductData> oplist = orderProductPersistence.search(ordproHql, new Object[] {pageid}); if (oplist != null && oplist.size() > 0) { for (OrderProductData data : oplist) { // 根据中间表查询订单表 String orderHql = " from OrderData o WHERE o.id=? and o.state in(0,1) "; List<OrderData> olist = orderPersistence.search(orderHql, new Object[] {data.getOrderId()}); if (olist != null && olist.size() > 0) { oplist1.add(data); } } } return oplist1; }