/**
   * 根据条件查询唯一的原始订单项
   *
   * @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);
  }
  /**
   * 猜测原始订单对应的品牌
   *
   * @param originalOrder
   */
  @Transactional
  public void guessOriginalOrderBrand(OriginalOrder originalOrder, boolean deleteBeforeGuess) {
    try {
      if (deleteBeforeGuess) {
        // 先删除原始猜测的记录
        deleteOriginalOrderBrands(originalOrder);
      }

      List<OriginalOrderItem> originalOrderItemList = originalOrder.getOriginalOrderItemList();
      if (originalOrderItemList == null || originalOrderItemList.isEmpty()) {
        return;
      }
      for (OriginalOrderItem originalOrderItem : originalOrderItemList) {
        String sku = originalOrderItem.getSku();
        if (StringUtils.isBlank(sku)) continue;
        Mealset mealset = mealSetService.findBySku(sku);
        if (mealset != null) {
          for (MealsetItem mealsetItem : mealset.getMealsetItemList()) {
            Product product = mealsetItem.getProduct();
            if (product == null || product.getBrandId() == null) {
              continue;
            }
            createOriginalOrderBrand(originalOrder, originalOrderItem, product.getBrandId());
          }
        } else {
          Product product = productService.findProductBySKU(sku);
          if (product == null || product.getBrandId() == null) {
            continue;
          }
          createOriginalOrderBrand(originalOrder, originalOrderItem, product.getBrandId());
        }
      }
    } catch (Exception e) {
      logger.error("猜测原始订单对应品牌的时候发生错误", e);
    }
  }