package com.oqpo.api.web.dto.response.loanmng;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.settmng.StlMgntBaseInfoEntity;
import com.oqpo.api.entity.settmng.StlMgntDtlPtclEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.util.List;
import java.util.stream.Collectors;


@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class UnpaidMngInfoResponse {

    @ApiModelProperty(value = "정산관리고유번호")
    private String sttlMgntUnqNo;
    @ApiModelProperty(value = "정산요청일자")
    private String sttlReqDt;
    @ApiModelProperty(value = "브랜드아이디")
    private String brandId;
    @ApiModelProperty(value = "브랜드명")
    private String brandNm;
    @ApiModelProperty(value = "매장아이디")
    private String storeId;
    @ApiModelProperty(value = "매장명")
    private String storeNm;
    @ApiModelProperty(value = "정산상태코드")
    private String sttlStCd;
    @ApiModelProperty(value = "정산상태명")
    private String sttlStNm;
    @ApiModelProperty(value = "정산부가상태명")
    private String sttlAddStNm;
    @ApiModelProperty(value = "정산요청금액")
    private Long sttlReqAmt;
    @ApiModelProperty(value = "정산일자")
    private String sttlDt;
    @ApiModelProperty(value = "정산금액")
    private Long sttlAmt;
    @ApiModelProperty(value = "미납금액(후불사용)")
    private Long unpaidAmt;
    @ApiModelProperty(value = "정산등록담당자명")
    private String sttlRegMgrNm;
    @ApiModelProperty(value = "정산등록담당자아이디")
    private String sttlRegMgrId;
    @ApiModelProperty(value = "시스템등록일시")
    private String sysRegDttm;
    @ApiModelProperty(value = "시스템등록아이디")
    private String sysRegId;
    @ApiModelProperty(value = "시스템등록자")
    private String sysRegNm;
    @ApiModelProperty(value = "시스템변경일시")
    private String sysChgDttm;
    @ApiModelProperty(value = "시스템변경아이디")
    private String sysChgId;

    @ApiModelProperty(value = "계좌잔액")
    private Long acctBal;

    @ApiModelProperty(value = "사용가능한도")
    private Long useAmtTotal;
    @ApiModelProperty(value = "수납여부(후불사용)")
    private String rcptYn;

    public static UnpaidMngInfoResponse toDTO(StlMgntBaseInfoEntity entity) {
        if (entity == null) return null;
        return UnpaidMngInfoResponse.builder()
                .sttlMgntUnqNo(entity.getSttlMgntUnqNo())
                .sttlReqDt(entity.getSttlReqDt())
                .sttlDt(entity.getSttlDt())
                .brandId(entity.getBrandId())
                .brandNm(entity.getBrandNm())
                .storeId(entity.getStoreId())
                .storeNm(entity.getStoreNm())
                .sttlStCd(entity.getSttlStCd())
                .sttlStNm(entity.getSttlStNm())
                .sttlAddStNm(entity.getSttlAddStNm())       /* 정산부가상태명 */
                .sttlReqAmt(entity.getSttlReqAmt())         /* 정산요청금액 */
                .sttlAmt(entity.getSttlAmt())               /* 정산확정금액 */
                .unpaidAmt(entity.getUnpaidAmt())           /* 미납금액 */
                .sttlRegMgrNm(entity.getSttlRegMgrNm())
                .sttlRegMgrId(entity.getSttlRegMgrId())
                .sysRegDttm(entity.getSysRegDttm())
                .sysRegId(entity.getSysRegId())
                .sysRegNm(entity.getSysRegNm())
                .sysChgDttm(entity.getSysChgDttm())
                .sysChgId(entity.getSysChgId())
                .acctBal(entity.getAcctBal())               /* 계좌잔액 */
                .useAmtTotal(entity.getUseAmtTotal())       /* 사용가능한도금액 */
                .rcptYn(entity.getRcptYn())
                .build();
    }

}
