コード例 #1
0
ファイル: SMSService.java プロジェクト: tfy1010/trade
 /**
  * 通知SMS中心
  *
  * @param smsParam
  * @return
  */
 private boolean noticeSmsCenter(OrderBean orderBean, SmsParam smsParam, AlarmType alarmType) {
   boolean result = false;
   int cnum =
       orderAlarmService.countOrderAlarmByOrderNo(
           orderBean.getOrderNo(), alarmType, AlarmStatus.SUCCESS);
   if (cnum == 0) {
     String json = JSON.toJSONString(smsParam);
     try {
       String rsp = httpClientService.sendReqPost(smsUrl, json);
       if (!rsp.contains("200")) {
         log.error("短信接口返回 [" + rsp + "]");
         orderAlarmService.insertAlarmLog(orderBean, alarmType, AlarmStatus.FAIL, json, rsp);
       } else {
         orderAlarmService.insertAlarmLog(orderBean, alarmType, AlarmStatus.SUCCESS, json, rsp);
         result = true;
       }
     } catch (Exception e) {
       log.error("", e);
     }
   } else {
     log.error(
         "订单["
             + orderBean.getOrderNo()
             + "]已经存在发送短信[alarmtype:"
             + alarmType.value
             + "  value:"
             + AlarmStatus.SUCCESS.value
             + "]");
   }
   return result;
 }
コード例 #2
0
  @Test
  public void orderSubmit() {
    calculatePrice();
    String jsonParam = properties.getProperty("order.submit");
    QunarOrderSubmitParam inputs = JSON.parseObject(jsonParam, QunarOrderSubmitParam.class);
    assertNotNull(inputs);
    String thirdOrderNo = String.valueOf(System.currentTimeMillis());
    inputs.setqOrderId(thirdOrderNo);
    inputs.setTotalPrice(price);
    inputs.setPricemark(pricemark);
    inputs.setCarType(carType);
    QunarOrderSubmitDetail detail = inputs.getDetail();
    assertNotNull(detail);
    detail.setBasePrice(price);
    inputs.setDetail(detail);
    inputs.setSign(generateSign(inputs));
    jsonParam = JSON.toJSONString(inputs);

    try {
      String calculateResponse =
          http.postJSON("http://openapi.test.hbc.tech/ota/qunar/v2.0/orderSubmit", jsonParam);
      QunarOrderSubmitResult resultBean =
          JSON.parseObject(calculateResponse, QunarOrderSubmitResult.class);

      assertNotNull(resultBean);
      assertEquals(resultBean.getErrorCode(), new Integer(0));
      assertEquals(thirdOrderNo, resultBean.getqOrderId());
    } catch (IOException e) {
      e.printStackTrace();
      fail();
    }
  }
コード例 #3
0
 @Test
 @Ignore
 public void calculatePrice() {
   String jsonParam = properties.getProperty("calculate.price.others");
   QunarCalculatePriceParam inputs = JSON.parseObject(jsonParam, QunarCalculatePriceParam.class);
   inputs.setSign(generateSign(inputs));
   jsonParam = JSON.toJSONString(inputs);
   try {
     String calculateResponse =
         http.postJSON("http://openapi.test.hbc.tech/ota/qunar/v2.0/calculatePrice", jsonParam);
     QunarCalculatePriceResult resultBean =
         JSON.parseObject(calculateResponse, QunarCalculatePriceResult.class);
     assertNotNull(resultBean);
     QunarPriceDetail priceDetail = resultBean.price;
     assertNotNull(priceDetail);
     List<QunarPriceDetailTypes> types = priceDetail.types;
     assertNotNull(types);
     QunarPriceDetailTypes type = types.get(0);
     price = type.getPrice();
     assertNotNull(price);
     pricemark = resultBean.getPricemark();
     assertNotNull(pricemark);
     carType = type.getCarType();
     assertNotNull(carType);
   } catch (IOException e) {
     e.printStackTrace();
     fail();
   }
 }
コード例 #4
0
 @Test
 @Ignore
 public void orderCancel() {
   String jsonParam = properties.getProperty("order.cancel");
   QunarOrderCancelParam inputs = JSON.parseObject(jsonParam, QunarOrderCancelParam.class);
   String qOrderId = "gjc14526856784130248";
   inputs.setqOrderId(qOrderId);
   inputs.setSign(generateSign(inputs));
   jsonParam = JSON.toJSONString(inputs);
   try {
     String calculateResponse =
         http.postJSON("http://openapi.test.hbc.tech/ota/qunar/v2.0/orderCancel", jsonParam);
     QunarCancelOrderResult resultBean =
         JSON.parseObject(calculateResponse, QunarCancelOrderResult.class);
     assertNotNull(resultBean);
     assertEquals(resultBean.getqOrderId(), qOrderId);
   } catch (IOException e) {
     e.printStackTrace();
     fail();
   }
 }