package card_info_walmart

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

	"kami/api/card_info_walmart/v1"
)

func (c *ControllerV1) RedeemConfigSet(ctx context.Context, req *v1.RedeemConfigSetReq) (res *v1.RedeemConfigSetRes, err error) {
	err = service.SysConfigDict().SetIsAllowRedeemCardDifferentAmount(ctx, consts.CardRedeemAccountCategoryWalMart, req.IsAllowDifferentAmount)
	err = service.SysConfigDict().SetRedeemCardMinAmount(ctx, consts.CardRedeemAccountCategoryWalMart, req.RedeemCardMinAmount)
	err = service.SysConfigDict().SetRedeemCardFailCallbackIsAllow(ctx, consts.CardRedeemAccountCategoryWalMart, req.IsAllowDifferentSucceedCallback)
	err = service.SysConfigDict().SetRedeemCardSucceedCallbackIsAllow(ctx, consts.CardRedeemAccountCategoryWalMart, req.IsAllowDifferentFailCallback)
	err = service.SysConfigDict().SetRedeemCardCompensatedAutoCallback(ctx, consts.CardRedeemAccountCategoryWalMart, req.IsAllowCompensatedCallback)
	err = service.SysConfigDict().SetIsAllowedRepeated(ctx, consts.CardRedeemAccountCategoryWalMart, req.IsCardAllowRepeated)
	service.SysConfigDict().SetMaxAccountRedeemCount(ctx, consts.CardRedeemAccountCategoryWalMart, req.MaxAccountRedeemCount)
	service.SysConfigDict().SetRedeemCardRate(ctx, consts.CardRedeemAccountCategoryWalMart, req.RedeemCardRate)
	_ = service.SysConfigDict().SetRedeemScheduleStrategy(ctx, consts.CardRedeemAccountCategoryWalMart, req.RedeemOrderScheduleStrategy, nil)
	return
}
