1 public List<?> getUntakedOrderList(Long userId, List statusList) { 2 Session currentSession = this.getSessionFactory().getCurrentSession(); 3 String hql = "select orderInfo.orderStatus as orderStatus, orderInfo.orderTime as orderTime, areaRelationStart.areaCityName as startCityName, areaRelationStart.areaName as startAreaName, areaRelationEnd.areaCityName as endCityName, " + 4 "areaRelationEnd.areaName as endAreaName,userAddressStart.addressLocation as startAddress,userAddressEnd.addressLocation as endAddress,orderInfo.orderId as orderId," + 5 "userAddressEnd.addressName as addressName,orderInfo.orderCommonNo as orderCommonNo " + 6 "from OrderInfo as orderInfo left outer join OrderInfoAppend as orderInfoAppend on orderInfo.orderId=orderInfoAppend.appendOrderId " + 7 "left join UserAddress as userAddressStart on orderInfo.orderSendAddId=userAddressStart.addressId " + 8 "left join UserAddress as userAddressEnd on orderInfo.orderReceiveAddId=userAddressEnd.addressId " + 9 "left join AreaRelation as areaRelationStart on areaRelationStart.areaCode=userAddressStart.addressCity " + 10 "left join AreaRelation as areaRelationEnd on areaRelationEnd.areaCode=userAddressEnd.addressCity" + 11 " where (orderInfoAppend.appendOrderId = null and orderInfo.orderUserId=(:userId) and orderInfo.orderStatus in (:statusList) " + 12 "and orderInfo.orderDeleted=false) or (orderInfo.orderUserId=(:userId) and orderInfo.orderStatus=(:orderStatus) and orderInfo.orderDeleted=false) order by orderInfo.orderTime desc "; 13 Query query = currentSession.createQuery(hql) 14 .setParameter("userId", userId) 15 .setParameterList("statusList", statusList) 16 .setParameter("orderStatus", 290) 17 .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); 18 return query.list(); 19 }
1.红色部分为第一部分的条件,蓝色部分为第二部分的条件
时间: 2024-11-06 05:42:35