package jdapi

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

	"git.rosy.net.cn/baseapi"

	"git.rosy.net.cn/baseapi/utils"
	"go.uber.org/zap"
)

var (
	api         *API
	sugarLogger *zap.SugaredLogger
)

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

	// sandbox
	// api = New("594ab45a-9a73-4a43-82b0-a64cbd55d883", "06692746f7224695ad4788ce340bc854", "d6b42a35a7414a5490d811654d745c84")
	// prod
	// api = New("73e2e9f6-b21e-4dcd-8c92-71e4e100b07e", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4")
	// 天天果园
	//api = New("c45e6510-00ba-4be2-977e-bcb9c9792cc7", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26")
	// 京东果园 320406
	api = New("317e2b80-c884-4227-b20e-684cf3466290", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4")
	// 京东秒送
	//api = New("697379cc-dde4-4b42-b845-5257ac5b4312", "64C3C0F83C23398B706BDAF3C8276B5A", "10b7d760b8504bf98e6faeba2561c7b9")
	// 京东白货
	//api = New("9053e4fd-4e0e-4e9e-8ab1-f348e5cbf3e7", "4602bd4b84984186815dbc03299c7094", "386ab19719d9470487011217d0c57349")
	// 果切 379599
	//api = New("8a843f5c-6c75-4604-9976-04c1aae3decc", "f2ed33075faf4773a47e065acd79532b", "aed14cbbecac4456843570e90c5f46ec")
	// 李氏水果 346254
	//api = New("c7c41cb6-6db4-4f67-a864-ca5f524653d0", "13493b4a951945f689dcc989b6693631", "7e28a37be43a430bb5928c835e482fe2")
	// 381564
	//api = New("4d0c707a-54eb-4f05-8187-6cedf95827c7", "d2d1e2e3213d4320bc2712a684307831", "1750f5b9848d4a6492c1c20b487074da")
	// 390558
	//api = New("9053e4fd-4e0e-4e9e-8ab1-f348e5cbf3e7", "4602bd4b84984186815dbc03299c7094", "386ab19719d9470487011217d0c57349")

	// 384633
	///api = New("02a3f772-89f3-46f1-bbd5-74be346cba54", "e496a0f9b88a407297fea283b8dc9e29", "9bb82ffbec144c4b8fc8d627e5ca6a35")

	// 京东超市 359459
	//api = New("21ff22c5-0716-4c05-9468-8e4dde2b1cd6", "21b627c23ea04c69b64b48d0b361213e", "51cd27a748e64c829b4b7f83f4844610")
	//prod zs
	// api = New("6f8d3290-0120-4ad7-8b53-943c67c84f3f", "789279b9ae814ba091ac52815566b54d", "5d668cd227644637bb0fd73ed8118ec8")
	// const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHCT3RM3CQG7IJIPUQ3THS5UIUYWMKINM7ETUOQB7OBPOPZVCT3ZJY55243TDVXLO25PP4UYSPTTPMNQ7HPMWOJKJ3BJWGVHD243MXH7NZWW264TKN5UOCJBSSSOKD2QQII"
	//const cookieValue = "OPJQMA7B3FTKCAUGO7FHCH5NMBGAWGGXYRNLEHYYZNGNPNIBCAM4IOEPG3NT3RIA44G5C3535Q5LGG4F4SR4AZVLGYKYTKFJJKEAOXENVBL5VXNILRP3GLNVVWA26XZ3VGSYOHA72RICMVZS3G53DTEH3JWVXCZBKYQN5CW57OZAUUGW26BM5GBMDUKCPJGLYBMEIVPIGG6PY2HOZTQL5PWKCSDJLG7AKSLKUQ422BVJDNQ36DIA74FV7RFQMMQPNJ5YQMCG2M72IH43LZDVSAYZWKUGAVD7VFRMEYTOXYHWCYVDXJ6HYFIPWIN3ULLXDDLN2ICON4GRK"
	//api.SetJdCookie(cookieValue)
	//api.SetCookie("user", "VCQUVHVJI4ELNGFZOYMCDYDUSHEJMPXZRZXSNBRB4MVBNENP72REAAZR3R4SGDJ5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NO55XN2SMAXUPVUKXVBWMNPYGDEBVKAKJM7EMI; lsp-store1.jddj.com=Y636M7QUOPPH4QLOVU6JOUNGDHIEJV5CWKMQ743LVDPNW6TN4TYFFV4XOXKLERC2UXFT44TMCUMRFMMWOJ7BV6P3FECMT2ZVQQEK6DMCX33SS54V4AHXHO2APRYZGCBIPYXPP6LCRVUFA3GCF3XHLTKSAKINWFTZ4LD3BYM23ELADBGKCC47HILWKM7BNBUEPVVQEVABWBMUBPAXIFKB2WDCEK56RTBOHEBYVN6GHVPHP67PNOJ57CP7SFDYOYSATTQ4MQJCQQP2E6K3QQUQ3JKQFGBCTCPUXLJ4TNFFSLMV6UQQKZMWHG4UK2LPOIXJYX35PXSETJRYOTV6JFGFFAOVGHSCOOPQYIZ4BZEEBIDH5HRXX7MQNO55XN2SMAXUPVUKXVBWMNPYGDEBVKAKJM7EMI`)
}

