From 792da4ce7b0a8cd4a039b23c7bc467aa1faa2f9d Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Sat, 11 Jan 2025 17:41:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=80=82=E9=85=8D=E9=A3=9F=E5=A0=82?= =?UTF-8?q?=E7=BA=BF=E4=B8=8B=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/order/HardCarServiceImpl.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java index 34eb1739c..a949d13ae 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java @@ -5,7 +5,9 @@ import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsd.pjcloud.canteen.api.feign.RemoteCanteenSpuService; import com.bsd.pjcloud.canteen.api.feign.RemoteOnlineCanteenSpuService; +import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity; import com.bsd.pjcloud.canteen.vo.app.CanteenOnlineSpuAppVO; import com.bsd.pjcloud.common.core.util.BeanUtils; import com.bsd.pjcloud.hard.api.constant.HardTypeEnum; @@ -51,6 +53,7 @@ public class HardCarServiceImpl extends ServiceImpl supList = canteenSpuService.getSpuListByIds(productIds).getData(); + for (HardCreateCarDto v : list) { + supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { + int itemTotalPrice = v.getProductCount() * spu.getPrice(); + canteenTotalPrice.addAndGet(itemTotalPrice); + }); + } } yield canteenTotalPrice.get(); } @@ -180,6 +189,7 @@ public class HardCarServiceImpl extends ServiceImpl carObjectList = new ArrayList<>(); + // 线上 if (ObjectUtil.equals(HardOrderTypeEnum.RESERVE, orderType)) { List supList = onlineCanteenSpuService.getSpuListByIds(productIds).getData(); for (HardCreateCarDto v : productList) { @@ -197,8 +207,23 @@ public class HardCarServiceImpl extends ServiceImpl supList = canteenSpuService.getSpuListByIds(productIds).getData(); + for (HardCreateCarDto v : productList) { + HardCarEntity item = HardCarEntity.builder().parentCarId(parentCarId).build(); + supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { + int totalPrice = v.getProductCount() * spu.getPrice(); + item.setProductId(spu.getId()); + item.setProductName(spu.getName()); + item.setProductPrice(spu.getPrice()); + item.setProductPic(spu.getPicUrl()); + item.setTotalPrice((long) totalPrice); + item.setProductCount(v.getProductCount()); + item.setProductWeight(new BigDecimal(0)); + carObjectList.add(item); + }); + } } baseMapper.insert(carObjectList); return; @@ -244,7 +269,12 @@ public class HardCarServiceImpl extends ServiceImpl supList = canteenSpuService.getSpuListByIds(productIds).getData(); + for (HardCreateCarDto v : list) { + supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { + str.append(spu.getName()).append("x").append(v.getProductCount()).append(";"); + }); + } } } // 超市