package com.brilliance.isc.common.api.liaccv.vo;

import com.brilliance.mda.runtime.mda.util.Decimals;
import com.brilliance.mda.support.jakson.serialize.BigDecimalSerializeRate;
import com.brilliance.mda.support.jakson.serialize.DecimalLength;
import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.common.liaccv.vo.LiaccvVo;
import com.brilliance.isc.common.liaccv.vo.LiaccvgVo;
import com.brilliance.isc.common.vo.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.brilliance.mda.runtime.mda.Constants.NULLSTR;

@Data
@ApiModel(value = "保证金请求信息", description = "保证金请求信息")
@JsonIgnoreProperties(ignoreUnknown = true)
public class LiaccvRequest<T1 extends BizInfoVo, T2 extends BizAmdInfoVo> extends AbstractCommonVo {

    @ApiModelProperty(value = "当前交易码", name = "transName", required = true)
    private String transName = NULLSTR;

    @ApiModelProperty(value = "当前经办人员ID", name = "userId", required = true)
    private String userId = NULLSTR;

    @ApiModelProperty(value = "经办数据Spt主键", name = "sptInr", required = true)
    private String sptInr = NULLSTR;

    @ApiModelProperty(value = "业务摘要信息", name = "rec", required = true)
    private T1 rec;

    @ApiModelProperty(value = "业务摘要修改信息", name = "rec", required = true)
    private T2 amdRec;

    @ApiModelProperty(value = "CBB列表", name = "cbsMap", required = true)
    private Map<String, Cbb> cbsMap;

    @ApiModelProperty(value = "交易角色参与方列表", name = "ptsList", required = true)
    private List<PtsptaVo> ptsList;

    @ApiModelProperty(value = "Liaccvg列表", name = "liaallgList", required = true)
    private List<LiaccvgVo> liaccvg;

    private FcdVo fcdVo;

    private String oldcur = "";

    private BigDecimal oldamt = Decimals.ZERO_SCALE2;

    private BigDecimal chgamt = Decimals.ZERO_SCALE2;

    private String concur = "";

    private String gleflg = "";

    private String chgcurflg = "";

    private String newrol = "";

    //old info read X表示已经读了old
    private String oldredflg = NULLSTR;

    private BigDecimal oldresamt = Decimals.ZERO_SCALE2;

    private BigDecimal cshpct = Decimals.ZERO_SCALE6;

    private BigDecimal chgresamt = Decimals.ZERO_SCALE2;

    private String macold = "";

    private String objmodpath = "";

    @ApiModelProperty(value = "合同金额", name = "newamt", required = true)
    private BigDecimal newamt = BigDecimal.ZERO;

    @ApiModelProperty(value = "保留金额", name = "newresamt", required = true)
    private BigDecimal newresamt = BigDecimal.ZERO;

    @ApiModelProperty(value = "实收比例", name = "relcshpct", required = true)
    @JsonSerialize(using = BigDecimalSerializeRate.class)
    @DecimalLength(6)
    private BigDecimal relcshpct = BigDecimal.ZERO;

    @ApiModelProperty(value = "应付金额", name = "pctresamt", required = true)
    private BigDecimal pctresamt = BigDecimal.ZERO;

    @ApiModelProperty(value = "折算金额总和", name = "totcovamt", required = true)
    private BigDecimal totcovamt = BigDecimal.ZERO;

    @ApiModelProperty(value = "附加信息", name = "addinf", required = true)
    private String addinf;

    /**
     * cbe 列表
     */
    private String cbeListJson = "";

    @ApiModelProperty(hidden = true)
    private LiaccvVo liaccvVo;

    @Override
    public void reset() {
        if (rec == null) {
            rec = (T1) new BizInfoVo();
        }
        rec.reset();
        if (amdRec == null) {
            amdRec = (T2) new BizAmdInfoVo();
        }
        amdRec.reset();
        if (cbsMap == null) {
            cbsMap = new HashMap<>();
        }
        if (ptsList == null) {
            ptsList = new ArrayList<>();
        }
        ptsList.forEach(p -> p.reset());
        if (liaccvg == null) {
            liaccvg = new ArrayList<>();
        }
        liaccvg.forEach(liaccvgVo -> liaccvgVo.reset());
        if (liaccvVo == null) {
            liaccvVo = new LiaccvVo(this);
        }
        liaccvVo.reset();
        if (fcdVo == null) {
            fcdVo = new FcdVo();
        }
    }
}