func TestTest(t *testing.T) {
	sugarLogger.Debug(utils.GetCurTimeStr())
}

func TestAccessAPI(t *testing.T) {
	result, err := api.AccessAPI("address/allcities", nil)
	if err != nil {
		t.Fatalf("Error when accessing AccessAPI: %v", err)
	} else {
		code := result["code"].(string)
		if code != "0" {
			t.Fatalf("code is not 0, %v", code)
		}
	}
}

func TestAccessAPINoPage(t *testing.T) {
	result, err := api.AccessAPINoPage("address/allcities", nil, []string{"yn"}, nil, nil)
	if err != nil {
		t.Fatalf("TestAccessAPINoPage return error:%v", err)
	}
	cityInfo := result.([]interface{})
	if len(cityInfo) == 0 {
		t.Fatal("city info is empty")
	}
	oneCity := cityInfo[0].(map[string]interface{})
	if _, ok := oneCity["areaName"]; !ok {
		t.Fatal("no areaName key")
	}
	if _, ok := oneCity["yn"]; ok {
		t.Fatal("yn field havn't been removed 222")
	}
}

func TestAccessAPIHavePage(t *testing.T) {
	jdParams := map[string]interface{}{
		"pageNo":   1,
		"pageSize": 20,
	}
	skuInfo, totalCount, err := api.AccessAPIHavePage("pms/querySkuInfos", jdParams, nil, []string{"skuName", "skuId"}, nil)
	if err != nil {
		t.Fatalf("AccessAPIHavePage return error:%v", err)
	}

	if len(skuInfo) == 0 || totalCount == 0 {
		t.Fatal("sku info is empty")
	}
	oneSku := skuInfo[0].(map[string]interface{})
	if _, ok := oneSku["skuName"]; !ok {
		t.Fatal("no skuName key")
	}
	if _, ok := oneSku["outSkuId"]; ok {
		t.Fatal("outSkuId key not removed")
	}
}

func TestGenerateURL(t *testing.T) {
	params := make(map[string]interface{})
	params["key"] = "v"
	params["key2"] = "v2"

	fullURL := utils.GenerateGetURL(prodURL, "address/allcities", params)

	response, err := http.Get(fullURL)
	if err != nil {
		t.Fatalf("Get return error:%v", err)
	}
	defer response.Body.Close()
}

