/** 晒单录入操作 */
  @RequestMapping("/orderInput.json")
  @ResponseBody
  public JsonResult orderInput(
      Long dynamicId,
      Long userId,
      @RequestParam(value = "stockCode") String[] stockCodes,
      @RequestParam(value = "num") Long[] nums,
      @RequestParam(value = "tradeType") String[] tradeTypes,
      @RequestParam(value = "tradePrice") Double[] tradePrices,
      String auditDesc,
      Long parentGroupId,
      HttpServletRequest request) {
    // 查询晒单的动态记录
    UserDynamicInfo userDynamicInfo = userDynamicInfoService.findById(dynamicId);
    userDynamicInfo.setAuditDesc(auditDesc);

    List<Trade> trades = new ArrayList<Trade>();
    for (int i = 0; i < stockCodes.length; i++) {
      String stockCode = stockCodes[i];
      Trade trade = new Trade();
      trade.setUserId(userId);

      Stock stock = stockService.findByStockCode(stockCode);
      trade.setStockId(stock.getStockId());
      trade.setStockCode(stockCode);
      trade.setStockName(stock.getStockName());
      if (tradePrices != null && tradePrices.length > i) {
        trade.setTradePrice(tradePrices[i]);
      }
      if (nums != null && nums.length > i) {
        trade.setTradeNumber(nums[i]);
      }
      trade.setTurnoverAmount(
          MathUtil.mul(
              (trade.getTradePrice() == null ? 0 : trade.getTradePrice()), trade.getTradeNumber()));
      trade.setTradeType(tradeTypes[i]);
      trade.setIsRevoke(TradeIsRevokeEnum.N.getCode());
      trade.setTradeDate(userDynamicInfo.getCreateDate());
      trade.setTradeTime(userDynamicInfo.getCreateDate());
      Date currDate = new java.util.Date();
      trade.setCreateDate(currDate);
      trade.setUpdateDate(currDate);
      trade.setTradeDate(currDate);
      trade.setTradeTime(currDate);
      trade.setShareholderCode(stock.getStockCode());
      trades.add(trade);
    }
    // 添加晒单
    userDynamicInfoService.addOrder(userDynamicInfo, trades, userId, parentGroupId);

    // return jsonResultHelper.buildFailJsonResult(UserDynamicInfoResultCode.SIGN_ERROR);
    return jsonResultHelper.buildSuccessJsonResult(true);
  }
  /** 晒单作废操作 */
  @RequestMapping("/orderInputCancel.json")
  @ResponseBody
  public JsonResult orderInputCancel(Long dynamicId, String auditDesc) {
    // 查询晒单的动态记录
    UserDynamicInfo userDynamicInfo = userDynamicInfoService.findById(dynamicId);
    userDynamicInfo.setAuditDesc(auditDesc);

    // 将此条记录修改成审批通过
    userDynamicInfo.setAuditDate(new java.util.Date());
    userDynamicInfo.setAuditName(AuthUtil.getUserName());
    userDynamicInfo.setAuditStatus(UserDynamicInfoAuditStatusEnum.D.getCode());
    userDynamicInfo.setIsInput(UserDynamicInfoIsInputEnum.Y.getCode());
    userDynamicInfoService.update(userDynamicInfo);
    return jsonResultHelper.buildSuccessJsonResult(null);
  }
  /**
   * 晒单信息屏蔽
   *
   * @param dynamic_id
   * @return
   */
  @RequestMapping("/orderCancel.json")
  @ResponseBody
  public String orderCancel(Long dynamic_id, String auditDesc) {
    logger.info("晒单信息屏蔽: dynamic_id", dynamic_id);
    String status = "1";
    try {
      UserDynamicInfo userDynamicInfo = userDynamicInfoService.findById(dynamic_id);
      userDynamicInfo.setAuditStatus(UserDynamicInfoAuditStatusEnum.D.getCode());
      userDynamicInfo.setAuditDesc(auditDesc);
      userDynamicInfo.setAuditDate(new Date());
      Long userId = AuthUtil.getUserId();
      UUser user = uUserService.findById(userId);
      userDynamicInfo.setAuditName(user.getFullname());
      userDynamicInfoService.update(userDynamicInfo);
    } catch (Exception e) {
      e.printStackTrace();
      status = "2";
      logger.error("晒单信息屏蔽异常: dynamic_id=" + dynamic_id, e);
    }

    return status;
  }