package com.jkcredit.invoice.hub.service.realCharge;

import com.jkcredit.invoice.hub.mapper.RealChargeMapper;
import com.jkcredit.invoice.hub.model.dto.realCharge.RealChargeDto;
import com.jkcredit.invoice.hub.model.po.realCharge.RealChargePo;
import com.jkcredit.invoice.hub.service.base.BaseService;
import com.jkcredit.invoice.hub.spi.lang.exception.ServiceException;
import com.jkcredit.invoice.hub.util.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @description:
 * @author: xusonglin
 * @create: 2020/1/18 22:25
 * @version: V1.0
 **/
@Slf4j
@Service
public class RealChargeServiceImpl extends BaseService implements RealChargeService {
    @Resource
    RealChargeMapper mapper;

    @Override
    public void saveRealCharge(RealChargeDto dto) {
        try {
            RealChargePo po = new RealChargePo();
            BeanUtil.copyProperties(po, dto);
            po.setCreateTime(new Date());
            mapper.insert(po);
        } catch (Exception e) {
            log.error("新增实际计费数据失败，失败原因：{}", e.getMessage());
            throw new ServiceException("新增实际计费数据失败");
        }
    }
}
