package com.dxhy.common.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.dxhy.common.rabbitmq.RabbitMqSender;
import com.dxhy.common.service.InvoiceLogService;
import com.dxhy.common.vo.InvoiceLog;

import cn.hutool.core.codec.Base64;
import lombok.extern.slf4j.Slf4j;

/**
 * @author jiaohongyang
 */
@Service("invoiceLogService")
@Slf4j
public class InvoiceLogServiceImpl implements InvoiceLogService {
    @Resource
    private RabbitMqSender rabbitLogsSender;

    @Override
    public boolean toInvoiceLog(List<InvoiceLog> invoiceLog) {
        try {
            String json = JSON.toJSONString(invoiceLog);
            rabbitLogsSender.sendInvoiceLogs(Base64.encode(json));
            return true;
        } catch (Exception e) {
            log.debug("发票操作记录生成日志异常：{}" + e.getMessage());
            return false;
        }
    }

}
