Ejemplo n.º 1
0
  /** 我的购物车列表 */
  public void myStore() throws IOException {
    id = Integer.parseInt(ServletActionContext.getRequest().getParameter("id"));
    List<GoodStore> listgoostore = goodStoreService.getMyStore(id);
    for (GoodStore goodStore : listgoostore) {
      JSONObject jsonObj = new JSONObject();
      Goods good = goodsService.getGoods(goodStore.getGoodId());
      jsonObj.put("goodStoreid", goodStore.getGoodStoreid());
      jsonObj.put("title", good.getTitle());
      jsonObj.put("price", good.getPrice());
      jsonObj.put("count", goodStore.getCount());
      jsonObj.put("id", goodStore.getGoodId());
      List<Image> listimage = imageServiceImpl.getimage(goodStore.getGoodId(), 3);
      Image image = new Image();
      if (listimage.size() > 0) {
        image.setImageUrl(IpMain.IP + listimage.get(1).getImageUrl());
      } else {
        image.setImageUrl("");
      }

      jsonObj.put("imgUrl", image);
      array.add(jsonObj);
    }
    m.put("msg", array);
    ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
  }
Ejemplo n.º 2
0
  /**
   * 保存地址
   *
   * @throws IOException
   */
  public void addAdress() throws IOException {
    ids = ServletActionContext.getRequest().getParameter("ids");
    goodowner = ServletActionContext.getRequest().getParameter("goodowner");
    addressOwner = ServletActionContext.getRequest().getParameter("addressOwner");
    phonenumerowner = ServletActionContext.getRequest().getParameter("phonenumerowner");
    ids = ServletActionContext.getRequest().getParameter("ids");
    List<GoodStore> listGoodStore = goodStoreService.getMyStore(id);
    String str[] = ids.split(",");
    int array[] = new int[str.length];
    GoodAddress goodAddress = new GoodAddress();
    goodAddress.setAddressOwner(addressOwner);
    goodAddress.setGoodowner(goodowner);
    goodAddress.setPhonenumerowner(phonenumerowner);

    int f = goodAdressServiceImpl.saveAddress(goodAddress);

    try {
      for (int i = 0; i < str.length; i++) {
        array[i] = Integer.parseInt(str[i]);
        goodStore = goodStoreService.getGoodsStore(array[i]);
        goodStore.setAddressId(f);
        goodStoreService.saveOrUpdate(goodStore);
      }
      m.put("msg", "1");
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
    } catch (Exception e) {
      e.printStackTrace();
      m.put("msg", "-1");
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
    }
  }