Пример #1
0
  private void setOrderCountInfo(OrderCountInfo orderCountInfo, Order order) {

    orderCountInfo.setOrderCount(orderCountInfo.getOrderCount() + 1);
    orderCountInfo.setCoinAmount(Arith.add(order.getCoinAmount(), orderCountInfo.getCoinAmount()));
    orderCountInfo.setCouponsAmount(
        Arith.add(order.getCouponsAmount(), orderCountInfo.getCouponsAmount()));
    orderCountInfo.setGoodsAmount(
        Arith.add(order.getGoodsAmount(), orderCountInfo.getGoodsAmount()));
    orderCountInfo.setGoodsTransportAmount(
        Arith.add(order.getGoodsTransportAmount(), orderCountInfo.getGoodsTransportAmount()));
    orderCountInfo.setRealAmount(Arith.add(order.getRealAmount(), orderCountInfo.getRealAmount()));
  }
Пример #2
0
  public Map<String, Object> getGridData(HttpServletRequest request, SysUnits sysUnits) {

    Map<String, Object> gridData = new HashMap<String, Object>();

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("unitId", sysUnits.getId());
    map.put("unitType", sysUnits.getUnitType());
    map.put("zoneCode", sysUnits.getZoneCode() + "%");

    String startDay_str = request.getParameter("startDay");
    String endDay_str = request.getParameter("endDay");
    String unitName = request.getParameter("unitName");

    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
    if (null != startDay_str
        && !startDay_str.equals("")
        && null != endDay_str
        && !endDay_str.equals("")) {

      map.put("startDay", DateUtil.toDate(startDay_str, DateUtil.YYYY_MM_DD));
      map.put("endDay", DateUtil.toDate(endDay_str, DateUtil.YYYY_MM_DD));
      if (null != unitName && !"".equals(unitName)) {

        map.put("unitName", "%" + unitName + "%");
      }
      dataList = orderCountDao.getListMap(map);
    }

    if (null != dataList && !dataList.isEmpty()) {

      for (Map<String, Object> countData : dataList) {

        List<OrderCountInfo> infoList =
            orderCountInfoDao.getListByCountId(Long.valueOf(countData.get("ID") + ""));

        countData.put(
            "AVG_AMOUNT",
            Arith.div(
                null == countData.get("GOODS_AMOUNT")
                    ? 0d
                    : Double.valueOf(countData.get("GOODS_AMOUNT") + ""),
                null == countData.get("ORDER_COUNT")
                    ? 0d
                    : Double.valueOf(countData.get("ORDER_COUNT") + "")));
        if (null != infoList && !infoList.isEmpty()) {

          for (OrderCountInfo orderCountInfo : infoList) {

            int infoType = orderCountInfo.getInfoType();
            countData.put("ORDER_COUNT_" + infoType, orderCountInfo.getOrderCount());
            countData.put("REAL_AMOUNT_" + infoType, orderCountInfo.getRealAmount());
            countData.put("GOODS_AMOUNT_" + infoType, orderCountInfo.getGoodsAmount());
            countData.put("COIN_AMOUNT_" + infoType, orderCountInfo.getCoinAmount());
            countData.put(
                "GOODS_TRANSPORT_AMOUNT_" + infoType, orderCountInfo.getGoodsTransportAmount());
            countData.put("COUPONS_AMOUNT_" + infoType, orderCountInfo.getCouponsAmount());
            countData.put(
                "AVG_AMOUNT_" + infoType,
                Arith.div(
                    orderCountInfo.getGoodsAmount(),
                    Double.valueOf(orderCountInfo.getOrderCount())));
          }
        }
      }
    }
    long totalRows = null == dataList ? 0 : dataList.size();
    gridData.put("Rows", dataList);
    gridData.put("Total", totalRows);
    return gridData;
  }