package pposRequest

import (
	"errors"
	"net/url"
)

//NewShopOrderTradeExits 营业点是否营业过
func (that *PPOSClient) NewShopOrderTradeExits() *ShopOrderTradeExitsRequest {
	return &ShopOrderTradeExitsRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/shop/order/tradeExits",
		},
	}
}

//ShopOrderTradeExitsRequest ...
type ShopOrderTradeExitsRequest struct {
	Request
}

//Params ...
func (that *ShopOrderTradeExitsRequest) 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 *ShopOrderTradeExitsRequest) Do() (bool, error) {
	//
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return false, _err
	}
	_rs, _ok := _data.(map[string]interface{})
	if !_ok {
		return false, errors.New(that.apiAddress + "请求响应格式不正确")
	}
	_bool, _ok2 := _rs["result"].(bool)
	if !_ok2 {
		return false, errors.New(that.apiAddress + "请求响应格式不正确")
	}
	return _bool, nil
}
