package com.casic.missiles.dto.finance;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.alibaba.excel.enums.poi.BorderStyleEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * @Description: 业务结算列表响应实体
 * @Author: wangpeng
 * @Date: 2023/3/31 17:20
 */
@ColumnWidth(30)
@HeadRowHeight(15)
@ContentRowHeight(20)
@ContentStyle(borderLeft = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN, borderTop = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN)
@ExcelIgnoreUnannotated
@ApiModel
@Data
public class SettlementInfoListResponse {
    private Long id;

    @ApiModelProperty(hidden = true)
    private Long orderId;

    @ApiModelProperty(value = "委托书编号", dataType = "String")
    @ExcelProperty(value = "委托书编号")
    private String orderCode;

    @ApiModelProperty(value = "委托方id", dataType = "String")
    private String customerId;

    @ApiModelProperty(value = "委托方编号", dataType = "String")
    @ExcelProperty(value = "委托方编号")
    private String customerNo;

    @ApiModelProperty(value = "委托方名称", dataType = "String")
    @ExcelProperty(value = "委托方名称")
    private String customerName;

    @ApiModelProperty(value = "送样人", dataType = "String")
    @ExcelProperty(value = "送样人")
    private String deliverer;

    @ApiModelProperty(value = "送样人联系方式", dataType = "String")
    @ExcelProperty(value = "送样人联系方式")
    private String delivererTel;

    @ApiModelProperty(value = "样品数量", dataType = "Integer")
    @ExcelProperty(value = "样品数量")
    private Integer sampleCount;

    @ApiModelProperty(value = "是否加急", dataType = "String")
    @ExcelProperty(value = "是否加急")
    private String isUrgent;

    public String getIsUrgent() {
        if("1".equals(isUrgent)){
            isUrgent = "是";
        }else {
            isUrgent = "否";
        }
        return isUrgent;
    }

    @ApiModelProperty(value = "创建时间", dataType = "String")
    @ExcelProperty(value = "创建时间")
    private String createTime;

    @ApiModelProperty(value = "标价-单位分", dataType = "Integer")
    private Integer postedPrice;

    public String getPostedPriceYuan() {
        if(Objects.nonNull(suggestedDiscount)){
            postedPriceYuan = BigDecimal.valueOf(suggestedDiscount).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).toPlainString();
        }
        return postedPriceYuan;
    }

    @ExcelProperty(value = "标价(元)")
    private String postedPriceYuan;

    @ApiModelProperty(value = "建议折扣-单位%", dataType = "Integer")
    private Integer suggestedDiscount;

    @ExcelProperty(value = "建议折扣")
    private String suggestedDiscountExport;

    public String getSuggestedDiscountExport() {
        if(Objects.nonNull(suggestedDiscount)) {
            suggestedDiscountExport = suggestedDiscount + "%";
        }
        return suggestedDiscountExport;
    }

    @ApiModelProperty(value = "建议价格-单位分", dataType = "Integer")
    private Integer suggestedPrice;

    @ExcelProperty(value = "建议价格(元)")
    private String suggestedPriceYuan;

    public String getSuggestedPriceYuan() {
        if(Objects.nonNull(suggestedPrice)){
            suggestedPriceYuan = BigDecimal.valueOf(suggestedPrice).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).toPlainString();
        }
        return suggestedPriceYuan;
    }

    @ApiModelProperty(value = "附加费用-单位分", dataType = "Integer")
    private Integer extraCharge;

    @ExcelProperty(value = "附加费用(元)")
    private String extraChargeYuan;

    public String getExtraChargeYuan() {
        if(Objects.nonNull(extraCharge)){
            extraChargeYuan = BigDecimal.valueOf(extraCharge).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).toPlainString();
        }
        return extraChargeYuan;
    }

    @ApiModelProperty(value = "附加费用说明", dataType = "String")
    @ExcelProperty(value = "附加费用说明")
    private String extraChargeIllustration;

    @ApiModelProperty(value = "总计结算费用-单位分", dataType = "Integer")
    private Integer totalSettlement;

    @ExcelProperty(value = "总计结算费用(元)")
    private String totalSettlementYuan;

    public String getTotalSettlementYuan() {
        if(Objects.nonNull(totalSettlement)){
            totalSettlementYuan = BigDecimal.valueOf(totalSettlement).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).toPlainString();
        }
        return totalSettlementYuan;
    }
}
