package pposRequest

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

//订单支付通知
func (that *PPOSClient) NewPlatformAliOrderPayNoticeRequest() *PlatformAliOrderPayNoticeRequest {
	return &PlatformAliOrderPayNoticeRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/platform/aliOrder/payNotice",
			publicParamsSlice: []string{
				"ali_trade_no",
				"order_price",
			},
		}}
}

type PlatformAliOrderPayNoticeRequest struct {
	Request
}

func (that *PlatformAliOrderPayNoticeRequest) SetAliTradeNo(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("ali_trade_no", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetOrderPrice(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("order_price", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetRealPay(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("real_pay", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetPayMode(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("pay_mode", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetStadiumId(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("stadium_id", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetUserId(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("user_id", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetAliUid(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("aliuid", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetCardId(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("card_id", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetCardNo(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("card_no", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetTime(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("time", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetProductType(value int64) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("product_type", utils.ToString(value))
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetPayGroup(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("pay_group", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetExtra(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("extra", value)
	return that
}
func (that *PlatformAliOrderPayNoticeRequest) SetAlipayOrderId(value string) *PlatformAliOrderPayNoticeRequest {
	that.initParams()
	that.params.Set("alipay_order_id", value)
	return that
}

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