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

import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.common.liaall.vo.LiaallVo;
import com.brilliance.isc.common.liaccv.vo.LiaccvVo;
import com.brilliance.isc.common.setfeg.vo.SetfegVo;
import com.brilliance.isc.common.setfog.vo.SetfogVo;
import com.brilliance.isc.common.setglg.vo.SetglgVo;
import com.brilliance.isc.common.setmod.vo.PtsFeeDetailVo;
import com.brilliance.isc.common.setmod.vo.SetmodVo;
import com.brilliance.isc.common.trndoc.vo.DoceotVo;
import com.brilliance.isc.common.vo.AbstractCommonVo;
import com.brilliance.isc.common.vo.BizAmdInfoVo;
import com.brilliance.isc.common.vo.BizInfoVo;
import com.brilliance.isc.common.vo.PtsptaVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

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
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
@ApiModel(value = "试算账务请求信息", description = "试算账务请求信息")
public class SettleDetailRequestVo<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 = "业务摘要信息", 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 = "他行收费信息", name = "setfg", required = true)
    private SetfogVo setfog;

    @ApiModelProperty(value = "我行收费信息", name = "setfeg", required = true)
    private SetfegVo setfeg;

    @ApiModelProperty(value = "费用角色详情集合", name = "ptydet", required = true)
    private List<PtsFeeDetailVo> ptydet;

    @ApiModelProperty(value = "面函信息", name = "doceotList", required = true)
    private List<DoceotVo> doceot;

    @ApiModelProperty(value = "表外记账", name = "liaall", required = true)
    private LiaallVo liaall;

    @ApiModelProperty(value = "表外保证金", name = "liaccv", required = true)
    private LiaccvVo liaccv;

    @ApiModelProperty(value = "账务信息", name = "setglg", required = true)
    private SetglgVo setglg;

    //费用试算计算模型
    @ApiModelProperty(hidden = true)
    private SetmodVo setmodVo;

    @ApiModelProperty(value = "sptinr", name = "sptinr", required = true)
    private String sptinr;

    private String doccur = "";

    private BigDecimal docamt = BigDecimal.ZERO;

    @Override
    public void reset() {
        if (rec == null) {
            rec = (T1) new BizInfoVo();
        }
        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 (setfog == null) {
            setfog = new SetfogVo();
        }
        setfog.reset();
        if (setfeg == null) {
            setfeg = new SetfegVo();
        }
        setfeg.reset();
        if (setglg == null) {
            setglg = new SetglgVo();
        }
        setglg.reset();
        if (ptydet == null) {
            ptydet = new ArrayList<>();
        }
        ptydet.forEach(ptsFeeDetailVo -> ptsFeeDetailVo.reset());
        if (liaall == null) {
            liaall = new LiaallVo();
        }
        liaall.reset();
        if (liaccv == null) {
            liaccv = new LiaccvVo();
        }
        liaccv.reset();
        if (setmodVo == null) {
            setmodVo = new SetmodVo(this);
        }
        setmodVo.reset();
    }
}
