コード例 #1
0
 /**
  * 把指定策略下面&未预定的活动价格设置成默认策略的价格
  *
  * @param mapping
  * @param actionForm
  * @param request
  * @param response
  * @return
  * @throws Exception
  */
 public ActionForward applyDefaultTactics(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   try {
     Long venueId = UserUtil.getCurrentVenueLongId(request);
     String fieldType = StringUtil.getParameter("fieldType", request);
     String strTacticsId = StringUtil.getParameter("tacticsId", "0", request);
     Long tacticsId = Long.valueOf(strTacticsId);
     tacticsManager.applyDefaultTactics(venueId, tacticsId, fieldType);
     printSuccess(response);
   } catch (Exception e) {
     log.error(e.getMessage(), e);
     printErrorLabel(response);
   }
   return null;
 }
コード例 #2
0
 /**
  * 统计使用特殊策略生成的活动条数
  *
  * @param mapping
  * @param actionForm
  * @param request
  * @param response
  * @return
  * @throws Exception
  */
 public ActionForward countActivityOfTactics(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   try {
     String fieldType = StringUtil.getParameter("fieldType", request);
     String tacticsId = StringUtil.getParameter("tacticsId", request);
     Class<? extends FieldActivity> activityPojoClass =
         FieldUtil.getFieldActivityPojoClass(fieldType);
     List<? extends FieldActivity> findBy =
         getBaseManager().findBy(activityPojoClass, "tacticsId", tacticsId);
     print(String.valueOf(findBy.size()), response);
   } catch (Exception e) {
     log.error(e.getMessage(), e);
     printErrorLabel(response);
   }
   return null;
 }
コード例 #3
0
 /**
  * 检查指定的策略日期是否和本场馆已存在的策略日期重叠
  *
  * @param mapping
  * @param actionForm
  * @param request
  * @param response
  * @return
  * @throws Exception
  */
 public ActionForward checkRepeatDates(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   try {
     Long venueId = UserUtil.getCurrentVenueLongId(request);
     String strFromDate = StringUtil.getParameter("fromDate", request);
     String strToDate = StringUtil.getParameter("toDate", request);
     String fieldType = StringUtil.getParameter("fieldType", request);
     Date fromDate = Date.valueOf(strFromDate);
     Date toDate = Date.valueOf(strToDate);
     JSONObject checkRepeatDates =
         tacticsManager.checkRepeatDates(venueId, fieldType, fromDate, toDate);
     print(checkRepeatDates.toString(), response);
   } catch (Exception e) {
     log.error(e.getMessage(), e);
     printErrorLabel(response);
   }
   return null;
 }
コード例 #4
0
  /**
   * 清空策略范围内的活动,并重新生成,已预定的备份到策略活动备份表中
   *
   * @param mapping
   * @param actionForm
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward deleteAndBakActivity(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    try {
      Long venueLongId = UserUtil.getCurrentVenueLongId(request);
      String fieldType = request.getParameter("fieldType");
      Long tacticsId = Long.parseLong(StringUtil.getParameter("tacticsId", "0", request));

      tacticsManager.deleteAndBakActivity(venueLongId, tacticsId, fieldType);
      printSuccess(response);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      printErrorLabel(response);
    }
    return null;
  }
コード例 #5
0
  /**
   * 添加策略日期
   *
   * @param mapping
   * @param actionForm
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward addTacticsDate(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    try {
      JSONObject jsonObject = readJson(request);
      String strTacticsId = StringUtil.getParameter("tacticsId", request);
      Tactics tactics = null;

      if (StringUtils.isEmpty(strTacticsId)) {
        throw new TacticsException("没有找到相应策略");
      } else {
        long tacticsId = Long.parseLong(strTacticsId);
        Object object = getBaseManager().get(Tactics.class, tacticsId);
        if (object == null) {
          throw new TacticsException("没有找到相应策略");
        } else {
          tactics = (Tactics) object;
        }
      }

      Long venueId = UserUtil.getCurrentVenueLongId(request);
      String strFromDate = jsonObject.getString("fromDate");
      String strToDate = jsonObject.getString("toDate");
      String fieldType = tactics.getFieldType();
      Date fromDate = DateUtil.getSqlDate(strFromDate, DateUtil.TYPE_DATE);
      Date toDate = DateUtil.getSqlDate(strToDate, DateUtil.TYPE_DATE);
      if (StringUtils.isEmpty(strFromDate) || StringUtils.isEmpty(strToDate)) {
        throw new TacticsException("日期段不能为空");
      } else {
        JSONObject checkRepeatDates =
            tacticsManager.checkRepeatDates(venueId, fieldType, fromDate, toDate);
        if (checkRepeatDates.getBoolean("repeat")) {
          throw new TacticsException(checkRepeatDates.toString());
        }
      }

      TacticsDate tacticsDate = new TacticsDate();
      tacticsDate.setFromDate(fromDate);
      tacticsDate.setToDate(toDate);
      if (NumberUtil.isEmptyWithZero(tacticsDate.getId())) {
        tacticsDate.setVenueId(UserUtil.getCurrentVenueLongId(request));
        tacticsDate.setTactics(tactics);
      }

      getBaseManager().insertOrUpdate(tacticsDate);

      // 设置更新状态
      if (!tactics.getIsModify()) {
        tactics.setIsModify(true);
        getBaseManager().insertOrUpdate(tactics);
      }

      printSuccess(response);

    } catch (TacticsException e) {
      e.printStackTrace();
      log.error("保存策略日期时:" + e.getMessage());
      printErrorInfo(e.getMessage(), response);
    } catch (Exception e) {
      e.printStackTrace();
      log.error("保存策略日期时:" + e.getMessage());
      printErrorLabel(response);
    }
    return null;
  }