Exemplo n.º 1
0
 public static void main(String[] args) {
   Map<String, Object> paramMap = new HashMap<>();
   paramMap.put("orderId", "D000000000913182");
   paramMap.put("transId", "20151203155117187130810888661617");
   paramMap.put("status", 3);
   paramMap.put(
       "failedReason",
       "8888:产品200M全国流量订购失败。失败描述:[INDETERMINATE]Utility.cpp:207,CRMException-300263: TCS_ChangeServiceReg执行异常:[INDETERMINATE]TradeCheckTradeSuperLimit.cpp:403,CRMException-300263: 特殊限制判断:用户必选3种服务EDGE+服务,接入2G网络,3G上网服务 中的一个才能继续受理业务!");
   String sign =
       OpenSign.getSign(
           paramMap,
           DESUtil.decryptToString(
               "6fugMFC5BEB92yolInanfVN0kZ7ztdAXmMghhv6j7dBW1DIxbSYX9Q==", "sd_yafeida"));
   System.out.println(sign);
 }
Exemplo n.º 2
0
  /** 执行回调 */
  public void doCallback(Callback callback) {
    long begin = System.currentTimeMillis();

    Map<String, Object> paramMap = new HashMap<>();
    String notifyUrl = callback.getNotifyUrl();
    String result = null;
    try {
      // 回调地址不为空才执行回调;
      if (!StringUtils.hasText(notifyUrl)) {
        return;
      }

      // 获取用户密钥
      String secret = getSecret(callback.getUserName());
      if (secret == null) {
        return;
      }

      paramMap.put("orderId", callback.getOrderId());
      paramMap.put("transId", callback.getTransId());
      paramMap.put("status", callback.getRechargeState().ordinal());
      paramMap.put("failedReason", callback.getFailedReason());
      String sign = OpenSign.getSign(paramMap, secret);
      paramMap.put("sign", sign);

      result =
          callbackRestTemplate.getForObject(
              notifyUrl
                  + "?orderId={orderId}&transId={transId}&status={status}&failedReason={failedReason}&sign={sign}",
              String.class,
              paramMap);

    } catch (Exception ex) {
      callbackLogger.warn(
          "回调失败; notifyUrl:{}, paramMap:{}, exMsg:{}", notifyUrl, paramMap, ex.getMessage());
    } finally {
      callbackLogger.info(
          "回调结束; notifyUrl:{}, paramMap:{}; result:{}; costTime:{}",
          notifyUrl,
          paramMap,
          result,
          (System.currentTimeMillis() - begin));
    }
  }