package com.bonus.canteen.core.order.custom;

import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.common.custom.business.CustomBusiness;
import com.bonus.canteen.core.drp.dto.AndroidSupermarketOutDTO;
import com.bonus.canteen.core.drp.dto.SupermarketInventoryRepairDTO;
import com.bonus.canteen.core.marketing.coupon.model.MktCouponPayModel;
import com.bonus.canteen.core.marketing.v2.rule.price.dto.RulePriceDTO;
import com.bonus.canteen.core.menu.dto.MenuRecipeChangeSurplusNum;
import com.bonus.canteen.core.order.common.constants.ChangeDetailTypeEnum;
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 com.bonus.canteen.core.supermarket.dto.SmtCheckProductLimitBuyDTO;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Set;

@Service
public class OrderCustomPlaceBusiness implements CustomBusiness {
   public String name() {
      return "订单（下单）";
   }

   public List<CustomBusiness.Version> versions() {
      return CollUtil.newArrayList(new CustomBusiness.Version[]{CustomBusiness.Version.of("3.7.1", "初版"), CustomBusiness.Version.of("3.11.3+", "支付前支持跳过支付"), CustomBusiness.Version.of("3.15.0", "餐券与混合支付改造")});
   }

   public boolean willCheckWaitPalaceOrder(List<OrderInfo> orderInfoList) {
      return true;
   }

   public boolean willCheckOrderPermission(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList) {
      return true;
   }

   public boolean willCallApiCheckOrderPermission(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, RulePriceDTO rulePriceDTO) {
      return true;
   }

   public boolean willFillOrderDetailPrice(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList) {
      return true;
   }

   public void didFillOrderDetailPrice(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList) {
   }

   public boolean willFillOrderDeliveryAmountV2(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderDelivery> orderDeliveryList, OrderDeliveryResultVO resultVO) {
      return true;
   }

   public OrderDeliveryResultVO didFillOrderDeliveryAmountV2(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderDelivery> orderDeliveryList, OrderDeliveryResultVO resultVO) {
      return resultVO;
   }

   public boolean willCalcNeedPayAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderAmountChange> orderAmountChangeList) {
      return true;
   }

   public void didCalcNeedPayAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderAmountChange> orderAmountChangeList) {
   }
//
//   public boolean willCustomNeedPayAmount(List<OrderInfo> orderInfoList, BigDecimal customAmount, List<OrderAmountChange> orderAmountChangeList) {
//      return true;
//   }
//
//   public void didCustomNeedPayAmount(List<OrderInfo> orderInfoList, BigDecimal customAmount, List<OrderAmountChange> orderAmountChangeList) {
//   }

   public OrderAmountChange willAddAmountChange(OrderInfo orderInfo, BigDecimal changeAmount, ChangeDetailTypeEnum type) {
      return null;
   }

   public OrderAmountChange didAddAmountChange(OrderInfo orderInfo, BigDecimal changeAmount, ChangeDetailTypeEnum type, OrderAmountChange orderAmountChange) {
      return orderAmountChange;
   }

   public boolean willCheckCouponV3(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList) {
      return true;
   }

   public MktCouponPayModel didCheckCouponV3(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList, MktCouponPayModel couponPayModel) {
      return couponPayModel;
   }

   public boolean willCalcRuleAmount(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderAmountChange> orderAmountChangeList, boolean isTrail) {
      return true;
   }

   public RulePriceDTO didPackageRulePriceDTO(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderAmountChange> orderAmountChangeList, boolean isTrail, RulePriceDTO RulePriceDTO) {
      return RulePriceDTO;
   }

   public void didCalcRuleAmount(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, List<OrderAmountChange> orderAmountChangeList, boolean isTrail) {
   }

   public boolean willInventoryDeduct(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList) {
      return true;
   }

   public boolean willShopInventoryLimit(OrderInfo orderInfo, List<OrderDetail> orderDetailList, SmtCheckProductLimitBuyDTO checkDTO) {
      return true;
   }

   public boolean willShopInventoryDeduct(OrderInfo orderInfo, List<OrderDetail> orderDetailList, AndroidSupermarketOutDTO outDTO) {
      return true;
   }

   public boolean willDishesInventoryDeduct(OrderInfo orderInfo, List<OrderDetail> orderDetailList, List<MenuRecipeChangeSurplusNum> changeSurplusNumList, Set<Long> goodIds) {
      return true;
   }

   public boolean willInventoryRepair(OrderInfo orderInfo, List<OrderDetail> orderDetailList) {
      return true;
   }

   public boolean willShopInventoryRepair(OrderInfo orderInfo, List<OrderDetail> orderDetailList, SupermarketInventoryRepairDTO repairDTO) {
      return true;
   }

   public boolean willDishesInventoryRepair(OrderInfo orderInfo, List<OrderDetail> orderDetailList, List<MenuRecipeChangeSurplusNum> changeSurplusNumList) {
      return true;
   }

   public boolean willCalcOrderRealAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, BigDecimal payAmount, List<TradeChannelVO> channelDetailList, List<OrderAmountDetail> orderAmountDetailList) {
      return true;
   }

   public UnifyPayVO willOrderPayV2(UnifyPayDTO unifyPayDTO, List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList) {
      return null;
   }

   public void didCalcOrderRealAmount(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, BigDecimal payAmount, List<TradeChannelVO> channelDetailList, List<OrderAmountDetail> orderAmountDetailList) {
   }

   public void didUpdateOrderFieldAfterPay(OrderInfo orderInfo, OrderDidPayInfoDTO didPayInfoDTO) {
   }

   public boolean willHandleOrderDidFailed(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList,
                                           Integer payState, boolean orderExists) {
      return true;
   }

   public void didHandleOrderDidFailed(List<OrderInfo> orderInfoList, List<OrderDetail> orderDetailList, Integer payState,
                                       boolean orderExists) {
   }

   public boolean willSaveOrder(OrderSavePO orderSavePO, boolean removeDetails, boolean removeAmountChanges) {
      return true;
   }

   public void didSaveOrder(OrderSavePO orderSavePO, boolean removeDetails, boolean removeAmountChanges) {
   }
}
