/**
 * 核心服务接口sdk（golang版）
 *
 * @desc 啪啪运动 核心服务接口sdk
 * ---------------------------------------------------------------------
 * @author		logan <unphp@qq.com>
 * @date		2021-08-02
 * @copyright	core-utils
 * ---------------------------------------------------------------------
 */

package pposRequest

import (
	"encoding/json"
	"errors"
	"net/url"
)

//new...
func (that *PPOSClient) NewSalesGetByStadiumIds() *SalesGetByStadiumIdsRequest {
	return &SalesGetByStadiumIdsRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/base/salesPoint/getByStadiumIds",
		},
	}
}

type SalesGetByStadiumIdsResponse struct {
	PointLists []PointList `json:"point_list"`
}

//Response...
//type SalesGetByStadiumIdsResponse struct {
//	PointList []SalesList `json:"point_list"` //point_list
//}

type PointList struct {
	BusinessId int64  `json:"business_id"`
	PointId    int64  `json:"point_id"`
	PointName  string `json:"point_name"`
}

//Request...
type SalesGetByStadiumIdsRequest struct {
	Request
}

func (that *SalesGetByStadiumIdsRequest) SetStadiumIds(value string) *SalesGetByStadiumIdsRequest {
	that.initParams()
	that.params.Set("stadium_ids", value) //营业点信息获取通过ids
	return that
}
func (that *SalesGetByStadiumIdsRequest) SetColumn(value string) *SalesGetByStadiumIdsRequest {
	that.initParams()
	that.params.Set("column", value) //字段名，逗号隔开
	return that
}

//Params ...
func (that *SalesGetByStadiumIdsRequest) Params() (url.Values, error) {
	that.initParams()
	_params := that.params
	return _params, nil
}

//Do ...
func (that *SalesGetByStadiumIdsRequest) Do() ([]*SalesGetByStadiumIdsResponse, error) {
	_rs := make([]*SalesGetByStadiumIdsResponse, 0)
	//
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return _rs, _err
	}
	//
	_str, _err := json.Marshal(_data)
	if _err != nil {
		return _rs, errors.New(that.apiAddress + _err.Error())
	}
	_err = json.Unmarshal(_str, &_rs)
	if _err != nil {
		return _rs, errors.New(that.apiAddress + _err.Error())
	}
	return _rs, nil
}
