Exemplo n.º 1
0
  public int getItemCountInUncloseOrders(long userId, int itemId) {
    List<OrderItemsModel> orderItems = orderItemsDAO.getListByUserIdAndItemId(userId, itemId);
    if (org.apache.commons.collections.CollectionUtils.isEmpty(orderItems)) {
      return 0;
    }

    Set<Long> orderIds = new HashSet<>();
    for (OrderItemsModel orderItem : orderItems) {
      orderIds.add(orderItem.getOrderid());
    }

    if (org.apache.commons.collections.CollectionUtils.isEmpty(orderIds)) {
      return 0;
    }

    List<OrdersModel> orders = ordersDAO.getsByIds(orderIds);
    Map<Long, OrdersModel> ordersMap = new HashMap<>();
    for (OrdersModel order : orders) {
      ordersMap.put(order.getId(), order);
    }

    int itemCount = 0;
    for (OrderItemsModel orderItem : orderItems) {
      OrdersModel ordersModel = ordersMap.get(orderItem.getOrderid());
      if (ordersModel == null) {
        continue;
      }
      if (ordersModel.getStatus() != OrdersModel.STATUS_CLOSED) {
        itemCount += orderItem.getQuantity();
      }
    }
    return itemCount;
  }
Exemplo n.º 2
0
  private UserAccessInfo genUserAccessInfo(OrdersModel order) {
    UserAccessInfo accessInfo = new UserAccessInfo();
    accessInfo.setTm(DateUtils.formatDateTime(new Date()));
    Baby baby = babyService.getBabyByUidxUid(order.getUserid());
    accessInfo.setPreganancy(baby.getStatus());
    accessInfo.setBabyGender(baby.getGender());
    if (baby.getBirthday() != null) {
      accessInfo.setBabyBirthday(DateUtils.formatDate(baby.getBirthday()));
    }
    if (baby.getEdc() != null) {
      accessInfo.setEdc(DateUtils.formatDate(baby.getEdc()));
    }
    accessInfo.setUid(order.getUserid());
    accessInfo.setEvent("payreturn");
    accessInfo.setStatus(UserAccessInfo.STATUS_SUCCESS);

    List<OrderItemsModel> orderItems = orderItemsDAO.getListByOrderId(order.getId());
    accessInfo.setCartSelected(orderItems.size());
    int skuQuantity = 0;
    Set<Long> itemids = new HashSet<>();
    for (OrderItemsModel orderItem : orderItems) {
      itemids.add(orderItem.getItemid());
      skuQuantity += orderItem.getQuantity();
    }
    accessInfo.setItemQuantity(itemids.size());
    accessInfo.setSkuQuantity(skuQuantity);
    accessInfo.setOrderid(order.getId());
    accessInfo.setTotolFee(DecimalUtil.toStandard(order.getTotalfee()).doubleValue());
    accessInfo.setDeliveryFee(DecimalUtil.toStandard(order.getDeliveryfee()).doubleValue());
    return accessInfo;
  }