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..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 @@ -461,6 +496,21 @@ public class HardCarServiceImpl extends ServiceImpl 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.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(";"); + }); + } + } 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..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消息 diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java index e702fb9ce..b1aad55ef 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java @@ -399,7 +399,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto(); walletDto.setDeptIds(deptIds); walletDto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode())); - walletDto.setType(WalletTransactionSumAndCountDto.TYPE_EXPENSE); + // walletDto.setType(WalletTransactionSumAndCountDto.TYPE_EXPENSE); if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) { walletDto.setCreateTimeList(dto.getCreateTimeList()); } 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 diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletManageMapper.xml b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletManageMapper.xml index 18530584e..b9d12a26e 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletManageMapper.xml +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletManageMapper.xml @@ -194,20 +194,50 @@ - - + + + + + + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -312,4 +312,5 @@ + \ No newline at end of file