123 lines
3.6 KiB
Go
123 lines
3.6 KiB
Go
package mtwmapi
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
func TestFullDiscountBatchSave(t *testing.T) {
|
|
result, err := api.FullDiscountBatchSave(testPoiCode, &FullDiscountActInfo{
|
|
// ActIDs: "12345678",
|
|
ActName: "测试活动0402",
|
|
StartTime: time.Now().Unix(),
|
|
EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
|
ActType: ActTypeStoreFullDiscount,
|
|
}, []*FullDiscountActDetail{
|
|
&FullDiscountActDetail{
|
|
OriginalPrice: 10000,
|
|
ActPrice: 1,
|
|
},
|
|
}, /*[]*ActSkuInfo{
|
|
&ActSkuInfo{
|
|
AppFoodCode: "30902",
|
|
DayLimit: 1,
|
|
},
|
|
}*/nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// 30902
|
|
t.Log(result)
|
|
}
|
|
|
|
func TestFullDiscountList(t *testing.T) {
|
|
result, err := api.FullDiscountList(testPoiCode, ActTypeStoreFullDiscount)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestFullDiscountFoodsList(t *testing.T) {
|
|
result, err := api.FullDiscountFoodsList(testPoiCode, "497726932")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestFulllDiscountShippingFeeBatchSave(t *testing.T) {
|
|
err := api.FulllDiscountShippingFeeBatchSave(testPoiCode, []*ShippingFeeActData{&ShippingFeeActData{}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestFulllDiscountShippingFeeList(t *testing.T) {
|
|
result, err := api.FulllDiscountShippingFeeList(testPoiCode)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestRetailDiscountBatchSave(t *testing.T) {
|
|
result, err := api.RetailDiscountBatchSave(testPoiCode, RetailActTypeDirectDown, []*RetailDiscountActData{&RetailDiscountActData{
|
|
AppFoodCode: "1140",
|
|
UserType: UserTypeAll,
|
|
StartTime: time.Now().Unix(),
|
|
EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
|
OrderLimit: 1,
|
|
DayLimit: 1,
|
|
SettingType: SettingTypeAsDiscount,
|
|
DiscountCoefficient: 0.97,
|
|
}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestRetailDiscountList(t *testing.T) {
|
|
result, err := api.RetailDiscountList(testPoiCode, RetailActTypeDirectDown)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestRetailDiscountDelete(t *testing.T) {
|
|
err := api.RetailDiscountDelete(testPoiCode, RetailActTypeDirectDown, []string{"329187452"})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestInStoreCouponList(t *testing.T) {
|
|
result, err := api.InStoreCouponList(testPoiCode, 1, 100)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestParseErr4RetailDiscountDelete(t *testing.T) {
|
|
errStr := `
|
|
{"error_list":[{"act_id":1053302130,"error_msg":"活动ID不存在"},{"act_id":1053302127,"error_msg":"活动ID不存在"},{"act_id":1053302128,"error_msg":"活动ID不存在"},{"act_id":1053302129,"error_msg":"活动ID不存在"},{"act_id":1053302135,"error_msg":"活动ID不存在"},{"act_id":1053302132,"error_msg":"活动ID不存在"},{"act_id":1053302123,"error_msg":"活动ID不存在"},{"act_id":1053302125,"error_msg":"活动ID不存在"},{"act_id":1053302124,"error_msg":"活动ID不存在"},{"act_id":1053302133,"error_msg":"活动ID不存在"},{"act_id":1053302126,"error_msg":"活动ID不存在"},{"act_id":1053302134,"error_msg":"活动ID不存在"},{"act_id":1053302131,"error_msg":"活动ID不存在"}]}
|
|
|
|
`
|
|
errExt := utils.NewErrorCode(errStr, "")
|
|
failedList := ParseErr4RetailDiscountDelete(errExt)
|
|
t.Log(utils.Format4Output(failedList, false))
|
|
}
|
|
|
|
func TestGetByAppPoiCodeAndType(t *testing.T) {
|
|
result, err := api.GetByAppPoiCodeAndType("9375120", 1, 1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|