package ppos

import (
	"PPOSUtils/utils"
)

type paramsCustom struct {
	customMp  utils.Mp
	postionMp utils.Mp
}

func (that *paramsCustom) init() {
	if that.customMp == nil {
		that.customMp = utils.NewMP()
		that.postionMp = utils.NewMP()
	}
}

func (that *paramsCustom) SetCompayID(value int64) {
	that.init()
	that.customMp.Set("company_id", value)
}

func (that *paramsCustom) SetBusinessID(value int64) {
	that.init()
	that.customMp.Set("business_id", value)
}

func (that *paramsCustom) SetStadiumID(value int64) {
	that.init()
	that.customMp.Set("stadium_id", value)
}

func (that *paramsCustom) SetSalesID(value int64) {
	that.init()
	that.customMp.Set("sales_id", value)
}

func (that *paramsCustom) SetData(key string, value interface{}) {
	that.init()
	that.customMp.Set(key, value)
}

func (that *paramsCustom) GetData(key string) interface{} {
	that.init()
	return that.customMp.Get(key)
}

func (that *paramsCustom) GetCustom() utils.Mp {
	that.init()
	return that.customMp
}

func (that *paramsCustom) SetPositionData(key string, value interface{}) {
	that.init()
	that.postionMp.Set(key, value)
}

func (that *paramsCustom) getCustomValue(name string) interface{} {
	that.init()
	if that.customMp.Has(name) {
		return that.customMp.Get(name)
	}
	return nil
}

//get 会话相关的隔离字段
func (that *paramsCustom) GetPostion(appID ...int64) utils.Mp {
	that.init()
	if that.postionMp == nil {
		that.postionMp = utils.NewMP()
	}
	return that.postionMp
}
