/**
  * 根据开销户日期查询返回客户信息
  *
  * @param req
  * @param resp
  * @return
  * @throws Exception
  */
 public PaginationSupport q2(String qDate, String paramFromDate, String paramToDate, int offset) {
   PaginationSupport page = null;
   try {
     if ("openDate".equals(qDate)) {
       page = clientAdminService.findClientsByOpenDate(paramFromDate, paramToDate, offset);
     } else if ("closeDate".equals(qDate)) {
       page = clientAdminService.findClientsByCloseDate(paramFromDate, paramToDate, offset);
     } else {
       page = clientAdminService.findAllClients(offset);
     }
   } catch (Exception e) {
     page = clientAdminService.findAllClients(offset);
   }
   return page;
 }
 /**
  * 业务报表
  *
  * @param req
  * @param resp
  * @return
  * @throws Exception
  */
 public ModelAndView busniessReport(HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   String action = request.getParameter("action");
   String paramOffset = request.getParameter("offset");
   int offset =
       isEmptyParam(paramOffset) || !paramOffset.matches("\\d+")
           ? 0
           : Integer.valueOf(paramOffset);
   String selected1 = null;
   String selected2 = null;
   PaginationSupport page = null;
   Map<String, Object> models = new HashMap<String, Object>();
   if ("q1".equals(action)) {
     String qType = request.getParameter("qType"); // 查找类型
     String qValue = request.getParameter("qValue"); // 查找值
     String query =
         "action=q1&qType="
             + request.getParameter("qType")
             + "&qValue="
             + request.getParameter("qValue");
     page = q1(qType, qValue, offset);
     selected1 =
         "".equals(qType)
             ? "noselected1"
             : ("name".equals(qType))
                 ? "name"
                 : ("certificateNum".equals(qType)) ? "certificateNum" : "bankAccount";
     models.put(selected1, "selected='selected'");
     models.put("qValue", qValue);
     models.put("query", query);
   } else if ("q2".equals(action)) {
     String qDate = request.getParameter("qDate");
     String paramFromDate = request.getParameter("fromDate");
     String paramToDate = request.getParameter("toDate");
     String query =
         "action=q2&qDate="
             + request.getParameter("qDate")
             + "&fromDate="
             + request.getParameter("fromDate")
             + "&toDate="
             + request.getParameter("toDate");
     page = q2(qDate, paramFromDate, paramToDate, offset);
     selected2 =
         "".equals(qDate) ? "noseleted2" : ("openDate".equals(qDate)) ? "openDate" : "closeDate";
     models.put(selected2, "selected='selected'");
     models.put("fromDate", paramFromDate);
     models.put("toDate", paramToDate);
     models.put("query", query);
   } else {
     page = clientAdminService.findAllClients(offset);
   }
   models.put("page", page);
   return new ModelAndView(getBusinessReportView(), models);
 }
  /**
   * 根据姓名,证件号码,银行账号查询
   *
   * @param request
   * @return
   */
  private PaginationSupport q1(String qType, String qValue, int offset) {
    // 获取查找参数
    qType = qType == null || qType.trim().isEmpty() ? null : qType.trim();
    qValue = qValue == null || qValue.trim().isEmpty() ? null : qValue.trim();

    PaginationSupport page = null;
    if ("name".equals(qType) && qValue != null) {
      // 按照名字查询
      page = clientAdminService.findClientsByName(qValue, offset);
    } else if ("certificateNum".equals(qType) && qValue != null) {
      // 按照证件号码查询
      page = clientAdminService.findClientsByCerficateNum(qValue, offset);
    } else if ("bankAccount".equals(qType) && qValue != null) {
      page = clientAdminService.findClientsByBankAccount(qValue, offset);
    } else {
      // 没有查询条件,显示全部
      page = clientAdminService.findAllClients(offset);
    }
    return page;
  }
  /**
   * 查询所有客户资料
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ModelAndView clientManage(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    String qType = request.getParameter("qType"); // 查找类型
    String qValue = request.getParameter("qValue"); // 查找值
    String action = request.getParameter("action");
    String paramOffset = request.getParameter("offset");
    // 当前查询类型
    System.out.println("qType:" + qType);
    int offset =
        isEmptyParam(paramOffset) || !paramOffset.matches("\\d+")
            ? 0
            : Integer.valueOf(paramOffset);

    PaginationSupport page = null;
    Map<String, Object> models = new HashMap<String, Object>();
    if ("q1".equals(action)) {
      page = q1(qType, qValue, offset);
      String query =
          "action=q1&qType="
              + request.getParameter("qType")
              + "&qValue="
              + request.getParameter("qValue");
      models.put("query", query);
      String selected =
          (qType == null || "".equals(qType))
              ? "noselected"
              : ("name".equals(qType)) ? "name" : "certificateNum";
      models.put(selected, "selected='selected'");
      models.put("qValue", qValue);
    } else {
      page = clientAdminService.findAllClients(offset);
    }
    models.put("page", page);
    System.out.println(models);
    return new ModelAndView(getClientManageView(), models);
  }