diff --git a/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java b/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java index e316245d..a619a8e3 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java @@ -127,6 +127,69 @@ public class GoodsController { } } + @RequestMapping(value = "/getListGoodsDetailByHome", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品列表") + public ResponseData getListGoodsDetail( + @RequestParam(value = "goodsTypeId", required = false) String goodsTypeId, + @RequestParam(value = "companyId", required = false) Long companyId + ) { + try { + + Map map = new HashMap<>(); + map.put("companyId", companyId); + map.put("status", 1); + List goodsModels = new ArrayList<>(); + List list = new ArrayList<>(); + + if (goodsTypeId != null) { + Map maps = new HashMap<>(); + maps.put("parentId", goodsTypeId); + + List goodsTypes = highGoodsTypeService.getListGoodsType(maps); + + for (HighGoodsType highGoodsType : goodsTypes) { + map.put("goodsType", highGoodsType.getId()); + list.addAll(goodsDetailService.getGoodsDetailList(map)); + } + + } else { + list = goodsDetailService.getGoodsDetailList(map); + } + + for (GoodsDetail goodsDetail : list) { + + GoodsModel goodsModel = new GoodsModel(); + + List goodsSku = goodsSkuService.getGoodsSkuList(goodsDetail.getId()); + if (goodsSku.size() > 0) { + BigDecimal minPrice = goodsSku.get(0).getPrice(); + BigDecimal minOriginalPrice = goodsSku.get(0).getOriginalPrice(); + + for (GoodsSku sku : goodsSku) { + if (sku.getPrice().compareTo(minPrice) < 0) { + minPrice = sku.getPrice(); + minOriginalPrice = sku.getOriginalPrice(); + } + } + BeanUtils.copyProperties(goodsDetail, goodsModel); + goodsModel.setOriginalPrice(minOriginalPrice); + goodsModel.setPrice(minPrice); + goodsModel.setWhetherMultiple(goodsSku.size() != 1); + + goodsModels.add(goodsModel); + + } + } + return ResponseMsgUtil.success(goodsModels); + + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/findGoodsDetailById", method = RequestMethod.GET) @ResponseBody