package dada

import (
	"testing"
	"time"

	_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
	"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
	"git.rosy.net.cn/jx-callback/business/model"
	"git.rosy.net.cn/jx-callback/business/partner"
	"git.rosy.net.cn/jx-callback/globals/testinit"
)

func init() {
	testinit.Init()
}

func TestCreateWaybill(t *testing.T) {
	orderID := "817540316000041"
	if order, err := partner.CurOrderManager.LoadOrder(orderID, model.VendorIDJD); err == nil {
		_, err = CurDeliveryHandler.CreateWaybill(order, 0)
		if err == nil {
			time.Sleep(1 * time.Second)
			bill := &model.Waybill{
				VendorOrderID:   orderID,
				WaybillVendorID: model.VendorIDDada,
			}
			err = CurDeliveryHandler.CancelWaybill(bill, partner.CancelWaybillReasonOther, "")
			if err != nil {
				t.Fatal(err.Error())
			}
		} else {
			t.Fatal(err.Error())
		}
	} else {
		t.Fatal(err.Error())
	}
}

func TestGetRidderPosition(t *testing.T) {
	lng, lat, err := CurDeliveryHandler.GetRidderPosition(jxcontext.AdminCtx, "", "80704840263399812", "", "")
	if err != nil {
		t.Fatal(err)
	}
	t.Logf("lng:%f, lat:%f", lng, lat)
}
