package com.kmall.common.utils.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.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Scott Chen
 * @since 1.0
 * 2018-10-25
 */
public class Test {

    public static void main(String[] args) {

        //---------- 小票字体 ----------

        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);


        //---------- 小票信息 ----------

        // 小票头
        TicketHead head = new TicketHead();
        head.setTitle("三如生活馆");
        head.setCashierId("10000");
        head.setPosId("1001");
        head.setMemberId("900800");
        head.setIntegral("120");
        head.setOrderId("201810301000");
        head.setTradeTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEE").format(new Date()));

        // 商品信息
        List<Goods> goods = new ArrayList<Goods>();
        goods.add(new Goods("奥地利 进口 Loacker/莱家 威化饼干巧克力味250g/袋", "59.90", "1", "59.9"));
        goods.add(new Goods("比利时进口零食品 LOTUS和情焦糖饼干312.5g咖啡伴侣小吃", "16.80", "1", "16.80 "));
        goods.add(new Goods("博智900g高钙燕麦植物奶", "238.00", "1", "238.00"));
        goods.add(new Goods("韩国进口 海太蜂蜜黄油薯片60g*5袋土豆片休闲网红零食大礼包批发", "100.00", "1", "100.00"));
        goods.add(new Goods("新西兰进口纽瑞滋脱脂奶粉1kg成人青少年中老年奶粉", "100.00", "1", "100.00"));

        // 收银信息
        CashInfo cashInfo = new CashInfo();
        cashInfo.setTotal("517.70");
        cashInfo.setGoodsTotal("5");
        cashInfo.setReceipts("517.70");
        cashInfo.setOddChange("0.00");
        cashInfo.setCoupon("0.00");
        cashInfo.setIntegral("0");
        cashInfo.setFreight("0.00");
        cashInfo.setPaymentMode("微信支付");

        // 海关清单
        CusListing cusListing = new CusListing();
        cusListing.setOrderId("201810301000");
        cusListing.setWaybillId("920187494");
        cusListing.setInvtNo("5011235610990");
        cusListing.setConsignee("张三");
        cusListing.setConsigneeTel("13923908230");
        cusListing.setOriginAddress("深圳前海保税仓");
        cusListing.setDeliveryAddress("临海大道59号海运中心主塔楼1701室");

        // 小票脚信息
        TicketFoot foot = new TicketFoot();
        foot.setSummary("======双11活动火爆销售大促======");
        foot.setServiceTel("0750-7755897");
        foot.setUrl1("http://www.ds-bay.com");


        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.print2(ticket);


        //---------------------------------------------

    }



}
