package com.seer.teach.mall.app.order.service.impl;

import com.seer.teach.mall.app.order.service.IAppLogisticsService;
import com.seer.teach.mall.entity.OrderChildEntity;
import com.seer.teach.mall.factory.LogisticsServiceFactory;
import com.seer.teach.mall.service.ILogisticsService;
import com.seer.teach.mall.service.IOrderChildService;
import com.seer.teach.mall.shipping.jt.resp.TraceResp;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class AppLogisticsServiceImpl implements IAppLogisticsService {

    private final LogisticsServiceFactory logisticsServiceFactory;

    private final IOrderChildService orderChildService;

    @Override
    public List<TraceResp> getLogisticsTrace(String childOrderSn) {
        OrderChildEntity orderChildEntity = orderChildService.checkOrderChildByChildOrderSn(childOrderSn);

        ILogisticsService logisticsService = logisticsServiceFactory.getService(orderChildEntity.getLogisticsCode());

        return logisticsService.queryLogisticsTrace(orderChildEntity.getShippingNo());
    }
}