1.??? ???:
CREATE TABLE `orders` ( `oid` int(11) NOT NULL AUTO_INCREMENT, `total` double DEFAULT NULL, `ordertime` datetime DEFAULT NULL, `state` int(11) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, `addr` varchar(100) DEFAULT NULL, `phone` varchar(20) DEFAULT NULL, `uid` int(11) DEFAULT NULL, PRIMARY KEY (`oid`), KEY `FKC3DF62E5AA3D9C7` (`uid`), CONSTRAINT `FKC3DF62E5AA3D9C7` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; CREATE TABLE `orderitem` ( `itemid` int(11) NOT NULL AUTO_INCREMENT, `count` int(11) DEFAULT NULL, `subtotal` double DEFAULT NULL, `pid` int(11) DEFAULT NULL, `oid` int(11) DEFAULT NULL, PRIMARY KEY (`itemid`), KEY `FKE8B2AB6166C01961` (`oid`), KEY `FKE8B2AB6171DB7AE4` (`pid`), CONSTRAINT `FKE8B2AB6166C01961` FOREIGN KEY (`oid`) REFERENCES `orders` (`oid`), CONSTRAINT `FKE8B2AB6171DB7AE4` FOREIGN KEY (`pid`) REFERENCES `product` (`pid`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
2.?
public class Order { private Integer oid; private Double total; private Date ordertime; private String name; private String addr; private String phone; private Integer state; // 與用戶的關(guān)聯(lián)關(guān)系 private User user; // 與訂單項(xiàng)關(guān)聯(lián)關(guān)系 private Set<OrderItem> orderItems = new HashSet<OrderItem>(); .... }
public class OrderItem { private Integer itemid; private Integer count; private Double subtotal; private Product product; private Order order; .... }
3. ?? ??
public String createOrder() { // 將Order對(duì)象存入到數(shù)據(jù)庫中: // 封裝Order對(duì)象: Order order = new Order(); // 封裝總價(jià)---從購物車的信息獲得. // 獲得購物車: Cart cart = (Cart) ServletActionContext.getRequest().getSession() .getAttribute("cart"); // 判斷: if (cart == null) { this.addActionError("親!您還沒有購物!請(qǐng)先去購物!"); return "msg"; } // 設(shè)置所屬用戶: User existUser = (User) ServletActionContext.getRequest().getSession() .getAttribute("existUser"); if (existUser == null) { this.addActionError("親!您還沒有登錄!請(qǐng)先去登錄!"); return "msg"; } order.setUser(existUser); order.setTotal(cart.getTotal()); // 封裝時(shí)間 order.setOrdertime(new Date()); // 封裝狀態(tài) order.setState(1); // 1 未付款 2 已經(jīng)付款,未發(fā)貨 3.已經(jīng)發(fā)貨,沒有確認(rèn)收貨 4.訂單完成. // 為訂單設(shè)置訂單項(xiàng)集合: for (CartItem cartItem : cart.getCartItems()) { // 將購物項(xiàng)的數(shù)據(jù)封裝到訂單項(xiàng)中. OrderItem orderItem = new OrderItem(); orderItem.setCount(cartItem.getCount()); orderItem.setSubtotal(cartItem.getSubtotal()); orderItem.setProduct(cartItem.getProduct()); orderItem.setOrder(order); // 放入訂單的集合: order.getOrderItems().add(orderItem); } // 購物車清空了. cart.clearCart(); // 調(diào)用Service保存訂單的操作: orderService.save(order); // 將訂單存入到值棧中: ActionContext.getContext().getValueStack().set("order", order); // 頁面跳轉(zhuǎn): return "createOrderSuccess"; }
4. ? ??? ?????
1.??? id
? ?? ?? ??
5?? ?? :
1.?? ???ID?? ??
? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??
?? ?? ?? ??? | Uma Musume Pretty Derby
1 ? ? ?
By Jack chen
<night> : ???? 99 ? - ?? ?? ? ?? ?? ??
4 ? ? ?
By DDD
Uma Musume Pretty Derby ?? ?? (2025 ? 7 ?)
1 ? ? ?
By Jack chen
?? ? ??? ????? Rimworld Odyssey ?? ???
3 ? ? ?
By Jack chen
Windows ??? ?? ??? ??? ???? ????
1 ? ? ?
By 下次還敢

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)