1.向购物车添加商品,(首先,应该判断该商品是否在购物车中已经存在,若存在,该商品数量+1,若不存在,则将该商品加入购物车并数量设置为1)
2.修改商品的数量(请求一个servlet,并根据该商品的某个唯一属性修改其数量)
3.删除商品(通过请求servlet并根据要删除商品的唯一属性将其删除)
4.清空购物车(请求servlet将购物车清空)
5.获得商品的初始价格
6.获得商品的会员价格
7.获得优惠价格
8.获得购物车中的所有商品
public class Gwc {
private int gwcId;
private int custId;
private int bookId;
private String bookName;
private String smallImg;
private float price;
private float hyPrice;
private int num;
public Gwc() {
// TODO Auto-generated constructor stub
}
public Gwc(int gwcId, int custId, int bookId, String bookName,
String smallImg, float price, float hyPrice, int num) {
super();
this.gwcId = gwcId;
this.custId = custId;
this.bookId = bookId;
this.bookName = bookName;
this.smallImg = smallImg;
this.price = price;
this.hyPrice = hyPrice;
this.num = num;
}
public Gwc(int custId, int bookId, String bookName, String smallImg,
float price, float hyPrice, int num) {
super();
this.custId = custId;
this.bookId = bookId;
this.bookName = bookName;
this.smallImg = smallImg;
this.price = price;
this.hyPrice = hyPrice;
this.num = num;
}
public int getGwcId() {
return gwcId;
}
public void setGwcId(int gwcId) {
this.gwcId = gwcId;
}
public int getCustId() {
return custId;
}
public void setCustId(int custId) {
this.custId = custId;
}
public int getBookId() {
return bookId;
}
public void setBookId(int bookId) {
this.bookId = bookId;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getSmallImg() {
return smallImg;
}
public void setSmallImg(String smallImg) {
this.smallImg = smallImg;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public float getHyPrice() {
return hyPrice;
}
public void setHyPrice(float hyPrice) {
this.hyPrice = hyPrice;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
购物车接口:
import java.util.List;
import com.jinzhi.entity.Gwc;
public interface IGwcDAO {
public int add(int custId, Gwc gwc);
public int updateNum(int custId, int bookId, int num);
public int delete(int custId, int bookId);
public int clear(int custId);
public Gwc findById(int custId, int bookId);
public float getOldPrices(int custId);
public float getHyPrices(int custId);
public float getYhPrice(int custId);
public List<Gwc> getAllItems(int custId);
}