func TestJdMap2StructByJson(t *testing.T) {
	testStr := `
{
	"stationNo": "11053496",
	"stationName": "京西菜市-三平台测试门店4",
	"outSystemId": "2",
	"mobile": "18109051396",
	"phone": "13684045765",
	"lat": 34.224367,
	"lng": 108.726791,
	"city": 2376,
	"county": 50231,
	"stationAddress": "西安市长安区长安区",
	"serviceTimeEnd1": 47,
	"serviceTimeStart1": 1,
	"closeStatus": 1,
	"allowRangeOptimized": 0,
	"cacheKey4StoreList": "_sn_11053496vi_82029p_2376c_2376co_50231oi_2wt_2sne_京西菜市-三平台测试门店4sa_西安市长安区长安区yn_0pe_2",
	"carrierNo": 9966,
	"cityName": "西安市",
	"coordinate": "108.726791,34.224367",
	"coordinateAddress": "韩南村",
	"countyName": "长安区",
	"createPin": "jd_jxcs8285",
	"createTime": {
		"day": 4,
		"hours": 13,
		"minutes": 33,
		"seconds": 22,
		"time": 1470893602321,
		"timezoneOffset": -480,
		"date": 11,
		"month": 7,
		"year": 116
	},
	"id": 123108,
	"industryTag": 3,
	"innerNoStatus": 1,
	"isAutoOrder": 0,
	"isMembership": 0,
	"isNoPaper": 2,
	"onlineTime": 1470893602123,
	"orderAging": 60,
	"orderNoticeType": 1,
	"preWarehouse": 2,
	"province": 2376,
	"provinceName": "西安市",
	"qualifyStatus": 2,
	"regularFlag": 3,
	"stationDeliveryStatus": 2,
	"supportInvoice": 0,
	"supportOfflinePurchase": 0,
	"testMark": 0,
	"timeAmType": 1,
	"timePmType": 0,
	"ts": {
		"day": 2,
		"hours": 16,
		"minutes": 22,
		"seconds": 13,
		"time": 1571127733000,
		"timezoneOffset": -480,
		"date": 15,
		"month": 9,
		"year": 119
	},
	"updatePin": "jxadmin-zhouyang",
	"updateTime": 1571127733,
	"venderId": "82029",
	"venderName": "测试京西菜市",
	"wareType": 2,
	"whiteDelivery": false,
	"yn": 0
}
`
	var rawData interface{}
	err := utils.UnmarshalUseNumber([]byte(testStr), &rawData)
	if err != nil {
		t.Fatal(err)
	}

	var store *StoreDetail
	err = JdMap2StructByJson(rawData, &store, true)
	if err != nil {
		t.Fatal(err)
	}
	if store.CreateTime.GoTime().Unix() != 1470893602 ||
		store.OnlineTime.GoTime().Unix() != 1470893602 ||
		store.UpdateTime.GoTime().Unix() != 1571127733 {
		t.Fatalf("%d,%d,%d", store.CreateTime.GoTime().Unix(), store.OnlineTime.GoTime().Unix(), store.UpdateTime.GoTime().Unix())
	}
	t.Log(utils.Format4Output(store, false))
	t.Log(store.CreateTime)
}

