Skip to content

springboot+策略模式 实现简单促销

Notifications You must be signed in to change notification settings

luozijing/sb_promotion

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

使用策略模式 实现一个基本的促销

    //加法
    BigDecimal result1 = num1.add(num2);
    //减法
    BigDecimal result2 = num1.subtract(num2);
    //乘法
    BigDecimal result3 = num1.multiply(num2);
    //除法
    BigDecimal result5 = num2.divide(num1,20,BigDecimal.ROUND_HALF_UP);
    //绝对值
    BigDecimal result4 = num3.abs();

    比较大小
    结果是:   -1:小于;   0 :等于;   1 :大于;
    BigDecimal b1 = new BigDecimal("-121454125453.145");
    if(b1.compareTo(BigDecimal.ZERO)==-1) {
    	System.out.println("金额为负数!");
    }

/**
 * 商品
 */
public class Product implements Serializable {

    private String code;

    private String name;

    /**
     * 销售价
     */
    private BigDecimal amount;

    /**
     * 优惠金额
     */
    private BigDecimal discountAmount;

    /**
     * 最终实付价格
     */
    private BigDecimal finalAmount;


    private Integer quantity;
 }

About

springboot+策略模式 实现简单促销

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 88.2%
  • HTML 11.8%