袁野 7 months ago
parent 187a277c1a
commit 1e8853383a
  1. 63
      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<String, Object> map = new HashMap<>();
map.put("companyId", companyId);
map.put("status", 1);
List<GoodsModel> goodsModels = new ArrayList<>();
List<GoodsDetail> list = new ArrayList<>();
if (goodsTypeId != null) {
Map<String,String> maps = new HashMap<>();
maps.put("parentId", goodsTypeId);
List<HighGoodsType> 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> 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

Loading…
Cancel
Save