Beispiel #1
0
  /**
   * @param publicModel
   * @param aggregatedAccountType 使用{AggregatedAccountType 这个类}
   * @return
   */
  public static String synchChartReportProtocal(
      RequestPublicModel publicModel, int aggregatedAccountType, String lastUpdate) {
    String result = null;
    try {
      JSONObject jsonObj = new JSONObject();
      JSONObject synchChartObj = new JSONObject();
      synchChartObj.put("bankName", publicModel.getBankName());
      synchChartObj.put("channel", publicModel.getChannel());
      synchChartObj.put("customerCode", publicModel.getCustomerCode());
      synchChartObj.put("enterpriseId", publicModel.getEnterpriseId());
      synchChartObj.put("serviceType", ServiceType.SYNCHCHART);
      synchChartObj.put("userAgent", publicModel.getUserAgent());
      synchChartObj.put("sessionId", publicModel.getSessionId());
      synchChartObj.put("token", publicModel.getToken());
      if (lastUpdate != null || !lastUpdate.equals("")) {
        synchChartObj.put("lastUpdate", lastUpdate);
      }
      synchChartObj.put("aggregatedAccountType", aggregatedAccountType);

      jsonObj.put("SynchChartRequest", synchChartObj);
      result = jsonObj.toString();
    } catch (Exception e) {
      LogManager.e("synchChartReportProtocal is error" + e.getLocalizedMessage());
    }
    return result;
  }
  /**
   * @param accountCode
   * @param publicModel
   * @param amount
   * @param purposeDescription
   * @param destCardCode
   * @param cardNumber
   * @param title
   * @param name
   * @return
   */
  public static String CheckRechargeCardReportProtocal(
      String accountCode,
      RequestPublicModel publicModel,
      double amount,
      String purposeDescription,
      String destCardCode,
      String cardNumber,
      String title,
      String name,
      String currency) {
    String result = null;
    try {
      JSONObject jsonObj = new JSONObject();
      JSONObject checkRechargeCardObj = new JSONObject();
      checkRechargeCardObj.put("serviceType", ServiceType.checkRechargeCard);
      checkRechargeCardObj.put("bankName", publicModel.getBankName());
      checkRechargeCardObj.put("enterpriseId", publicModel.getEnterpriseId());
      checkRechargeCardObj.put("customerCode", publicModel.getCustomerCode());
      checkRechargeCardObj.put("channel", publicModel.getChannel());
      checkRechargeCardObj.put("userAgent", publicModel.getUserAgent());
      checkRechargeCardObj.put("sessionId", publicModel.getSessionId());
      checkRechargeCardObj.put("token", publicModel.getToken());
      checkRechargeCardObj.put("amount", amount);
      checkRechargeCardObj.put("purposeDescription", purposeDescription);
      checkRechargeCardObj.put("destCardCode", destCardCode);
      checkRechargeCardObj.put("cardNumber", cardNumber);
      checkRechargeCardObj.put("title", title);
      checkRechargeCardObj.put("name", name);
      checkRechargeCardObj.put("accountCode", accountCode);
      checkRechargeCardObj.put("currency", currency);
      if (App.isNewPaymentsUpdate) {
        checkRechargeCardObj.put("transferCheck", true);
      }

      jsonObj.put("CheckRechargeCardRequest", checkRechargeCardObj);
      result = jsonObj.toString();
    } catch (Exception e) {
      LogManager.e("CheckRechargeCardReportProtocal is error" + e.getLocalizedMessage());
    }
    return result;
  }
  /**
   * @param json
   * @return
   */
  public static CheckRechargeCardResponseModel ParseCheckRechargeCardResponse(String json) {
    CheckRechargeCardResponseModel checkRechargeCardResponse = new CheckRechargeCardResponseModel();
    if (json == null) {
      return null;
    }

    try {
      JSONObject jsonObj = new JSONObject(json);
      JSONObject checkRechargeCardUpObj = jsonObj.getJSONObject("CheckRechargeCardResponse");

      checkRechargeCardResponse.responsePublicModel.setResultCode(
          checkRechargeCardUpObj.getInt("resultCode"));
      checkRechargeCardResponse.responsePublicModel.setResultDescription(
          checkRechargeCardUpObj.optString("resultDescription"));
      if (checkRechargeCardResponse.responsePublicModel.getResultCode() != 0) {
        JSONObject eventManagementObj = checkRechargeCardUpObj.getJSONObject("eventManagement");
        checkRechargeCardResponse.responsePublicModel.eventManagement.setErrorCode(
            eventManagementObj.optString("errorCode"));
        checkRechargeCardResponse.responsePublicModel.eventManagement.setErrorDescription(
            eventManagementObj.optString("errorDescription"));
        return checkRechargeCardResponse;
      }
      checkRechargeCardResponse.responsePublicModel.setTransactionId(
          checkRechargeCardUpObj.optString("transactionId"));

      if (App.isNewPaymentsUpdate) {
        checkRechargeCardResponse.setTransferId(checkRechargeCardUpObj.optString("transferId"));
      }
      checkRechargeCardResponse.setCharges(checkRechargeCardUpObj.optDouble("charges"));
      checkRechargeCardResponse.setExecutionDate(checkRechargeCardUpObj.optString("executionDate"));
      checkRechargeCardResponse.setSrcbankName(checkRechargeCardUpObj.optString("srcbankName"));
      checkRechargeCardResponse.setSrcBranchName(checkRechargeCardUpObj.optString("srcBranchName"));

    } catch (Exception e) {
      LogManager.e("ParseCheckRechargeCardResponse is error" + e.getLocalizedMessage());
    }
    return checkRechargeCardResponse;
  }
