Exemplo n.º 1
0
  /**
   * 返回null表示修改成功
   *
   * @param cell
   * @return
   */
  @SuppressWarnings("unused")
  private BatchExceptionData modifyUserAccountProject(Cell[] cell) {

    String message = "";

    try {

      String projectName = cell[0].getContents().trim();
      int projectId = Integer.parseInt(cell[1].getContents().trim());

      String realName = cell[3].getContents().trim();
      String userName = cell[4].getContents().trim();

      CompanyProject project = companyProjectServices.findCompanyProjectById(projectId);
      if (project == null || !projectName.equals(project.getProjectName())) {

        message = "项目名称与id不一致";
        throw new Exception();
      }

      UserAccount user = userAccountServices.findUserAccountByUserNameIncludeDelete(userName);
      if (user == null || !realName.equals(user.getRealName())) {

        message = "用户的姓名与账号不一致";
        throw new Exception();
      }

      user.setProjectId(projectId);

      user.setModId(SessionUser.getUserId());
      user.setModTime(new Date());

      userAccountServices.updateUserAccount(user);

    } catch (Exception e) {

      if (CommonUtils.isStrEmpty(message)) {

        message = "数据格式不合法";
      }
    }

    if (CommonUtils.isStrEmpty(message)) {
      // 表示修改成功

      return null;
    }

    BatchExceptionData retPojo = new BatchExceptionData();

    retPojo.setProjectName(cell[0].getContents());
    retPojo.setProjectId(cell[1].getContents());
    retPojo.setJobNumber(cell[2].getContents());
    retPojo.setRealName(cell[3].getContents());
    retPojo.setUserName(cell[4].getContents());
    retPojo.setExceptionData(message);

    return retPojo;
  }
