package mtwmapi

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

type PackagePriceItem struct {
	Label string `json:"label"`
	Value int    `json:"value"`
}

type PackagePriceInfo struct {
	PackagePayType    int                 `json:"packagePayType"`
	PackagePrice      int                 `json:"packagePrice"`
	PackagePriceRange []*PackagePriceItem `json:"packagePriceRange"`
	WmPoiID           int                 `json:"wmPoiId"`
	Message           string              `json:"message"`
}

func (a *API) PackagePriceUpdate(poiCode string, packetPayType, packetPrice int) (err error) {
	params := map[string]interface{}{
		"wmPoiId":       poiCode,
		"packetPayType": packetPayType,
		"packetPrice":   packetPrice,
	}
	_, err = a.AccessUserPage2("reuse/sc/product/packageprice/w/update", params, true)
	return err
}

func (a *API) PackagePriceGet(poiCode string) (priceInfo *PackagePriceInfo, err error) {
	params := map[string]interface{}{
		"wmPoiId": poiCode,
	}
	result, err := a.AccessUserPage2("reuse/sc/product/packageprice/r/get", params, true)
	if err == nil {
		err = utils.Map2StructByJson(result, &priceInfo, false)
	}
	return priceInfo, err
}
