/**
   * 插入新的傭金資料
   *
   * @param ProjectCommissionRequestVo vo
   * @return ProjectCommissionResponseVo
   * @throws Exception
   */
  public ProjectCommissionResponseVo newCommission(ProjectCommissionRequestVo vo) {

    ProjectCommissionResponseVo resp = new ProjectCommissionResponseVo();
    long newId = 0;
    String txStatus = "";
    boolean chk = false;
    String newPro = "";
    try {
      // logger.debug("newProjectCommission entry=======================");
      // logger.debug("ProjectCommissionRequestVo vo:" + vo);

      CommissionVo rvo = new CommissionVo();
      CommissionDao dao = new CommissionDao();

      rvo.setCost(vo.getCost());
      rvo.setProjectprice(vo.getProjectprice());
      rvo.setVoice_reward(vo.getVoice_reward());
      rvo.setVoice_data_reward(vo.getData_reward());
      rvo.setData_reward(vo.getData_reward());
      rvo.setBonus(vo.getBonus());
      rvo.setCost_gap(vo.getCost_gap());
      rvo.setRatesid(vo.getRatesid());

      newPro = StringTK.cleanInvalidString(Strings.nullToEmpty(vo.getPrmotion_code()));
      rvo.setPrmotion_code(newPro);

      // 插入新的傭金資料
      chk = dao.insert(rvo);

      if (!chk) {
        throw new Exception("EC001:新增專案主檔失敗");
      }

      newId = rvo.getId();
      View_project_commissionVo f = dao.viewFindByCommissionId(newId);

      List<View_project_commissionVo> list = new ArrayList<View_project_commissionVo>();
      list.add(f);
      resp.setTxCode(vo.getTxCode());
      resp.setData(list);
      resp.setTxStatus(ApplicationConstant.TX_SUCCESS); // 設定交易成功狀態		

    } catch (Exception e) {
      txStatus = e.getMessage();
      logger.error(e.getMessage());
      resp.setTxStatus(txStatus);
    } finally {
      try {
        String ac = getResource().getRequestTranslet().getAccount();
        long aUid = UsersTK.getIdFromAccount(ac);
        LogTK.info(aUid, LogTK.CATEGORY_PROJECT, "新增傭金資料:" + newId + "/" + resp.getTxStatus());
      } catch (Exception e) {

      }
    }

    return resp;
  }
Exemplo n.º 2
0
 /**
  * 清除\t\n與前後空白字元
  *
  * @param str
  * @return
  */
 public static String filterString(String str) {
   return StringTK.cleanInvalidString(Strings.nullToEmpty(str));
 }