/**
  * 查询店铺
  *
  * @param shop
  * @return
  */
 @Transactional(readOnly = true)
 public List<Shop> getShop(Shop shop) {
   if (logger.isInfoEnabled()) {
     logger.info("getShop方法参数为shop[{}]", shop);
   }
   Search search = new Search(Shop.class).setCacheable(true);
   if (shop != null) {
     if (!NumberUtil.isNullOrZero(shop.getId())) {
       search.addFilterEqual("id", shop.getId());
     }
     if (StringUtils.isNotBlank(shop.getNick())) {
       search.addFilterLike("nick", "%" + shop.getNick().trim() + "%");
     }
     if (StringUtils.isNotBlank(shop.getUid())) {
       search.addFilterLike("uid", "%" + shop.getUid().trim() + "%");
     }
     if (StringUtils.isNotBlank(shop.getTitle())) {
       search.addFilterLike("title", "%" + shop.getTitle().trim() + "%");
     }
     if (shop.getPlatformType() != null) {
       search.addFilterEqual("platformType", shop.getPlatformType());
     }
     if (!NumberUtil.isNullOrZero(shop.getOutShopId())) {
       search.addFilterEqual("outShopId", shop.getOutShopId());
     }
   }
   search.addFilterEqual("isDelete", false);
   return generalDAO.search(search);
 }
 /**
  * 查询店铺
  *
  * @param shop
  * @return
  */
 @Transactional(readOnly = true)
 public List<Shop> getOnlineShopAndAuth(Shop shop) {
   if (logger.isInfoEnabled()) {
     logger.info("getShop方法参数为shop[{}]", shop);
   }
   Search search = new Search(Shop.class).addFetch("shopAuth").setCacheable(true);
   if (shop != null) {
     // 根据id精确查询
     if (!NumberUtil.isNullOrZero(shop.getId())) {
       search.addFilterEqual("id", shop.getId());
     }
     // 根据nick模糊查询
     if (StringUtils.isNotBlank(shop.getNick())) {
       search.addFilterLike("nick", "%" + shop.getNick().trim() + "%");
     }
     // 根据店铺名称模糊查询
     if (StringUtils.isNotBlank(shop.getTitle())) {
       search.addFilterLike("title", "%" + shop.getTitle().trim() + "%");
     }
     // 根据外部平台店铺id精确查询
     if (!NumberUtil.isNullOrZero(shop.getOutShopId())) {
       search.addFilterEqual("outShopId", shop.getOutShopId());
     }
     // 根据平台模糊查询
     if (shop.getPlatformType() != null) {
       search.addFilterEqual("platformType", shop.getPlatformType());
     }
   }
   search.addFilterNotEmpty("shopAuthId");
   search.addFilterEqual("isDelete", false);
   return generalDAO.search(search);
 }
 /**
  * 根据条件检索原始订单项
  *
  * @param originalOrderItem
  * @return
  */
 public List<OriginalOrderItem> findOriginalOrderItem(OriginalOrderItem originalOrderItem) {
   Search search = new Search(OriginalOrderItem.class);
   if (originalOrderItem != null) {
     if (NumberUtil.isNotNullOrNotZero(originalOrderItem.getOriginalOrderId())) {
       search.addFilterEqual("originalOrderId", originalOrderItem.getOriginalOrderId());
     }
   }
   return generalDAO.search(search);
 }
 /**
  * 查询
  *
  * @param originalOrder
  * @return
  */
 @Transactional(readOnly = true)
 public List<OriginalOrder> getOriginalOrder(
     OriginalOrder originalOrder, Date startTime, Date endTime) {
   if (logger.isInfoEnabled()) {
     logger.info(
         String.format(
             "getOriginalOrder方法参数为originalOrder[{}],startTime[{}],endTime[{}]",
             originalOrder,
             startTime,
             endTime));
   }
   Search search = new Search(OriginalOrder.class);
   if (originalOrder != null) {
     if (StringUtils.isNotBlank(originalOrder.getPlatformOrderNo())) {
       search.addFilterLike(
           "platformOrderNo", "%" + originalOrder.getPlatformOrderNo().trim() + "%");
     }
     if (!NumberUtil.isNullOrZero(originalOrder.getShopId())) {
       search.addFilterEqual("shopId", originalOrder.getShopId());
     }
     if (!NumberUtil.isNullOrZero(originalOrder.getProcessed())) {
       search.addFilterEqual("processed", originalOrder.getProcessed());
     }
     if (!NumberUtil.isNullOrZero(originalOrder.getOutShopId())) {
       search.addFilterEqual("outShopId", originalOrder.getOutShopId());
     }
     if (!NumberUtil.isNullOrZero(originalOrder.getStatus())) {
       search.addFilterEqual("status", originalOrder.getStatus());
     }
     if (originalOrder.getPlatformType() != null) {
       search.addFilterEqual("platformType", originalOrder.getPlatformType());
     }
     if (startTime != null) {
       search.addFilterGreaterOrEqual("buyTime", startTime);
     }
     if (endTime != null) {
       search.addFilterLessOrEqual("buyTime", endTime);
     }
   }
   return generalDAO.search(search);
 }
 /**
  * 查询店铺授权
  *
  * @param shopAuth
  * @return
  */
 @Transactional(readOnly = true)
 public List<ShopAuth> getShopAuth(ShopAuth shopAuth) {
   if (logger.isInfoEnabled()) {
     logger.info("getShop方法参数为shop[{}]", shopAuth);
   }
   Search search = new Search(ShopAuth.class);
   if (shopAuth != null) {
     if (!NumberUtil.isNullOrZero(shopAuth.getId())) {
       search.addFilterEqual("id", shopAuth.getId());
     }
   }
   search.addFilterEqual("isDelete", false);
   return generalDAO.search(search);
 }
  /**
   * 根据条件查询唯一的授权信息
   *
   * @param shopAuth
   * @return
   */
  public ShopAuth getShopAuthByCondition(ShopAuth shopAuth) {
    if (logger.isInfoEnabled()) {
      logger.info("getShop方法参数为shop[{}]", shopAuth);
    }
    Search search = new Search(ShopAuth.class);
    if (shopAuth != null) {
      if (!NumberUtil.isNullOrZero(shopAuth.getId())) {
        search.addFilterEqual("id", shopAuth.getId());
      }
    }
    search.addFilterEqual("isDelete", false);

    List<ShopAuth> shopAuthList = generalDAO.search(search);
    return CollectionUtils.isNotEmpty(shopAuthList) ? shopAuthList.get(0) : null;
  }
  /**
   * 获取店铺及其授权信息
   *
   * @param id
   * @return
   */
  public ShopVo getShopVo(Integer id) {
    if (logger.isInfoEnabled()) {
      logger.info("getShopVo方法参数为id={}", id);
    }
    Search search = new Search(Shop.class).addFetch("shopAuth").setCacheable(true);
    if (!NumberUtil.isNullOrZero(id)) {
      search.addFilterEqual("id", id);
    }
    search.addFilterEqual("isDelete", false);

    List<Shop> shopList = generalDAO.search(search);
    Shop shop = CollectionUtils.isNotEmpty(shopList) ? shopList.get(0) : null;
    ShopVo shopVo = convertShopAndAuth2ShopVo(shop);
    return shopVo;
  }
 /**
  * 根据条件查询优惠详情
  *
  * @param promotionInfo
  * @return
  */
 @Transactional(readOnly = true)
 public List<PromotionInfo> findPromotionInfos(PromotionInfo promotionInfo) {
   Search search = new Search(PromotionInfo.class);
   if (promotionInfo != null) {
     if (StringUtils.isNotBlank(promotionInfo.getPlatformOrderNo())) {
       search.addFilterEqual("platformOrderNo", promotionInfo.getPlatformOrderNo());
     }
     if (StringUtils.isNotBlank(promotionInfo.getSkuId())) {
       search.addFilterEqual("skuId", promotionInfo.getSkuId());
     }
     if (NumberUtil.isNotNullOrNotZero(promotionInfo.getOriginalOrderId())) {
       search.addFilterEqual("originalOrderId", promotionInfo.getOriginalOrderId());
     }
   }
   List<PromotionInfo> promotionInfoList = generalDAO.search(search);
   return promotionInfoList;
 }
 /**
  * 根据条件查询唯一的返回值
  *
  * @param shop
  * @return
  */
 public Shop getShopByConditionIncludeDelete(Shop shop) {
   if (logger.isInfoEnabled()) {
     logger.info("getShop方法参数为shop[{}]", shop);
   }
   Search search = new Search(Shop.class).setCacheable(true);
   if (shop != null) {
     if (!NumberUtil.isNullOrZero(shop.getUid())) {
       search.addFilterEqual("uid", shop.getUid());
     }
     if (shop.getPlatformType() != null) {
       search.addFilterEqual("platformType", shop.getPlatformType());
     }
   }
   // search.addFilterEqual("isDelete", false);
   List<Shop> shopList = generalDAO.search(search);
   return CollectionUtils.isNotEmpty(shopList) ? shopList.get(0) : null;
 }
  /**
   * 根据条件查询唯一的原始订单项
   *
   * @param originalOrderItem
   * @return
   */
  @Transactional(readOnly = true)
  public OriginalOrderItem getOriginalOrderItemByCondition(OriginalOrderItem originalOrderItem) {
    if (logger.isInfoEnabled()) {
      logger.info("getOriginalOrderItemByCondition方法参数为OriginalOrderItem[{}]", originalOrderItem);
    }
    Search search = new Search(OriginalOrderItem.class);
    if (originalOrderItem != null) {
      if (StringUtils.isNotBlank(originalOrderItem.getSku())) {
        search.addFilterEqual("sku", originalOrderItem.getSku());
      }
      if (StringUtils.isNotBlank(originalOrderItem.getPlatformSubOrderNo())) {
        search.addFilterEqual("platformSubOrderNo", originalOrderItem.getPlatformSubOrderNo());
      }
      if (!NumberUtil.isNullOrZero(originalOrderItem.getOriginalOrderId())) {
        search.addFilterEqual("originalOrderId", originalOrderItem.getOriginalOrderId());
      }
    }
    List<OriginalOrderItem> originalOrderItemList = generalDAO.search(search);

    return CollectionUtils.isEmpty(originalOrderItemList) ? null : originalOrderItemList.get(0);
  }