From ff25e0e5cf97d326d966074d5053aebca303f60e Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Wed, 22 Oct 2025 16:27:55 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat=E4=BD=99=E9=A2=9D=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/order/HardCarServiceImpl.java | 9 ++ .../impl/order/HardOrderServiceImpl.java | 3 +- .../impl/order/HardOrderTotalServiceImpl.java | 2 +- .../resources/mapper/WalletManageMapper.xml | 109 +++++++++--------- 4 files changed, 66 insertions(+), 57 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 35fc6f96d..f16ffac49 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 @@ -461,6 +461,15 @@ public class HardCarServiceImpl extends ServiceImpl supList = hardSpuService.getByIds(productIds); + 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(";"); + }); + } + } return str.toString(); } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderServiceImpl.java index 9637c7fb1..a9f2cc62f 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderServiceImpl.java @@ -670,8 +670,7 @@ public class HardOrderServiceImpl extends ServiceImpl - - + + + + + + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -312,4 +312,5 @@ + \ No newline at end of file From 0a0bccdc54774b874738ce43b4fab61a01530963 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Wed, 22 Oct 2025 16:35:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:RemoteMallProductService=E6=B3=A8?= =?UTF-8?q?=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org.springframework.cloud.openfeign.FeignClient.imports | 1 + 1 file changed, 1 insertion(+) diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports index b60b55d6b..191afdcd8 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports @@ -1,3 +1,4 @@ +com.bsd.pjcloud.supermarket.api.feign.RemoteMallProductService com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketCategoryService com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketSpuService com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService From ee6783ab4fb7eec30fd47fda056fe137570feec8 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Wed, 22 Oct 2025 16:55:13 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=E5=85=B1=E5=AF=8C=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/order/HardCarServiceImpl.java | 45 ++++++++++++++++- .../impl/order/HardOrderServiceImpl.java | 50 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 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 f16ffac49..4d42cf77c 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 @@ -28,12 +28,14 @@ import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper; import com.bsd.pjcloud.hard.mapper.order.HardParentCarMapper; import com.bsd.pjcloud.hard.service.HardCarService; import com.bsd.pjcloud.hard.service.HardSpuService; +import com.bsd.pjcloud.supermarket.api.feign.RemoteMallProductService; import com.bsd.pjcloud.supermarket.api.feign.RemoteShopSkuService; import com.bsd.pjcloud.supermarket.api.feign.RemoteShopSpuService; import com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService; import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity; import com.bsd.pjcloud.supermarket.vo.app.ShopSpuDetailAppVo; import com.bsd.pjcloud.supermarket.vo.erp.SmErpUnitWithSpuVo; +import com.bsd.pjcloud.supermarket.vo.mall.MallProductDetailAppVo; import com.bsd.pjcloud.thirdparty.dto.pay.PayDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -68,6 +70,7 @@ public class HardCarServiceImpl extends ServiceImpl pageJoin(Page page, HardCarDto dto) { @@ -416,6 +419,38 @@ public class HardCarServiceImpl extends ServiceImpl carObjectList = new ArrayList<>(); + List spuList = remoteMallProductService.getDetailByIds(productIds).getData(); + for (HardCreateCarDto v : productList) { + HardCarEntity item = HardCarEntity.builder().parentCarId(parentCarId).build(); + spuList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { + Integer price = getSupermarket(spu); + int totalPrice = 0; + if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) { + // 按数量 + totalPrice = v.getProductCount() * price; + } else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) { + // 按重量 + totalPrice = v.getProductWeight().multiply(BigDecimal.valueOf(price)).setScale(0, RoundingMode.CEILING).intValue(); + } + item.setProductId(spu.getId()); + item.setProductName(spu.getTitle()); + item.setProductPrice(price); + item.setProductPic(spu.getCoverImage()); + item.setTotalPrice((long) totalPrice); + if (ObjectUtil.isNotEmpty(v.getProductNature())) { + item.setProductNature(v.getProductNature().getType()); + } + item.setProductCount(v.getProductCount()); + item.setProductWeight(v.getProductWeight()); + carObjectList.add(item); + }); + } + baseMapper.insert(carObjectList); + return; + } } @Override @@ -463,10 +498,16 @@ public class HardCarServiceImpl extends ServiceImpl supList = hardSpuService.getByIds(productIds); + List supList = remoteMallProductService.getDetailByIds(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(";"); + str.append(spu.getTitle()).append("x"); + if (ObjectUtil.equals(spu.getProductNature(), HardProductNatureEnum.DEFAULT.getType())) { + str.append(v.getProductCount()); + } else if (ObjectUtil.equals(spu.getProductNature(), HardProductNatureEnum.WEIGHT.getType())) { + str.append(v.getProductWeight()).append("/kg"); + } + str.append(";"); }); } } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderServiceImpl.java index a9f2cc62f..bf2d91be7 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderServiceImpl.java @@ -65,9 +65,11 @@ import com.bsd.pjcloud.hard.api.vo.wechat.WechatMicropayVo; import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper; import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper; import com.bsd.pjcloud.hard.service.*; +import com.bsd.pjcloud.supermarket.api.feign.RemoteMallProductService; import com.bsd.pjcloud.supermarket.api.feign.RemoteShopSkuService; import com.bsd.pjcloud.supermarket.api.feign.RemoteShopSpuService; import com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketSpuService; +import com.bsd.pjcloud.supermarket.dto.MallProductStockChangeDTO; import com.bsd.pjcloud.supermarket.dto.SkuStockChangeDTO; import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity; @@ -150,6 +152,7 @@ public class HardOrderServiceImpl extends ServiceImpl carList = hardCarService.getByParentCarId(order.getParentCarId()); + // 扣件库存 + MallProductStockChangeDTO dto = new MallProductStockChangeDTO(); + dto.setDeviceType(0); + List itemList = carList.stream().map(v -> { + MallProductStockChangeDTO.Item item = new MallProductStockChangeDTO.Item(); + item.setId(v.getProductId()); + item.setProductType(1); + if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) { + // 按数量 + int prouctCount = v.getProductCount(); + // 如果退款购物车数组里有,就用退款购物车的数量 + if (ObjectUtil.isNotEmpty(refundCarList)) { + HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null); + if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) { + prouctCount = refundCarTarget.getProductCount(); + } + } + double count = BigDecimal.valueOf(prouctCount).multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + item.setIncrCount(count); + } else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) { + // 按重量 + BigDecimal productWeight = v.getProductWeight(); + // 如果退款购物车数组里有,就用退款购物车的数量 + if (ObjectUtil.isNotEmpty(refundCarList)) { + HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null); + if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) { + productWeight = refundCarTarget.getProductWeight(); + } + } + double weight = productWeight.multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + item.setIncrCount(weight); + } + return item; + }).toList(); + dto.setItems(itemList); + R updateSkuStockRes = remoteMallProductService.deductStock(dto); + if (updateSkuStockRes.getCode() != 0 || !updateSkuStockRes.getData()) { + log.info("|{}|{},失败,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto)); + throw new RuntimeException(CarErrorMsg + "错误"); + } + log.info("|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto)); + return; + } } // 发送mq消息