资源简介
Java电子商务系统Java电子商务系统Java电子商务系统Java电子商务系统
代码片段和文件信息
package com.lzw;
import java.util.Date;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.view.RedirectView;
import com.lzw.collect.GoodsElement;
import com.lzw.dao.Dao;
import com.lzw.form.CartCheckoutForm;
import com.lzw.model.TbGoods;
import com.lzw.model.TbMember;
import com.lzw.model.TbOrder;
import com.lzw.model.TbOrderDetail;
public class CartCheckoutController extends SimpleFormController {
private Dao dao;
public CartCheckoutController() {
setCommandClass(CartCheckoutForm.class);
}
protected ModelAndView onsubmit(HttpServletRequest request
HttpServletResponse response object command BindException errors)
throws Exception {
HttpSession session = request.getSession();
CartCheckoutForm form = (CartCheckoutForm) command;
TbMember user = dao.getUser(form.getUsername() null);
if (user == null) {
session.invalidate();
return new ModelAndView(getFormView());
}
float rebate = dao.getUserRebate(form.getUsername());
List cart = (List) session
.getAttribute(“cart“);
int number = 0;
double nowprice = (float) 0.0;
double sum = (float) 0;
double Totalsum = (float) 0;
long ID = -1;
// 插入订单主表数据
short bnumber = 0;
if (cart != null) {
bnumber = (short) cart.size();
}
TbOrder order = new TbOrder();
order.setAddress(form.getAddress());
order.setBnumber(bnumber);
order.setBz(form.getBz());
order.setCarry(form.getCarry());
order.setPay(form.getPay());
order.setPostcode(form.getPostcode());
order.setRebate(rebate);
order.setTel(form.getTel());
order.setTruename(form.getTruename());
order.setUsername(form.getUsername());
order.setOrderDate(new Date());
order.setEnforce(0);
Set tbOrderDetails = order.getTbOrderDetails();
// 插入订单明细表数据
for (int i = 0; i < bnumber; i++) {
GoodsElement myGoodsElement = cart.get(i);
ID = myGoodsElement.getID();
nowprice = myGoodsElement.getNowPrice() * rebate;
number = myGoodsElement.number;
sum = nowprice * number;
TbOrderDetail details = new TbOrderDetail();
details.setNumber(number);
details.setPrice(nowprice);
details.setTbOrder(order);
TbGoods goods = dao.getGoods(ID);
details.setTbGoods(goods);
tbOrderDetails.add(details);
Totalsum = Totalsum + sum;
}
// 更新会员信息和会员等级
user.setAmount(user.getAmount() == null ? Totalsum : user.getAmount()
+ Totalsum);
int userGrade = dao.getGrade(user.getAmount());
if (user.getGrade() == null || userGrade > user.getGrade())
user.setGrade(userGrade);
dao.insertobject(user order);// 在事物中完成订单保存
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 1310720 2008-08-15 01:11 Java电子商务系统\Databa
....... 1048576 2008-08-15 01:11 Java电子商务系统\Databa
....... 919552 2008-04-07 08:52 Java电子商务系统\readme.doc
....... 780 2007-11-29 11:04 Java电子商务系统\XinXiangShop\.classpath
....... 34 2007-11-18 08:52 Java电子商务系统\XinXiangShop\.hibernateSynchronizer3\config.properties
....... 459 2006-12-28 10:57 Java电子商务系统\XinXiangShop\.myhibernatedata
....... 309 2007-12-05 09:25 Java电子商务系统\XinXiangShop\.myme
....... 1860 2007-12-05 09:24 Java电子商务系统\XinXiangShop\.project
....... 506 2007-03-24 08:39 Java电子商务系统\XinXiangShop\.settings\org.eclipse.wst.validation.prefs
....... 490 2007-01-29 09:55 Java电子商务系统\XinXiangShop\.springBeans
....... 3519 2007-12-02 13:14 Java电子商务系统\XinXiangShop\src\com\lzw\CartCheckoutController.java
....... 2891 2007-11-26 14:17 Java电子商务系统\XinXiangShop\src\com\lzw\CartController.java
....... 689 2007-11-05 10:10 Java电子商务系统\XinXiangShop\src\com\lzw\collect\GoodsElement.java
....... 8156 2007-11-29 11:11 Java电子商务系统\XinXiangShop\src\com\lzw\dao\Dao.java
....... 1217 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\form\CartCheckoutForm.java
....... 341 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\form\CommandForm.java
....... 1931 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\form\ModifyMemberForm.java
....... 315 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\form\SearchForm.java
....... 378 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\form\UserLoginForm.java
....... 1156 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\GoodsDetailsController.java
....... 1257 2007-11-21 20:13 Java电子商务系统\XinXiangShop\src\com\lzw\GridLayoutDemo.java
....... 2009 2007-11-23 09:10 Java电子商务系统\XinXiangShop\src\com\lzw\LoginController.java
....... 335 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\manager\form\LoginForm.java
....... 211 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\manager\form\ProductCommand.java
....... 388 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\manager\form\SubTypeAddForm.java
....... 232 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\manager\form\SuperTypeAddForm.java
....... 204 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\manager\form\SuperTypeForm.java
....... 1412 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\manager\GoodsAddController.java
....... 1526 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\manager\GoodsDelController.java
....... 1864 2007-03-24 09:07 Java电子商务系统\XinXiangShop\src\com\lzw\manager\GoodsModifyController.java
............此处省略316个文件信息
- 上一篇:UDP客户端demo
- 下一篇:android_本地多图片选择Demo
评论
共有 条评论