package tao_vegetable

import (
	"fmt"
	"git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability2770/domain"
	"git.rosy.net.cn/baseapi/utils"
	"testing"
	"time"
)

/*
商品活动
*/
//创建活动
func TestActivityCreate(t *testing.T) {
	resp, err := apiTao.ActivityCreate(domain.AlibabaRetailMarketingItemdiscountActivityCreateItemDiscountActivityOperateRequest{
		ActivityName: utils.String2Pointer("创建单品特价活动测试616"),
		CreatorId:    utils.String2Pointer("20230616112030"),
		CreatorName:  utils.String2Pointer("京西菜市"),
		Description:  utils.String2Pointer("特价活动很火热"),
		Terminals:    &[]int32{1},
		StoreIds:     &[]string{"JX668998"},
		DiscountType: utils.Int64ToPointer(3),
		StartTime:    utils.Int64ToPointer(time.Now().UnixNano() / int64(time.Millisecond)),
		EndTime:      utils.Int64ToPointer((time.Now().UnixNano() / int64(time.Millisecond)) + 3*time.Hour.Milliseconds()),
	})
	fmt.Println(resp)
	fmt.Println(err)
}

//查询单品特价活动【同城零售】
func TestQueryAct(t *testing.T) {
	resp, err := apiTao.ActivityQuery(230658198, "")
	fmt.Println(resp)
	fmt.Println(err)
}

//更新单品特价活动【同城零售】
func TestUpdateAct(t *testing.T) {
	err := apiTao.ActivityUpdate(domain.AlibabaRetailMarketingItemdiscountActivityUpdateItemDiscountActivityOperateRequest{
		ActivityName: utils.String2Pointer("成都直降测试0713"),
		CreatorId:    utils.String2Pointer("20230619180157"),
		CreatorName:  utils.String2Pointer("京西菜市"),
		Description:  utils.String2Pointer("特价活动很火热"),
		Terminals:    &[]int32{1},
		StoreIds:     &[]string{"JX668594"},
		StartTime:    utils.Int64ToPointer(1689220800000),
		//EndTime:      utils.Int64ToPointer((time.Now().UnixNano() / int64(time.Millisecond)) + 3*time.Hour.Milliseconds()),
		EndTime: utils.Int64ToPointer(1691855999000),
		ActId:   utils.Int64ToPointer(230658198),
	})
	fmt.Println(err)
}

//删除单品特价活动【同城零售】
func TestDeleteAct(t *testing.T) {
	err := apiTao.ActivityDelete("20230619180157", "京西菜市", 230658198)
	fmt.Println(err)
}
