package tiktok_api

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

//var token = `{
//	"access_token": "b668f8cc-d875-4887-a613-5452f05e752e",
//	"expires_in": 1671432212,
//	"scope": "SCOPE",
//	"shop_id": 63141688,
//	"shop_name": "小时达开放平台专用店",
//	"refresh_token": "fa64fedf-05a7-4c1b-b6c4-f97f90e10b75",
//	"authority_id": ""
//}`

var token = `{"access_token":"71896365-cec7-4982-a686-0d8f3044cc1e","expires_in":1682872676,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"76d410d2-e869-4ddc-b8ad-0ae652114e13","authority_id":""}`

//var token = `{"access_token":"e3173e9f-266f-4d87-88e7-e7cd837bc9d9","expires_in":1672882632,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"5070aae2-493f-46bd-b5d6-6ea0cd64729f","authority_id":""}`

var a = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)

// 查询售后单详情
func TestAfsOrder(t *testing.T) {
	a.QueryAfsOrderDetail("7165706329204670732", true)
}

// 同意/拒绝售后单
func TestAggreOrNotAggreAfs(t *testing.T) {
	a.AfterSaleOperate(int32(201), "7165706329204670732", "1", 0)
	fmt.Println("11", 8|16|32|1)
}

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

//
func TestName(t *testing.T) {
	body := `[{
    "tag": "101",
    "msg_id": "69793528590852580050:0:101:1670233754:1024588978:7136048270014416392",
    "data": "{\"biz\":2,\"order_status\":2,\"order_type\":0,\"p_id\":5008525809582539796,\"pay_amount\":2640,\"pay_time\":1670233752,\"pay_type\":1,\"s_ids\":[5008525809582539796],\"shop_id\":57939570}"
}]`
	signParam := a.appKey + body + a.appSecret
	sign := fmt.Sprintf("%X", md5.Sum([]byte(signParam)))
	fmt.Println(sign)
}
