java1

public String countFee(Order order){

    double totalFee = 0;
    ArrayList<DiscountInfo>  discountInfos = order.getDiscountInfos();
    ArrayList<Product>products = order.getProducts();
    String coupon = order.getCouponInfo();
    if(null!=discountInfos&&discountInfos.size()>0){
        for(int i=0;i<discountInfos.size();i++){
            for(int j=0;j<products.size();j++){
                //此处做判断是为了防止结算日期和打折日期不一致,也就是该订单已经过了打折日期
                if(discountInfos.get(i).getDate().trim().equals(order.getPayDate().trim())){
                    if(products.get(j).getType().trim().equals(discountInfos.get(i).getProType().trim())){
                        products.get(j).setFee(products.get(j).getUnitPrice()*products.get(j).getCount()*Double.valueOf(discountInfos.get(i).getDiscount()));
                    }else{
                        products.get(j).setFee(products.get(j).getUnitPrice()*products.get(j).getCount());

                    }
                }else{
                    products.get(j).setFee(products.get(j).getUnitPrice()*products.get(j).getCount());
                }
            }

        }
    }else{
        for(int j=0;j<products.size();j++){
            products.get(j).setFee(products.get(j).getUnitPrice()*products.get(j).getCount());
        }
    }

    for(int i=0;i<products.size();i++){
        totalFee = totalFee+products.get(i).getFee();
    }
    if(null!=order.getCouponInfo()&&(order.getCouponInfo().length()>0)){
        String[] coupons = order.getCouponInfo().split(" ");
        if(coupons[0].trim().compareTo(order.getPayDate().trim())>0){
            if(totalFee>Double.valueOf(coupons[1])){
                totalFee = totalFee-Double.valueOf(coupons[2]);
            }
        }
    }
    double temp = (double)Math.round(totalFee*100)/100;
    BigDecimal big = new BigDecimal(temp);
    DecimalFormat df = new DecimalFormat("#.00");

    return df.format(temp);

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值