xxx購物超市折扣規則描述:
1.任何顧客的購物總價大于1000元則享受9折優惠
2.vip顧客的時候無論購物總價是多少享受7折優惠
3.普通顧客沒有特別政策,另有規定的除外
4.白金顧客享受8.5優惠,無論購物總價多少。
5.黃金顧客享受9折優惠無論購物總價多少。
6.任何顧客所夠商品中包含tv的時候,優惠后再優惠9.5折
這個user case 是自己想的,不是很復雜
對應的規則文件
#created on: 2006-6-10
#created by: kebo
package com.sample
import com.sample.Person;
import com.sample.ShopCat;
import com.sample.Product;
import com.sample.Helper;
rule "PRICE_DISCOUT"
salience 2
no-loop true
when
p:Person(c:cat->(c.getTotalPrice()>1000),discout==1)
then
p.setDiscout(0.9);
modify(p);
end
rule "VIP"
salience 3
no-loop true
when
p:Person(type==Person.VIP,discout==1)
then
p.setDiscout(0.7);
modify(p);
end
rule "COMMON"
salience 3
no-loop true
when
p:Person(type==Person.COMMON,discout==1)
then
p.setDiscout(1);
modify(p);
end
rule "PLATINA"
salience 3
no-loop true
when
p:Person(type==Person.PLATINA,discout==1)
then
p.setDiscout(0.85);
modify(p);
end
rule "GOLD"
salience 3
no-loop true
when
p:Person(type==Person.GOLD,discout==1)
then
p.setDiscout(0.9);
modify(p);
end
rule "CONTAIN TV"
salience 1
no-loop true
when
p:Person(c:cat->(Helper.isContainType(c.getProducts(),Product.TV)))
then
p.setDiscout(0.95 * p.getDiscout());
modify(p);
end
解決rule的沖突還是比較麻煩的。
為什么blogjava沒有code著色功能呢?代碼貼上去一點都不好看,唉!
posted on 2006-06-13 01:19
kebo 閱讀(2041)
評論(0) 編輯 收藏 所屬分類:
java