public static int selectStore(ModelLocalCar localCar) {
   List<ModelLocalCar> localCars = getLocalCars();
   boolean b = !localCar.isSelected();
   for (int i = 0; i < localCars.size(); i++) {
     if (localCars.get(i).getStore().getNo().equals(localCar.getStore().getNo())) {
       // 定位到此店铺,遍历店铺下所有产品,修改选择状态
       for (int j = 0; j < localCars.get(i).getCarGoods().size(); j++) {
         localCars.get(i).getCarGoods().get(j).setSelected(b);
       }
       break;
     }
   }
   return save(localCars);
 }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHolder holder;
   if (convertView == null) {
     convertView = layoutInflater.inflate(R.layout.list_local_car_buy, null);
     holder = new ViewHolder();
     holder.storeTextView = (TextView) convertView.findViewById(R.id.local_car_store_name);
     holder.goodsListView = (InnerListView) convertView.findViewById(R.id.local_car_goods);
     holder.diliverTextView = (TextView) convertView.findViewById(R.id.local_car_store_diliver);
     holder.paymentTextView = (TextView) convertView.findViewById(R.id.local_car_store_pay);
     holder.moneyTextView = (TextView) convertView.findViewById(R.id.local_car_store_money);
     holder.moneyDetailTextView =
         (TextView) convertView.findViewById(R.id.local_car_store_money_detail);
     convertView.setTag(holder);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   ModelLocalCar localCar = localCars.get(position);
   holder.storeTextView.setText(localCar.getStore().getServicename());
   holder.goodsListView.setAdapter(new CarGoodsAdapter(localCar));
   holder.diliverTextView.setText(localCar.getDiliver().getName());
   holder.paymentTextView.setText(localCar.getPayment().getName());
   holder.moneyTextView.setText(
       Parameters.CONSTANT_RMB + decimalFormat.format(localCar.getTotalMoney()));
   holder.moneyDetailTextView.setText(
       getMoneyDetailString(localCar.getGoodsMoney(), localCar.getPostFee()));
   return convertView;
 }
 public static int selectPayment(ModelLocalCar localCar, ModelPayment payment) {
   List<ModelLocalCar> localCars = getLocalCars();
   for (int i = 0; i < localCars.size(); i++) {
     if (localCars.get(i).getStore().getNo().equals(localCar.getStore().getNo())) {
       // 定位到此店铺,修改付款方式
       localCars.get(i).setPayment(payment);
       break;
     }
   }
   return save(localCars);
 }
 public static int selectDiliver(ModelLocalCar localCar, ModelDiliver diliver) {
   List<ModelLocalCar> localCars = getLocalCars();
   for (int i = 0; i < localCars.size(); i++) {
     if (localCars.get(i).getStore().getNo().equals(localCar.getStore().getNo())) {
       // 定位到此店铺,修改配送方式
       localCars.get(i).setDiliver(diliver);
       break;
     }
   }
   return save(localCars);
 }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHolder viewHolder;
   if (convertView == null) {
     convertView = layoutInflater.inflate(R.layout.list_diliver_payment, null);
     viewHolder = new ViewHolder();
     viewHolder.textView = (TextView) convertView.findViewById(R.id.diliver_payment_name);
     convertView.setTag(viewHolder);
   } else {
     viewHolder = (ViewHolder) convertView.getTag();
   }
   if (localCar.getPayment().getType() == localCar.getPayments().get(position).getType()) {
     viewHolder.textView.setTextColor(getResources().getColor(R.color.red));
     viewHolder.textView.setBackgroundResource(R.drawable.back_trans_rec_border_red);
   } else {
     viewHolder.textView.setTextColor(getResources().getColor(R.color.textColorSecond));
     viewHolder.textView.setBackgroundResource(R.drawable.back_trans_rec_border);
   }
   viewHolder.textView.setText(localCar.getPayments().get(position).getName());
   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, null);
        holder = new ViewHolder();
        holder.selectionImageView = (ImageView) convertView.findViewById(R.id.local_car_check);
        holder.selectButton = (LinearLayout) convertView.findViewById(R.id.local_car_selectall);
        holder.storeTextView = (TextView) convertView.findViewById(R.id.local_car_store);
        holder.storePostInfoTextView =
            (TextView) convertView.findViewById(R.id.local_car_post_info);
        holder.moneyTextView = (TextView) convertView.findViewById(R.id.local_car_total);
        holder.moneyDetailTextView =
            (TextView) convertView.findViewById(R.id.local_car_total_detail);
        holder.goodsListView = (InnerListView) convertView.findViewById(R.id.local_car_list);
        holder.diliverPayButton =
            (LinearLayout) convertView.findViewById(R.id.local_car_pay_diliver);
        holder.diliverPayTextView =
            (TextView) convertView.findViewById(R.id.local_car_pay_diliver_type);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }
      if (localCars.get(position).isSelected()) {
        holder.selectionImageView.setImageResource(R.drawable.iconfont_check_checked);
      } else {
        holder.selectionImageView.setImageResource(R.drawable.iconfont_check_normal);
      }
      final ModelLocalCar localCar = localCars.get(position);
      holder.storeTextView.setText(localCar.getStore().getServicename());
      holder.storePostInfoTextView.setText(getStorePostInfoString(localCar.getStorePostInfo()));
      holder.moneyTextView.setText(
          Parameters.CONSTANT_RMB + decimalFormat.format(localCar.getTotalMoney()));
      holder.moneyDetailTextView.setText(
          getMoneyDetailString(localCar.getGoodsMoney(), localCar.getPostFee()));
      holder.goodsListView.setAdapter(new CarGoodsAdapter(localCar));
      holder.diliverPayTextView.setText(getDiliverPayString(localCar));
      holder.selectButton.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              showLoading();
              LocalCarController.selectStore(localCar);
              hideLoading();
              refresh();
            }
          });
      holder.diliverPayButton.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              new DiliverPaymentDialog(localCar).show(getFragmentManager(), null);
            }
          });
      return convertView;
    }
 @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;
 }
  /**
   * 获取所有选中的商品
   *
   * @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 Object getItem(int position) {
   return localCar.getPayments().get(position);
 }
 @Override
 public int getCount() {
   return localCar.getPayments().size();
 }
 @Override
 public Object getItem(int position) {
   return localCar.getDilivers().get(position);
 }
 @Override
 public int getCount() {
   return localCar.getDilivers().size();
 }
    @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 int getCount() {
   return localCar.getCarGoods().size();
 }