Exemplo n.º 1
0
 public void myBuyedStore() throws IOException {
   id = Integer.parseInt(ServletActionContext.getRequest().getParameter("id"));
   List<GoodStore> listgoostore = goodStoreService.getMyBuyedStore(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(
         "addTime", goodStore.getAddtime() == null ? "" : sdf1.format(goodStore.getAddtime()));
     jsonObj.put("price", good.getPrice() * goodStore.getCount());
     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));
 }
Exemplo n.º 2
0
 /** 从购物车删除 */
 public void deleteGoodsStore() throws IOException {
   id = Integer.parseInt(ServletActionContext.getRequest().getParameter("id"));
   GoodStore goodStore = goodStoreService.getGoodsStore(id);
   goodStore.setState(-1);
   try {
     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));
   }
 }
Exemplo n.º 3
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));
    }
  }
Exemplo n.º 4
0
  public void addGoodsStoredirect() throws IOException {
    id = Integer.parseInt(ServletActionContext.getRequest().getParameter("id"));
    goodId = Integer.parseInt(ServletActionContext.getRequest().getParameter("goodId"));
    count = Integer.parseInt(ServletActionContext.getRequest().getParameter("goodId"));
    GoodStore goodstore = new GoodStore();
    goodstore.setState(1);
    goodstore.setCount(count);
    goodstore.setAddressId(id);
    goodstore.setGoodId(goodId);

    try {
      goodStoreService.saveGoodStore(goodstore);
      m.put("msg", "1");
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
    } catch (Exception e) {
      m.put("msg", "-1");
      e.printStackTrace();
      ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));
    }
  }
Exemplo n.º 5
0
  /** 加入购物车 */
  public void addGoodsStore() throws IOException {
    try {
      goodStore.setState(0);
      goodStoreService.saveGoodStore(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));
    }
  }
Exemplo n.º 6
0
  /** 从购物车提交 */
  public void commitGoodsStore() throws IOException {
    ids = ServletActionContext.getRequest().getParameter("ids");
    String str[] = ids.split(",");
    int array[] = new int[str.length];

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