Ejemplo n.º 1
0
 public String updateStock() {
   String gstockid = ServletActionContext.getRequest().getParameter("gstockid");
   String amount = ServletActionContext.getRequest().getParameter("amount");
   GoodsStock goodsStock = goodsStockService.get(Integer.parseInt(gstockid));
   Goods goods = goodsService.get(goodsStock.getGoodsId());
   goods.setAmount(
       goodsStockService.queryStockAll(goodsStock.getGoodsId().toString())
           - goodsStock.getAmount()
           + Integer.parseInt(amount));
   goodsStock.setAmount(Integer.parseInt(amount));
   goodsStockService.updateStock(goodsStock, goodsService, goods);
   // goodsStockService.update(goodsStock);
   // goodsService.update(goods);
   jsonMap.put("data", "right");
   return "json";
 }
Ejemplo n.º 2
0
 public String AddStock() {
   String gid = ServletActionContext.getRequest().getParameter("goodsId");
   String goodstype = ServletActionContext.getRequest().getParameter("goodstype");
   String amount = ServletActionContext.getRequest().getParameter("amount");
   if (goodsStockService.queryCount(gid, goodstype)) {
     Goods goods = goodsService.get(Integer.parseInt(gid));
     GoodsStock goodsStock = new GoodsStock();
     goodsStock.setGoodsId(Integer.parseInt(gid));
     goodsStock.setAmount(Integer.parseInt(amount));
     goodsStock.setGoodstype(goodstype);
     goods.setAmount(goodsStockService.queryStockAll(gid) + goodsStock.getAmount());
     // goodsStockService.add(goodsStock);
     // goodsService.update(goods);
     goodsStockService.addStock(goodsStock, goodsService, goods);
     jsonMap.put("data", "right");
   } else {
     jsonMap.put("data", "wrong");
   }
   return "json";
 }
Ejemplo n.º 3
0
 // zz for shopGoods
 public String updateG() {
   UserInfo userinfo = (UserInfo) session.get("userinfo");
   String goodId = req.getParameter("goodId");
   String sid = req.getParameter("shopId");
   Shop shop = shopService.get(Integer.parseInt(sid));
   session.put("shopid", shop.getShopId());
   request.put("shop", shop);
   Goods good = goodsService.get(Integer.parseInt(goodId));
   if (good.getState().equals("0")) {
     good.setState("2");
   } else {
     good.setState("0");
   }
   goodsService.updateGoods(good, messageService, userinfo, shop);
   //		goodsService.update(good);
   //		messageService.sendMessage(messageService,"您店铺的商品已被管理员下架,请点击查看!", userinfo.getUserinfoId(),
   // shop.getUserinfo().getUserinfoId(),
   //				"goodsAction_queryById.action", "shopId", shop.getShopId());
   jsonMap.put("data", "right");
   return "json";
 }
Ejemplo n.º 4
0
 public String setTopGoods() {
   String goodsId = ServletActionContext.getRequest().getParameter("goodsId");
   String state = ServletActionContext.getRequest().getParameter("state");
   pagegoods.setPageSize(6);
   pagegoods = goodsService.getTop(pagegoods);
   if (state.equals("3")) {
     if (pagegoods != null && pagegoods.getTotalItems() == 6) {
       jsonMap.put("data", "wrong");
     } else {
       Goods goods = goodsService.get(Integer.parseInt(goodsId));
       goods.setState(state);
       goodsService.update(goods);
       jsonMap.put("data", "right");
     }
   } else {
     Goods goods = goodsService.get(Integer.parseInt(goodsId));
     goods.setState(state);
     goodsService.update(goods);
     jsonMap.put("data", "right");
   }
   return "json";
 }