一:目录
二:代码实现
1、商家层面
Dao层:
public List<Order> list(Order order, PageBean pageBean) throws Exception {
// String sql="select * from t_easyui_order order by orderTime desc";
String sql = "select * from t_easyui_order where 1=1 ";
long id = order.getId();
int orderState = order.getOrderState();
if (id != 0) {
sql += " and id=" + id;//根据订单id进行查询
}
if (orderState != 0) {
sql += " and orderState=" + orderState;//根据订单的状态进行查询
}
sql += " order by orderTime desc";
return super.executeQuery(sql, Order.class, pageBean);
}
Action:
public void list(HttpServletRequest req, HttpServletResponse resp) {
PageBean pageBean = new PageBean();
pageBean.setRequest(req);
try {
List<Order> list = orderDao.list(order, pageBean);//运用list方法,查询到对应的订单
ResponseUtil.writeJson(resp, new R().data("total", pageBean.getTotal()).data("rows", list));
} catch (Exception e) {
e.printStackTrace();
}
}
mvc.xml:
<action path="/order" type="com.zking.web.OrderAction">
</action>
效果展示:
不发货:
已发货:
已签收:
1、发货功能
Dao层:
public void editState(Order t) throws Exception {
String sql = "update t_easyui_order set orderState=? where id=?";
int orderState = t.getOrderState();
if(orderState==2) {
//需要优化发货时间,因为从未发货到已发货需要生成时间
sql = "update t_easyui_order set orderState=?,sendTime=now() where id=?";
}
super.executeUpdate(sql, t, new String[] { "orderState", "id" });
}
Action:
public void cancelAndReceive(HttpServletRequest req, HttpServletResponse resp) {
try {
orderDao.editState(order);
ResponseUtil.writeJson(resp, 1);
} catch (Exception e) {
try {
ResponseUtil.writeJson(resp, 0);
} catch (Exception e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
2.订单项查看功能
OrderItmeDao:
public List<OrderItem> list(OrderItem orderItem, PageBean pageBean) throws Exception {
String sql="select * from t_easyui_orderItem where 1=1";
long oid = orderItem.getOid();
if(oid!=0) {
sql+=" and oid="+oid;//根据订单id进行查询
}
return super.executeQuery(sql, OrderItem.class, pageBean);
}
OrderItmeAction:
public void list(HttpServletRequest req, HttpServletResponse resp) {
PageBean pageBean = new PageBean();
pageBean.setRequest(req);
try {
List<OrderItem> list = orderItemDao.list(orderItem, pageBean);
ResponseUtil.writeJson(resp, new R().data("total", pageBean.getTotal()).data("rows", list));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
mvc.xml:
<action path="/orderItem" type="com.zking.web.OrderItemAction">
</action>
2、买家:
查看订单(未发货、已发货、已签收)、撤单、签收的整体思路:
1.查看订单运行效果:
未发货:
已发货:
已签收:
撤单功能:
签收功能:
签收完成:
项目功能展示完毕