package merchant

import (
	"context"
	"kami/internal/model"
	"kami/internal/service"

	"github.com/gogf/gf/v2/errors/gerror"

	"kami/api/merchant/v1"
)

func (c *ControllerV1) StealCreate(ctx context.Context, req *v1.StealCreateReq) (res *v1.StealCreateRes, err error) {
	//判断规则是否正常
	for _, i := range req.AmountRule {
		if i > req.FaceAmount {
			err = gerror.New("偷卡金额大于偷卡面额")
			return
		}
	}
	err = service.StealRule().Create(ctx, &model.MerchantHiddenConfigInput{
		MerchantHiddenConfig: req.MerchantHiddenConfig,
	})
	return
}
