/**
   * 通关
   *
   * @param passPortInfo
   */
  public void pass(PassPortInfo passPortInfo) {
    boolean flag = false;
    Long adultQuantity = 0l;
    Long childQuantity = 0l;
    long realTotal = passPortInfo.getAdult().intValue() + passPortInfo.getChild().intValue();
    if (passPortInfo.getTotalMan().intValue() != realTotal) {
      adultQuantity = passPortInfo.getAdult();
      childQuantity = passPortInfo.getChild();
    }
    if (passPortInfo.getSerialNo() != null) {
      // 二维码信息更新
      PassPortCode passPortCode =
          passCodeService.getPassPortCodeByCodeIdAndPortId(
              passPortInfo.getCodeId(), passPortInfo.getTargetId());
      passPortCode.setStatus(Constant.PASSCODE_USE_STATUS.USED.name());
      passPortCode.setUsedTime(new Date());
      // 更新通关点信息
      passCodeService.updatePassPortCode(passPortCode);
      flag =
          this.addPerform(
              passPortInfo.getOrderId(), passPortInfo.getTargetId(), adultQuantity, childQuantity);

    } else {
      flag =
          this.addPerform(
              passPortInfo.getOrderId(), passPortInfo.getTargetId(), adultQuantity, childQuantity);
    }
    if (flag) {
      ZkMessage.showInfo("凭证正常通关");
      this.closeWindow();
    } else {
      this.closeWindow();
      ZkMessage.showInfo("该订单已经履行");
    }
  }
  @SuppressWarnings({"unchecked", "rawtypes"})
  private Map<String, List<String>> checkAllApplySuccess(PassCode passCode) {

    /*
     * 检查订单中所有由非服务商发送短信、独立申码、并且开通了凭证短信合并功能
     * 的所有短信是否都已经生成,然后按服务商分组passCode
     *
     * 按服务商分组passCode的目的是,各服务商的凭证短信单独发送
     */
    Map params = new HashMap();
    params.put("orderId", passCode.getOrderId());
    List<PassPortCode> passportcodeList = passCodeService.selectAllMergeSmsByParams(params);

    int mergeCount = 0;
    if (passCode.getCodeTotal().intValue() == passportcodeList.size()) {
      for (PassPortCode passportcode : passportcodeList) {
        // 剔除非合并凭证短信的通关码
        if (!passportcode.isMergeCertificateSMS()) {
          if (otherPassportcodeList == null) {
            otherPassportcodeList = new ArrayList();
          }
          otherPassportcodeList.add(passportcode);

          continue;
        }
        mergeCount++;
      }
    } else {
      return null;
    }

    params.put("checkSmsContent", "true");
    List<PassPortCode> passportcodeStatusList = passCodeService.selectAllMergeSmsByParams(params);
    log.info(passportcodeStatusList.size());
    // 所有的合并凭证短信的码,都已经申码成功、生成短信内容片段成功
    if (mergeCount == passportcodeStatusList.size()) {
      Map<String, List<String>> groupPassPortCode = new HashMap<String, List<String>>();
      for (PassPortCode passportcode : passportcodeStatusList) {
        String providerName = passportcode.getProviderName();
        Long codeId = passportcode.getCodeId();
        List<String> codeList = groupPassPortCode.get(providerName);
        if (codeList == null) {
          codeList = new ArrayList<String>();
        }
        codeList.add(codeId.toString());
        groupPassPortCode.put(providerName, codeList);
      }
      return groupPassPortCode;
    }

    return null;
  }
  private void singleSmsInMerged(PassCode passCode, boolean mergeCertificateSMS) {
    List<OrdOrderItemMeta> ordItemMetaList = null;
    OrdOrderItemMeta itemMeta = null;
    if (passCode.isForOrder()) {
      ordItemMetaList = orderServiceProxy.queryOrdOrderItemMetaByOrderId(passCode.getOrderId());
      itemMeta = ordItemMetaList.get(0);
    } else {
      itemMeta = orderServiceProxy.queryOrdOrderItemMetaBy(passCode.getObjectId());
    }
    OrdOrderItemProd ordItemProd =
        orderServiceProxy.queryOrdOrderItemProdById(itemMeta.getOrderItemId());
    ProdProductBranch prodProductBranch =
        prodProductBranchDAO.selectByPrimaryKey(ordItemProd.getProdBranchId());

    // 凭证短信合并发送,并且是各子子项独立申码
    if (mergeCertificateSMS && passCode.isForOrderItemMeta() && generateSMS) {
      // 【${销售类别} 取票码 ${code},辅助码xxxx ,含${adult} ${chaild}】
      String formatString = "【%s %s,%s,%s】";

      String branchName = prodProductBranch.getBranchName();
      String code = "";
      if (!"BASE64".equalsIgnoreCase(passCode.getCode())) {
        code = "取票码 " + passCode.getCode();
      }
      String addCode = passCode.getAddCode();

      if (StringUtils.isNotEmpty(addCode)) {
        addCode = "辅助码 " + addCode;
      } else {
        addCode = "";
      }

      long adult = ordItemProd.getQuantity() * prodProductBranch.getAdultQuantity();
      long child = ordItemProd.getQuantity() * prodProductBranch.getChildQuantity();

      StringBuilder quantity = new StringBuilder();
      if (itemMeta.isStudent()) {
        quantity.append("学生人数:" + (adult + child));
      } else {
        quantity.append("含");
        if (adult > 0) {
          quantity.append(adult + "成人  ");
        }
        if (child > 0) {
          quantity.append(child + "儿童");
        }
      }
      String smsContent = String.format(formatString, branchName, code, addCode, quantity);
      log.info("=====singleSmsInMerged smsContent===========" + smsContent);
      PassCode temp = new PassCode();
      temp.setCodeId(passCode.getCodeId());
      temp.setSmsContent(smsContent);
      passCodeService.updatePassCode(temp);
    }
  }
  @Override
  Map<String, Object> getContentData() {
    Map<String, Object> data = new HashMap<String, Object>();

    StringBuffer content = new StringBuffer();
    content.append(productName);

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("codeList", codeIds);
    List<PassCode> passCodeList = passCodeService.queryPassCodeByParam(params);
    for (PassCode passCode : passCodeList) {
      content.append(passCode.getSmsContent());
    }

    data.put("orderId", objectId);
    data.put("visitDate", DateUtil.formatDate(order.getVisitTime(), "yyyy-MM-dd"));
    data.put("content", content.toString());
    return data;
  }