package com.bonus.core.order.client;

import com.bonus.core.allocation.api.AllocMetadataApi;
import com.bonus.core.allocation.canteen.dto.AllocCanteenDeliveryModel;
import com.bonus.core.allocation.canteen.dto.AllocCanteenOrderDTO;
import com.bonus.core.customer.api.CustInfoApi;
import com.bonus.core.customer.dto.CustPayDTO;
import com.bonus.core.customer.vo.CustPayVO;
import com.bonus.core.menu.model.AllocMealtimeModel;
import com.bonus.core.order.client.po.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderModuleClient {
   @Autowired
   @Lazy
   protected CustInfoApi custInfoApi;
   @Autowired
   @Lazy
   private AllocMetadataApi allocMetadataApi;
//   @Autowired
//   @Lazy
//   protected CustPlaceApi custPlaceApi;

   public String metadataGetValue(MetaDataValueParam param) {
      return this.allocMetadataApi.getMetadataValue(param.getModelTypeEnum(), param.getModelKey());
   }
//
//   public AllocPayModel metadataQueryPayConfig(OrderConfigQueryParam param) {
//      return this.allocMetadataApi.payApi().queryAvailablePayModel(param.getCanteenId());
//   }

   public AllocCanteenOrderDTO metadataQueryOrderConfig(OrderConfigQueryParam param) {
      return this.allocMetadataApi.orderApi().queryAvailableOrder(param.getCanteenId(), param.getStallId());
   }

   public AllocCanteenDeliveryModel metadataQueryDeliveryConfig(OrderConfigQueryParam param) {
      return this.allocMetadataApi.deliveryApi().queryDeliveryModel(param.getCanteenId(), param.getStallId());
   }

   public AllocMealtimeModel mealtimeCheckNow(MealtimeCheckNowParam param) {
      return this.allocMetadataApi.mealtimeApi().getAndCheckNowMealtime(param.getCanteenId(), param.getStallId());
   }

   public List<AllocMealtimeModel> mealtimelist(MealtimeQueryParam param) {
      return this.allocMetadataApi.mealtimeApi().listUseAvailableMealtime(param.getCanteenId(), param.getStallId(), (Integer)null);
   }

   public AllocMealtimeModel mealtimeQuery(MealtimeQueryParam param) {
      return param.getAssignTime() != null ? this.allocMetadataApi.mealtimeApi().getUseAssignTimeMealtime(param.getAssignTime()
              , param.getCanteenId(), param.getStallId())
              : this.allocMetadataApi.mealtimeApi().getAvailableMealtimeByType(param.getMealtimeType()
              , param.getCanteenId(), param.getStallId());
   }

   public CustPayVO custPayInfoQuery(CustPayInfoQueryParam param) {
      return this.custInfoApi.getCustPayVO((new CustPayDTO()).setCustId(param.getCustId()).setSerialNum(param.getSerialNum()).setOpenid(param.getOpenid()));
   }

//   public List<CustInfo> custList(CustListQueryParam param) {
//      return this.custInfoApi.selectCustListByCustIds(param.getCustIds());
//   }
//
//   public List<Long> custPlaceIdListByUserIds(CustPlaceListQueryParam param) {
//      return this.custPlaceApi.listPlaceIdByUserIds(param.getUserIds());
//   }
//
//   public List<Long> custPlaceIdListBySuperId(CustPlaceListQueryParam param) {
//      return this.custPlaceApi.queryCustPlaceBySuperId(param.getSuperId());
//   }
//
//   public String custPlaceGetUserName(CustPlaceQueryParam param) {
//      return this.custPlaceApi.getPlaceUserNameByPlaceId(param.getPlaceId());
//   }
//
//   public List<CustPlaceListDutyAreaVO> custPlaceListByIds(CustPlaceListQueryParam param) {
//      return this.custPlaceApi.listPlaceFullNameByIds(param.getPlaceIds());
//   }
}
