package setting

import (
	"context"
	"git.oa00.com/supply-chain/service/client"
	"github.com/shopspring/decimal"
)

type rate struct {
}

type RateItem struct {
	Id   uint            `json:"id"`
	Name string          `json:"name"`
	Rate decimal.Decimal `json:"rate"`
}

// All @Title 全部利率
func (r *rate) All(ctx context.Context) (result []RateItem, err error) {
	xClient, err := client.GetClient(r)
	if err != nil {
		return
	}
	err = xClient.Call(ctx, "All", 0, &result)
	return
}

type ArgsRateChannel struct {
	ChannelId uint // 渠道id
	RateId    uint // 费率id
}

// Channel @Title 设置渠道利率
func (r *rate) Channel(ctx context.Context, args ArgsRateChannel) error {
	reply := 0
	xClient, err := client.GetClient(r)
	if err != nil {
		return err
	}
	return xClient.Call(ctx, "Channel", args, &reply)
}