package com.jeesharp.business.modules.coupon.application.api;

import com.jeesharp.business.modules.coupon.api.CouponCheckoutApi;
import com.jeesharp.business.modules.coupon.application.CouponCheckoutApplicationService;
import com.jeesharp.business.modules.coupon.dto.CouponCheckoutContextDTO;
import com.jeesharp.business.modules.coupon.dto.CouponFreezeCommandDTO;
import com.jeesharp.business.modules.coupon.vo.CouponCheckoutListVO;
import com.jeesharp.business.modules.coupon.vo.CouponOrderDiscountVO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Map;

/**
 * {@link CouponCheckoutApi} 实现，委托 {@link CouponCheckoutApplicationService}。
 *
 * @author jeesharp
 * @since 2026-06-08
 */
@Service
@AllArgsConstructor
public class CouponCheckoutApiImpl implements CouponCheckoutApi {

    private final CouponCheckoutApplicationService couponCheckoutApplicationService;

    @Override
    public CouponCheckoutListVO listForCheckout(CouponCheckoutContextDTO context) {
        return couponCheckoutApplicationService.listForCheckout(context);
    }

    @Override
    public Map<String, Object> listForCheckoutLegacyMap(String memberId, BigDecimal orderAmount) {
        return couponCheckoutApplicationService.listForCheckoutLegacyMap(memberId, orderAmount);
    }

    @Override
    public BigDecimal resolveDiscount(CouponCheckoutContextDTO context, String memberCouponId) {
        return couponCheckoutApplicationService.resolveDiscount(context, memberCouponId);
    }

    @Override
    public void freezeForOrder(CouponFreezeCommandDTO command) {
        couponCheckoutApplicationService.freezeForOrder(command);
    }

    @Override
    public void confirmOrderPaid(String orderId) {
        couponCheckoutApplicationService.confirmOrderPaid(orderId);
    }

    @Override
    public void returnOnRefund(String orderId, String reason) {
        couponCheckoutApplicationService.returnOnRefund(orderId, reason);
    }

    @Override
    public BigDecimal getFrozenDiscountAmount(String orderId) {
        return couponCheckoutApplicationService.getFrozenDiscountAmount(orderId);
    }

    @Override
    public void releaseFrozen(String orderId, String reason) {
        couponCheckoutApplicationService.releaseFrozen(orderId, reason);
    }

    @Override
    public CouponOrderDiscountVO resolveOrderCouponDisplay(String orderId) {
        return couponCheckoutApplicationService.resolveOrderCouponDisplay(orderId);
    }

    @Override
    public String resolveTemplateTenantCode(String memberCouponId) {
        return couponCheckoutApplicationService.resolveTemplateTenantCode(memberCouponId);
    }

    @Override
    public void confirmAllFrozenForMallBatch(String batchId, java.util.List<String> subOrderIds) {
        couponCheckoutApplicationService.confirmAllFrozenForMallBatch(batchId, subOrderIds);
    }

    @Override
    public void releaseAllFrozenForMallBatch(String batchId, java.util.List<String> subOrderIds, String reason) {
        couponCheckoutApplicationService.releaseAllFrozenForMallBatch(batchId, subOrderIds, reason);
    }
}
