@Override
 protected void initViews() {
   selfAddressTextView.setText(
       Store.getStore().getStoreAddess()
           + "\n联系人:"
           + Store.getStore().getStoreContactor()
           + "\n"
           + Store.getStore().getStoreName());
   sendTypeGroup.check(R.id.order_deliver_self);
   selectDeliverType();
 }
 private void getProductDetail() {
   List<RequestParam> requestParams = new ArrayList<>();
   requestParams.add(new RequestParam("jmdId", Store.getStore().getStoreId()));
   requestParams.add(new RequestParam("productId", productId));
   post(
       API.API_PRODUCT_DETAIL,
       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")) {
                   JSONObject detailObject = object.optJSONObject("dataMap");
                   if (detailObject != null) {
                     product = new ModelProduct(detailObject);
                     getProductSaleInfo();
                   }
                 }
               } catch (JSONException e) {
                 e.printStackTrace();
               }
             }
           }
         }
       });
 }
 private void getService() {
   List<RequestParam> requestParams = new ArrayList<>();
   requestParams.add(new RequestParam("pageNo", pagenum + ""));
   requestParams.add(new RequestParam("pageSize", pagesize + ""));
   requestParams.add(new RequestParam("productName", productName));
   requestParams.add(new RequestParam("organizationId", Store.getStore().getStoreId()));
   post(
       API.API_LOCAL_BUSINESS_SERVICE,
       requestParams,
       new OnNetworkListener() {
         @Override
         public void onSuccess(String result) {
           refreshScrollView.onRefreshComplete();
           if (result.length() > 0) {
             JSONObject object;
             try {
               object = new JSONObject(result);
               if (object.optString("state").equalsIgnoreCase("SUCCESS")) {
                 JSONArray array = object.optJSONArray("dataList");
                 if (array != null) {
                   if (array.length() > 0) {
                     if (array.length() < pagesize) {
                       refreshScrollView.setMode(Mode.PULL_FROM_START);
                     }
                     for (int i = 0; i < array.length(); i++) {
                       JSONObject jsonObject = array.optJSONObject(i);
                       if (jsonObject != null) {
                         localServices.add(new ModelLocalService(jsonObject));
                       }
                     }
                     serviceAdapter.notifyDataSetChanged();
                     return;
                   } else {
                     refreshScrollView.setMode(Mode.PULL_FROM_START);
                   }
                 }
               }
             } catch (JSONException e) {
               e.printStackTrace();
             }
             if (localServices.size() == 0) {
               missionNodata();
             }
           } else {
             missionFailed();
           }
         }
       });
 }
  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();
          }
        });
  }