package pposRequest

import (
	"errors"
	"net/url"
)

//来沪动体育地图 - 接收类请求
func (that *PPOSClient) NewLhdRequest() *LhdCarInRequest {
	return &LhdCarInRequest{
		Request: Request{
			Client:     that,
			apiAddress: "",
		},
	}
}

//来沪动票券售卖列表
func (that *LhdCarInRequest) SaleTicketList() *LhdCarInRequest {
	that.apiAddress = "/platform/lhdStadium/saleTicketList"
	return that
}

//来沪动场地可预约日期列表
func (that *LhdCarInRequest) SaleFieldDateList() *LhdCarInRequest {
	that.apiAddress = "/platform/lhdStadium/saleFieldDateList"
	return that
}

//来沪动场次时间矩阵图
func (that *LhdCarInRequest) SaleFieldBoardList() *LhdCarInRequest {
	that.apiAddress = "/platform/lhdStadium/saleFieldBoardList"
	return that
}

//创建订单
func (that *LhdCarInRequest) OrderCreate() *LhdCarInRequest {
	that.apiAddress = "/platform/lhdOrder/create"
	return that
}

//来沪动场次时间矩阵图
func (that *LhdCarInRequest) OrderCancel() *LhdCarInRequest {
	that.apiAddress = "/platform/lhdOrder/cancel"
	return that
}

//来沪动场次时间矩阵图
func (that *LhdCarInRequest) OrderPayNotice() *LhdCarInRequest {
	that.apiAddress = "/platform/lhdOrder/payNotice"
	return that
}

//来沪动场次时间矩阵图
func (that *LhdCarInRequest) OrderRefund() *LhdCarInRequest {
	that.apiAddress = "/platform/lhdOrder/refund"
	return that
}

//来沪动场次时间矩阵图
func (that *LhdCarInRequest) OrderVerify() *LhdCarInRequest {
	that.apiAddress = "/platform/lhdOrder/verify"
	return that
}

//
type LhdCarInRequest struct {
	Request
}

//SetPostParams...
func (that *LhdCarInRequest) SetBizContent(value string) *LhdCarInRequest {
	that.initParams()
	that.params.Set("biz_content", value)
	return that
}

//Params ...
func (that *LhdCarInRequest) Params() (url.Values, error) {
	that.initParams()
	_params := that.params
	if that.publicParamsSlice != nil {
		for _, _v := range that.publicParamsSlice {
			if _params.Get(_v) == "" {
				return nil, errors.New(that.apiAddress + "缺少参数:" + _v)
			}
		}
	}
	return _params, nil
}

//Do ...
func (that *LhdCarInRequest) Do() (interface{}, error) {
	if that.apiAddress == "" {
		return "", errors.New("接口不存在")
	}
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return "", _err
	}
	return _data, nil
}
