package com.bonus.core.order.common.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.core.common.utils.LogUtil;
import com.bonus.core.menu.api.MenuDishesApi;
import com.bonus.core.menu.constant.MenuSalesTypeEnum;
import com.bonus.core.menu.entity.MenuDishes;
import com.bonus.core.order.common.constants.DetailTypeEnum;
import com.bonus.core.order.common.mapper.OrderDetailMapper;
import com.bonus.core.order.common.model.OrderDetail;
import com.bonus.core.order.common.service.OrderDetailService;
import com.bonus.core.order.common.vo.OrderDetailWithImage;
import com.bonus.core.order.common.vo.OrderGoodsNumVO;
import com.bonus.core.order.utils.LeNumUtil;
import com.bonus.core.order.utils.LeOrderUtil;
import com.bonus.core.supermarket.api.SupermarketApi;
import com.bonus.core.supermarket.vo.SupermarketProductInfoImageVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements OrderDetailService {
   private static final Logger log = LoggerFactory.getLogger(OrderDetailServiceImpl.class);
   @Autowired
   @Lazy
   protected MenuDishesApi menuDishesApi;
   @Autowired
   @Lazy
   protected SupermarketApi supermarketApi;
//   @Autowired
//   @Lazy
//   protected DeviceApi deviceApi;
//
   @Transactional(
      rollbackFor = {Exception.class}
   )
   public void saveList(Collection<OrderDetail> entityList) {
      if (!CollUtil.isEmpty(entityList)) {
         Iterator var2 = entityList.iterator();

         while(var2.hasNext()) {
            OrderDetail entity = (OrderDetail)var2.next();
            boolean exists = this.baseMapper.exists(Wrappers
                    .lambdaQuery(OrderDetail.class).eq(OrderDetail::getDetailId, entity.getDetailId())
                    .eq(OrderDetail::getOrderDate, entity.getOrderDate()));
            if (exists) {
               ((OrderDetailMapper)this.baseMapper).update(entity, Wrappers.
                       lambdaUpdate(OrderDetail.class).eq(OrderDetail::getDetailId, entity.getDetailId())
                       .eq(OrderDetail::getOrderDate, entity.getOrderDate()));
            } else {
               ((OrderDetailMapper)this.baseMapper).insert(entity);
            }
         }

      }
   }
//
//   public List<OrderDetail> getOrderDetailListForPrint(Long orderId, LocalDate orderDate) {
//      return this.list(((LambdaQueryWrapper)((LambdaQueryWrapper)this.getDetailSelectWrapper().eq(OrderDetail::getOrderId, orderId)).in(OrderDetail::getDetailType, new Object[]{DetailTypeEnum.DISHES.getKey(), DetailTypeEnum.PACKAGE.getKey(), DetailTypeEnum.PRODUCT.getKey(), DetailTypeEnum.KEYAMOUNT.getKey()})).eq(orderDate != null, OrderDetail::getOrderDate, orderDate));
//   }

   @Override
   public List<OrderDetail> getOrderDetailList(Long orderId, LocalDate orderDate) {
      return (List<OrderDetail>)(!LeNumUtil.isValidId(orderId) ? CollUtil.newArrayList(new OrderDetail[0]) :
              this.getOrderDetailList((List)CollUtil.toList(new Long[]{orderId}),
                      (Collection)(orderDate != null ? CollUtil.newArrayList(new LocalDate[]{orderDate}) : null)));
   }

   public List<OrderDetail> getOrderDetailList(List<Long> orderIdList, Collection<LocalDate> orderDates) {
      return this.getOrderDetailList(orderIdList, orderDates, (List)null);
   }

   @Override
   public List<OrderDetail> getOrderDetailList(List<Long> orderIdList, Collection<LocalDate> orderDates, List<Integer> detailStateList) {
      if (CollUtil.isEmpty(orderIdList)) {
         return CollUtil.newArrayList(new OrderDetail[0]);
      } else {
         List<LocalDate> dateRange = LeOrderUtil.queryDateRange((Collection)orderIdList, (Collection)orderDates);
         return this.list((Wrapper)((LambdaQueryWrapper<OrderDetail>)Wrappers.lambdaQuery(OrderDetail.class).in(OrderDetail::getOrderId, orderIdList)).between(OrderDetail::getOrderDate, dateRange.get(0), dateRange.get(1)));
      }
   }
//
//   public List<OrderDetail> listByDetailIds(List<Long> detailIds, List<LocalDate> orderDates) {
//      if (CollUtil.isEmpty(detailIds)) {
//         return CollUtil.newArrayList(new OrderDetail[0]);
//      } else {
//         List<LocalDate> dateRange = LeOrderUtil.queryDateRange((Collection)detailIds, (Collection)orderDates);
//         return ((OrderDetailMapper)this.baseMapper).selectList((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(OrderDetail.class).in(OrderDetail::getDetailId, detailIds)).between(OrderDetail::getOrderDate, dateRange.get(0), dateRange.get(1)));
//      }
//   }

   public void orderDetailHandler(OrderDetail orderDetail, boolean ifMember) {
      LogUtil.infoFields("订单详情计算金额" + ifMember, orderDetail, OrderDetail.logFieldsGoods());
      if (ObjectUtil.isNull(orderDetail.getWeightUnit())) {
         orderDetail.setWeightUnit(100);
      }

      if (ObjectUtil.isNull(orderDetail.getSalesMode())) {
         orderDetail.setSalesMode(MenuSalesTypeEnum.PORTION_ON.key());
      }

      if (orderDetail.getTotalWeight() == null || orderDetail.getTotalWeight() == 0) {
         orderDetail.setTotalWeight(MenuSalesTypeEnum.WEIGHT_ON.key().equals(orderDetail.getSalesMode()) ? orderDetail.getQuantity() : orderDetail.getQuantity() * orderDetail.getWeightUnit());
      }

      BigDecimal price = ifMember ? orderDetail.getPrefPrice() : orderDetail.getSalePrice();
      orderDetail.setPrice(price);
      BigDecimal totalAmount = this.calcDetailAmount(orderDetail.getSalePrice(), orderDetail.getQuantity(), orderDetail.getWeightUnit(), orderDetail.getSalesMode());
      BigDecimal prefAmount = this.calcDetailAmount(orderDetail.getPrice(), orderDetail.getQuantity(), orderDetail.getWeightUnit(), orderDetail.getSalesMode());
      orderDetail.setTotalAmount(totalAmount);
      orderDetail.setCalcTotalAmount(prefAmount);
      LogUtil.printArgsOut("orderDetailHandler", orderDetail);
   }

   public BigDecimal calcDetailAmount(BigDecimal price, Integer quantity, Integer weightUnit, Integer salesMode) {
      BigDecimal totalAmount = price.multiply(new BigDecimal(quantity.toString()));
      if (MenuSalesTypeEnum.WEIGHT_ON.key().equals(salesMode)) {
         totalAmount = totalAmount.divide(new BigDecimal(weightUnit), 0, RoundingMode.DOWN);
      }

      return totalAmount;
   }
//
//   public void updateOrderDetailQuantity(Long detailId, LocalDate orderDate, Integer quantity, BigDecimal totalAmount, BigDecimal calcTotalAmount) {
//      ((OrderDetailMapper)this.baseMapper).update((Object)null, ((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)(new LambdaUpdateWrapper()).set(OrderDetail::getQuantity, quantity)).set(OrderDetail::getTotalAmount, totalAmount)).set(OrderDetail::getCalcTotalAmount, calcTotalAmount)).eq(OrderDetail::getDetailId, detailId)).eq(orderDate != null, OrderDetail::getOrderDate, orderDate));
//   }

   public void batchUpdateDetailRefundQuantity(List<OrderDetail> orderDetailList) {
      if (!CollUtil.isEmpty(orderDetailList)) {
         List<Long> detailIds = (List)orderDetailList.stream().map(OrderDetail::getDetailId).collect(Collectors.toList());
         List<LocalDate> dateRange = LeOrderUtil.queryDateRange((Collection)detailIds, (Collection)((Collection)orderDetailList.stream().map(OrderDetail::getOrderDate).collect(Collectors.toList())));
         ((OrderDetailMapper)this.baseMapper).batchUpdateDetailRefundQuantity(orderDetailList, detailIds, (LocalDate)dateRange.get(0), (LocalDate)dateRange.get(1));
      }
   }

   public List<OrderGoodsNumVO> getQuantityByCustId(Long custId, LocalDate orderDate, Integer mealtimeType, List<Long> goodsIdList) {
      return ((OrderDetailMapper)this.baseMapper).getOrderDetailHistoryList(LeNumUtil.idOrDefault(custId), orderDate, mealtimeType, (List)null);
   }
//
//   private LambdaQueryWrapper<OrderDetail> getDetailSelectWrapper() {
//      return Wrappers.lambdaQuery(OrderDetail.class).select(new SFunction[]{OrderDetail::getDetailId, OrderDetail::getOrderId, OrderDetail::getGoodsDishesId, OrderDetail::getGoodsDishesName, OrderDetail::getMenuDetailId, OrderDetail::getSalePrice, OrderDetail::getPrefPrice, OrderDetail::getPrice, OrderDetail::getWeightUnit, OrderDetail::getQuantity, OrderDetail::getSalesMode, OrderDetail::getDetailType, OrderDetail::getTotalAmount, OrderDetail::getRealAmount, OrderDetail::getDetailState, OrderDetail::getRefundAmount, OrderDetail::getGoodsRefundNum, OrderDetail::getInventoryId, OrderDetail::getCalcTotalAmount});
//   }
//
//   public Map<Long, List<OrderDetailVO>> getDetailVOGroupByOrderIdList(List<Long> orderIdList, List<LocalDate> orderDateList) {
//      return this.getDetailVOGroupByOrderIdList(orderIdList, orderDateList, true);
//   }
//
//   public Map<Long, List<OrderDetailVO>> getDetailVOGroupByOrderIdList(List<Long> orderIdList, List<LocalDate> orderDateList, boolean fillImage) {
//      return (Map)this.listDetailVOByOrderIds(orderIdList, orderDateList, fillImage).stream().collect(Collectors.groupingBy(OrderDetailVO::getOrderId));
//   }
//
//   public List<OrderDetailVO> listDetailVOByOrderIds(List<Long> orderIdList, List<LocalDate> orderDateList) {
//      return this.listDetailVOByOrderIds(orderIdList, orderDateList, true);
//   }
//
//   public List<OrderDetailVO> listDetailVOByOrderIds(List<Long> orderIdList, List<LocalDate> orderDateList, boolean fillImage) {
//      List<OrderDetailVO> voList = (List)this.getOrderDetailList((List)orderIdList, (Collection)orderDateList).stream().map(OrderDetailVO::of).collect(Collectors.toList());
//      if (fillImage) {
//         this.fillOrderDetailImage(voList);
//      }
//
//      return voList;
//   }

   public void removeByOrderIds(List<Long> orderIds, Collection<LocalDate> orderDates) {
      if (!CollUtil.isEmpty(orderIds)) {
         List<LocalDate> dateRange = LeOrderUtil.queryDateRange((Collection)orderIds, (Collection)orderDates);
         this.baseMapper.delete(Wrappers.lambdaQuery(OrderDetail.class)
                 .in(OrderDetail::getOrderId, orderIds).between(OrderDetail::getOrderDate, dateRange.get(0), dateRange.get(1)));
      }
   }
//
//   public void removeByDetailId(Long detailId, LocalDate orderDate) {
//      ((OrderDetailMapper)this.baseMapper).delete(((LambdaUpdateWrapper)Wrappers.lambdaUpdate(OrderDetail.class).eq(OrderDetail::getDetailId, detailId)).eq(orderDate != null, OrderDetail::getOrderDate, orderDate));
//   }

   @Override
   public <T extends OrderDetailWithImage> void fillOrderDetailImage(List<T> orderDetails) {
      if (!CollUtil.isEmpty(orderDetails)) {
         log.info("[订单详情]填充图片：{}", orderDetails.size());
         Map<Long, String> dishesImgMapById = MapUtil.empty();
         Map<Long, String> goodsImgMapById = MapUtil.empty();
         Set<Long> dishesIdList = (Set)orderDetails.stream().filter((s) -> {
            return DetailTypeEnum.isDishesCategory(s.getDetailType());
         }).map(OrderDetailWithImage::getGoodsDishesId).collect(Collectors.toSet());
         if (CollUtil.isNotEmpty(dishesIdList)) {
            dishesImgMapById = (Map)this.menuDishesApi.getMenuDishesList(CollUtil.newArrayList(dishesIdList)).stream().collect(Collectors.toMap(MenuDishes::getDishesId, (s) -> {
               return CharSequenceUtil.nullToEmpty(s.getImageUrl());
            }, (s, s2) -> {
               return s;
            }));
         }

         Set<Long> goodsIdList = (Set)orderDetails.stream().filter((s) -> {
            return DetailTypeEnum.isProductType(s.getDetailType());
         }).map(OrderDetailWithImage::getGoodsDishesId).collect(Collectors.toSet());
         if (CollUtil.isNotEmpty(goodsIdList)) {
            List<SupermarketProductInfoImageVO> productImgList = this.supermarketApi.getProductImg(CollUtil.newArrayList(goodsIdList));
            goodsImgMapById = (Map)productImgList.stream().collect(Collectors.toMap(SupermarketProductInfoImageVO::getMaterialId, (s) -> {
               return CharSequenceUtil.nullToEmpty(s.getImgUrl());
            }, (s, s2) -> {
               return s;
            }));
         }

         Iterator var8 = orderDetails.iterator();

         while(var8.hasNext()) {
            OrderDetailWithImage orderDetail = (OrderDetailWithImage)var8.next();
            if (DetailTypeEnum.isDishesCategory(orderDetail.getDetailType())) {
               orderDetail.setGoodsDishesImgUrl((String)dishesImgMapById.get(orderDetail.getGoodsDishesId()));
            } else if (DetailTypeEnum.isProductType(orderDetail.getDetailType())) {
               orderDetail.setGoodsDishesImgUrl((String)goodsImgMapById.get(orderDetail.getGoodsDishesId()));
            }
         }

      }
   }

//   public <T extends OrderDetailWithMachine> void fillOrderDetailMachine(List<T> orderDetails) {
//      if (!CollUtil.isEmpty(orderDetails)) {
//         Set<String> machineSnSet = (Set)orderDetails.stream().map(OrderDetailWithMachine::getMachineSn).filter(CharSequenceUtil::isNotBlank).collect(Collectors.toSet());
//         if (!CollUtil.isEmpty(machineSnSet)) {
//            Map<String, DeviceInfo> deviceMapBySn = (Map)this.deviceApi.listInfoBySns(CollUtil.newArrayList(machineSnSet)).stream().collect(Collectors.toMap(DeviceInfo::getDeviceSn, Function.identity()));
//            Iterator var4 = orderDetails.iterator();
//
//            while(var4.hasNext()) {
//               OrderDetailWithMachine orderDetail = (OrderDetailWithMachine)var4.next();
//               DeviceInfo deviceInfo = (DeviceInfo)deviceMapBySn.get(orderDetail.getMachineSn());
//               if (deviceInfo != null) {
//                  orderDetail.setMachineName(deviceInfo.getDeviceName());
//                  orderDetail.setMachineNum(deviceInfo.getDeviceNum());
//               }
//            }
//
//         }
//      }
//   }
//
//   // $FF: synthetic method
//   private static Object $deserializeLambda$(SerializedLambda lambda) {
//      switch (lambda.getImplMethodName()) {
//         case "getQuantity":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return OrderDetail::getQuantity;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return OrderDetail::getQuantity;
//            }
//            break;
//         case "getMenuDetailId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getMenuDetailId;
//            }
//            break;
//         case "getRefundAmount":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getRefundAmount;
//            }
//            break;
//         case "getInventoryId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return OrderDetail::getInventoryId;
//            }
//            break;
//         case "getTotalAmount":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getTotalAmount;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getTotalAmount;
//            }
//            break;
//         case "getCalcTotalAmount":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getCalcTotalAmount;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getCalcTotalAmount;
//            }
//            break;
//         case "getSalesMode":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return OrderDetail::getSalesMode;
//            }
//            break;
//         case "getOrderDate":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDate;")) {
//               return OrderDetail::getOrderDate;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDate;")) {
//               return OrderDetail::getOrderDate;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDate;")) {
//               return OrderDetail::getOrderDate;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDate;")) {
//               return OrderDetail::getOrderDate;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDate;")) {
//               return OrderDetail::getOrderDate;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDate;")) {
//               return OrderDetail::getOrderDate;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDate;")) {
//               return OrderDetail::getOrderDate;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDate;")) {
//               return OrderDetail::getOrderDate;
//            }
//            break;
//         case "getOrderId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getOrderId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getOrderId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getOrderId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getOrderId;
//            }
//            break;
//         case "getGoodsDishesName":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return OrderDetail::getGoodsDishesName;
//            }
//            break;
//         case "getRealAmount":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getRealAmount;
//            }
//            break;
//         case "getPrice":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getPrice;
//            }
//            break;
//         case "getDetailState":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return OrderDetail::getDetailState;
//            }
//            break;
//         case "getGoodsRefundNum":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return OrderDetail::getGoodsRefundNum;
//            }
//            break;
//         case "getPrefPrice":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getPrefPrice;
//            }
//            break;
//         case "getWeightUnit":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return OrderDetail::getWeightUnit;
//            }
//            break;
//         case "getSalePrice":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/math/BigDecimal;")) {
//               return OrderDetail::getSalePrice;
//            }
//            break;
//         case "getGoodsDishesId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getGoodsDishesId;
//            }
//            break;
//         case "getDetailId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getDetailId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getDetailId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getDetailId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getDetailId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getDetailId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return OrderDetail::getDetailId;
//            }
//            break;
//         case "getDetailType":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return OrderDetail::getDetailType;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/order/common/model/OrderDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return OrderDetail::getDetailType;
//            }
//      }
//
//      throw new IllegalArgumentException("Invalid lambda deserialization");
//   }
}
