Przeglądaj źródła

修复报价商品审核状态校验反转:to_examine=1才是审核通过可售

菜单接口口径为 eq(to_examine,'1'),原实现照抄036写反成'1'即拒绝,
导致所有正常在售商品报价报invalidProduct。补待审核拒绝用例。
qmj 4 dni temu
rodzic
commit
972836339b

+ 2 - 1
ruoyi-admin/src/main/java/com/ruoyi/app/order/FoodDeliveryPromotionQuoteService.java

@@ -134,8 +134,9 @@ public class FoodDeliveryPromotionQuoteService
         for (FoodDeliveryPromotionQuoteRequest.Item item : request.getItems())
         {
             PosFood food = foods.selectById(item.getProductId());
+            // 口径与菜单一致(PosFoodController):to_examine='1' 审核通过、stacking_up='0' 上架
             if (food == null || !request.getStoreId().equals(food.getMdid())
-                    || !"0".equals(food.getStackingUp()) || "1".equals(food.getToExamine())
+                    || !"0".equals(food.getStackingUp()) || !"1".equals(food.getToExamine())
                     || food.getPrice() == null || food.getPrice().signum() < 0)
             {
                 throw invalid("promotion.freeDelivery.invalidProduct");

+ 15 - 1
ruoyi-admin/src/test/java/com/ruoyi/app/order/FoodDeliveryPromotionQuoteServiceTest.java

@@ -136,6 +136,20 @@ class FoodDeliveryPromotionQuoteServiceTest
         assertEquals("promotion.freeDelivery.invalidProduct", badQuantity.getMessage());
     }
 
+    @Test
+    void quote_shouldRejectUnapprovedFood()
+    {
+        // to_examine='0' 为待审核(菜单口径 '1' 才可售),必须拒绝
+        FoodDeliveryPromotionQuoteService spy = spyWithRoute(BigDecimal.valueOf(3000));
+        PosFood pending = food(STORE_ID, "50");
+        pending.setToExamine("0");
+        when(foods.selectById(FOOD_ID)).thenReturn(pending);
+
+        ServiceException rejected = assertThrows(ServiceException.class,
+                () -> spy.quote(request(), USER_ID));
+        assertEquals("promotion.freeDelivery.invalidProduct", rejected.getMessage());
+    }
+
     @Test
     void quote_shouldRejectUnknownOrderTypeOrMissingStore()
     {
@@ -321,7 +335,7 @@ class FoodDeliveryPromotionQuoteServiceTest
         food.setPrice(new BigDecimal(price));
         food.setName("测试商品");
         food.setStackingUp("0");
-        food.setToExamine("0");
+        food.setToExamine("1");
         return food;
     }