package com.bonus.canteen.core.order.common.business;

import com.bonus.canteen.core.marketing.coupon.model.MktCouponPayModel;
import com.bonus.canteen.core.menu.model.AllocMealtimeModel;
import com.bonus.canteen.core.order.common.dto.OrderDidPayInfoDTO;
import com.bonus.canteen.core.order.common.model.*;
import com.bonus.canteen.core.order.common.vo.OrderDeliveryResultVO;
import com.bonus.canteen.core.order.mq.po.OrderSavePO;
import com.bonus.canteen.core.pay.api.dto.UnifyPayDTO;
import com.bonus.canteen.core.pay.api.vo.UnifyPayVO;
import com.bonus.canteen.core.pay.common.vo.TradeChannelVO;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

public interface OrderPlaceBusiness {
   void checkOrderSubmitted(String repeatedId);

//   void checkMacOrderId(String macOrderId, boolean checkTradeRecord);
//
   void checkWaitPlaceOrder(List<OrderInfo> orderInfoList);
//
   void orderHandlerLock(String lockId, int lockSecond);

   void orderHandlerUnLock(String lockId);
//
//   void saveCache(OrderSavePO orderSavePO, boolean saveToDiskAsync);
//
//   void cleanCache(String macOrderId);

   AllocMealtimeModel checkMealtime(Integer mealtimeType, Long canteenId, Long stallId);
//
//   @Nonnull
//   AllocMealtimeModel checkMealtime(@Nullable Integer mealtimeType, @Nullable LocalDateTime orderTime, @Nullable Long canteenId, @Nullable Long stallId);

   void checkOrderPermission(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList);

   OrderDeliveryResultVO fillOrderDeliveryAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList
           , List<OrderDelivery> orderDeliveryList);

   void fillOrderDetailPrice(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList);

   List<OrderAmountChange> calcNeedPayAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList);
//
//   OrderAmountChange addAmountChange(OrderInfo orderInfo, BigDecimal changeAmount, ChangeDetailTypeEnum type, String remark);
//
//   List<OrderAmountChange> customNeedPayAmount(List<OrderInfo> orderInfoList, BigDecimal customAmount);

   List<OrderAmountChange> calcRuleAmount(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, boolean isTrail);

   MktCouponPayModel checkCoupon(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList);

   void inventoryDeduct(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList);

   void inventoryRestore(OrderInfo orderInfo, List<OrderDetail> orderDetailList);

   void save(OrderSavePO orderSavePO, boolean removeDetails, boolean removeAmountChanges);

   UnifyPayVO pay(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList);
//
//   List<OrderDetail> removeDetailDishes(List<OrderDetail> orderDetailList, List<OrderDetailRefundDTO> removeList);
//
   List<OrderAmountDetail> calcOrderRealAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderAmountChange> orderAmountChangeList, BigDecimal payAmount, List<TradeChannelVO> channelDetailList);

   void updateOrderFieldAfterPay(OrderInfo orderInfo, OrderDidPayInfoDTO didPayInfoDTO);
//
//   boolean ifUseCall(OrderInfo orderInfo);
}
