From aa464ee2d2b4af2dee5365f12570a4a9f5c0eaea Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Thu, 31 Jul 2025 19:17:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=9C=A8=E7=BA=BF=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E9=83=A8=E5=88=86=E8=BF=9C=E7=A8=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/feign/RemoteShopCategoryService.java | 30 +++++ .../api/feign/RemoteShopSpuService.java | 103 ++++++++++++++++++ .../RemoteSupermarketCategoryService.java | 2 +- ...mework.cloud.openfeign.FeignClient.imports | 4 +- .../controller/AppShopSpuController.java | 32 ++++++ .../controller/SmErpSpuController.java | 2 +- 6 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteShopCategoryService.java create mode 100644 pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteShopSpuService.java diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteShopCategoryService.java b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteShopCategoryService.java new file mode 100644 index 000000000..ec8a5d083 --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteShopCategoryService.java @@ -0,0 +1,30 @@ +package com.bsd.pjcloud.supermarket.api.feign; + + +import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; +import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.supermarket.vo.ShopCategoryTreeVo; +import com.bsd.pjcloud.supermarket.vo.erp.SmErpCategorySimpleVo; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +import java.util.List; + +/** + * @author zjf + * @date 2018/6/22 + */ +@FeignClient(contextId = "remoteShopCategoryService", value = ServiceNameConstants.SUPERMARKET_SERVICE) +public interface RemoteShopCategoryService { + + + + + /** + * 查询所有分类列表(树形结构) + * @return R + */ + @GetMapping("/app/shopCategory/list") + R> appCategoryList(); + +} diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteShopSpuService.java b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteShopSpuService.java new file mode 100644 index 000000000..6b3044c6f --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteShopSpuService.java @@ -0,0 +1,103 @@ +/* + * + * Copyright (c) 2018-2025, pjcloud All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: pjcloud + * + */ + +package com.bsd.pjcloud.supermarket.api.feign; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; +import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.supermarket.dto.SupermarketSpuQueryDTO; +import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockByCodeReqDTO; +import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; +import com.bsd.pjcloud.supermarket.vo.ad.SmErpSpuDetailsVo; +import com.bsd.pjcloud.supermarket.vo.ad.SpuVo; +import com.bsd.pjcloud.supermarket.vo.app.ShopSpuDetailAppVo; +import com.bsd.pjcloud.supermarket.vo.app.ShopSpuListAppVo; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author zjf + * @date 2018/6/22 + */ +@FeignClient(contextId = "remoteShopSpuService", value = ServiceNameConstants.SUPERMARKET_SERVICE) +public interface RemoteShopSpuService { + + + + /** + * 商品分页 + * @return R + */ + @GetMapping("/app/shopSpu/page") + R> page(@RequestParam Page page, + @RequestParam(required = false) Long categoryId, + @RequestParam(required = false) String keyword, + @RequestParam(required = false) String merchantId); + + + + /** + * 根据spu id 查询spu详情,详情包括辅助条码和包装单位基本信息 + * @param ids + * @return + */ + @GetMapping("/app/shopSpu/spuDetails") + R> getShopSpuDetailByIds(@RequestParam List ids); + + + /** + * 更新库存 + * @return + */ + /** + * 根据skuId和数量扣减库存 + * @param skuId + * @param num * 正数:增加库存,负数:扣减库存 + * @return + */ + @PostMapping("/app/shopSpu/deductStock") + R deductStock(@RequestParam Long skuId, @RequestParam Integer num); + + + /** + * 查询所有的超市spu列表信息,根据条件 + * @return R + */ +// @PostMapping("/supermarketSpu/app/selectListAll") +// R getSupermarketSpu(@RequestBody SupermarketSpuQueryDTO supermarketSpuQueryDTO); + + + /** + * 购物车效验库存 + * @param spuId + * @param incrCount 扣减数量,正数负数都行 + * @return + */ + @GetMapping("/app/shopSpu/checkSpuStock") + R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount); + +} diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java index 9e3f666a7..a758d7455 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java @@ -14,7 +14,7 @@ import java.util.List; * @author zjf * @date 2018/6/22 */ -@FeignClient(contextId = "remoteSupermarketCategoryServic", value = ServiceNameConstants.SUPERMARKET_SERVICE) +@FeignClient(contextId = "remoteSupermarketCategoryService", value = ServiceNameConstants.SUPERMARKET_SERVICE) public interface RemoteSupermarketCategoryService { 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 3a54f37cd..670a7cc7d 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,5 @@ com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketCategoryService com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketSpuService -com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService \ No newline at end of file +com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService +com.bsd.pjcloud.supermarket.api.feign.RemoteShopCategoryService +com.bsd.pjcloud.supermarket.api.feign.RemoteShopSpuService diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/AppShopSpuController.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/AppShopSpuController.java index b356b60e8..239e79bf5 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/AppShopSpuController.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/AppShopSpuController.java @@ -9,6 +9,8 @@ import com.bsd.pjcloud.common.core.util.BeanUtils; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.supermarket.entity.ShopSpuEntity; import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity; +import com.bsd.pjcloud.supermarket.entity.SmErpSpuEntity; +import com.bsd.pjcloud.supermarket.entity.SmErpStockEntity; import com.bsd.pjcloud.supermarket.service.ShopSpuService; import com.bsd.pjcloud.supermarket.service.ShopSkuService; import com.bsd.pjcloud.supermarket.vo.app.ShopSpuListAppVo; @@ -19,6 +21,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springdoc.core.annotations.ParameterObject; import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -84,10 +88,38 @@ public class AppShopSpuController { return R.ok(vo); } + @GetMapping("/spuDetails") + @Operation(summary = "商品详情", description = "根据SpuIds获取商品详情") + public R> getShopSpuDetailByIds(@RequestParam List ids) { + List shopSpuEntities = shopSpuService.listByIdsDeep(ids); + List shopSpuDetailAppVos = new ArrayList<>(); + for (ShopSpuEntity shopSpuEntity : shopSpuEntities) { + ShopSpuDetailAppVo shopSpuDetailAppVo = BeanUtils.toBean(shopSpuEntity, ShopSpuDetailAppVo.class); + shopSpuDetailAppVos.add(shopSpuDetailAppVo); + // 查询sku列表 + List skuList = shopSkuService.list(Wrappers.lambdaQuery().eq(ShopSkuEntity::getSpuId, shopSpuEntity.getId())); + shopSpuDetailAppVo.setSkuList(skuList.stream().map(sku -> BeanUtils.toBean(sku, ShopSkuAppVo.class)).collect(Collectors.toList())); + shopSpuDetailAppVos.add(shopSpuDetailAppVo); + } + return R.ok(shopSpuDetailAppVos); + } + @PostMapping("/deductStock") @Operation(summary = "扣减库存", description = "根据skuId和数量扣减库存") public R deductStock(@RequestParam Long skuId, @RequestParam Integer num) { boolean result = shopSkuService.deductStock(skuId, num); return result ? R.ok(true) : R.failed("库存不足或扣减失败"); } + + @GetMapping("/checkSpuStock") + @Operation(summary = "检查商品库存", description = "检查商品库存") + public R checkSpuStock(@RequestParam(value ="skuId")Long skuId,@RequestParam("incrCount")Integer incrCount) { + ShopSkuEntity shopSkuEntity = shopSkuService.getById(skuId); + if (shopSkuEntity == null) return R.failed("商品sku不存在"); + if (shopSkuEntity.getStock()