package com.jeesharp.business.modules.food.application.settle;

import cn.hutool.core.util.StrUtil;
import com.jeesharp.business.modules.finance.api.PayRefundSuccessHandler;
import com.jeesharp.business.modules.finance.paymentrecord.enums.PayRecordBizSceneEnum;
import com.jeesharp.business.modules.food.application.support.FoodCompanyMealRefundCoordinator;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 企业团餐退款成功回调：回滚企业账户补贴、释放库存并关单。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Service
@AllArgsConstructor
public class FoodCompanyMealPayRefundSuccessHandler implements PayRefundSuccessHandler {

    private final FoodCompanyMealRefundCoordinator foodCompanyMealRefundCoordinator;

    @Override
    public boolean supports(String bizScene) {
        return PayRecordBizSceneEnum.FOOD_COMPANY_MEAL_ORDER.getCode().equals(bizScene);
    }

    @Override
    public void onRefundSuccess(String payRefundOrderId, String bizRefId) {
        if (StrUtil.isBlank(bizRefId)) {
            return;
        }
        foodCompanyMealRefundCoordinator.applyRefundSuccess(bizRefId.trim(), null, null);
    }
}
