package com.bonus.canteen.core.marketing.v2.rule.price.dto;

import cn.hutool.core.bean.BeanUtil;
import com.bonus.canteen.core.marketing.vo.MarketRuleRecordVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@ApiModel("计价规则出参-订单列表")
public class RulePriceResultOrderDTO extends RulePriceOrderDTO {
   @ApiModelProperty("实付金额")
   private BigDecimal realAmount;
   @ApiModelProperty("优惠金额")
   private BigDecimal discountsAmount;
   @ApiModelProperty("钱包实付金额详情，目前计价规则里面涉及固定补贴")
   private List<RulePriceWalletDTO> walletDetails;
   @ApiModelProperty("命中消费规则记录")
   private List<MarketRuleRecordVO> ruleRecord;

   public RulePriceResultOrderDTO(RulePriceOrderDTO order) {
      BeanUtil.copyProperties(order, this, new String[0]);
      this.realAmount = order.getPayableAmount();
      this.discountsAmount = BigDecimal.ZERO;
      this.ruleRecord = new ArrayList();
      this.walletDetails = new ArrayList();
   }

   public static List<RulePriceResultOrderDTO> convertToResultOrder(List<RulePriceOrderDTO> orders) {
      return (List)orders.stream().map(RulePriceResultOrderDTO::new).collect(Collectors.toList());
   }

   public BigDecimal getRealAmount() {
      return this.realAmount;
   }

   public BigDecimal getDiscountsAmount() {
      return this.discountsAmount;
   }

   public List<RulePriceWalletDTO> getWalletDetails() {
      return this.walletDetails;
   }

   public List<MarketRuleRecordVO> getRuleRecord() {
      return this.ruleRecord;
   }

   public RulePriceResultOrderDTO setRealAmount(final BigDecimal realAmount) {
      this.realAmount = realAmount;
      return this;
   }

   public RulePriceResultOrderDTO setDiscountsAmount(final BigDecimal discountsAmount) {
      this.discountsAmount = discountsAmount;
      return this;
   }

   public RulePriceResultOrderDTO setWalletDetails(final List<RulePriceWalletDTO> walletDetails) {
      this.walletDetails = walletDetails;
      return this;
   }

   public RulePriceResultOrderDTO setRuleRecord(final List<MarketRuleRecordVO> ruleRecord) {
      this.ruleRecord = ruleRecord;
      return this;
   }


   public RulePriceResultOrderDTO(final BigDecimal realAmount, final BigDecimal discountsAmount, final List<RulePriceWalletDTO> walletDetails, final List<MarketRuleRecordVO> ruleRecord) {
      this.realAmount = realAmount;
      this.discountsAmount = discountsAmount;
      this.walletDetails = walletDetails;
      this.ruleRecord = ruleRecord;
   }

   public RulePriceResultOrderDTO() {
   }
}
