Ejemplo n.º 1
0
  @Override
  public void pack(Map<String, Object> fieldValues, ControlMessage cm, BusinessMessage bm)
      throws PacketOperationException {

    // 备付金密码
    FIXSTRINGPacketUtils.addFieldValue(fieldValues, "D_PREPAY_PWD", bm.getPrePayPwd());

    // 交易金额
    FIXSTRINGPacketUtils.addFieldValue(fieldValues, "D_AMOUNT", Double.toString(bm.getAmount()));

    // 用户号
    FIXSTRINGPacketUtils.addFieldValue(fieldValues, "D_USER_CODE", bm.getUserCode());

    // 附加响应数据
    FIXSTRINGPacketUtils.addFieldValue(fieldValues, "D_ADDITIONAL_TIP", bm.getAdditionalTip());

    // 货币代码
    FIXSTRINGPacketUtils.addFieldValue(fieldValues, "D_CURRENCY_CODE", bm.getCurrencyCode());

    // 自定义域
    FIXSTRINGPacketUtils.addFieldValue(fieldValues, "D_CUSTOM_FIELD", bm.getCustomField());

    // 原系统水流号
    FIXSTRINGPacketUtils.addFieldValue(fieldValues, "D_SYS_ORIGSEQNO", bm.getOrigSysJournalSeqno());
  }
Ejemplo n.º 2
0
  @Override
  protected boolean getTempValue(ControlMessage cm, BusinessMessage bm) {
    try {
      TempData cashTemp = (TempData) baseHibernateDao.get(TempData.class, bm.getOldPbSeqno());
      if (cashTemp == null) {
        bm.setResponseCode(GlobalConst.RESPONSECODE_FAILURE);
        bm.setResponseMsg("缴费失败,请拨打客服电话咨询!");
        cm.setResultCode(GlobalConst.RESULTCODE_FAILURE);
        cm.setResultMsg("缴费失败,现金查询时没有保存水费明细数据等重要信息!");
        logger.info("现金查询时,水费明细数据等信息没有保存,商户号:{} ", bm.getShopCode());
        return false;
      }

      String str = cashTemp.getTempValue();
      String[] savedStr = str.split("\\|");
      String userno = savedStr[0]; // 用户编号
      String userName = savedStr[1]; // 用户名称
      Double sumFee = Double.parseDouble(savedStr[2]); // 应缴金额
      String recNum = savedStr[3]; // 欠费月数

      // 缴费金额必须大于应缴金额
      //			if (sumFee > bm.getAmount()) {
      //				cm.setResultCode(GlobalConst.RESULTCODE_FAILURE);
      //				cm.setResultMsg("缴费金额小于应缴金额!");
      //				bm.setResponseCode(GlobalConst.RESPONSECODE_FAILURE);
      //				bm.setResponseMsg("缴费金额小于应缴金额!");
      //				return false;
      //			}
      WaterCashData waterCashData = new WaterCashData();
      // 用户编号
      waterCashData.setUserNo(userno);
      // 用户编号
      waterCashData.setUsername(userName);
      bm.setUserName(userName);
      // 应收总额
      waterCashData.setSumFee(String.valueOf(sumFee));
      // 缴费金额
      waterCashData.setPayAmt(String.valueOf(bm.getAmount()));
      // 水费欠费月数
      waterCashData.setRecNum(recNum);
      // 凭证号码,如没有提供默认值
      waterCashData.setCertNo("");
      // 凭证类型,如没有提供默认值
      waterCashData.setVoucKind("");

      bm.setCustomData(waterCashData);
    } catch (Exception e) {
      bm.setResponseCode(GlobalConst.RESPONSECODE_FAILURE);
      bm.setResponseMsg("缴费不正常,请拨打客服电话咨询!");
      cm.setResultCode(GlobalConst.RESULTCODE_FAILURE);
      cm.setResultMsg("缴费不正常,请拨打客服电话咨询!");
      logger.error("缴费不正常!请查询表:CashTemp.商户号" + bm.getShopCode());
    }
    return true;
  }
Ejemplo n.º 3
0
  @Test
  public void test8583Pay() {
    // 备付金明细查询	000005

    /*00676000038009602200000857020000
    20000100c08019110120001030323831
    39313430363531323334353637382020
    20202020202020202020303532313031
    39342020202020202020202020203135
    36000005001132303131303832383030
    312dddd89cca21af63*/

    String hexString =
        "00676000038009602200000857020000"
            + "20000100c08019110120001030323831"
            + "39313430363531323334353637382020"
            + "20202020202020202020303532313031"
            + "39342020202020202020202020203135"
            + "36000005001132303131303832383030"
            + "312dddd89cca21af63";

    // unpack
    ControlMessage cm = new ControlMessage();
    cm.setChanelType(CHANEL_TYPE.POS);
    BusinessMessage bm = new BusinessMessage();
    byte[] origPacket = ConvertUtils.hexStr2Bytes(hexString);
    Map<DATA_TYPE, Object> map = new HashMap<DATA_TYPE, Object>();
    map.put(DATA_TYPE.ORIGREQPACKET, origPacket);
    map.put(DATA_TYPE.CONTROLOBJECT, cm);
    map.put(DATA_TYPE.BUSINESSOBJECT, bm);
    try {
      packetHelperISO8583.unpackObject(map);
    } catch (PacketOperationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    cm = (ControlMessage) map.get(DATA_TYPE.CONTROLOBJECT);
    bm = (BusinessMessage) map.get(DATA_TYPE.BUSINESSOBJECT);
    System.out.println("msgtype: " + cm.getPacketHeader().getMessageType());
    assertEquals("0200", cm.getPacketHeader().getMessageType());
    assertEquals(new Double(0.00), new Double(bm.getAmount()));
    assertEquals("000005", bm.getTranCode());

    cm.setResultCode("000000");
    bm.setLocalDate("20110830");
    bm.setLocalTime("123143");
    bm.setPbSeqno("12405");

    Map<DATA_TYPE, Object> message = new HashMap<DATA_TYPE, Object>();
    message.put(DATA_TYPE.CONTROLOBJECT, cm);
    message.put(DATA_TYPE.BUSINESSOBJECT, bm);

    // pack
    try {
      packetHelperISO8583.packBuffer(message);
      String resultHexString =
          ConvertUtils.bytes2HexStr((byte[]) PacketUtils.getOrigAnsPacket(message));
      System.out.println(resultHexString);
    } catch (PacketOperationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }