package jdapi

import (
	"testing"
	"time"

	"git.rosy.net.cn/baseapi/utils"
)

func TestOrderDiscountSubmitActivity(t *testing.T) {
	actInfo := &OrderDiscountActivity{
		OutActivityID:     utils.GetUUID(),
		PromName:          "测试0404",
		PromType:          OrderDiscountActivityTypeManJian,
		BeginTime:         utils.Time2Str(time.Now().Add(1 * time.Hour)),
		EndTime:           utils.Time2Str(time.Now().Add(48 * time.Hour)),
		ParticipationMode: ParticipationModePartSku,
		Display:           "hello",
		OutStationNos:     []string{"2"},
		// OutSkuIDs:            []string{"5199"},
		SkuIDs:               []string{"2023747677"},
		LimitUserTotalNumber: 1,
		RuleRequestList: []*OrderDiscountRuleRequest{
			&OrderDiscountRuleRequest{
				LowerLimitAmount: 1000,
				DiscountAmount:   100,
				DiscountRate:     8.5,
			},
		},
	}
	actID, err := api.OrderDiscountSubmitActivity(actInfo)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(actID)
}

func TestOrderDiscountQuerySubmitActivityResult(t *testing.T) {
	result, err := api.OrderDiscountQuerySubmitActivityResult(10000051)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(result)
}

func TestOrderDiscountQueryActivityInfo(t *testing.T) {
	result, err := api.OrderDiscountQueryActivityInfo(10000051)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestOrderDiscountCancelActivity(t *testing.T) {
	err := api.OrderDiscountCancelActivity(10000049, "test", "")
	if err != nil {
		t.Fatal(err)
	}
}
