فهرست منبع

fixed 根据库存状态查询商品

fushengqian 1 سال پیش
والد
کامیت
ee7d6d2a3d

+ 9 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java

@@ -111,7 +111,14 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
         if (StringUtils.isNotBlank(type)) {
             lambdaQueryWrapper.eq(MtGoods::getType, type);
         }
-
+        String hasStock = paginationRequest.getSearchParams().get("stock") == null ? "" : paginationRequest.getSearchParams().get("stock").toString();
+        if (StringUtils.isNotBlank(hasStock)) {
+            if (hasStock.equals(YesOrNoEnum.YES.getKey())) {
+                lambdaQueryWrapper.gt(MtGoods::getStock, 0);
+            } else {
+                lambdaQueryWrapper.lt(MtGoods::getStock, 1);
+            }
+        }
         lambdaQueryWrapper.orderByAsc(MtGoods::getSort);
         List<MtGoods> goodsList = mtGoodsMapper.selectList(lambdaQueryWrapper);
         List<GoodsDto> dataList = new ArrayList<>();
@@ -135,6 +142,7 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
             item.setName(mtGoods.getName());
             item.setGoodsNo(mtGoods.getGoodsNo());
             item.setCateId(mtGoods.getCateId());
+            item.setStock(mtGoods.getStock());
             item.setCateInfo(cateInfo);
             item.setType(mtGoods.getType());
             item.setPrice(mtGoods.getPrice());

+ 11 - 7
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGoodsController.java

@@ -92,6 +92,7 @@ public class BackendGoodsController extends BaseController {
         String type = request.getParameter("type");
         String status = request.getParameter("status");
         String searchStoreId = request.getParameter("storeId");
+        String stock = request.getParameter("stock");
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         if (accountInfo == null) {
@@ -131,6 +132,9 @@ public class BackendGoodsController extends BaseController {
         if (StringUtil.isNotEmpty(status)) {
             params.put("status", status);
         }
+        if (StringUtil.isNotEmpty(stock)) {
+            params.put("stock", stock);
+        }
         paginationRequest.setSearchParams(params);
         PaginationResponse<GoodsDto> paginationResponse = goodsService.queryGoodsListByPagination(paginationRequest);
 
@@ -273,11 +277,11 @@ public class BackendGoodsController extends BaseController {
                 String name = specNameArr.get(i);
                 for (MtGoodsSpec mtGoodsSpec : goods.getSpecList()) {
                     if (mtGoodsSpec.getName().equals(name)) {
-                        GoodsSpecChildDto e = new GoodsSpecChildDto();
-                        e.setId(mtGoodsSpec.getId());
-                        e.setName(mtGoodsSpec.getValue());
-                        e.setChecked(true);
-                        child.add(e);
+                        GoodsSpecChildDto goodsSpecChildDto = new GoodsSpecChildDto();
+                        goodsSpecChildDto.setId(mtGoodsSpec.getId());
+                        goodsSpecChildDto.setName(mtGoodsSpec.getValue());
+                        goodsSpecChildDto.setChecked(true);
+                        child.add(goodsSpecChildDto);
                     }
                 }
                 item.setId(specId);
@@ -571,7 +575,7 @@ public class BackendGoodsController extends BaseController {
     /**
      * 保存商品规格
      *
-     * @param request  HttpServletRequest对象
+     * @param request HttpServletRequest对象
      */
     @ApiOperation(value = "保存商品规格")
     @RequestMapping(value = "/saveSpecName", method = RequestMethod.POST)
@@ -624,7 +628,7 @@ public class BackendGoodsController extends BaseController {
     /**
      * 保存商品规格值
      *
-     * @param request  HttpServletRequest对象
+     * @param request HttpServletRequest对象
      * @return
      */
     @ApiOperation(value = "保存商品规格值")