package com.heyu.api.alibaba.request.mm;

import com.heyu.api.alibaba.request.mm.order.VvActivityDTO;

import java.math.BigDecimal;

public class ActivityUtils {


    public static VvActivityDTO bestActivityDTO(VvActivityDTO v1, VvActivityDTO v2) {


        if (v1 == null) {

            return v2;
        }

        if (v2 == null) {

            return v1;
        }

        BigDecimal awardAmount = v1.getAwardAmount();
        BigDecimal discountAmount = v1.getDiscountAmount();

        if (awardAmount == null || (v2.getAwardAmount() != null && v2.getAwardAmount().compareTo(awardAmount) >= 0)) {
            awardAmount = v2.getAwardAmount();
        }

        if (discountAmount == null || (v2.getDiscountAmount() != null && v2.getDiscountAmount().compareTo(discountAmount) >= 0)) {
            discountAmount = v2.getDiscountAmount();
        }

        v1.setAwardAmount(awardAmount);
        v1.setDiscountAmount(discountAmount);
        return v1;
    }
}
