package rules.demo;

import cn.bunny.drools.bean.demo.demo1.Order;

/**
* 当订单金额超过100元时，给予5%折扣
*  VIP客户额外获得2%折扣
*  两种折扣可以叠加
*/
// 大于100元 5折优惠
rule "Give 5% discount for orders over 100"
    when
        $order: Order(amount > 100)
    then
        $order.applyDiscount(0.05);
        System.out.println("当订单金额超过100元时，给予5%折扣");
end

// VIP客户额外获得2%折扣
rule "Give additional 2% discount for VIP customers"
    when
        $order: Order(amount > 100,vip == true)
    then
       $order.applyDiscount(0.02);
       System.out.println("是个Vip");
end

// 没有优惠
rule "No discount for small orders"
    when
        $order: Order(amount <= 100)
    then
       System.out.println("没有优惠");
end