From 1e8853383a59ae6500bc05ee23efcac90f728d0f Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 29 Apr 2024 09:41:44 +0800 Subject: [PATCH] 1 --- .../controller/Goods/GoodsController.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) 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