package com.oqpo.api.web.dto.response.stinfo.store;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.stinfo.BrandEntity;
import com.oqpo.api.entity.stinfo.StoreBaseInfoEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;


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

    @ApiModelProperty(value = "브랜드아이디")
    private String brandId;

    @ApiModelProperty(value = "브랜드명")
    private String brandNm;

    @ApiModelProperty(value = "매장아이디")
    private String storeId;

    @ApiModelProperty(value = "매장명")
    private String storeNm;

    @ApiModelProperty(value = "매장구분")
    private String storeDvsn;

    @ApiModelProperty(value = "매장구분명")
    private String storeDvsnNm;

    @ApiModelProperty(value = "오픈일")
    private String openDt;

    @ApiModelProperty(value = "폐점일")
    private String closeDt;

    @ApiModelProperty(value = "여신관리고유번호")
    private String loanMgntUnqNo;

    @ApiModelProperty(value = "여신구분")
    private String loanDvsn;

    @ApiModelProperty(value = "여신구분명")
    private String loanDvsnNm;

    @ApiModelProperty(value = "한도금액")
    private Integer limitAmt;

    @ApiModelProperty(value = "우편번호")
    private String zipNo;

    @ApiModelProperty(value = "주소1")
    private String addr1;

    @ApiModelProperty(value = "주소2")
    private String addr2;

    @ApiModelProperty(value = "전화번호")
    private String telNo;

    @ApiModelProperty(value = "팩스번호")
    private String faxNo;

    @ApiModelProperty(value = "이메일")
    private String emalAddr;

    @ApiModelProperty(value = "상태코드")
    private String storeStCd;

    @ApiModelProperty(value = "상태명")
    private String storeStNm;

    @ApiModelProperty(value = "사업자번호")
    private String bsnsRegNo;

    @ApiModelProperty(value = "법인번호")
    private String corpRegNo;

    @ApiModelProperty(value = "업태")
    private String ctgrBsns;

    @ApiModelProperty(value = "업종")
    private String bsnsCndt;

    @ApiModelProperty(value = "예금주명")
    private String ownerNm;

    @ApiModelProperty(value = "삭제구분")
    private String delYn;

    @ApiModelProperty(value = "지역구분코드")
    private String areaCd;

    @ApiModelProperty(value = "지역명")
    private String areaNm;

    @ApiModelProperty(value = "x좌표")
    private String latX;

    @ApiModelProperty(value = "y좌표")
    private String longY;

    @ApiModelProperty(value = "잔액")
    private Integer tmpRcvAcctTotal;

    @ApiModelProperty(value = "가수금액")
    private Integer acctBal;

    @ApiModelProperty(value = "매장 은행코드")
    private String storeBnkCd;

    @ApiModelProperty(value = "매장 은행명")
    private String storeBnkNm;

    @ApiModelProperty(value = "매장 계좌번호")
    private String storeAcctNo;

    @ApiModelProperty(value = "매장 예금주")
    private String storeOwacNm;

    @ApiModelProperty(value = "브랜드 은행코드")
    private String brandBnkCd;

    @ApiModelProperty(value = "브랜드 은행명")
    private String brandBnkNm;

    @ApiModelProperty(value = "브랜드 계좌번호")
    private String brandAcctNo;

    @ApiModelProperty(value = "브랜드 예금주")
    private String brandOwacNm;

    @ApiModelProperty(value = "등록일")
    private String sysRegDttm;

    @ApiModelProperty(value = "등록자")
    private String sysRegId;

    @ApiModelProperty(value = "수정일")
    private String sysChgDttm;

    @ApiModelProperty(value = "수정자")
    private String  sysChgId;

    public static StoreInfoResponse toDTO(StoreBaseInfoEntity entity) {
        if (entity == null) return null;
        return StoreInfoResponse.builder()
                .brandId(entity.getBrandId())
                .brandNm(entity.getBrandInfo() == null ? "" : entity.getBrandInfo().getBrandNm() == null ? "" : entity.getBrandInfo().getBrandNm())
                .storeId(entity.getStoreId())
                .storeNm(entity.getStoreNm())
                .storeDvsn(entity.getStoreDvsn() == null ? "" :entity.getStoreDvsn())
                .storeDvsnNm(entity.getStoreDvsnNm() == null ? "" :entity.getStoreDvsnNm())
                .openDt(entity.getOpenDt() == null ? "" :entity.getOpenDt())
                .closeDt(entity.getCloseDt() == null ? "" :entity.getCloseDt())
                .loanMgntUnqNo(entity.getLoanMgntUnqNo() == null ? "" :entity.getLoanMgntUnqNo())
                .loanDvsn(entity.getLoanDvsn() == null ? "" :entity.getLoanDvsn())
                .loanDvsnNm(entity.getLoanDvsnNm() == null ? "" :entity.getLoanDvsnNm())
                .zipNo(entity.getZipNo() == null ? "" :entity.getZipNo())
                .addr1(entity.getAddr1() == null ? "" :entity.getAddr1())
                .addr2(entity.getAddr2() == null ? "" :entity.getAddr2())
                .latX(entity.getLatX() == null ? "" :entity.getLatX())
                .longY(entity.getLongY() == null ? "" :entity.getLongY())
                .telNo(entity.getTelNo() == null ? "" :entity.getTelNo())
                .faxNo(entity.getFaxNo() == null ? "" :entity.getFaxNo())
                .emalAddr(entity.getEmalAddr() == null ? "" :entity.getEmalAddr())
                .storeStCd(entity.getStoreStCd() == null ? "" :entity.getStoreStCd())
                .storeStNm(entity.getStoreStNm() == null ? "" :entity.getStoreStNm())
                .bsnsRegNo(entity.getBsnsRegNo() == null ? "" :entity.getBsnsRegNo())
                .corpRegNo(entity.getCorpRegNo() == null ? "" :entity.getCorpRegNo())
                .ctgrBsns(entity.getCtgrBsns() == null ? "" :entity.getCtgrBsns())
                .bsnsCndt(entity.getBsnsCndt() == null ? "" :entity.getBsnsCndt())
                .ownerNm(entity.getOwnerNm() == null ? "" :entity.getOwnerNm())
                .delYn(entity.getDelYn() == null ? "" :entity.getDelYn())
                .areaCd(entity.getAreaCd() == null ? "" :entity.getAreaCd())
                .areaNm(entity.getAreaNm() == null ? "" :entity.getAreaNm())
                .sysRegDttm(entity.getSysRegDttm() == null ? "" :entity.getSysRegDttm())
                .sysRegId(entity.getSysRegId() == null ? "" :entity.getSysRegId())
                .sysChgDttm(entity.getSysChgDttm() == null ? "" :entity.getSysChgDttm())
                .sysChgId(entity.getSysChgId() == null ? "" :entity.getSysChgId())
                .tmpRcvAcctTotal(entity.getLoanInfo() == null ? 0 : entity.getLoanInfo().getTmpRcvAcctTotal()  == null ? 0 : entity.getLoanInfo().getTmpRcvAcctTotal() )
                .storeBnkCd(entity.getBnkCd()== null ? "" :entity.getBnkCd())
                .storeBnkNm(entity.getBnkNm()== null ? "" :entity.getBnkNm())
                .storeAcctNo(entity.getAcctNo()== null ? "" :entity.getAcctNo())
                .storeOwacNm(entity.getOwnerNm()== null ? "" :entity.getOwnerNm())
                .acctBal(entity.getLoanInfo() == null ? 0 : entity.getLoanInfo().getAcctBal()  == null ? 0 : entity.getLoanInfo().getAcctBal() )
                .brandBnkCd(entity.getBrandInfo() == null ? "" : entity.getBrandInfo().getBnkCd()  == null ? "" : entity.getBrandInfo().getBnkCd() )
                .brandBnkNm(entity.getBrandInfo() == null ? "" : entity.getBrandInfo().getBnkNm()  == null ? "" : entity.getBrandInfo().getBnkNm() )
                .brandAcctNo(entity.getBrandInfo() == null ? "" : entity.getBrandInfo().getAcctNo()  == null ? "" : entity.getBrandInfo().getAcctNo() )
                .brandOwacNm(entity.getBrandInfo() == null ? "" : entity.getBrandInfo().getOwacNm()  == null ? "" : entity.getBrandInfo().getOwacNm() )
                .build();
    }
}
