package com.yc.ship.module.trade.convert.invoice;

import com.yc.ship.module.ota.api.dto.DistributorRespDTO;
import com.yc.ship.module.trade.api.invoice.dto.InvoicingReqDTO;
import com.yc.ship.module.trade.dal.dataobject.invoice.InvoiceDO;
import com.yc.ship.module.trade.enums.invoice.InvoiceSourceEnum;
import com.yc.ship.module.trade.enums.invoice.InvoiceTitleTypeEnum;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;


@Mapper
public interface InvoiceConvert {

    InvoiceConvert INSTANCE = Mappers.getMapper(InvoiceConvert.class);

    InvoiceDO convert(InvoicingReqDTO reqDTO);
    default InvoicingReqDTO convertOtc(DistributorRespDTO distributor){
        InvoicingReqDTO reqDTO = new InvoicingReqDTO();
        reqDTO.setBuyerTaxCode(distributor.getAccountNumber());
        reqDTO.setBuyerAddress(distributor.getUnitAddress());
        reqDTO.setBuyerAccount(distributor.getBankAccount());
        reqDTO.setBuyerBank(distributor.getDepositBank());
        reqDTO.setBuyerName(distributor.getName());
        reqDTO.setAgencyId(distributor.getId().toString());
        //来源：1散客，2团票
        reqDTO.setSource(InvoiceSourceEnum.OTC.getType());
        reqDTO.setBuyerTel(distributor.getPhone());
        reqDTO.setBuyerEmail(distributor.getEmail());
        reqDTO.setTitleType(InvoiceTitleTypeEnum.ENTERPRISE_UNIT.getType());
        return  reqDTO;
    }
}
