package com.trade.admin.order.service.impl;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.trade.admin.order.service.BPurchaseOrderService;
import com.trade.service.order.dto.PurchaseOrderLogisticsSearchDto;
import com.trade.service.order.service.PurchaseOrderLogisticsService;
import com.trade.service.order.vo.PurchaseOrderDetailsVo;
import com.trade.service.order.vo.PurchaseOrderLogisticsPageVo;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import com.trade.common.core.page.GridPage;

import com.trade.common.utils.LoggerUtil;

import com.trade.service.order.dto.PurchaseSearchDto;
import com.trade.service.order.service.PurchaseOrderService;
import com.trade.service.order.vo.PurchaseOrderVo;

/**
 * @description: 采购订单服务实现类
 * @Author: wanglang
 * @Date: 2024/9/12
 * @Version: 1.0
 */
@Service
public class BPurchaseOrderServiceImpl implements BPurchaseOrderService {

    private static final Logger log = LoggerUtil.logger(LoggerUtil.LogFileNameEnum.SERVICES_LOG);;
    @Resource
    private PurchaseOrderService purchaseOrderService;
    @Resource
    private PurchaseOrderLogisticsService purchaseOrderLogisticsService;

    @Override
    public GridPage<PurchaseOrderVo> queryListByPage(PurchaseSearchDto purchaseSearch) {
        purchaseSearch.setCustomerUserId(null);
        purchaseSearch.setPoint(false);
        Page<PurchaseOrderVo> page = PageHelper.startPage(purchaseSearch.getPage(), purchaseSearch.getRows());
        List<PurchaseOrderVo> voList = purchaseOrderService.selectByCondition(purchaseSearch);
        return new GridPage<>(purchaseSearch.getPage(), purchaseSearch.getRows(), page.getTotal(), voList);
    }

    @Override
    public PurchaseOrderDetailsVo getDetailsById(Long id) {
        return purchaseOrderService.getDetailsById(id);
    }

    @Override
    public GridPage<PurchaseOrderLogisticsPageVo> queryOrderLogisticsByPage(
            PurchaseOrderLogisticsSearchDto orderLogisticsSearch) {
        orderLogisticsSearch.setCustomerUserId(null);
        orderLogisticsSearch.setPoint(false);
        Page<PurchaseOrderVo> page = PageHelper.startPage(orderLogisticsSearch.getPage(),
                orderLogisticsSearch.getRows());
        return new GridPage<>(orderLogisticsSearch.getPage(), orderLogisticsSearch.getRows(), page.getTotal(),
                purchaseOrderLogisticsService.queryOrderLogisticsByPage(orderLogisticsSearch));
    }
}
