Exemplo n.º 1
0
        @Override
        public void getChar(
            String oid,
            String type,
            String ip,
            String currency,
            String couponId,
            final CtFetchCallback<String> callback) {
          LogHelper.e(TAG, TextUtils.join("|", new String[] {oid, type, ip, currency, couponId}));
          OrderBusiness.getCharge(
              ((PayOrderAcivity) iPayOrderView),
              mClient,
              new LabAsyncHttpResponseHandler() {
                @Override
                public void onSuccess(LabResponse response, Object data) {
                  callback.onSuc(String.valueOf(data));
                }

                @Override
                public void onFailure(LabResponse response, Object data) {
                  String msg = response.msg;
                  if (TextUtils.isEmpty(msg)) {
                    msg = PlatformUtil.getInstance().getString(R.string.ct_pay_failed);
                  }
                  callback.onFailed(new CtException(msg));
                }
              },
              oid,
              type,
              ip,
              currency,
              couponId);
        }
Exemplo n.º 2
0
        @Override
        public void needCharge(
            String oid, String currency, String couponId, final CtFetchCallback<Boolean> callback) {
          LogHelper.e(TAG, TextUtils.join("|", new String[] {oid, currency, couponId}));
          OrderBusiness.getFinalPrice(
              ((PayOrderAcivity) iPayOrderView),
              mClient,
              new LabAsyncHttpResponseHandler() {
                @Override
                public void onSuccess(LabResponse response, Object data) {
                  LogHelper.e(TAG, " need char " + String.valueOf(response.result));
                  JSONObject jsonObject = JSONObject.parseObject(String.valueOf(data));
                  double value = 0;

                  try {
                    value = Double.valueOf(jsonObject.getString("finalPrice"));
                  } catch (NumberFormatException e) {
                    value = 1;
                  }
                  callback.onSuc(value > 0);
                }

                @Override
                public void onFailure(LabResponse response, Object data) {
                  String msg = response.msg;
                  if (TextUtils.isEmpty(msg)) {
                    msg = PlatformUtil.getInstance().getString(R.string.ct_pay_failed);
                  }
                  callback.onFailed(new CtException(msg));
                }
              },
              oid,
              currency,
              couponId);
        }
Exemplo n.º 3
0
        @Override
        public void setDiscount(String oid, String discountCode, final CtApiCallback callback) {
          OrderBusiness.payOrder(
              ((PayOrderAcivity) iPayOrderView),
              mClient,
              new LabAsyncHttpResponseHandler() {
                @Override
                public void onSuccess(LabResponse response, Object data) {
                  callback.onSuc();
                }

                @Override
                public void onFailure(LabResponse response, Object data) {
                  String msg = response.msg;
                  if (TextUtils.isEmpty(msg)) {
                    msg = PlatformUtil.getInstance().getString(R.string.ct_pay_failed);
                  }
                  callback.onFailed(new CtException(msg));
                }
              },
              oid,
              discountCode);
        }
Exemplo n.º 4
0
        @Override
        public void fetchPayOrder(String oid, final CtFetchCallback<PayOrderMode> callback) {
          final AtomicInteger count = new AtomicInteger(2);
          OrderBusiness.getOrderInfo(
              ((PayOrderAcivity) iPayOrderView),
              mClient,
              new LabAsyncHttpResponseHandler(OrderItem.class) {
                @Override
                public void onSuccess(LabResponse response, Object data) {

                  orderItem = ((OrderItem) data);
                  count.decrementAndGet();
                  onResult(count, callback, orderItem, discountItems);
                }

                @Override
                public void onFailure(LabResponse response, Object data) {
                  String reason;
                  if (response != null && !TextUtils.isEmpty(response.msg)) {
                    reason = response.msg;
                  } else {
                    reason =
                        PlatformUtil.getInstance().getString(R.string.ct_get_order_detail_failed);
                  }
                  callback.onFailed(new CtException(reason));
                }
              },
              String.valueOf(oid));

          OrderBusiness.getValidCoupon(
              ((PayOrderAcivity) iPayOrderView),
              mClient,
              new LabAsyncHttpResponseHandler() {
                @Override
                public void onSuccess(LabResponse response, Object data) {
                  LogHelper.e(TAG, " result " + String.valueOf(response.result));
                  try {
                    JSONObject jsonObject = JSONObject.parseObject(String.valueOf(response.result));

                    LogHelper.e(TAG, " result  list s " + jsonObject.getString("lists"));
                    discountItems =
                        JSON.parseArray(jsonObject.getString("lists"), DiscountItem.class);

                  } catch (Exception e) {
                    LogHelper.e(TAG, " result  error" + e.getMessage());
                  }
                  if (discountItems == null) {
                    discountItems = new ArrayList<>();
                  }
                  count.decrementAndGet();
                  onResult(count, callback, orderItem, discountItems);
                }

                @Override
                public void onFailure(LabResponse response, Object data) {
                  String reason;
                  if (response != null && !TextUtils.isEmpty(response.msg)) {
                    reason = response.msg;
                  } else {
                    reason =
                        PlatformUtil.getInstance().getString(R.string.ct_get_order_detail_failed);
                  }
                  callback.onFailed(new CtException(reason));
                }
              },
              UnitUtils.getMoneyType());
        }