func TestStringTo(t *testing.T) {
	aa := `{"pageNo":1,"totalPage":1,"maxPageSize":100,"pageSize":100,"page":1,"totalCount":3,"resultList":[{"deliveryManPhone":"18822558816","orderType":10000,"srcOrderType":2,"appVersion":"RN","industryTag":3,"orderDynamicFreightMoney":0,"orderTotalMoney":6760,"orderId":2226675449000192,"orderJdSendpay":"{\"orderAddTimeFreightMoney\":200,\"packageFeeCollector\":1}","discount":[{"discountDetailType":2,"orderShareRatioData":"venderShareProportion=100&platShareProportion=0&venderPayMoney=500&platPayMoney=0","discountPrice":500,"discountType":8,"skuIds":"2023435541"},{"discountName":"满19元享特惠","discountDetailType":2201,"discountCode":"879","orderShareRatioData":"venderShareProportion=0&platShareProportion=100&venderPayMoney=0&platPayMoney=200&promotionId=879","discountPrice":200,"discountType":3,"skuIds":"2023435541"},{"discountName":"会员红包月卡6","discountDetailType":1,"discountCode":"1666998435664XC0Ube711800828-1029182512#592637779","orderShareRatioData":"promotionId=1029182512&venderShareProportion=0&platShareProportion=100&venderPayMoney=0&platPayMoney=400&createPin=exc_newviponly@imdada.cn&sortId=1","discountPrice":400,"discountType":3,"skuIds":"2023435541"}],"grabTime":"2022-11-05 20:00:41","tips":0,"deliveryDelayAgreed":0,"buyerCity":"3","yn":false,"orderInvoiceOpenMark":2,"grabMark":4,"adjustCount":0,"buyerCoordType":2,"srcPlatId":4,"deliveryCarrierName":"达达专送","localDeliveryMoney":0,"produceStationName":"京西菜市-中北店","acceptDeadline":"2022-11-05 18:06:08","cartId":"2408:8210:5435:35a0:f951:6182:c95f:2852","srcInnerType":0,"packagingMoney":120,"orderBaseFreightMoney":500,"buyerFullAddress":"订单完结5小时后，隐藏顾客地址。","isJDGetCash":true,"orderDistanceStepFreight":300,"buyerPoi":"云锦世家","pickPin":"jxadmin","middleNumBindingTime":"2022-11-08 19:47:00","buyerTelephone":"17822641285,0126","venderBalanceDeductMoney":0,"buyerLat":39.110653,"buyerPin":"JD_20eb62963769382","orderStatusTime":"2022-11-05 17:51:03","orderAcceptTime":"2022-11-05 18:52:33","srcOrderId":"2226675449000192","isDeleted":false,"cancelOrderIsReadable":true,"deliveryStationNo":"11954632","deliveryPackageWeight":1.5,"orderSkuType":1,"product":[{"skuJdPrice":3380,"promotionType":1,"skuIdIsv":"25011","canteenMoney":0,"skuName":"【新鲜】猪肝（下午易缺货）约750g/份(1斤半)","firstCategoryName":"肉品","skuStorePrice":3380,"skuPurchasePrice":0,"skuSpuId":0,"isGift":false,"adjustMode":0,"skuStockOwner":0,"artificerName":"35247","skuId":2023435541,"categoryId":"20248,20352,20359","skuCount":2,"skuWeight":0.75}],"produceStationNoIsv":"666707","pickTime":"2022-11-05 18:52:49","pickMark":2,"deliveryConfirmTime":"2022-11-05 20:00:41","merchantPaymentDistanceFreightMoney":0,"buyerCityName":"天津市","orderVenderChargeMoney":0,"orderAgingType":9,"orderIsClosed":true,"orderJingdouMoney":0,"orderPreEndDeliveryTime":"2022-11-05 19:47:00","orderAdditionFreightMoney":0,"orderBalanceUsed":0,"ts":"2022-11-05 18:53:29","orderStockOwner":3,"popVenderId":"0","deliveryManNo":"18822558816","equipmentId":"RN_84401c7e00fcdcb2b98e928e5420011999829d63","orderPreDeliveryTime":"2022-11-05 19:47:00","orderFreightMoney":500,"buyerIp":2130706433,"buyerFullName":"天**","deliveryBillNo":"2226675449000192","storeLat":39.127495,"orderPreStartDeliveryTime":"2022-11-05 18:07:00","orderFinanceOrgCode":706,"buyerCountryName":"西青区","adjustIsExists":false,"prescriptionJson":"","prescriptionDTO":{"orderTimeFreightMoney":0,"isRigorous":false,"presaleTotalFrontMoney":0,"orderBizUuid":"0"},"buyerCountry":"51045","orderCloseTime":"2022-11-05 20:00:41","transmissionTime":"2022-11-05 17:51:08","orderBuyerRemark":"\n缺货时电话与我沟通","orderGoodsMoney":6760,"buyerMobile":"17822641285,0126","deliveryStationName":"京西菜市-中北店","orderDiscountMoney":600,"businessTag":"dj_new_promise_v3;dj_new_cashier;dj_aging_immediately;;dj_sx;dj_freight_vender_pay;dj_vender_vip;dj_mobile_safe_order;dj_coupon_logic_80;picking_up;","orderTakeSelfCode":"","adjustId":0,"clientOrderPreStartDeliveryTime":"2022-11-05 18:07:00","produceStationNo":"11954632","orderStatus":90000,"orderPayType":4,"orderNum":3,"deliverInputTime":"2022-11-05 18:52:51","artificerPortraitUrl":"","srcInnerOrderId":0,"deliveryStationNoIsv":"666707","platformPointsDeductionMoney":0,"orderPurchaseTime":"2022-11-05 17:50:57","orgCode":"320406","buyerLng":117.07322,"orderLadderFreightMoney":0,"userAdditionalTips":0,"storeLng":117.087837,"updatePin":"杨向伟","buyerProvince":"0","venderVipCardId":"18622886717","buyerPinType":0,"deliveryType":1,"deliveryPackageVolume":0.0,"userTip":0,"deliveryManName":"杨向伟","orderBuyerPayableMoney":6780,"venderIntegralDeductMoney":0,"lastFourDigitsOfBuyerMobile":"6717","orderBaseReceivableFreight":500,"orderReceivableFreight":1000,"payChannel":8001,"isGroupon":false,"printMark":1,"middleNumBindingId":"2022110517510364682954192880","businessType":1,"grouponId":0,"orderStartTime":"2022-11-05 17:50:48","deliveryCarrierNo":"9966","pickDeadline":"2022-11-05 18:07:00"},{"deliveryManPhone":"17729065398","orderType":10000,"srcOrderType":2,"appVersion":"RN","industryTag":3,"orderDynamicFreightMoney":0,"orderTotalMoney":6160,"orderId":2226674100000073,"orderJdSendpay":"{\"orderAddTimeFreightMoney\":200,\"packageFeeCollector\":1}","discount":[{"discountDetailType":2,"orderShareRatioData":"venderShareProportion=100&platShareProportion=0&venderPayMoney=500&platPayMoney=0","discountPrice":500,"discountType":8,"skuIds":"2027954813,2027905512,2040077538"},{"discountName":"满19元享特惠","discountDetailType":2201,"discountCode":"879","orderShareRatioData":"venderShareProportion=0&platShareProportion=100&venderPayMoney=0&platPayMoney=200&promotionId=879","discountPrice":200,"discountType":3,"skuIds":"2027954813,2027905512,2040077538"},{"discountName":"老朋友福利满25减6","discountDetailType":1,"discountCode":"1667639710994NsHZmY1922937929-1029437765#1629041029","orderShareRatioData":"promotionId=1029437765&venderShareProportion=0&platShareProportion=100&venderPayMoney=0&platPayMoney=600&createPin=liushuting@imdada.cn&sortId=1","discountPrice":600,"discountType":3,"skuIds":"2027905512,2040077538,2027954813"},{"discountName":"会员红包月卡1","discountDetailType":1,"discountCode":"1667640420681t6MgXw1494680005-1029179013#1629041029","orderShareRatioData":"promotionId=1029179013&venderShareProportion=0&platShareProportion=100&venderPayMoney=0&platPayMoney=400&createPin=exc_newviponly@imdada.cn&sortId=2","discountPrice":400,"discountType":3,"skuIds":"2027905512,2040077538,2027954813"}],"grabTime":"2022-11-05 18:02:31","tips":0,"deliveryDelayAgreed":0,"buyerCity":"3","yn":false,"orderInvoiceOpenMark":2,"grabMark":4,"adjustCount":0,"buyerCoordType":2,"srcPlatId":4,"deliveryCarrierName":"达达专送","localDeliveryMoney":0,"produceStationName":"京西菜市-中北店","acceptDeadline":"2022-11-05 17:43:42","cartId":"39.144.82.150","srcInnerType":0,"packagingMoney":120,"orderBaseFreightMoney":500,"buyerFullAddress":"订单完结5小时后，隐藏顾客地址。","isJDGetCash":true,"orderDistanceStepFreight":0,"buyerPoi":"曹庄欣苑7号楼","pickPin":"jxadmin","middleNumBindingTime":"2022-11-08 19:19:00","buyerTelephone":"17695443984,2580","venderBalanceDeductMoney":0,"buyerLat":39.13958,"buyerPin":"JD_21bd8cc7b826acf","orderStatusTime":"2022-11-05 17:28:37","orderAcceptTime":"2022-11-05 17:28:45","srcOrderId":"2226674100000073","isDeleted":false,"cancelOrderIsReadable":true,"deliveryStationNo":"11954632","deliveryPackageWeight":1.3,"orderSkuType":1,"product":[{"skuJdPrice":2310,"promotionType":1,"skuIdIsv":"34431","canteenMoney":0,"skuName":"【火锅食材】脆爽黄喉约150g/份","firstCategoryName":"肉品","skuStorePrice":2310,"skuPurchasePrice":0,"skuSpuId":0,"isGift":false,"adjustMode":0,"skuStockOwner":0,"artificerName":"35247","skuId":2027905512,"categoryId":"20248,20260,20264","skuCount":1,"skuWeight":0.15},{"skuJdPrice":2310,"promotionType":1,"skuIdIsv":"6046768","canteenMoney":0,"skuName":"[火锅伴侣]牛毛肚约150g/份","firstCategoryName":"肉品","skuStorePrice":2310,"skuPurchasePrice":0,"skuSpuId":0,"isGift":false,"adjustMode":0,"skuStockOwner":0,"artificerName":"35247","skuId":2040077538,"categoryId":"20248,20260,20264","skuCount":1,"skuWeight":0.15},{"skuJdPrice":1540,"promotionType":1,"skuIdIsv":"34441","canteenMoney":0,"skuName":"【火锅伴侣】火锅套餐1千克约1kg/份","firstCategoryName":"水果/蔬菜","skuStorePrice":1540,"skuPurchasePrice":0,"skuSpuId":0,"isGift":false,"adjustMode":0,"skuStockOwner":0,"artificerName":"35247","skuId":2027954813,"categoryId":"20307,20363,20364","skuCount":1,"skuWeight":1.0}],"produceStationNoIsv":"666707","pickTime":"2022-11-05 17:41:32","pickMark":2,"deliveryConfirmTime":"2022-11-05 18:02:31","merchantPaymentDistanceFreightMoney":0,"buyerCityName":"天津市","orderVenderChargeMoney":0,"orderAgingType":9,"orderIsClosed":true,"orderJingdouMoney":0,"orderPreEndDeliveryTime":"2022-11-05 19:19:00","orderAdditionFreightMoney":0,"orderBalanceUsed":369,"ts":"2022-11-05 17:41:41","orderStockOwner":3,"popVenderId":"0","deliveryManNo":"17729065398","equipmentId":"RN_234c8e33a69b1660cbfa877d578458681bbea5ad","orderPreDeliveryTime":"2022-11-05 19:19:00","orderFreightMoney":200,"buyerIp":663769750,"buyerFullName":"天**","deliveryBillNo":"2226674100000073","storeLat":39.127495,"orderPreStartDeliveryTime":"2022-11-05 17:44:00","orderFinanceOrgCode":706,"buyerCountryName":"西青区","adjustIsExists":false,"prescriptionJson":"","prescriptionDTO":{"orderTimeFreightMoney":0,"isRigorous":false,"presaleTotalFrontMoney":0,"orderBizUuid":"0"},"buyerCountry":"51045","orderCloseTime":"2022-11-05 18:02:31","transmissionTime":"2022-11-05 17:28:42","orderBuyerRemark":"\n缺货时电话与我沟通","orderGoodsMoney":6160,"buyerMobile":"17695443984,2580","deliveryStationName":"京西菜市-中北店","orderDiscountMoney":1200,"businessTag":"dj_new_promise_v3;dj_new_cashier;dj_aging_immediately;;dj_sx;dj_freight_vender_pay;dj_vender_vip;dj_purchase_vip;vender_first_order;dj_mobile_safe_order;dj_coupon_logic_80;BT00007;picking_up;","orderTakeSelfCode":"","adjustId":0,"clientOrderPreStartDeliveryTime":"2022-11-05 17:44:00","produceStationNo":"11954632","orderStatus":90000,"orderPayType":4,"orderNum":2,"deliverInputTime":"2022-11-05 17:41:34","artificerPortraitUrl":"","srcInnerOrderId":0,"deliveryStationNoIsv":"666707","platformPointsDeductionMoney":0,"orderPurchaseTime":"2022-11-05 17:28:30","orgCode":"320406","buyerLng":117.08362,"orderLadderFreightMoney":0,"userAdditionalTips":0,"storeLng":117.087837,"updatePin":"邵庆文","buyerProvince":"0","buyerPinType":0,"deliveryType":1,"deliveryPackageVolume":0.0,"userTip":0,"deliveryManName":"邵庆文","orderBuyerPayableMoney":5280,"venderIntegralDeductMoney":0,"lastFourDigitsOfBuyerMobile":"3625","orderBaseReceivableFreight":500,"orderReceivableFreight":700,"payChannel":8001,"isGroupon":false,"printMark":1,"middleNumBindingId":"c3ed675857a34ad8880a3a5cc25a756b","businessType":1,"grouponId":0,"orderStartTime":"2022-11-05 17:28:19","deliveryCarrierNo":"9966","pickDeadline":"2022-11-05 17:44:00"},{"deliveryManPhone":"18822558816","orderType":10000,"srcOrderType":2,"appVersion":"RN","industryTag":3,"orderDynamicFreightMoney":0,"orderTotalMoney":4020,"orderId":2226646931001172,"orderJdSendpay":"{\"orderAddTimeFreightMoney\":200,\"packageFeeCollector\":1}","discount":[{"discountDetailType":2,"orderShareRatioData":"venderShareProportion=100&platShareProportion=0&venderPayMoney=500&platPayMoney=0","discountPrice":500,"discountType":8,"skuIds":"2046346925"},{"discountName":"满19元享特惠","discountDetailType":2201,"discountCode":"879","orderShareRatioData":"venderShareProportion=0&platShareProportion=100&venderPayMoney=0&platPayMoney=200&promotionId=879","discountPrice":200,"discountType":3,"skuIds":"2046346925"},{"discountName":"老朋友福利满25减6","discountDetailType":1,"discountCode":"1667613256039jvUzb31581972164-1029437765#454681300","orderShareRatioData":"promotionId=1029437765&venderShareProportion=0&platShareProportion=100&venderPayMoney=0&platPayMoney=600&createPin=liushuting@imdada.cn&sortId=1","discountPrice":600,"discountType":3,"skuIds":"2046346925"}],"grabTime":"2022-11-05 11:20:16","tips":0,"deliveryDelayAgreed":0,"buyerCity":"3","yn":false,"orderInvoiceOpenMark":2,"grabMark":4,"adjustCount":0,"buyerCoordType":2,"srcPlatId":4,"deliveryCarrierName":"达达专送","localDeliveryMoney":0,"produceStationName":"京西菜市-中北店","acceptDeadline":"2022-11-05 10:10:57","cartId":"2408:8210:5448:9930:d087:827b:91b2:708","srcInnerType":0,"packagingMoney":120,"orderBaseFreightMoney":500,"buyerFullAddress":"订单完结5小时后，隐藏顾客地址。","isJDGetCash":true,"orderDistanceStepFreight":0,"buyerPoi":"华侨城万科翡翠嘉和","pickPin":"jxadmin-15022721580","middleNumBindingTime":"2022-11-08 11:21:00","buyerTelephone":"17822641279,3081","venderBalanceDeductMoney":0,"buyerLat":39.132973,"buyerPin":"JD_206acf3dd06bf19","orderStatusTime":"2022-11-05 09:55:52","orderAcceptTime":"2022-11-05 09:55:59","srcOrderId":"2226646931001172","isDeleted":false,"cancelOrderIsReadable":true,"deliveryStationNo":"11954632","deliveryPackageWeight":2.0,"orderSkuType":1,"product":[{"skuJdPrice":2010,"promotionType":1,"skuIdIsv":"6092274","canteenMoney":0,"skuName":"鸡蛋15枚1kg/组","firstCategoryName":"日配/冷藏","skuStorePrice":2010,"skuPurchasePrice":0,"skuSpuId":0,"isGift":false,"adjustMode":0,"skuStockOwner":0,"artificerName":"35247","skuId":2046346925,"upcCode":"6666060922740","categoryId":"20386,22844,23327","skuCount":2,"skuWeight":1.0}],"produceStationNoIsv":"666707","pickTime":"2022-11-05 09:59:23","pickMark":2,"deliveryConfirmTime":"2022-11-05 11:20:16","merchantPaymentDistanceFreightMoney":0,"buyerCityName":"天津市","orderVenderChargeMoney":0,"orderAgingType":9,"orderIsClosed":true,"orderJingdouMoney":0,"orderPreEndDeliveryTime":"2022-11-05 11:21:00","orderAdditionFreightMoney":0,"orderBalanceUsed":0,"ts":"2022-11-05 10:38:48","orderStockOwner":3,"popVenderId":"0","deliveryManNo":"18822558816","equipmentId":"RN_e0729506d407f693c8d3c46c42b7c82749613123","orderPreDeliveryTime":"2022-11-05 11:21:00","orderFreightMoney":200,"buyerIp":2130706433,"buyerFullName":"天**","deliveryBillNo":"2226646931001172","storeLat":39.127495,"orderPreStartDeliveryTime":"2022-11-05 10:11:00","orderFinanceOrgCode":706,"buyerCountryName":"西青区","adjustIsExists":false,"prescriptionJson":"","prescriptionDTO":{"orderTimeFreightMoney":0,"isRigorous":false,"presaleTotalFrontMoney":0,"orderBizUuid":"0"},"buyerCountry":"51045","orderCloseTime":"2022-11-05 11:20:16","transmissionTime":"2022-11-05 09:55:57","orderBuyerRemark":"\n缺货时电话与我沟通","orderGoodsMoney":4020,"buyerMobile":"17822641279,3081","deliveryStationName":"京西菜市-中北店","orderDiscountMoney":800,"businessTag":"dj_new_promise_v3;dj_new_cashier;dj_aging_immediately;;dj_sx;dj_freight_vender_pay;vender_first_order;dj_mobile_safe_order;dj_coupon_logic_80;picking_up;","orderTakeSelfCode":"","adjustId":0,"clientOrderPreStartDeliveryTime":"2022-11-05 10:11:00","produceStationNo":"11954632","orderStatus":90000,"orderPayType":4,"orderNum":1,"deliverInputTime":"2022-11-05 09:59:25","artificerPortraitUrl":"","srcInnerOrderId":0,"deliveryStationNoIsv":"666707","platformPointsDeductionMoney":0,"orderPurchaseTime":"2022-11-05 09:55:46","orgCode":"320406","buyerLng":117.073975,"orderLadderFreightMoney":0,"userAdditionalTips":0,"storeLng":117.087837,"updatePin":"杨向伟","buyerProvince":"0","buyerPinType":0,"deliveryType":1,"deliveryPackageVolume":0.0,"userTip":0,"deliveryManName":"杨向伟","orderBuyerPayableMoney":3540,"venderIntegralDeductMoney":0,"lastFourDigitsOfBuyerMobile":"7906","orderBaseReceivableFreight":500,"orderReceivableFreight":700,"payChannel":8001,"isGroupon":false,"printMark":1,"middleNumBindingId":"2022110509555235502180092799","businessType":1,"grouponId":0,"orderStartTime":"2022-11-05 09:55:30","deliveryCarrierNo":"9966","pickDeadline":"2022-11-05 10:11:00"}]}`
	var result0 = make(map[string]interface{}, 0)
	if err := utils.UnmarshalUseNumber([]byte(aa), &result0); err != nil {
		globals.SugarLogger.Debugf("==============err := %s", err.Error())
	}

}

