?? sale.java
字號(hào):
/**
* @name Sale.java
* @version 1.1
* @author Administrator/pan
* @date 2009/2/11
*/
package com.digitstore.process.sale;
import java.io.Serializable;
import java.util.Date;
import com.digitstore.process.manageruser.Customer;
import com.digitstore.process.sale.Cart;
import com.digitstore.process.OrderForm;
import com.digitstore.process.server.PricingStrategyFactory;
import com.digitstore.process.server.sale.CashPayment;
import com.digitstore.process.server.sale.CompositeBestForCustomerPricingStrategy;
import com.digitstore.process.server.sale.CreditPayment;
import com.digitstore.process.server.sale.Payment;
import com.digitstore.process.server.sale.PercentDiscountPricingStrategy;
import com.digitstore.process.server.sale.VirtualMoneyPayment;
public class Sale implements Serializable {
//顧客編號(hào)
private String customerID;
//時(shí)間
private Date date;
//是否購物完成
private boolean isCompleted;
//所購商品的總價(jià)
private double total = 0;
//購物車
private Cart cart;
//賬單
private Payment payment;
//訂單
private OrderForm orderForm;
//獲取顧客最有組合定價(jià)策略
private CompositeBestForCustomerPricingStrategy compBFCPstra = PricingStrategyFactory.getInstance().getCompBestCustPriStrategy();
//構(gòu)造函數(shù)
public Sale(String customerID){
date = new Date();
isCompleted = false;
cart = new Cart();
this.customerID = customerID;
}
//對應(yīng)的get/set方法
public String getCustomerID(){
return customerID;
}
public void setCustomerID(String customerID){
this.customerID = customerID;
}
public Date getDate(){
return date;
}
public void setDate(Date date){
this.date = date;
}
public boolean getIscompleted(){
return isCompleted;
}
public void setIscompleted(boolean isCompleted){
this.isCompleted = isCompleted;
}
public Cart getCart(){
return cart;
}
public void setCart(Cart cart){
this.cart = cart;
}
public Payment getPayment(){
return payment;
}
public void setPayment(Payment payment){
this.payment = payment;
}
public OrderForm getOrderForm(){
return orderForm;
}
public void setOrderForm(OrderForm orderForm){
this.orderForm = orderForm;
}
//購物完畢的設(shè)置方法
public void becomeCompleted(){
this.isCompleted = true;
}
//添加物品,默認(rèn)是添加1
public void makeLineItem(String itemID){
cart.addSalesLineItem(itemID);
}
//移除商品
public void removeSalesLineItem(String itemID){
cart.removeSalesLineItem(itemID);
}
//更新指定的SalesLineItem的商品數(shù)量
public void setQuntitySLI(String itemID, int quantity){
cart.setQuntitySLI(itemID, quantity);
}
//用貨幣支付商品款項(xiàng)
public void makeCashPayment(String customerID){
payment = new CashPayment(customerID, total);
}
//用信用卡支付商品貨款
public void makeCreditPayment(String customerID){
payment = new CreditPayment(customerID, total);
}
//使用虛擬貨幣支付
public void makeVirtualPayment(String customerID){
payment = new VirtualMoneyPayment(customerID, total);
}
//填寫表單
public void makeOrderForm(){
orderForm = new OrderForm();
}
//算總賬,沒有折扣
public double getTotal(){
//設(shè)置總價(jià)格
setTotal(cart.getTotal());
return total;
}
//算總賬,有折扣
public double getTotal(Sale sale){
//設(shè)置總價(jià)格
setTotal(compBFCPstra.getTotal(sale));
return total;
}
//設(shè)置商品總價(jià)格
public void setTotal(double total){
this.total = total;
}
//輸入用戶類型,計(jì)算本次折扣
public void enterCustomerForDiscount(Customer customer){
PercentDiscountPricingStrategy percDPStrategy = PricingStrategyFactory.getInstance().getPercDisPriStrategy();
percDPStrategy.setPercentage(customer.getDiscount());
compBFCPstra.add(percDPStrategy);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -