package pposRequest

import (
	"PPOSUtils/utils"
	"errors"
	"net/url"
)

//创建订单
func (that *PPOSClient) NewPlatformAliOrderCreateRequest() *PlatformAliOrderCreateRequest {
	return &PlatformAliOrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/platform/aliOrder/create",
			publicParamsSlice: []string{
				"ali_trade_no",
				"product_id",
				"stadium_id",
			},
		}}
}

type PlatformAliOrderCreateRequest struct {
	Request
}

func (that *PlatformAliOrderCreateRequest) SetAliTradeNo(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("ali_trade_no", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetOrderPrice(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("order_price", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetBuyerPhone(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("buyer_phone", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetProductId(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("product_id", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetStadiumId(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("stadium_id", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetProductType(value int64) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("product_type", utils.ToString(value))
	return that
}
func (that *PlatformAliOrderCreateRequest) SetGroundBookingIds(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("ground_booking_ids", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetCount(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("count", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetAliUid(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("aliuid", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetOutResourceNo(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("out_resource_no", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetExtra(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("extra", value)
	return that
}
func (that *PlatformAliOrderCreateRequest) SetExtras(value string) *PlatformAliOrderCreateRequest {
	that.initParams()
	that.params.Set("extras", value)
	return that
}

//Params ...
func (that *PlatformAliOrderCreateRequest) 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 *PlatformAliOrderCreateRequest) Do() (interface{}, error) {
	//返回data
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	return _data, nil
}