func TestDecode(t *testing.T) {
	ccc := `8FvHJcQmVojAIU61SNaS1ermHN2UVWknueRHFSNf2q5EbxNNmznoTYpRu7ySc/8CuU+QGZ9UIBMCyTuFafY3PuszEokEKc8M1Qfv/+o15h5bIU8LXfwRKOCm3JYzZtTOvJVU0hk/USvtDgraToszFl2hQZjZN5gGH1af0X8vopo=`
	appSecret := `0bcbe9d6e6124cf2aef2856a540f1326` // 试例token

	//appSecret := `a88d031a1e7b462cb1579f12e97fe7f4` // 320406
	//ccc := `8FvHJcQmVojAIU61SNaS1ermHN2UVWknueRHFSNf2q5EbxNNmznoTYpRu7ySc/8CuU+QGZ9UIBMCyTuFafY3PuszEokEKc8M1Qfv/+o15h5bIU8LXfwRKOCm3JYzZtTOvJVU0hk/USvtDgraToszFl2hQZjZN5gGH1af0X8vopo=`
	data, err := JDDecodeToData(appSecret, ccc)
	fmt.Println(err)
	fmt.Println(string(data))
	fmt.Println(len(data))
	dataMap := make(map[string]interface{}, 0)

	if err := utils.UnmarshalUseNumber(data, &dataMap); err != nil {
		fmt.Println("errr2 ==", err)
	}

	fmt.Println("data2 :========", utils.Format4Output(dataMap, false))
}

func TestDDDD(t *testing.T) {
	fmt.Println(time.Now().Sub(utils.Str2Time("2024-09-04 22:00:00")))
}
