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

    FirmSettleFee firmSettleFee = (FirmSettleFee) this.entity;

    if (firmSettleFee.getSettleFeeAlgr().intValue() == 1) {
      firmSettleFee.setSettleFeeRate_B(
          Double.valueOf(
              Arith.div(
                  firmSettleFee.getSettleFeeRate_B().doubleValue(),
                  new Double(100.0D).doubleValue())));
      firmSettleFee.setSettleFeeRate_S(
          Double.valueOf(
              Arith.div(
                  firmSettleFee.getSettleFeeRate_S().doubleValue(),
                  new Double(100.0D).doubleValue())));
    }

    firmSettleFee.setModifyTime(getService().getSysDate());

    getService().update(firmSettleFee);

    addReturnValue(1, 119902L);

    writeOperateLog(
        1505,
        "修改特殊商品交收手续费! 交易商ID:"
            + firmSettleFee.getFirmID()
            + ",商品ID:"
            + firmSettleFee.getCommodityID(),
        1,
        "");

    return "success";
  }
  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 updateTradeMargin() throws Exception {
    this.logger.debug("enter updateTradeMargin");

    FirmTradeMargin firmTradeMargin = (FirmTradeMargin) this.entity;

    if (firmTradeMargin.getMarginAlgr().intValue() == 1) {
      firmTradeMargin.setMarginItem1(
          Double.valueOf(
              Arith.div(
                  firmTradeMargin.getMarginItem1().doubleValue(),
                  new Double(100.0D).doubleValue())));
      firmTradeMargin.setMarginItem1_S(
          Double.valueOf(
              Arith.div(
                  firmTradeMargin.getMarginItem1_S().doubleValue(),
                  new Double(100.0D).doubleValue())));
      firmTradeMargin.setMarginItemAssure1(
          Double.valueOf(
              Arith.div(
                  firmTradeMargin.getMarginItemAssure1().doubleValue(),
                  new Double(100.0D).doubleValue())));
      firmTradeMargin.setMarginItemAssure1_S(
          Double.valueOf(
              Arith.div(
                  firmTradeMargin.getMarginItemAssure1_S().doubleValue(),
                  new Double(100.0D).doubleValue())));
      if (firmTradeMargin.getMarginItem2() != null) {
        firmTradeMargin.setMarginItem2(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem2().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItem2_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem2_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure2(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure2().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure2_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure2_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
      }
      if (firmTradeMargin.getMarginItem3() != null) {
        firmTradeMargin.setMarginItem3(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem3().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItem3_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem3_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure3(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure3().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure3_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure3_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
      }
      if (firmTradeMargin.getMarginItem4() != null) {
        firmTradeMargin.setMarginItem4(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem4().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItem4_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem4_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure4(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure4().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure4_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure4_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
      }
      if (firmTradeMargin.getMarginItem5() != null) {
        firmTradeMargin.setMarginItem5(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem5().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItem5_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem5_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure5(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure5().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure5_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure5_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
      }
    }

    firmTradeMargin.setModifyTime(getService().getSysDate());

    getService().update(firmTradeMargin);

    addReturnValue(1, 119902L);

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

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

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

      if (firmTradeMargin.getMarginAlgr().intValue() == 1) {
        firmTradeMargin.setMarginItem1(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem1().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItem1_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItem1_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure1(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure1().doubleValue(),
                    new Double(100.0D).doubleValue())));
        firmTradeMargin.setMarginItemAssure1_S(
            Double.valueOf(
                Arith.div(
                    firmTradeMargin.getMarginItemAssure1_S().doubleValue(),
                    new Double(100.0D).doubleValue())));
        if (firmTradeMargin.getMarginItem2() != null) {
          firmTradeMargin.setMarginItem2(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItem2().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItem2_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItem2_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItemAssure2(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItemAssure2().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItemAssure2_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItemAssure2_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
        }
        if (firmTradeMargin.getMarginItem3() != null) {
          firmTradeMargin.setMarginItem3(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItem3().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItem3_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItem3_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItemAssure3(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItemAssure3().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItemAssure3_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItemAssure3_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
        }
        if (firmTradeMargin.getMarginItem4() != null) {
          firmTradeMargin.setMarginItem4(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItem4().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItem4_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItem4_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItemAssure4(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItemAssure4().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItemAssure4_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItemAssure4_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
        }
        if (firmTradeMargin.getMarginItem5() != null) {
          firmTradeMargin.setMarginItem5(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItem5().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItem5_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItem5_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItemAssure5(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItemAssure5().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeMargin.setMarginItemAssure5_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeMargin.getMarginItemAssure5_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
        }
      }

      firmTradeMargin.setModifyTime(getService().getSysDate());

      getService().add(firmTradeMargin);

      addReturnValue(1, 119901L);

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

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

    FirmTradeFee tradeFee = (FirmTradeFee) this.entity;

    if ((tradeFee.getFirmID() != null) && (!"".equals(tradeFee.getFirmID()))) {
      boolean flag = existCommoditySpecial(tradeFee.getFirmID(), tradeFee.getCommodityID());
      if (flag) {
        addReturnValue(-1, 151103L, new Object[] {"添加特殊商品交易手续费失败,已存在!"});
      } else {
        FirmTradeFee firmTradeFee = (FirmTradeFee) this.entity;

        if (firmTradeFee.getFeeAlgr().intValue() == 1) {
          firmTradeFee.setFeeRate_B(
              Double.valueOf(
                  Arith.div(
                      firmTradeFee.getFeeRate_B().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeFee.setFeeRate_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeFee.getFeeRate_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeFee.setHistoryCloseFeeRate_B(
              Double.valueOf(
                  Arith.div(
                      firmTradeFee.getHistoryCloseFeeRate_B().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeFee.setHistoryCloseFeeRate_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeFee.getHistoryCloseFeeRate_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeFee.setTodayCloseFeeRate_B(
              Double.valueOf(
                  Arith.div(
                      firmTradeFee.getTodayCloseFeeRate_B().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeFee.setTodayCloseFeeRate_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeFee.getTodayCloseFeeRate_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeFee.setForceCloseFeeRate_B(
              Double.valueOf(
                  Arith.div(
                      firmTradeFee.getForceCloseFeeRate_B().doubleValue(),
                      new Double(100.0D).doubleValue())));
          firmTradeFee.setForceCloseFeeRate_S(
              Double.valueOf(
                  Arith.div(
                      firmTradeFee.getForceCloseFeeRate_S().doubleValue(),
                      new Double(100.0D).doubleValue())));
        }

        firmTradeFee.setModifyTime(getService().getSysDate());

        getService().add(firmTradeFee);

        addReturnValue(1, 119901L);

        writeOperateLog(
            1505,
            "添加特殊商品交易手续费!交易商ID:"
                + firmTradeFee.getFirmID()
                + ",商品ID:"
                + firmTradeFee.getCommodityID(),
            1,
            "");
      }
    } else {
      List list = this.commodityIdService.firmIdList("desc");
      for (int i = 0; i < list.size(); i++) {
        Map map = (Map) list.get(i);
        Collection coll = map.values();
        Iterator iter = coll.iterator();

        tradeFee.setFirmID((String) iter.next());
        boolean flag = existCommoditySpecial(tradeFee.getFirmID(), tradeFee.getCommodityID());
        if (flag) {
          System.out.println("nihao");
        } else {
          FirmTradeFee firmTradeFee1 = new FirmTradeFee();
          BeanUtils.copyProperties(tradeFee, firmTradeFee1);

          firmTradeFee1.setModifyTime(getService().getSysDate());

          getService().add(firmTradeFee1);

          addReturnValue(1, 119901L);

          writeOperateLog(
              1505,
              "添加特殊商品交易手续费!交易商ID:"
                  + firmTradeFee1.getFirmID()
                  + ",商品ID:"
                  + firmTradeFee1.getCommodityID(),
              1,
              "");
        }
      }
    }

    return "success";
  }