@Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.car_selectall:
        showLoading();
        LocalCarController.selectAll();
        hideLoading();
        refresh();
        break;

      case R.id.car_buy:
        if (User.getUser().isLogin()) {
          if (totalMoney > 0) {
            jump(LocalCarBuyFragment.class.getName(), "确认订单");
          } else {
            Notify.show("请选择要购买商品");
          }
        } else {
          Notify.show("请先登录");
          jump(UserLoginFragment.class.getName(), "登录");
        }
        break;

      default:
        break;
    }
  }
 private void initSignature() {
   TelephonyManager telephonyManager =
       (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
   SignatureTool.saveSignature(
       YtBox.encode(
           SignatureTool.key,
           User.getUser().getUseraccount() + "ytgogo" + telephonyManager.getDeviceId()));
 }
 private void phoneCharge() {
   List<RequestParam> requestParams = new ArrayList<>();
   requestParams.add(new RequestParam("phoneno", phoneNumber));
   requestParams.add(new RequestParam("pervalue", amounts[amountSelection] + ""));
   if (times[timeSelection] > 1) {
     requestParams.add(new RequestParam("mctype", (int) times[timeSelection] + ""));
   } else {
     requestParams.add(new RequestParam("mctype", times[timeSelection] + ""));
   }
   if (User.getUser().isLogin()) {
     requestParams.add(new RequestParam("memberAccount", User.getUser().getUseraccount()));
   }
   post(
       API.API_BIANMIN_PHONE_CHARGE,
       requestParams,
       new OnNetworkListener() {
         @Override
         public void onSuccess(String result) {
           if (!TextUtils.isEmpty(result)) {
             try {
               JSONObject object = new JSONObject(result);
               if (object.optString("state").equalsIgnoreCase("SUCCESS")) {
                 JSONObject dataMap = object.optJSONObject("dataMap");
                 ModelBianminOrderResult orderResult = new ModelBianminOrderResult(dataMap);
                 if (orderResult != null) {
                   if (orderResult.getSellPrice() > 0) {
                     payMoney(orderResult);
                     getActivity().finish();
                     return;
                   }
                 }
               }
               ApplicationTool.showToast(object.optString("message"));
             } catch (JSONException e) {
               e.printStackTrace();
             }
           }
         }
       });
 }
 private void getAddresses() {
   addresses.clear();
   addressAdapter.notifyDataSetChanged();
   List<RequestParam> requestParams = new ArrayList<>();
   requestParams.add(new RequestParam("memberAccount", User.getUser().getUseraccount()));
   post(
       API.API_USER_ADDRESS_LIST,
       requestParams,
       new OnNetworkListener() {
         @Override
         public void onSuccess(String result) {
           if (!TextUtils.isEmpty(result)) {
             JSONObject object;
             try {
               object = new JSONObject(result);
               if (object.optString("state").equalsIgnoreCase("SUCCESS")) {
                 JSONArray array = object.optJSONArray("dataList");
                 if (array != null) {
                   for (int i = 0; i < array.length(); i++) {
                     addresses.add(new ModelAddress(array.optJSONObject(i)));
                   }
                   if (addresses.size() > 0) {
                     addressAdapter.notifyDataSetChanged();
                     return;
                   }
                 }
               }
             } catch (JSONException e) {
               e.printStackTrace();
             }
             if (addresses.size() == 0) {
               missionNodata();
             }
           }
         }
       });
 }
 @Override
 protected void initViews() {
   numberEditText.setText(User.getUser().getPhone());
   amountGridView.setAdapter(amountAdapter);
   timeGridView.setAdapter(timeAdapter);
 }
  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("下单失败");
          }
        });
  }
  /**
   * 添加本地产品订单
   *
   * @author Tiger @Result {"message":"ok","state":"SUCCESS","cacheKey":null,"dataList":[{
   *     "servicetelephone" :"028-12345678","deliveryType":"送货上门","paymentType" :"1","orderDate"
   *     :"2015-10-16","servicename":"易田测试加盟店四","productInfo":
   *     "[{\"spname\":\"产品组-测试产品\",\"price\":\"33.0\",\"Amount\":\"66.0\",\"num\":\"2\"}]"
   *     ,"ordernumber":"YT5966059962","postagePrice":"满50.0包邮", "orderPrice"
   *     :"66.0","servicePhone":"13228116626"}],"totalCount":1, "dataMap":{},"object":null}
   */
  private void addLocalGoodsOrder() {
    Request request = new Request();
    request.setUrl(API.API_LOCAL_BUSINESS_GOODS_ORDER_ADD);
    request.addRequestParam("serviceProvidID", Store.getStore().getStoreId());
    request.addRequestParam("memberAccount", User.getUser().getUseraccount());
    request.addRequestParam("customerName", addressFragment.getAddress().getPersonName());
    request.addRequestParam("customerPhone", addressFragment.getAddress().getPhone());
    request.addRequestParam("retailOrderPrice", totalMoney + "");
    JSONArray data = new JSONArray();
    JSONArray deliveryInfo = new JSONArray();
    try {
      for (int i = 0; i < localCars.size(); i++) {
        JSONObject deliveryInfoObject = new JSONObject();
        deliveryInfoObject.put("supplyId", localCars.get(i).getStore().getId());
        deliveryInfoObject.put("deliveryType", localCars.get(i).getDiliver().getName());
        switch (localCars.get(i).getDiliver().getType()) {
          case ModelDiliver.TYPE_HOME:
            deliveryInfoObject.put(
                "address",
                addressFragment.getAddress().getAreaAddress()
                    + addressFragment.getAddress().getDetailedAddress());
            break;
          case ModelDiliver.TYPE_SELF:
            deliveryInfoObject.put("address", localCars.get(i).getStore().getServiceaddress());
            break;
          default:
            break;
        }
        deliveryInfoObject.put("paymentType", localCars.get(i).getPayment().getType());
        deliveryInfo.put(deliveryInfoObject);
        for (int j = 0; j < localCars.get(i).getCarGoods().size(); j++) {
          JSONObject dataObject = new JSONObject();
          ModelLocalCarGoods dataGoods = localCars.get(i).getCarGoods().get(j);
          dataObject.put("retailProductManagerID", dataGoods.getGoods().getId());
          dataObject.put("orderType", "0");
          dataObject.put("shopNum", dataGoods.getGoodsCount());
          dataObject.put("productPrice", dataGoods.getGoods().getRetailPrice());
          data.put(dataObject);
        }
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
    request.addRequestParam("data", data.toString());
    request.addRequestParam("deliveryInfo", deliveryInfo.toString());

    MissionController.startRequestMission(
        getActivity(),
        request,
        new RequestListener() {
          @Override
          protected void onStart() {
            showLoading("下单中,请稍候...");
          }

          @Override
          protected void onFail(MissionMessage missionMessage) {
            Notify.show("下单失败," + missionMessage.getMessage());
          }

          @Override
          protected void onSuccess(RequestMessage requestMessage) {
            if (!TextUtils.isEmpty(requestMessage.getResult())) {
              JSONObject object;
              try {
                object = new JSONObject(requestMessage.getResult());
                if (object.optString("state").equalsIgnoreCase("SUCCESS")) {
                  LocalCarController.deleteSelectedGoods();
                  Notify.show("下单成功");
                  JSONArray orderArray = object.optJSONArray("dataList");
                  if (orderArray != null) {
                    double payPrice = 0;
                    ArrayList<String> orderNumbers = new ArrayList<String>();
                    for (int i = 0; i < orderArray.length(); i++) {
                      ModelLocalGoodsOrderResult orderResult =
                          new ModelLocalGoodsOrderResult(orderArray.optJSONObject(i));
                      if (orderResult.getPaymentType() == ModelPayment.TYPE_ONLINE) {
                        orderNumbers.add(orderResult.getOrdernumber());
                        payPrice += orderResult.getOrderPrice();
                      }
                    }
                    if (orderNumbers.size() > 0) {
                      if (payPrice > 0) {
                        payMoney(orderNumbers, payPrice, PayFragment.ORDER_TYPE_LP);
                        getActivity().finish();
                        return;
                      }
                    }
                  }
                  showOrder(PayFragment.ORDER_TYPE_LP);
                  getActivity().finish();
                  return;
                } else {
                  hideLoading();
                  Notify.show(object.optString("message"));
                  return;
                }
              } catch (JSONException e) {
                hideLoading();
                Notify.show("下单失败");
                e.printStackTrace();
                return;
              }
            } else {
              hideLoading();
              Notify.show("下单失败");
            }
          }

          @Override
          protected void onFinish() {
            hideLoading();
          }
        });
  }