package com.kmall.manager.manager.print.ticket;

import com.kmall.common.utils.print.ticket.item.*;
import com.kmall.common.utils.print.ticket.item.font.TicketCommonFont;
import com.kmall.common.utils.print.ticket.item.font.TicketGoodsTitleFont;
import com.kmall.common.utils.print.ticket.item.font.TicketHeadFont;

import java.awt.*;
import java.util.List;

public class TicketPrintUtil {

    public static Ticket print(TicketHead head, List<Goods> goods, CashInfo cashInfo, CusListing cusListing) {
        //---------- 小票字体 ----------
        TicketHeadFont headFont = new TicketHeadFont();
        headFont.setFamily("宋体");
        headFont.setWeight(Font.BOLD);
        headFont.setSize(12);

        TicketGoodsTitleFont goodsTitleFont = new TicketGoodsTitleFont();
        goodsTitleFont.setFamily("宋体");
        goodsTitleFont.setWeight(Font.BOLD);
        goodsTitleFont.setSize(8);

        TicketCommonFont commonFont = new TicketCommonFont();
        commonFont.setFamily("宋体");
        commonFont.setWeight(Font.PLAIN);
        commonFont.setSize(8);

        // 小票脚
        TicketFoot foot = new TicketFoot();
        foot.setSummary(PrintTicketPropertiesBuilder.instance().getSummary());
        foot.setServiceTel(PrintTicketPropertiesBuilder.instance().getServiceTel());
        foot.setUrl1(PrintTicketPropertiesBuilder.instance().getUrl1());

        //---------- 组装小票 ----------
        Ticket ticket = new Ticket();
        ticket.setTicketHead(head);
        ticket.setGoodsAlign(Ticket.BOTTOM);
        ticket.setGoods(goods);
        ticket.setCashInfo(cashInfo);
        ticket.setCusListing(cusListing);
        ticket.setTicketFoot(foot);

        ticket.setTicketHeadFont(headFont);
        ticket.setTicketGoodsTitleFont(goodsTitleFont);
        ticket.setTicketCommonFont(commonFont);

        // 打印
        // TicketPrinter.print(ticket);
        return ticket;
    }

}
