private double countTotalPrice() { double totalPrice = 0; if (orderProduct.isSale()) { totalPrice = orderProduct.getSalePrice() * orderProduct.getBuyCount(); } else { totalPrice = product.getPrice() * orderProduct.getBuyCount(); } return totalPrice; }
private void deleteCount() { if (orderProduct.getBuyCount() > 1) { orderProduct.setBuyCount(orderProduct.getBuyCount() - 1); } if (orderProduct.getBuyCount() == 1) { countDeleteButton.setClickable(false); } countAddButton.setClickable(true); countTextView.setText(orderProduct.getBuyCount() + ""); totalPriceTextView.setText(Parameters.CONSTANT_RMB + decimalFormat.format(countTotalPrice())); }
private void showProductInfo() { ImageLoader.getInstance().displayImage(product.getImg(), imageView); nameTextView.setText(product.getProductName()); if (orderProduct.isSale()) { priceTextView.setText( Parameters.CONSTANT_RMB + decimalFormat.format(orderProduct.getSalePrice())); } else { priceTextView.setText(Parameters.CONSTANT_RMB + decimalFormat.format(product.getPrice())); } countTextView.setText(orderProduct.getBuyCount() + ""); additionTextView.setText(orderProduct.getAddition()); totalPriceTextView.setText(Parameters.CONSTANT_RMB + decimalFormat.format(countTotalPrice())); }
private void buy() { List<RequestParam> requestParams = new ArrayList<>(); requestParams.add(new RequestParam("userNumber", User.getUser().getUseraccount())); requestParams.add( new RequestParam("customerName", addressFragment.getAddress().getPersonName())); requestParams.add(new RequestParam("phone", addressFragment.getAddress().getPhone())); requestParams.add( new RequestParam( "shippingaddress", addressFragment.getAddress().getAreaAddress() + addressFragment.getAddress().getDetailedAddress())); requestParams.add(new RequestParam("totalMoney", countTotalPrice() + "")); requestParams.add(new RequestParam("sex", User.getUser().getSex())); requestParams.add(new RequestParam("age", User.getUser().getAge())); requestParams.add(new RequestParam("address", Store.getStore().getStoreArea())); requestParams.add(new RequestParam("jmdId", Store.getStore().getStoreId())); requestParams.add(new RequestParam("orderType", "0")); JSONArray orderArray = new JSONArray(); try { JSONObject object = new JSONObject(); object.put("productIds", productId); object.put("shopNum", orderProduct.getBuyCount()); if (orderProduct.isSale()) { object.put("price", orderProduct.getSalePrice()); } else { object.put("price", product.getPrice()); } switch (saleType) { case CaptureActivity.SALE_TYPE_MIAOSHA: object.put("isIntegralMall", 2); break; default: object.put("isIntegralMall", 0); break; } orderArray.put(object); } catch (JSONException e) { e.printStackTrace(); } requestParams.add(new RequestParam("data", orderArray.toString())); post( API.API_ORDER_ADD_CENTER, requestParams, new OnNetworkListener() { @Override public void onSuccess(String result) { if (!TextUtils.isEmpty(result)) { JSONObject object; try { object = new JSONObject(result); if (object.getString("state").equalsIgnoreCase("SUCCESS")) { Toast.makeText(getActivity(), "下单成功", Toast.LENGTH_SHORT).show(); if (paymentFragment.getPaymentType() == OrderConfirmPartPaymentFragment.PAY_TYPE_CODE_ONLINE) { payMoney(object.optJSONArray("object")); getActivity().finish(); return; } showOrder(PayFragment.ORDER_TYPE_YY); getActivity().finish(); return; } else { ApplicationTool.showToast(object.optString("message")); return; } } catch (JSONException e) { ApplicationTool.showToast("下单失败"); e.printStackTrace(); return; } } ApplicationTool.showToast("下单失败"); } }); }
private void addCount() { if (orderProduct.isSale()) { if (orderProduct.getMaxBuyCount() > 0) { if (orderProduct.getMaxBuyCount() > orderProduct.getStock()) { if (orderProduct.getBuyCount() < orderProduct.getStock()) { orderProduct.setBuyCount(orderProduct.getBuyCount() + 1); } if (orderProduct.getBuyCount() == orderProduct.getStock()) { countAddButton.setClickable(false); } } else { if (orderProduct.getBuyCount() < orderProduct.getMaxBuyCount()) { orderProduct.setBuyCount(orderProduct.getBuyCount() + 1); } if (orderProduct.getBuyCount() == orderProduct.getMaxBuyCount()) { countAddButton.setClickable(false); } } } else if (orderProduct.getStock() > 0) { if (orderProduct.getBuyCount() < orderProduct.getStock()) { orderProduct.setBuyCount(orderProduct.getBuyCount() + 1); } if (orderProduct.getBuyCount() == orderProduct.getStock()) { countAddButton.setClickable(false); } } else { if (orderProduct.getBuyCount() < product.getNum()) { orderProduct.setBuyCount(orderProduct.getBuyCount() + 1); } if (orderProduct.getBuyCount() == product.getNum()) { countAddButton.setClickable(false); } } } else { if (orderProduct.getBuyCount() < product.getNum()) { orderProduct.setBuyCount(orderProduct.getBuyCount() + 1); } if (orderProduct.getBuyCount() == product.getNum()) { countAddButton.setClickable(false); } } countDeleteButton.setClickable(true); countTextView.setText(orderProduct.getBuyCount() + ""); totalPriceTextView.setText(Parameters.CONSTANT_RMB + decimalFormat.format(countTotalPrice())); }