func (d *UserBalanceController) addAmount() {
	var input InputRequest
	var model = new(models.UserBalance)

	debug, _ := conf.AppConfig.Bool("debug")
	defer LogErr()
	body, error := ioutil.ReadAll(d.Request.Body)
	error = json.Unmarshal(body, &input)
	if debug {
		Log.WithField("request", string(body)).Printf("deposit")
	}
	if error != nil {
		Log.WithField("error", error).Printf("read body or json error")
	}
	if input.UserId == 0 || input.Amount == 0 {
		d.makeIncorrectRequestParamsReponse("User and Amount params is required")
		return
	}

	model = model.GetById(input.UserId)
	if model.Id == 0 {
		model = models.CreateUserBalance(input.UserId, input.Amount, "")
	} else {
		model.AddAmount(input.Amount)
	}

	d.ResponseWriter(d.Request, d.Response, "")

	return
}
// add amount to user balance
add amount to user balance
// add amount to user balance
func (d *UserBalanceController) addAmount() {
	var input InputRequest
	var model = new(models.UserBalance)
	debug, _ := conf.AppConfig.Bool("debug")
	defer LogErr()
	body, error := ioutil.ReadAll(d.Request.Body)
	error = json.Unmarshal(body, &input)
	if debug {
		Log.WithField("request", string(body)).Printf("deposit")
	}
	if error != nil {
		Log.WithField("error", error).Printf("read body or json error")
	}
	if input.UserId == 0 || input.Amount == 0 {
		d.makeIncorrectRequestParamsReponse("User and Amount params is required")
		return
	}
	model = model.GetById(input.UserId)
	if model.Id == 0 {
		model = models.CreateUserBalance(input.UserId, input.Amount, "")
	} else {
		model.AddAmount(input.Amount)
	}
	d.ResponseWriter(d.Request, d.Response, "")
	return
}
func ( d * UserBalanceController ) addAmount ( ) { var input InputRequest var model = new ( models . UserBalance ) debug , _ := conf . AppConfig . Bool ( " " ) defer LogErr ( ) body , error := ioutil . ReadAll ( d . Request . Body ) error = json . Unmarshal ( body , & input ) if debug { Log . WithField ( " " , string ( body ) ) . Printf ( " " ) } if error != nil { Log . WithField ( " " , error ) . Printf ( " " ) } if input . UserId == 0 || input . Amount == 0 { d . makeIncorrectRequestParamsReponse ( " " ) return } model = model . GetById ( input . UserId ) if model . Id == 0 { model = models . CreateUserBalance ( input . UserId , input . Amount , " " ) } else { model . AddAmount ( input . Amount ) } d . ResponseWriter ( d . Request , d . Response , " " ) return }
add amount to user balance
add amount to user balance