Ejemplo n.º 1
0
  /**
   * 消息推送
   *
   * @param findActivity
   */
  public void pushMsg(FindActivity findActivity) {

    String describtion = PushMsgType.xiaoDaNews.text;
    SysDictDetail sysDictDetail =
        DictUtil.getDetailByCode(1, "pushMsgDescModel", "xiaoDaNewsModel");
    if (null != sysDictDetail
        && null != sysDictDetail.getValue()
        && !"".equals(sysDictDetail.getValue())) {
      describtion = sysDictDetail.getValue();
    }

    Map<String, Object> descMap = new HashMap<String, Object>();
    descMap.put("findActivity", findActivity);
    describtion = FreeMarkerUtil.getContentFromStringTemplate(descMap, describtion);

    FindService findService = findServiceDao.getByServiceCode("xiaodakuaibao");

    String pushUrl = SysBaseUtil.XDKB_URL + "?id=" + findActivity.getId();

    String body =
        PushUtil.getBody(PushMsgType.xiaoDaNews.value, 0, pushUrl, findService.getUrlParams());

    String sendDate = "";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
    PushMsg pushMsg = new PushMsg();
    PushToData toData = new PushToData();

    SysUnits sysUnits = sysUnitsDao.get(findActivity.getUnitId());
    String tag = ""; // 推送区域
    if (!"1".equals(sysUnits.getZoneCode())) {
      tag = sysUnits.getZoneCode();
      toData.setIsAll(0);
    } else {
      toData.setIsAll(1);
    }

    pushMsg.setTitle(PushMsgType.xiaoDaNews.title);
    pushMsg.setDescribtion(describtion);
    pushMsg.setBody(body);
    pushMsg.setCreateDate(DateUtil.getSystemTime());
    pushMsg.setTag(tag);
    pushMsg.setMto(tag);
    pushMsg.setDatasourceId(String.valueOf(findActivity.getId()));
    pushMsg.setDatasourceType(PushUtil.PushLoginType.datasourceType.value);

    toData.setTag(tag); // 推送区域
    toData.setCreateDate(DateUtil.getSystemTime());
    toData.setDatasourceId(String.valueOf(findActivity.getId()));
    toData.setDatasourceType(PushUtil.PushLoginType.datasourceType.value);
    toData.setMto(tag);

    try {
      if (0 == findActivity.getPushType()) { // 本月每天推送
        java.util.Calendar cal = java.util.Calendar.getInstance();
        // 获取当月共多少天
        int maxDay = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
        // 获取当天日期
        int currentDay = cal.get(java.util.Calendar.DATE);

        // 获取当前年月
        Date d = new Date();
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String dateNowStr = sdf2.format(d);

        // 计算推送天数
        int pushDay = maxDay - currentDay;
        if (pushDay > 0) { // 剩余推送天数
          for (int i = 1; i <= pushDay; i++) {
            for (int j = 1; j <= findActivity.getPushTimes(); j++) {
              if (j == 1) {
                sendDate = findActivity.getPushDate1();
              } else if (j == 2) {
                sendDate = findActivity.getPushDate2();
              } else if (j == 3) {
                sendDate = findActivity.getPushDate3();
              } else if (j == 4) {
                sendDate = findActivity.getPushDate4();
              } else if (j == 5) {
                sendDate = findActivity.getPushDate5();
              } else if (j == 6) {
                sendDate = findActivity.getPushDate6();
              }

              String toSendDate;
              if ((currentDay + pushDay) < 10) {
                toSendDate =
                    dateNowStr + "-" + "0" + String.valueOf(currentDay + pushDay) + " " + sendDate;
              } else {
                toSendDate =
                    dateNowStr + "-" + String.valueOf(currentDay + pushDay) + " " + sendDate;
              }

              // 设置推送时间
              pushMsg.setSendDate(sdf.parse(toSendDate));
              toData.setSendDate(sdf.parse(toSendDate));

              // 安卓推送
              pushMsg.setType(Integer.valueOf(PushLoginType.androidApp.value));
              toData.setLoginType(PushLoginType.androidApp.value);
              PushUtil.doPush(pushMsg, toData);

              // ios推送
              pushMsg.setType(Integer.valueOf(PushLoginType.iosApp.value));
              toData.setLoginType(PushLoginType.iosApp.value);
              PushUtil.doPush(pushMsg, toData);
            }
          }
        }

      } else if (1 == findActivity.getPushType()) { // 仅推一天
        // 获取当前年月
        Date d = new Date();
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
        String dateNowStr = sdf2.format(d);

        for (int j = 1; j <= findActivity.getPushTimes(); j++) {
          if (j == 1) {
            sendDate = findActivity.getPushDate1();
          } else if (j == 2) {
            sendDate = findActivity.getPushDate2();
          } else if (j == 3) {
            sendDate = findActivity.getPushDate3();
          } else if (j == 4) {
            sendDate = findActivity.getPushDate4();
          } else if (j == 5) {
            sendDate = findActivity.getPushDate5();
          } else if (j == 6) {
            sendDate = findActivity.getPushDate6();
          }

          String toSendDate = dateNowStr + " " + sendDate;

          // 设置推送时间
          pushMsg.setSendDate(sdf.parse(toSendDate));
          toData.setSendDate(sdf.parse(toSendDate));

          // 安卓推送
          pushMsg.setType(Integer.valueOf(PushLoginType.androidApp.value));
          toData.setLoginType(PushLoginType.androidApp.value);
          PushUtil.doPush(pushMsg, toData);

          // ios推送
          pushMsg.setType(Integer.valueOf(PushLoginType.iosApp.value));
          toData.setLoginType(PushLoginType.iosApp.value);
          PushUtil.doPush(pushMsg, toData);
        }

      } else { // 仅推一次,设置推送时间
        pushMsg.setSendDate(findActivity.getPushDate());
        toData.setSendDate(findActivity.getPushDate());

        // 安卓推送
        pushMsg.setType(Integer.valueOf(PushLoginType.androidApp.value));
        toData.setLoginType(PushLoginType.androidApp.value);
        PushUtil.doPush(pushMsg, toData);

        // ios推送
        pushMsg.setType(Integer.valueOf(PushLoginType.iosApp.value));
        toData.setLoginType(PushLoginType.iosApp.value);
        PushUtil.doPush(pushMsg, toData);
      }

    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  /** 获取订单分析数据 */
  public Map<String, Object> getAnalysesData(HttpServletRequest request, SysUnits loginUnit) {

    // 结果集
    Map<String, Object> gridData = new HashMap<String, Object>();

    // 订单分析数据总集
    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();

    // 分析订单的 条件
    String longitude = request.getParameter("longitude").trim(); // 经度
    String latitude = request.getParameter("latitude").trim(); // 纬度
    String radius = request.getParameter("radius").trim(); // 范围半径

    // 时间条件
    Date today = DateUtil.getToday(); // 今天 时间
    Date tomorrow = DateUtil.getTomorrow(today); // 明天 时间
    Date lastWeek = DateUtil.getLastWeek(today); // 上一周 时刻
    Date lastMonth = DateUtil.getLastMonth(today); // 上一月 时刻
    Date lastQuarter = DateUtil.getLastQuarter(today); // 前三月 时刻
    Date halfYear = DateUtil.getHalfYear(today); // 半年之前 时刻
    Date nineMonthEarlier = DateUtil.getNineMonthEarlier(today); // 九个月之前 时刻
    Date lastYear = DateUtil.getLastYear(today); // 一年之前 时刻

    // 单位信息条件
    String unitName = request.getParameter("unitName");
    if (unitName != null && !"".equals(unitName)) {
      unitName = "%" + unitName + "%";
    }
    long unitId = loginUnit.getId();
    String zoneCode = loginUnit.getZoneCode() + "%";
    int unitType = loginUnit.getUnitType();

    Map<String, Object> paraMap = new HashMap<String, Object>();
    paraMap.put("longitude", longitude);
    paraMap.put("latitude", latitude);
    paraMap.put("radius", radius);

    paraMap.put("unitName", unitName);
    paraMap.put("unitId", unitId);
    paraMap.put("zoneCode", zoneCode);
    paraMap.put("unitType", unitType);

    paraMap.put("endDate", tomorrow);

    // 当天的订单分析数据
    paraMap.put("startDate", today);
    List<Map<String, Object>> todayData = analysesData(paraMap, "今天");
    if (!todayData.isEmpty()) {
      dataList.addAll(todayData);
    }

    // 一周的订单分析数据
    paraMap.put("startDate", lastWeek);
    List<Map<String, Object>> weekData = analysesData(paraMap, "一周之内");
    if (!weekData.isEmpty()) {
      dataList.addAll(weekData);
    }

    // 一个月的订单分析数据
    paraMap.put("startDate", lastMonth);
    List<Map<String, Object>> monthData = analysesData(paraMap, "一个月之内");
    if (!monthData.isEmpty()) {
      dataList.addAll(monthData);
    }

    // 三个月的订单分析数据
    paraMap.put("startDate", lastQuarter);
    List<Map<String, Object>> quarterData = analysesData(paraMap, "三个月之内");
    if (!quarterData.isEmpty()) {
      dataList.addAll(quarterData);
    }

    // 半年之内的订单分析数据
    paraMap.put("startDate", halfYear);
    List<Map<String, Object>> halfYearData = analysesData(paraMap, "半年之内");
    if (!halfYearData.isEmpty()) {
      dataList.addAll(halfYearData);
    }

    // 九个月之内的订单分析数据
    paraMap.put("startDate", nineMonthEarlier);
    List<Map<String, Object>> nineMonthData = analysesData(paraMap, "九个月之内");
    if (!nineMonthData.isEmpty()) {
      dataList.addAll(nineMonthData);
    }

    // 一年之内的订单分析数据
    paraMap.put("startDate", lastYear);
    List<Map<String, Object>> oneYearData = analysesData(paraMap, "一年之内");
    if (!oneYearData.isEmpty()) {
      dataList.addAll(oneYearData);
    }

    int rowsCount = dataList.isEmpty() ? 0 : dataList.size();

    gridData.put("Rows", dataList);
    gridData.put("Total", rowsCount);

    return gridData;
  }
Ejemplo n.º 3
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;
  }
Ejemplo n.º 4
0
  public Map<String, Object> getTodayGridData(HttpServletRequest request, SysUnits sysUnits) {

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("unitId", sysUnits.getId());

    String startTime = request.getParameter("startTime");
    String endTime = request.getParameter("endTime");
    map.put("startTime", startTime);
    map.put("endTime", endTime);

    List<Order> orderList = orderDao.getTodayCountList(map);

    List<OrderCountInfo> dataList = new ArrayList<OrderCountInfo>();

    //// 汇总方式 0:有效订单、1:在线支付、2:线下支付、3:电话外卖、4:拒收订单
    OrderCountInfo orderCountInfo = new OrderCountInfo(); // 总订单
    orderCountInfo.setInfoType(-1);

    OrderCountInfo valiCountInfo = new OrderCountInfo(); // 有效订单
    valiCountInfo.setInfoType(0);

    OrderCountInfo jushouCountInfo = new OrderCountInfo(); // 拒收订单
    jushouCountInfo.setInfoType(4);

    OrderCountInfo onlineCountInfo = new OrderCountInfo(); // 线上订单
    onlineCountInfo.setInfoType(1);

    OrderCountInfo offlineCountInfo = new OrderCountInfo(); // 线下订单
    offlineCountInfo.setInfoType(2);

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

      for (Order order : orderList) {

        setOrderCountInfo(orderCountInfo, order);
        if (order.getDeliveryerStatus() == 12) { // 有效订单

          setOrderCountInfo(valiCountInfo, order);
        } else if (order.getDeliveryerStatus() == -11) { // 拒收订单

          setOrderCountInfo(jushouCountInfo, order);
        }

        if (order.getPayType() == 0) { // 线下支付

          setOrderCountInfo(offlineCountInfo, order);
        } else if (order.getPayType() == 1) {

          setOrderCountInfo(onlineCountInfo, order);
        }
      }
    }

    dataList.add(orderCountInfo);
    dataList.add(valiCountInfo);
    dataList.add(jushouCountInfo);
    dataList.add(onlineCountInfo);
    dataList.add(offlineCountInfo);

    Map<String, Object> countData = new HashMap<String, Object>();
    countData.put("Rows", dataList);
    countData.put("Total", null != dataList ? dataList.size() : 0);
    return countData;
  }