package com.bonus.core.marketing.v2.rule.price.handler.reductionfixed.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

@ApiModel("计价规则详情-固定减免")
public class PriceReductionFixedDTO {
   @ApiModelProperty("减免上限金额list(分)")
   private List<BigDecimal> items;

   public String toString() {
      StringBuilder stringBuilder = new StringBuilder();
      AtomicInteger index = new AtomicInteger(1);
      this.items.forEach((e) -> {
         if (index.get() == this.items.size()) {
            stringBuilder.append("后续减免上限：");
         } else {
            stringBuilder.append("第").append(index.get()).append("次减免上限：");
         }

         stringBuilder.append(e).append("<br/>");
         index.getAndIncrement();
      });
      return stringBuilder.toString();
   }

   public List<BigDecimal> getItems() {
      return this.items;
   }

   public void setItems(final List<BigDecimal> items) {
      this.items = items;
   }

}
