예제 #1
0
  @Override
  public void run() {
    try {
      String result = request("https://pay.vivo.com.cn/vcoin/trade");
      JSONObject os = JSONObject.fromObject(orderform.getDeviceOS());
      os.put("channel_data", result);
      orderform.setDeviceOS(os.toString());

      OrderformHeartbeat.getInstance().execute(new AddOrderformRun(orderform));

      JSONObject jsonResult = JSONObject.fromObject(result);
      if ("200".equals(jsonResult.getString("respCode"))) {
        LoggerCharge.chargeOrder("success", orderInfo, orderform.getOrderform());
        JSONObject json = new JSONObject();
        json.put("code", 1);
        json.put("customData", orderform.getOrderform());
        json.put("message", "OK");
        json.put("channel_data", result);
        sendMessage(session, json.toString());
      } else {
        LoggerCharge.chargeOrder("fail", orderInfo, orderform.getOrderform());
        JSONObject json = new JSONObject();
        json.put("code", 2);
        json.put("message", "暂时无法充值");
        sendMessage(session, json.toString());
      }
    } catch (Exception e) {
      LoggerError.error("创建VIVO订单失败", e);
      JSONObject json = new JSONObject();
      json.put("code", 2);
      json.put("message", "暂时无法充值");
      sendMessage(session, json.toString());
    }
  }
예제 #2
0
  public void setData(IoSession session, ChargeOrderform orderform, String orderInfo) {
    this.session = session;
    this.orderform = orderform;
    this.orderInfo = orderInfo;
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("version", "1.0.0");
    parameters.put("signMethod", "MD5");
    parameters.put("cpId", ProjectCofigs.getParameter("vivo_cpId"));
    parameters.put("appId", ProjectCofigs.getParameter("vivo_appId"));
    parameters.put("cpOrderNumber", orderform.getOrderform());
    parameters.put("notifyUrl", ProjectCofigs.getParameter("notifyUri_vivo"));
    parameters.put(
        "orderTime", DateUtil.formatDate(new Date(orderform.getTimeCreate()), "yyyyMMddHHmmss"));
    parameters.put("orderAmount", orderform.getItemPrice() + "");
    parameters.put("orderTitle", orderform.getItemName());
    parameters.put("orderDesc", orderform.getItemName());
    parameters.put("extInfo", orderform.getRoleId() + "");

    StringBuilder sb = new StringBuilder();
    sb.append("appId=").append(ProjectCofigs.getParameter("vivo_appId"));
    sb.append("&cpId=").append(ProjectCofigs.getParameter("vivo_cpId"));
    sb.append("&cpOrderNumber=").append(orderform.getOrderform());
    sb.append("&extInfo=").append(orderform.getRoleId());
    sb.append("&notifyUrl=").append(ProjectCofigs.getParameter("notifyUri_vivo"));
    sb.append("&orderAmount=").append(orderform.getItemPrice());
    sb.append("&orderDesc=").append(orderform.getItemName());
    sb.append("&orderTime=").append(parameters.get("orderTime"));
    sb.append("&orderTitle=").append(parameters.get("orderTitle"));
    sb.append("&version=").append(parameters.get("version"));
    sb.append("&")
        .append(MD5.getHashString(ProjectCofigs.getParameter("vivo_cpKey").toLowerCase()));

    parameters.put("signature", MD5.getHashString(sb.toString()).toLowerCase());
    setParameter(HttpsUtil.httpBuildQuery(parameters));
  }