package com.engine.salary.entity.siarchives.bo;

import com.engine.salary.entity.siarchives.dto.InsuranceArchivesFundSchemeDTO;
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesOtherSchemeDTO;
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesSocialSchemeDTO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import com.engine.salary.util.SalaryEnumUtil;

import java.util.Objects;

/**
 * @Author weaver_cl
 * @Description:
 * @Date 2022/3/15
 * @Version V1.0
 **/
public class InsuranceArchivesBO {

    public static InsuranceArchivesSocialSchemeDTO convertSocialPOtoDTO(InsuranceArchivesSocialSchemePO po, Long employeeId) {
        if (Objects.isNull(po)) {
            return InsuranceArchivesSocialSchemeDTO.builder().build();
        }
        return InsuranceArchivesSocialSchemeDTO.builder()
                .socialName(po.getSocialSchemeId() == null ? null : String.valueOf(po.getSocialSchemeId()))
                .socialSchemeId(po.getSocialSchemeId())
                .welfareType(SalaryEnumUtil.enumMatchByValue(po.getWelfareType(), WelfareTypeEnum.values(), WelfareTypeEnum.class))
                .id(po.getId())
                .employeeId(po.getEmployeeId())
                .nonPayment(po.getNonPayment())
                .paymentOrganization(po.getPaymentOrganization())
                .socialEndTime(po.getSocialEndTime())
                .socialStartTime(po.getSocialStartTime())
                .schemeAccount(po.getSocialAccount())
                .schemePaymentBaseString(po.getSocialPaymentBaseString())
                .schemePaymentComBaseString(po.getSocialPaymentComBaseString())
                .underTake(po.getUnderTake() == null ? null : String.valueOf(po.getUnderTake()))
                .build();
    }


    public static InsuranceArchivesFundSchemeDTO convertFundPOtoDTO(InsuranceArchivesFundSchemePO po, Long employeeId) {
        if (Objects.isNull(po)) {
            return InsuranceArchivesFundSchemeDTO.builder().build();
        }
        return InsuranceArchivesFundSchemeDTO.builder()
                .id(po.getId())
                .employeeId(po.getEmployeeId())
                .fundAccount(po.getFundAccount())
                .fundEndTime(po.getFundEndTime())
                .fundSchemeId(po.getFundSchemeId())
                .paymentOrganization(po.getPaymentOrganization())
                .fundPaymentBaseString(po.getFundPaymentBaseString())
                .fundPaymentComBaseString(po.getFundPaymentComBaseString())
                .fundStartTime(po.getFundStartTime())
                .supplementFundAccount(po.getSupplementFundAccount())
                .nonPayment(po.getNonPayment())
                .underTake(po.getUnderTake() == null ? null : String.valueOf(po.getUnderTake()))
                .welfareType(SalaryEnumUtil.enumMatchByValue(po.getWelfareType(), WelfareTypeEnum.values(), WelfareTypeEnum.class))
                .build();
    }

    public static InsuranceArchivesOtherSchemeDTO convertOtherPOtoDTO(InsuranceArchivesOtherSchemePO po, Long employeeId) {
        if (Objects.isNull(po)) {
            return InsuranceArchivesOtherSchemeDTO.builder().build();
        }
        return InsuranceArchivesOtherSchemeDTO.builder()
                .id(po.getId())
                .employeeId(po.getEmployeeId())
                .underTake(po.getUnderTake() == null ? null : String.valueOf(po.getUnderTake()))
                .nonPayment(po.getNonPayment())
                .otherName(po.getOtherSchemeId() == null ? null : String.valueOf(po.getOtherSchemeId()))
                .otherSchemeId(po.getOtherSchemeId())
                .otherPaymentBaseString(po.getOtherPaymentBaseString())
                .otherPaymentComBaseString(po.getOtherPaymentComBaseString())
                .otherStartTime(po.getOtherStartTime())
                .otherEndTime(po.getOtherEndTime())
                .paymentOrganization(po.getPaymentOrganization())
                .welfareType(SalaryEnumUtil.enumMatchByValue(po.getWelfareType(), WelfareTypeEnum.values(), WelfareTypeEnum.class))
                .build();
    }

}
