package com.bonus.core.order.api;

import com.bonus.core.order.common.model.OrderInfo;
import com.bonus.core.order.common.service.OrderDetailService;
import com.bonus.core.order.common.service.OrderInfoService;
import com.bonus.core.order.common.vo.OrderGoodsNumVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class OrderMenuApi {
   @Autowired
   @Lazy
   private OrderInfoService orderInfoService;
   @Lazy
   @Autowired
   private OrderDetailService orderDetailService;

   public Long getShopstallIdByOrdId(Long orderId) {
      OrderInfo orderInfo = this.orderInfoService.checkAndGetOrderInfo(orderId);
      return orderInfo.getStallId();
   }

   public void editOrdStateByOrdId(Long orderId) {
      this.orderInfoService.updateOrderCommented(orderId);
   }

   public List<OrderGoodsNumVO> getQuantityByCustId(Long custId, Integer mealtimeType, LocalDate orderDate) {
      return this.orderDetailService.getQuantityByCustId(custId, orderDate, mealtimeType, (List)null);
   }

   public LocalDateTime getOrdTimeByOrdId(Long orderId) {
      OrderInfo orderInfo = this.orderInfoService.checkAndGetOrderInfo(orderId);
      return orderInfo.getOrderTime();
   }
}