Beispiel #4
0
  public static SynchChartModel parseSynchChartResponse(String json) {

    SynchChartModel synchChartModel = new SynchChartModel();
    List<AggregatedAccount> aggregatedAccountsList = new ArrayList<AggregatedAccount>();
    if (json == null) {
      LogManager.d("parseSynchChartResponse" + "json null!");
      return null;
    }

    try {
      JSONObject jsonObj = new JSONObject(json);
      JSONObject synchChartObj = jsonObj.getJSONObject("SynchChartResponse");

      synchChartModel.responsePublicModel.setResultCode(synchChartObj.getInt("resultCode"));
      synchChartModel.responsePublicModel.setResultDescription(
          synchChartObj.optString("resultDescription"));
      if (synchChartModel.responsePublicModel.getResultCode() != 0) {
        JSONObject eventManagementObj = synchChartObj.getJSONObject("eventManagement");
        synchChartModel.responsePublicModel.eventManagement.setErrorCode(
            eventManagementObj.optString("errorCode"));
        synchChartModel.responsePublicModel.eventManagement.setErrorDescription(
            eventManagementObj.optString("errorDescription"));
        return synchChartModel;
      }

      synchChartModel.responsePublicModel.setTransactionId(
          synchChartObj.optString("transactionId"));
      JSONArray aggregatedAccountsArray = synchChartObj.optJSONArray("aggregatedAccounts");
      for (int i = 0; i < aggregatedAccountsArray.length(); i++) {
        AggregatedAccount aggregatedAccount = new AggregatedAccount();
        aggregatedAccount.setAccountCode(
            aggregatedAccountsArray.getJSONObject(i).optString("accountCode"));
        aggregatedAccount.setAggregatedAccountType(
            aggregatedAccountsArray.getJSONObject(i).optString("aggregatedAccountType"));
        aggregatedAccount.setAvailableBalance(
            aggregatedAccountsArray.getJSONObject(i).optDouble("availableBalance"));
        aggregatedAccount.setBankServiceCode(
            aggregatedAccountsArray.getJSONObject(i).optString("bankServiceCode"));
        aggregatedAccount.setTotalAmount(
            aggregatedAccountsArray.getJSONObject(i).optDouble("totalAmount"));
        JSONArray synchChartArray = aggregatedAccountsArray.getJSONObject(i).optJSONArray("charts");

        List<ChartModel> chartsList = new ArrayList<ChartModel>();
        for (int j = 0; j < synchChartArray.length(); j++) {
          ChartModel chartModel = new ChartModel();
          chartModel.setDate(synchChartArray.getJSONObject(j).optString("date"));
          chartModel.setInvestmentId(synchChartArray.getJSONObject(j).optInt("investmentId"));
          chartModel.setValue(synchChartArray.getJSONObject(j).optDouble("value"));
          chartsList.add(chartModel);
        }
        aggregatedAccount.setCharts(chartsList);
        aggregatedAccountsList.add(aggregatedAccount);

        add(aggregatedAccount);
      }
      synchChartModel.setAggregatedAccountsList(aggregatedAccountsList);
    } catch (Exception e) {
      LogManager.e("parseSynchChartResponse is error" + e.getLocalizedMessage());
    }

    return synchChartModel;
  }