package jxprintapi

import (
	"fmt"
	"git.rosy.net.cn/baseapi"
	"go.uber.org/zap"
	"testing"
	"time"
)

var (
	api         *API
	sugarLogger *zap.SugaredLogger
)

func init() {
	logger, _ := zap.NewDevelopment()
	sugarLogger = logger.Sugar()
	baseapi.Init(sugarLogger)

	api = New("1000", "rfBd56ti2SMtYvSg")
}

func TestAddPrinter(t *testing.T) {
	err := api.AddPrinter([]*AddPrinterParam{
		&AddPrinterParam{
			PrintNo: "20210615000012",
			Name:    "test1",
		},
	})
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	//baseapi.SugarLogger.Debug(result)
}

func TestDelPrinter(t *testing.T) {
	err := api.DelPrinter([]string{"20210615000012"}, "")
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	//baseapi.SugarLogger.Debug(result)
}

func TestUpdatePrinter(t *testing.T) {
	err := api.UpdatePrinter(&UpdatePrinterParam{
		PrintNo: "20210615000011",
	})
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	//baseapi.SugarLogger.Debug(result)
}

func TestDelPrinterSeq(t *testing.T) {
	err := api.DelPrinterSeq("20210615000012")
	if err != nil {
		t.Fatal(err)
	}
	//t.Log(utils.Format4Output(result, false))
}

func TestGetPrintMsg(t *testing.T) {
	result, err := api.GetPrintMsg("20210715104649_F3Z2JXyj")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(result)
}

func TestGetPrinterStatus(t *testing.T) {
	result, err := api.GetPrinterStatus("120220915001283")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(result)
}

// 20210615000012
func TestDoPrint(t *testing.T) {
	result, err := api.DoPrint("120220915001877", `{
	"allSkuCount": "2",
	"allSkuTypeCount": "1",
	"appId": "1000",
	"businessType": "1",
	"buyerComment": "(缺货时电话与我联系)",
	"consigneeAddress": "胜浦街道苏州市吴中区新胜路1号",
	"consigneeMobile": "18468578703,380",
	"consigneeName": "刘*****",
	"eBaiOrderNo": "好菜鲜生",
	"eBailCode": "1126",
	"officialName": "京西菜市",
	"orderNo": "4016410104553361126",
	"orderStatus": "5",
	"payOrderTime": "2023-03-22 11:15:06",
	"qrcOrder": "4016410104553361126",
	"skuList": "[{\"skuName\":\"【精选好价】肥瘦五花肉（下午易缺货）250g/组\",\"skuCount\":\"X2\",\"salePrice\":\"￥22.10\",\"totalCountPrice\":\"￥44.20\",\"upc\":\"\"}]",
	"storeName": "好菜鲜生(胜浦中胜路店)",
	"storeTel": "13205196216",
	"trySendTime": "2023-03-22 11:45:13",
	"userPayMoney": "￥43.20",
	"vendorID": "3",
	"vendorName": "饿百新零售",
	"vendorOrderNo": "5"
}`, 2)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(result)
}

func Test222(t *testing.T) {
	fmt.Println(time.Now().Minute())
}
