public String addSettleMargin() throws Exception {
    this.logger.debug("enter addSettleMargin");

    FirmSettleMargin settleMargin = (FirmSettleMargin) this.entity;
    boolean flag = existCommoditySpecial(settleMargin.getFirmID(), settleMargin.getCommodityID());
    if (flag) {
      addReturnValue(-1, 151103L, new Object[] {"添加特殊商品交收保证金失败,已存在!"});
    } else {
      FirmSettleMargin firmSettleMargin = (FirmSettleMargin) this.entity;

      if (firmSettleMargin.getSettleMarginAlgr_B().intValue() == 1) {
        firmSettleMargin.setSettleMarginRate_B(
            Double.valueOf(
                Arith.div(
                    firmSettleMargin.getSettleMarginRate_B().doubleValue(),
                    new Double(100.0D).doubleValue())));
      }
      if (firmSettleMargin.getSettleMarginAlgr_S().intValue() == 1) {
        firmSettleMargin.setSettleMarginRate_S(
            Double.valueOf(
                Arith.div(
                    firmSettleMargin.getSettleMarginRate_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
      }
      if (firmSettleMargin.getPayoutAlgr().intValue() == 1) {
        firmSettleMargin.setPayoutRate(
            Double.valueOf(
                Arith.div(
                    firmSettleMargin.getPayoutRate().doubleValue(),
                    new Double(100.0D).doubleValue())));
      }

      firmSettleMargin.setModifyTime(getService().getSysDate());

      getService().add(firmSettleMargin);

      addReturnValue(1, 119901L);

      writeOperateLog(
          1505,
          "添加特殊商品交收保证金!交易商ID:"
              + firmSettleMargin.getFirmID()
              + ",商品ID:"
              + firmSettleMargin.getCommodityID(),
          1,
          "");
    }

    return "success";
  }
  public String deleteSettleMargin() {
    this.logger.debug("enter deleteSettleMargin");

    String[] ids = this.request.getParameterValues("ids");

    if (ids != null) {
      String prompt = "";
      int count = 0;
      for (int i = 0; i < ids.length; i++) {
        String[] idArr = ids[i].split(",");
        String firmID = idArr[0];
        String commodityID = idArr[1];
        try {
          String sysStatus = this.firmSpecialService.getSystemStatus();
          if (("5".equals(sysStatus)) || ("6".equals(sysStatus))) {
            addReturnValue(-1, 151103L, new Object[] {"此时市场状态不允许删除!"});
            count++;
            break;
          }

          FirmSettleMargin settleMargin = new FirmSettleMargin();
          settleMargin.setFirmID(firmID);
          settleMargin.setCommodityID(commodityID);
          getService().delete(settleMargin);

          writeOperateLog(
              1505,
              "删除特殊商品交收保证金! 交易商ID:"
                  + settleMargin.getFirmID()
                  + ",商品ID:"
                  + settleMargin.getCommodityID(),
              1,
              "");
        } catch (DataIntegrityViolationException e) {
          e.getStackTrace();
          prompt = prompt + ids[i] + ",";
          addReturnValue(-1, 151103L, new Object[] {"[" + ids[i] + "]与其他数据关联,删除失败!"});
          count++;
        }
      }
      if (!prompt.equals("")) {
        prompt = prompt.substring(0, prompt.length() - 1);
        prompt = prompt + "与其他数据关联,不能删除!";
        addReturnValue(0, 151103L, new Object[] {prompt});
        count++;
      }
      if (count == 0) {
        addReturnValue(1, 119903L);
      }
    } else {
      addReturnValue(-1, 151103L, new Object[] {"删除主键为空或错误,请修改~!"});
    }

    return "success";
  }
  public String updateSettleMargin() throws Exception {
    this.logger.debug("enter updateSettleMargin");

    FirmSettleMargin firmSettleMargin = (FirmSettleMargin) this.entity;

    if (firmSettleMargin.getSettleMarginAlgr_B().intValue() == 1) {
      firmSettleMargin.setSettleMarginRate_B(
          Double.valueOf(
              Arith.div(
                  firmSettleMargin.getSettleMarginRate_B().doubleValue(),
                  new Double(100.0D).doubleValue())));
    }
    if (firmSettleMargin.getSettleMarginAlgr_S().intValue() == 1) {
      firmSettleMargin.setSettleMarginRate_S(
          Double.valueOf(
              Arith.div(
                  firmSettleMargin.getSettleMarginRate_S().doubleValue(),
                  new Double(100.0D).doubleValue())));
    }
    if (firmSettleMargin.getPayoutAlgr().intValue() == 1) {
      firmSettleMargin.setPayoutRate(
          Double.valueOf(
              Arith.div(
                  firmSettleMargin.getPayoutRate().doubleValue(),
                  new Double(100.0D).doubleValue())));
    }

    firmSettleMargin.setModifyTime(getService().getSysDate());

    getService().update(firmSettleMargin);

    addReturnValue(1, 119902L);

    writeOperateLog(
        1505,
        "修改特殊商品交收保证金! 交易商ID:"
            + firmSettleMargin.getFirmID()
            + ",商品ID:"
            + firmSettleMargin.getCommodityID(),
        1,
        "");

    return "success";
  }