package yilianyun

import (
	"fmt"
	"git.rosy.net.cn/baseapi/utils"
	"git.rosy.net.cn/jx-callback/business/partner"
	"testing"

	"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"

	_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
	_ "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
	"git.rosy.net.cn/jx-callback/globals/api"
	"git.rosy.net.cn/jx-callback/globals/testinit"
)

func init() {
	testinit.Init()
	api.YilianyunAPI.SetToken("8d54951744984b7a8908251c3063b445")
}

func TestPrintMsg(t *testing.T) {
	orderID := "88387051001754"
	vendorID := 0
	order, err := partner.CurOrderManager.LoadOrder(orderID, vendorID)
	if err != nil {
		t.Fatal(err)
	}

	storeDetail, err := partner.CurOrderManager.LoadStoreDetail(667278, 9)
	if err != nil {
		t.Fatal(err)
	}
	// context := CurPrinterHandler.getOrderContent(order, "13412345678")
	context := CurPrinterHandler.getOrderContentBig(order, "18981810340", storeDetail)
	status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "4004806902", "755845185619", "test", context)
	t.Log(utils.Format4Output(status, false))
	if err != nil {
		t.Fatal(err)
	}
}

func TestRegisterPrinter(t *testing.T) {
	newID1, newID2, err := CurPrinterHandler.RegisterPrinter(jxcontext.AdminCtx, "4004600675", "fem2ukwvduik", "title", 0)
	t.Log(newID1 + "," + newID2)
	if err != nil {
		t.Fatal(err)
	}
}

func TestStatusPrinter(t *testing.T) {
	data, err := CurPrinterHandler.GetPrinterStatus(jxcontext.AdminCtx, "4004802883", "441719962922")
	fmt.Println("data", data)
	fmt.Println("err", err)
}
