package tiktok_api

import (
	"fmt"
	"git.rosy.net.cn/baseapi/utils"
	"git.rosy.net.cn/jx-callback/globals"
	"testing"
	"time"
)

//(抖)京西菜市
var token1 = `{"access_token":"81qzlgabmw1j7t4nq1hehos0000yhugi-11","expires_in":1774781291,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市","refresh_token":"s0a144yh8m1j7t4nq1hehos0000yhugi-12","authority_id":""}`

//(抖)美好菜市 授权已被关闭，请重新打开授权开关
//var token1 = `{"access_token":"45f191d2-3917-4f49-a538-da83733c1d70","expires_in":1723882502,"scope":"SCOPE","shop_id":68032645,"shop_name":"京西果园","refresh_token":"a372e76b-6470-4d9f-a375-3cb53e6e32ab","authority_id":""}`

//(抖)蕾丝袜 授权已被关闭，请重新打开授权开关
//var token1 = `{"access_token":"h57u8famv01j7t4nq1hehos0000i4uwm-11","expires_in":1738376382,"scope":"SCOPE","shop_id":30459766,"shop_name":"蕾丝袜","refresh_token":"lrp6tl651c1j7t4nq1hehos0000i4uwm-12","authority_id":""}`

//(抖)京西到家 // 授权已被关闭，请重新打开授权开关
//var token1 = `{"access_token":"vyj6q0cyg91j7t4nq1hehos00014hzcz-11","expires_in":1770518421,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"pdxa2609jm1j7t4nq1hehos00014hzcz-12","authority_id":""}`

//(抖)易购生鲜超市 access_token不存在，请使用最新的access_token访问
//var token1 = `{"access_token":"c78874c8-0862-403c-8ddb-c25385221632","expires_in":1711559144,"scope":"SCOPE","shop_id":114868220,"shop_name":"易购生鲜超市","refresh_token":"3604ac64-384b-4ed7-a511-8d4794ff56e7","authority_id":""}`

//(抖)京西同城配送 app_key和access_token不匹配，请仔细检查
//var token1 = `{"access_token":"fb41e4d5-c92f-4b07-956f-46c63d0547be","expires_in":1692275028,"scope":"SCOPE","shop_id":92037439,"shop_name":"京西花园","refresh_token":"5fa3efc3-d3c4-410a-baaa-0fb23d408ccf","authority_id":""}`

// 测试门店
//var token1 = `{"access_token":"syriovzwwq1j7t4nq1hehos0004b2xdw-11","expires_in":1774425349,"scope":"SCOPE","shop_id":260477060,"shop_name":"开放平台测试专用店4","refresh_token":"8u762h27341j7t4nq1hehos0004b2xdw-12","authority_id":""}`

var a = New("7267745202649957900", "51998fcf-d521-4553-8c0c-fa662c8dbd6e", token1)

func TestCategory(t *testing.T) {
	data, err := a.GetShopCategory(0)
	for _, v := range data {
		fmt.Println(v.Id, "---", v.Name, "---", v.IsLeaf, "---", v.Level)
	}
	fmt.Println("data====", err)
}

// 查询售后单详情
func TestAfsOrder(t *testing.T) {
	data, err := a.QueryAfsOrderDetail("146453779045950796", false)
	globals.SugarLogger.Debugf("data=%s", utils.Format4Output(data, false))
	globals.SugarLogger.Debugf("data=%s", err)
}

func TestQueryAfsOrderList(t *testing.T) {
	a.QueryAfsOrderList("6921396434481348260")
}
func TestAfsOrder2(t *testing.T) {
	data, err := a.QueryAfsOrderDetail("146223488418888073", false)
	globals.SugarLogger.Debugf("data=%s", utils.Format4Output(data, false))
	globals.SugarLogger.Debugf("data=%s", err)
}

// 同意/拒绝售后单
func TestAggreOrNotAggreAfs(t *testing.T) {
	err := a.AfterSaleOperate(int32(201), "7293455053833322752", "1", 64270123)
	fmt.Println(err)
}

func TestGetSkuDetailLocalID(t *testing.T) {
	data, err := a.GetSkuDetailLocalID("83334636", "33189")
	globals.SugarLogger.Debugf("data=%s", utils.Format4Output(data, false))
	globals.SugarLogger.Debugf("data=%s", err)
}

func TestAaa(t *testing.T) {
	strTime := []string{"2025-05-06", "2025-05-07"}
	var err error
	timeList := make([]time.Time, len(strTime))
	for k, v := range strTime {
		if v == "" {
			timeList[k] = utils.DefaultTimeValue
		} else {
			if timeList[k], err = utils.TryStr2Time(v); err != nil {
				fmt.Println(err)
			}
		}
	}
	timeList[1].Add(24 * 60 * time.Minute)
	fmt.Println(timeList)
}
