package jdapi import ( "testing" "time" ) func TestCreatePromotionSingle(t *testing.T) { infoId, err := jdapi.CreatePromotionInfosSingle("测试1", time.Now(), time.Now().Add(24*time.Hour), "", "") if err != nil { t.Fatal(err) } t.Log(infoId) err = jdapi.CreatePromotionRules(infoId, "", 1, 1, 1, 1) if err != nil { t.Fatal(err) } skuInfos, err := jdapi.CreatePromotionSkuSingle(infoId, "", []map[string]interface{}{ { KeyOutSkuId: "2216", KeyStationNo: 11682042, KeyPromotionPrice: 500, KeyLimitSkuCount: 2, }, }) if err != nil { t.Fatal(err) } t.Log(skuInfos) err = jdapi.ConfirmPromotionSingle(infoId, "") if err != nil { t.Fatal(err) } } func TestCreatePromotionLimitTime(t *testing.T) { infoId, err := jdapi.CreatePromotionInfosLimitTime("测试1", time.Now(), time.Now().Add(24*time.Hour), "", "") if err != nil { t.Fatal(err) } t.Log(infoId) err = jdapi.CreatePromotionRules(infoId, "", 1, 1, 5, 1) if err != nil { t.Fatal(err) } skuInfos, err := jdapi.CreatePromotionSkuLimitTime(infoId, "", []map[string]interface{}{ { KeyOutSkuId: "2216", KeyStationNo: 11682042, KeyPromotionPrice: 300, KeyLimitSkuCount: 2, }, }) if err != nil { t.Fatal(err) } t.Log(skuInfos) err = jdapi.ConfirmPromotionLimitTime(infoId, "") if err != nil { t.Fatal(err) } } func TestQueryPromotionInfo(t *testing.T) { result, err := jdapi.QueryPromotionInfo(14885272) if err != nil { t.Fatal(err) } if len(result.SkuResultList) == 0 { t.Fatal("should have SkuResultList") } }