|
@@ -1,6 +1,9 @@
|
|
|
package com.izouma.dingdong.service;
|
|
package com.izouma.dingdong.service;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.izouma.dingdong.domain.OrderGoodsSpec;
|
|
import com.izouma.dingdong.domain.OrderGoodsSpec;
|
|
|
|
|
+import com.izouma.dingdong.domain.user.ShoppingCart;
|
|
|
import com.izouma.dingdong.exception.BusinessException;
|
|
import com.izouma.dingdong.exception.BusinessException;
|
|
|
import com.izouma.dingdong.repo.OrderGoodsSpecRepo;
|
|
import com.izouma.dingdong.repo.OrderGoodsSpecRepo;
|
|
|
import com.izouma.dingdong.repo.user.ShoppingCartRepo;
|
|
import com.izouma.dingdong.repo.user.ShoppingCartRepo;
|
|
@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
@SpringBootTest
|
|
@SpringBootTest
|
|
|
@RunWith(SpringRunner.class)
|
|
@RunWith(SpringRunner.class)
|
|
|
public class ShoppingCartServiceTest {
|
|
public class ShoppingCartServiceTest {
|
|
@@ -38,21 +43,36 @@ public class ShoppingCartServiceTest {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
- public void testSub(){
|
|
|
|
|
|
|
+ public void testSub() {
|
|
|
OrderGoodsSpec add = orderGoodsSpecService.add(1636L, null, 1);
|
|
OrderGoodsSpec add = orderGoodsSpecService.add(1636L, null, 1);
|
|
|
System.out.println(shoppingCartService.add(82L, add));
|
|
System.out.println(shoppingCartService.add(82L, add));
|
|
|
//System.out.println(shoppingCartService.sub(1500L, 83L));
|
|
//System.out.println(shoppingCartService.sub(1500L, 83L));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
- public void testFalse(){
|
|
|
|
|
|
|
+ public void testFalse() {
|
|
|
//System.out.println(shoppingCartRepo.findByIdAndEnabledIsFalse(1759L));
|
|
//System.out.println(shoppingCartRepo.findByIdAndEnabledIsFalse(1759L));
|
|
|
|
|
|
|
|
System.out.println(shoppingCartRepo.findById(1759L).orElse(null));
|
|
System.out.println(shoppingCartRepo.findById(1759L).orElse(null));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
- public void testAgain(){
|
|
|
|
|
|
|
+ public void testAgain() {
|
|
|
System.out.println(shoppingCartService.again(1729L));
|
|
System.out.println(shoppingCartService.again(1729L));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void testMyMer() {
|
|
|
|
|
+ ShoppingCart cart = shoppingCartRepo.findByUserIdAndMerchantId(82L, 927L);
|
|
|
|
|
+ if (ObjectUtil.isEmpty(cart)) {
|
|
|
|
|
+ System.out.println("null");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<OrderGoodsSpec> specs = cart.getOrderGoodsSpecs();
|
|
|
|
|
+ if (CollUtil.isEmpty(specs)) {
|
|
|
|
|
+ System.out.println("null");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ System.out.println(specs);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|