package com.bonus.canteen.core.customer.openapi;

import cn.hutool.core.bean.BeanUtil;
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.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.bonus.canteen.core.customer.constants.CustConstant;
import com.bonus.canteen.core.customer.dto.CustInfoModel;
import com.bonus.canteen.core.customer.mapper.CustInfoMapper;
import com.bonus.canteen.core.customer.model.CustInfo;
import com.bonus.canteen.core.customer.service.CustInfoService;
import com.bonus.canteen.core.customer.v4.mobile.service.CustPhotoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.invoke.SerializedLambda;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class CustInfoOpenApi {


   public static void infoModelSetOriginalValue(CustInfo custInfo, CustInfoModel infoModel) {
      if (infoModel.getPsnType() == null || infoModel.getPsnType() == -1) {
         infoModel.setPsnType(custInfo.getPsnType());
         infoModel.setPsnTypeName(custInfo.getPsnTypeName());
      }

      if (infoModel.getBirthday() == null) {
         infoModel.setBirthday(custInfo.getBirthday());
      }

      if (infoModel.getPlaceId() == null || infoModel.getPlaceId() == CustConstant.DATA_DEFAULT_LONG) {
         infoModel.setPlaceId(custInfo.getPlaceId());
      }

      if (infoModel.getPlaceFullName() == null || "".equals(infoModel.getPlaceFullName())) {
         infoModel.setPlaceFullName(custInfo.getPlaceFullName());
      }

      if (ObjectUtil.isNull(infoModel.getOrgId())) {
         infoModel.setOrgId(custInfo.getOrgId());
      }

      if (ObjectUtil.isNull(infoModel.getEthnicityCode())) {
         infoModel.setEthnicityCode(custInfo.getEthnicityCode());
      }

      if (ObjectUtil.isNull(infoModel.getCostCenterId())) {
         infoModel.setCostCenterId(custInfo.getCostCenterId());
      }

      if (ObjectUtil.isNull(infoModel.getEntryDate())) {
         infoModel.setEntryDate(custInfo.getEntryDate());
      }

      if (ObjectUtil.isNull(infoModel.getSigningDate())) {
         infoModel.setSigningDate(custInfo.getSigningDate());
      }

      if (ObjectUtil.isNull(infoModel.getExpiryDate())) {
         infoModel.setExpiryDate(custInfo.getExpiryDate());
      }

   }

   // $FF: synthetic method
//   private static Object $deserializeLambda$(SerializedLambda lambda) {
//      switch (lambda.getImplMethodName()) {
//         case "getOrgLevel":
//            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/customer/model/CustOrg") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return CustOrg::getOrgLevel;
//            }
//            break;
//         case "getCustThirdId":
//            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/customer/model/CustInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return CustInfo::getCustThirdId;
//            }
//
//            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/customer/model/CustInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return CustInfo::getCustThirdId;
//            }
//
//            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/customer/model/CustInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return CustInfo::getCustThirdId;
//            }
//            break;
//         case "getCustId":
//            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/customer/model/CustInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return CustInfo::getCustId;
//            }
//            break;
//         case "getCustNum":
//            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/customer/model/CustInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return CustInfo::getCustNum;
//            }
//            break;
//         case "getCustState":
//            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/customer/model/CustInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return CustInfo::getCustState;
//            }
//
//            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/customer/model/CustInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return CustInfo::getCustState;
//            }
//
//            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/customer/model/CustInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return CustInfo::getCustState;
//            }
//            break;
//         case "getIfDel":
//            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/customer/model/CustOrg") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return CustOrg::getIfDel;
//            }
//
//            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/customer/model/CustOrg") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return CustOrg::getIfDel;
//            }
//
//            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/customer/model/CustOrg") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return CustOrg::getIfDel;
//            }
//            break;
//         case "getOrgNum":
//            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/customer/model/CustOrg") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return CustOrg::getOrgNum;
//            }
//
//            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/customer/model/CustOrg") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return CustOrg::getOrgNum;
//            }
//      }
//
//      throw new IllegalArgumentException("Invalid lambda deserialization");
//   }
}