Exemplo n.º 2
0
  /**
   * 根据单元折扣id获取项目折扣的显示名称
   *
   * @param unitDiscountId
   * @return
   */
  public static String getProjectDiscountShowByUnitDiscountId(int unitDiscountId) {

    StringBuffer sb = new StringBuffer();

    UnitDiscount unitDiscount = unitDiscountServices.findUnitDiscountById(unitDiscountId);

    try {

      List<UnitDiscountDetail> detailList =
          unitDiscountDetailServices.findDetailByDiscountId(unitDiscountId);

      if (!CommonUtils.isCollectionEmpty(detailList)) {
        for (UnitDiscountDetail detail : detailList) {

          sb.append(detail.getDiscountPercent()).append("*");
        }
      }

      List<ProjectDiscount> proList =
          projectDiscountServices.findProjectDiscountByUnitDiscountId(unitDiscountId);

      if (!CommonUtils.isCollectionEmpty(proList)) {
        for (ProjectDiscount pro : proList) {

          sb.append(pro.getDiscountPercent()).append("*");
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
      sb.delete(0, sb.length());
      sb.append(unitDiscount.getDiscountName());
    }

    String ret = sb.toString();
    if (ret.endsWith("*")) {

      ret = ret.substring(0, ret.length() - 1);

      // 增加折扣对应的说明
      String computeWay = unitDiscount.getComputeWay();
      String wayValue = computeWayMap.get(computeWay);
      if (!CommonUtils.isStrEmpty(wayValue)) {

        ret += wayValue;
      }
    }

    if (CommonUtils.isStrEmpty(ret)) {
      ret = "查看折扣";
    }

    return ret;
  }
Exemplo n.º 3
0
  /**
   * 根据折扣detail获取折扣名称,(98*97*94_2010-07-12)
   *
   * @param someDetail
   * @return
   */
  public static String getDiscountName(String someDetail) {
    //// typeId1=3&percent1=99&remark1=&typeId2=4&percent2=97&remark2=&detailCount=2

    StringBuffer sb = new StringBuffer();

    String[] details = someDetail.split("&");

    for (String detail : details) {

      if (!CommonUtils.isStrEmpty(detail) && detail.startsWith("percent")) {

        String[] tmp = detail.split("=");
        try {
          sb.append(tmp[1]);
        } catch (Exception e) {
        }
        sb.append("*");
      }
    }

    String ret = sb.toString();
    ret = CommonUtils.removeLastChar(ret);

    return ret + "_" + CommonUtils.getNowForString();
  }
Exemplo n.º 4
0
  public String myGetCheckFeeDateList() throws Exception {

    JSONArray jsonArray = new JSONArray();

    confirmCond = new ConfirmCond();
    confirmCond.setPropertyId(request.getParameter("propertyId"));

    List<Map<String, Object>> checkFeeDateList = confirmServices.checkFeeDateList(confirmCond);

    for (int i = 0; i < checkFeeDateList.size(); i++) {

      Map<String, Object> mapobject = checkFeeDateList.get(i);

      String checkfee_date =
          mapobject.get("checkfee_date") == null ? "" : mapobject.get("checkfee_date").toString();

      if (!CommonUtils.isStrEmpty(checkfee_date)) {

        Map<String, Object> json = new HashMap<String, Object>();
        json.put(
            "checkFeeDate",
            CommonUtils.getDateString(CommonUtils.getDateFromString(checkfee_date)));

        jsonArray.add(json);
      }
    }

    CustomerUtils.writeResponse(response, jsonArray.toString());

    return null;
  }
Exemplo n.º 5
0
  /**
   * 新增Customer
   *
   * @param customer
   */
  public void saveCustomer(Customer customer) throws RuntimeException {
    // CustomerPermission.doCheckSave();

    // TODO 根据当前项目的customerOneSale,是否为1,才进行判断
    // 客户来源为来访判断,该项目下电话号码是否重复
    if ("2".equals(customer.getCustomerSource())) {
      PhoneUniqueUtils.isPhoneRepeat(customer);
    }

    // 增加号码归属地(可以改成定时器去执行),CustomerPhoneFromQuartz.java
    // customer = PhoneUtils.postPhone(customer);

    // 根据project_code设置customer的price_num对应的项目的PRICE_AMOUNT值,area_num对应的项目的REQUEST_AREA值
    ProjectCodeFieldUtils.setRriceAndAreaNum(customer);

    // 如果来访日期为空,就增加默认为当天,2013.8.14
    if (CommonUtils.isStrEmpty(customer.getVisitDate())) {
      customer.setVisitDate(CommonUtils.getDateString(new Date()));
    }

    // 设定follow_time,(因为该字段为后来新增的,所以要在这里增加)
    customer.setFollowTime(CommonUtils.getDateFromString(customer.getVisitDate()));

    // 实际保存
    customerMapper.saveCustomer(customer);

    // CacheUtils.removeCache(cacheKeyOne,customer.getId());
  }
Exemplo n.º 6
0
  /**
   * 根据请求参数及单元折扣id,获取单元折扣详细列表
   *
   * @param someDetail
   * @param discountId
   * @return
   * @throws Exception
   */
  public static List<UnitDiscountDetail> initForAddDiscountDetail(String someDetail, int discountId)
      throws Exception {
    // typeId1=3&percent1=99&remark1=&typeId2=4&percent2=97&remark2=&detailCount=2

    Map<String, String> map = new HashMap<String, String>();

    String[] details = someDetail.split("&");
    for (String detail : details) {

      String[] tmp = detail.split("=");
      try {

        map.put(tmp[0], tmp[1]);
      } catch (Exception e) {

        map.put(tmp[0], "");
      }
    }

    List<UnitDiscountDetail> retList = new ArrayList<UnitDiscountDetail>();
    int beanCount = Integer.parseInt(map.get("detailCount"));

    for (int i = 1; i <= beanCount; i++) {

      UnitDiscountDetail tmpDetail = new UnitDiscountDetail();

      String typeId = map.get("typeId" + i);
      String percent = map.get("percent" + i);
      String remark = map.get("remark" + i);

      if (CommonUtils.isStrEmpty(typeId)
          && CommonUtils.isStrEmpty(percent)
          && CommonUtils.isStrEmpty(remark)) continue;

      tmpDetail.setDiscountId(discountId);
      tmpDetail.setDiscountType(typeId);
      tmpDetail.setDiscountPercent(CommonUtils.exceptionToZero(percent));
      tmpDetail.setRemark(remark);

      CommonPojoUtils.initPojoCommonFiled(tmpDetail);

      retList.add(tmpDetail);
    }

    return retList;
  }
Exemplo n.º 7
0
  /**
   * 获取单元折扣dialog关闭要设置的值
   *
   * @param request
   * @return
   */
  public static Map<String, String> getUnitDiscountManagerCloseShowAndMultiplyByDiscountId(
      HttpServletRequest request) {

    int discountId = Integer.parseInt(request.getParameter("unitDiscountId"));

    Map<String, String> retMap = new HashMap<String, String>();

    StringBuffer sb = new StringBuffer();
    BigDecimal multiply = new BigDecimal(1); // 具体的折扣

    UnitDiscount unitDiscount = unitDiscountServices.findUnitDiscountById(discountId);

    try {

      List<PayWayDiscount> discountList =
          payWayDiscountServices.findPayWayDiscountByUnitDiscountId(discountId);

      if (!CommonUtils.isCollectionEmpty(discountList)) {
        for (PayWayDiscount discount : discountList) {

          sb.append(discount.getDiscountPercent()).append("*");
          multiply = multiply.multiply(discount.getDiscountPercent().divide(new BigDecimal(100)));
        }
      } else {

        sb.append(unitDiscount.getDiscountName());
      }

      retMap = initSumMoneyAndContractMoney(request, discountId, multiply, retMap); // 设置其他的相关金额

    } catch (Exception e) {
      e.printStackTrace();
    }

    String detail = sb.toString();
    if (detail.endsWith("*")) {
      detail = detail.substring(0, detail.length() - 1);
    }

    // 增加折扣对应的说明
    String computeWay = unitDiscount.getComputeWay();
    String wayValue = computeWayMap.get(computeWay);
    if (!CommonUtils.isStrEmpty(wayValue)) {

      detail += wayValue;
    }

    retMap.put("detail", detail); // 折扣显示
    retMap.put("multiply", multiply.toString()); // 具体的折扣

    return retMap;
  }
  /**
   * 根据文件名返回项目id,如果返回0表示该文件不合法 C:\\question\\兰乔圣菲_55.xl
   *
   * @param fileName
   * @return
   */
  private int getProjectIdByFileName(String fileName) {

    if (CommonUtils.isStrEmpty(fileName)) {

      return 0;
    }

    try {

      int start = fileName.lastIndexOf("\\");
      int end = fileName.lastIndexOf(".");

      fileName = fileName.substring(start + 1, end);

      String[] arr = fileName.split("_");

      String projectName = arr[0].trim(); // 项目名称
      int projectId = Integer.parseInt(arr[1].trim()); // 项目id

      CompanyProject project = companyProjectServices.findCompanyProjectById(projectId);

      if (project == null) {
        // 表示该文件不合法
        return 0;
      }

      if (!projectName.equals(project.getProjectName())) {

        return 0;
      }

      return projectId;

    } catch (Exception e) {

      return 0;
    }
  }
Exemplo n.º 9
0
  /**
   * 根据请求参数及项目折扣id获取单元折扣名称
   *
   * @param someDetail
   * @return
   */
  public static String getDiscountNameAndProjectDiscountId(
      String someDetail, Integer[] projectDiscountId) {
    //// typeId1=3&percent1=99&remark1=&typeId2=4&percent2=97&remark2=&detailCount=2

    StringBuffer sb = new StringBuffer();

    String[] details = someDetail.split("&");

    for (String detail : details) {

      if (!CommonUtils.isStrEmpty(detail) && detail.startsWith("percent")) {

        String[] tmp = detail.split("=");
        try {
          sb.append(tmp[1]);
        } catch (Exception e) {
        }
        sb.append("*");
      }
    }

    if (projectDiscountId != null && projectDiscountId.length > 0) {

      for (int proDiscountId : projectDiscountId) {

        ProjectDiscount proDiscount =
            projectDiscountServices.findProjectDiscountById(proDiscountId);
        sb.append(proDiscount.getDiscountPercent().intValue()).append("*");
      }
    }

    String ret = sb.toString();
    ret = CommonUtils.removeLastChar(ret);

    return ret + "_" + CommonUtils.getNowForString();
  }
Exemplo n.º 10
0
  /**
   * 返回null表示修改成功
   *
   * @param cell
   * @param proList
   * @param companyId
   * @return
   */
  private BatchExceptionData modifyUserAccountProject(
      Cell[] cell, List<CompanyProject> proList, int companyId) {

    String message = "";

    try {

      String projectName = cell[0].getContents().trim();
      int projectId = 0;
      try {
        projectId = Integer.parseInt(cell[1].getContents().trim());
      } catch (Exception e) {
      }

      String jobNumber = cell[2].getContents().trim();

      String realName = cell[3].getContents().trim();

      if (projectId > 0) {
        // 表示填了项目id

        CompanyProject project = companyProjectServices.findCompanyProjectById(projectId);
        if (project == null || !projectName.equals(project.getProjectName())) {

          message = "项目名称与id不一致";
          throw new Exception();
        }
      } else {
        // 没有填项目id

        List<CompanyProject> inclueProList = isIncludeOnlyCompanyProject(proList, projectName);
        if (CommonUtils.isCollectionEmpty(inclueProList) || inclueProList.size() != 1) {

          message = "选择的公司该项目不合法";
          throw new Exception();
        }

        projectId = inclueProList.get(0).getId();
      }

      UserAccount userAccount = new UserAccount(); // 参数
      userAccount.setCompanyId(companyId);
      userAccount.setRealName(realName);
      if (!CommonUtils.isStrEmpty(jobNumber)) {
        userAccount.setJobNumber(jobNumber);
      }

      List<UserAccount> userList =
          userAccountServices.findUserAccountByCompanyIdAndRealNameOrJobNumberIncludeDelete(
              userAccount);
      if (CommonUtils.isCollectionEmpty(userList) || userList.size() != 1) {

        message = "用户姓名不能唯一确定一个用户";
        throw new Exception();
      }

      UserAccount user = userList.get(0);

      user.setProjectId(projectId);

      user.setModId(SessionUser.getUserId());
      user.setModTime(new Date());

      userAccountServices.updateUserAccount(user);

    } catch (Exception e) {

      if (CommonUtils.isStrEmpty(message)) {

        message = "数据格式不合法\n" + e.getMessage();
      }
    }

    if (CommonUtils.isStrEmpty(message)) {
      // 表示修改成功

      return null;
    }

    BatchExceptionData retPojo = new BatchExceptionData();

    retPojo.setProjectName(cell[0].getContents());
    retPojo.setProjectId(cell[1].getContents());
    retPojo.setJobNumber(cell[2].getContents());
    retPojo.setRealName(cell[3].getContents());
    retPojo.setExceptionData(message);

    return retPojo;
  }