package com.brilliance.isc.common.umdmod.vo;

import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.bo.Umd;
import com.brilliance.isc.bo.model.Ptsaddg;
import com.brilliance.isc.common.api.usrmd.vo.UsrmdRequest;
import com.brilliance.isc.common.setglg.vo.SetglgVo;
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.brilliance.isc.vo.CipmodVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class UmdmodVo extends  AbstractCommonVo {

    /**
     * 交易吗
     */
    protected  String transName;

    protected BizInfoVo rec;

    protected BizAmdInfoVo amdRec;

    private List<PtsptaVo> ptsptas;

    private List<Ptsaddg> ptsaddg;

    private Map<String, Cbb> cbsMap;

    private  String excuteflg;
    /**
     * 原界面字段
     */
    private String bennam;
    /**
     * 命中标志
     */
    private String minzflg;
    /**
     * \\TRNMOD\\ORDMOD\\ORD\\SDHFLG
     */
    private String sdhflg;
    /**
     * \\TRNMOD\\ORDMOD\\ORD\\OWNUSR
     */
    private String ownusr;

    /**
     *\TRNMOD\TRN\INR
     */
    private String trninr;
    /**
     * TRNMOD\ORDMOD\ORD\INR
     */
    private String ordinr;
    /**
     * sptinr
     */
    private String sptinr;
    /**
     * 错误信息列表
     */
    private List<Map<String,Object>> errormaps;

    private Umd umd;
    /**
     * cips报文
     */
    private CipmodVo cipmodVo;

    private SetglgVo setglgVo;
    /**
     * 保存mac原文
     */
    private String maccontent;
    /**
     * 界面列表
     */
    private List<Umd> umdList;
    /**
     * 业务系统流水号
     */
    private String TRANS_ID;
    /**
     * 业务编号
     */
    private String TRANS_NO;
    /**
     * 查询类型
     */
    private String QUERY_TYPE;
    /**
     * 发起方
     */
    private String SYSTEM_ID;
    /**
     *机构代码
     */
    private String ORG_CODE;
    /**
     * 交易代码
     */
    private String TRANS_CODE;
    /**
     * 操作员
     */
    private String OPERATOR;
    /**
     * 发起时间
     */
    private String START_TM;
    /**
     * 报文类型
     */
    private String MESSAGE_TYP;
    /**
     * 客户号
     */
    private String CUST_NO;
    /**
     * 借贷标志
     */
    private String LOAN_FLAG;
    /**
     * 币种
     */
    private String TRANS_CUR;
    /**
     * 金额
     */
    private String TRANS_AMT;
    /**
     * 案例编号
     */
    private String CASE_NO;
    /**
     * 预留字段1
     */
    private String RESERVE1;
    /**
     * 预留字段2
     */
    private String RESERVE2;
    /**
     * 参与者信息
     */
    private List<CustVo> CUSTS;
    /**
     * 交易信息
     */
    private List<TranVo> TRANS;
    /**
     * 栏位信息
     */
    private List<TagVo> TAGS;

    public UmdmodVo(UsrmdRequest usrmdRequest){
        this.cbsMap=usrmdRequest.getCbsMap();
        this.ptsptas=usrmdRequest.getPtsList();
        this.rec=usrmdRequest.getRec();
        this.amdRec=usrmdRequest.getAmdRec();
        this.ptsaddg=usrmdRequest.getPtsaddg();
        this.bennam=usrmdRequest.getBennam();
        this.cipmodVo=usrmdRequest.getCipmodVo();
        this.setSetglgVo(usrmdRequest.getSetglgVo());
        this.setModifySet(usrmdRequest.getModifySet());
        this.umdList = usrmdRequest.getUmdList();
    }

    @Override
    public void reset() {
        if (rec == null) {
            rec = new BizInfoVo();
        }
        if (ptsptas == null) {
            ptsptas = new ArrayList<>();
        }
        ptsptas.forEach(ptsptaVo -> ptsptaVo.reset());

        if (ptsaddg == null) {
            ptsaddg = new ArrayList<>();
        }
        if (umdList == null) {
            umdList = new ArrayList<>();
        }
        if (setglgVo == null) {
            setglgVo = new SetglgVo();
        }
        setglgVo.reset();
        if (cipmodVo == null) {
            cipmodVo = new CipmodVo();
        }
    }

    public void addTran(TranVo tranVo) {
        if (TRANS == null) {
            TRANS = new ArrayList<>();
        }
        TRANS.add(tranVo);
    }
}
