/**
   * 获取所有选中的商品
   *
   * @return 商品数据
   */
  public static List<ModelLocalCar> getSelectedLocalCars() {
    // 创建集合用于存放选中的商品
    List<ModelLocalCar> selectedLocalCars = new ArrayList<ModelLocalCar>();
    try {
      // 获取所有购物车商品
      JSONArray array =
          new JSONArray(Content.getStringContent(Parameters.CACHE_KEY_CAR_LOCAL, "[]"));
      // 遍历所有店铺
      for (int i = 0; i < array.length(); i++) {
        // 创建单个店铺对象
        ModelLocalCar localCar = new ModelLocalCar(array.optJSONObject(i));
        // 单个店铺json数据
        JSONObject selectedObject = localCar.toJsonObject();
        if (selectedObject.has("goods")) {
          // 先去除店铺下所有的商品数据
          selectedObject.remove("goods");
        }
        // 用于存放选中的商品
        JSONArray selectedGoodsArray = new JSONArray();
        // 遍历店铺内添加的所有产品
        for (int j = 0; j < localCar.getCarGoods().size(); j++) {
          if (localCar.getCarGoods().get(j).isSelected()) {
            // 商品选中,则添加到新集合
            selectedGoodsArray.put(localCar.getCarGoods().get(j).toJsonObject());
          }
        }
        selectedObject.put("goods", selectedGoodsArray);
        ModelLocalCar selectedLocalCar = new ModelLocalCar(selectedObject);
        if (!selectedLocalCar.getCarGoods().isEmpty()) {
          selectedLocalCars.add(selectedLocalCar);
        }
      }

    } catch (JSONException e) {
      e.printStackTrace();
    }
    return selectedLocalCars;
  }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHolder holder;
   if (convertView == null) {
     convertView = layoutInflater.inflate(R.layout.list_car_buy, null);
     holder = new ViewHolder();
     holder.goodNameText = (TextView) convertView.findViewById(R.id.list_car_title);
     holder.goodsImageView = (ImageView) convertView.findViewById(R.id.list_car_image);
     holder.goodsPriceText = (TextView) convertView.findViewById(R.id.list_car_price);
     holder.guigeText = (TextView) convertView.findViewById(R.id.list_car_guige);
     holder.stateText = (TextView) convertView.findViewById(R.id.list_car_state);
     convertView.setTag(holder);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   ModelLocalCarGoods goods = localCar.getCarGoods().get(position);
   ImageLoader.getInstance()
       .displayImage(getSmallImageUrl(goods.getGoods().getBigImgUrl()), holder.goodsImageView);
   holder.goodNameText.setText(goods.getGoods().getRetailProdManagerName());
   holder.goodsPriceText.setText("¥" + decimalFormat.format(goods.getGoods().getRetailPrice()));
   holder.stateText.setText("×" + goods.getGoodsCount());
   return convertView;
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
      if (convertView == null) {
        convertView = layoutInflater.inflate(R.layout.list_car_local_goods, null);
        holder = new ViewHolder();
        holder.addButton = (ImageView) convertView.findViewById(R.id.list_car_count_add);
        holder.countText = (TextView) convertView.findViewById(R.id.list_car_count);
        holder.deleteButton = (ImageView) convertView.findViewById(R.id.list_car_count_delete);
        holder.goodNameText = (TextView) convertView.findViewById(R.id.list_car_title);
        holder.goodsImageView = (ImageView) convertView.findViewById(R.id.list_car_image);
        holder.goodsPriceText = (TextView) convertView.findViewById(R.id.list_car_price);
        holder.guigeText = (TextView) convertView.findViewById(R.id.list_car_guige);
        holder.stateText = (TextView) convertView.findViewById(R.id.list_car_state);
        holder.selectButton = (LinearLayout) convertView.findViewById(R.id.list_car_select);
        holder.selectionImageView = (ImageView) convertView.findViewById(R.id.list_car_selection);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }
      final ModelLocalCarGoods goods = localCar.getCarGoods().get(position);
      if (goods.isSelected()) {
        holder.selectionImageView.setImageResource(R.drawable.iconfont_check_checked);
      } else {
        holder.selectionImageView.setImageResource(R.drawable.iconfont_check_normal);
      }
      ImageLoader.getInstance()
          .displayImage(getSmallImageUrl(goods.getGoods().getBigImgUrl()), holder.goodsImageView);
      holder.goodNameText.setText(goods.getGoods().getRetailProdManagerName());
      holder.guigeText.setText(goods.getGoods().getAttName());
      holder.goodsPriceText.setText("¥" + decimalFormat.format(goods.getGoods().getRetailPrice()));
      holder.countText.setText(goods.getGoodsCount() + "");
      holder.addButton.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              showLoading();
              LocalCarController.addCount(goods);
              hideLoading();
              refresh();
            }
          });
      holder.deleteButton.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              showLoading();
              LocalCarController.deleteCount(goods);
              hideLoading();
              refresh();
            }
          });
      holder.selectButton.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              showLoading();
              LocalCarController.select(goods);
              hideLoading();
              refresh();
            }
          });
      return convertView;
    }
 @Override
 public Object getItem(int position) {
   return localCar.getCarGoods().get(position);
 }
 @Override
 public int getCount() {
   return localCar.getCarGoods().size();
 }