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

import com.jeesharp.business.modules.mall.api.MallOrderReadApi;
import com.jeesharp.business.modules.mall.api.dto.MallOrderInvoiceSummaryDTO;
import com.jeesharp.business.modules.mall.entity.MallOrder;
import com.jeesharp.business.modules.mall.service.MallOrderService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * {@link MallOrderReadApi} 实现，基于 {@link MallOrderService} 只读查询（Application 层 api 包）。
 *
 * @author jeesharp
 * @since 2026-06-08
 */
@Service
@AllArgsConstructor
public class MallOrderReadApiImpl implements MallOrderReadApi {

    private final MallOrderService mallOrderService;

    @Override
    public MallOrderInvoiceSummaryDTO getInvoiceSummary(String orderId) {
        MallOrder order = mallOrderService.get(orderId);
        if (order == null) {
            return null;
        }
        MallOrderInvoiceSummaryDTO dto = new MallOrderInvoiceSummaryDTO();
        dto.setId(order.getId());
        dto.setOrderNo(order.getOrderNo());
        dto.setMemberId(order.getMemberId());
        dto.setTenantId(order.getTenantId());
        dto.setTenantCode(order.getTenantCode());
        return dto;
    }
}
