chao пре 4 година
родитељ
комит
b9b25496f9

+ 8 - 8
src/main/java/com/caimei365/order/controller/CartClubApi.java

@@ -2,7 +2,7 @@ package com.caimei365.order.controller;
 
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.CartDto;
-import com.caimei365.order.service.CartService;
+import com.caimei365.order.service.CartClubService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
@@ -24,10 +24,10 @@ import java.util.Map;
 @Api(tags="机构购物车API")
 @RestController
 @RequiredArgsConstructor
-@RequestMapping("/order")
+@RequestMapping("/order/club")
 public class CartClubApi {
 
-    private final CartService cartService;
+    private final CartClubService cartClubService;
 
     /**
      * 购物车列表详细数据
@@ -39,7 +39,7 @@ public class CartClubApi {
         if (null == userId) {
             return ResponseJson.error("用户Id不能为空!", null);
         }
-        return cartService.getShoppingCartList(userId);
+        return cartClubService.getShoppingCartList(userId);
     }
 
     /**
@@ -52,7 +52,7 @@ public class CartClubApi {
         if (null == userId) {
             return ResponseJson.error("用户Id不能为空!", null);
         }
-        return cartService.getShoppingCartHead(userId);
+        return cartClubService.getShoppingCartHead(userId);
     }
 
     /**
@@ -76,7 +76,7 @@ public class CartClubApi {
         if (null == cartDto.getProductCount()) {
             return ResponseJson.error("商品数量不能为空!", null);
         }
-        return cartService.addShoppingCart(cartDto);
+        return cartClubService.addShoppingCart(cartDto);
     }
 
     /**
@@ -100,7 +100,7 @@ public class CartClubApi {
         if (null == cartDto.getProductCount()) {
             return ResponseJson.error("商品数量不能为空!", null);
         }
-        return cartService.updateShoppingCart(cartDto);
+        return cartClubService.updateShoppingCart(cartDto);
     }
 
     /**
@@ -120,6 +120,6 @@ public class CartClubApi {
         if (StringUtils.isEmpty(cartDto.getProductIds())) {
             return ResponseJson.error("商品Id集合不能为空!", null);
         }
-        return cartService.deleteShoppingCart(cartDto);
+        return cartClubService.deleteShoppingCart(cartDto);
     }
 }

+ 38 - 1
src/main/java/com/caimei365/order/controller/CartSellerApi.java

@@ -1,10 +1,20 @@
 package com.caimei365.order.controller;
 
+import com.caimei365.order.model.ResponseJson;
+import com.caimei365.order.service.CartClubService;
+import com.caimei365.order.service.CartSellerService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Map;
+
 /**
  * 协销购物车API
  *
@@ -14,7 +24,34 @@ import org.springframework.web.bind.annotation.RestController;
 @Api(tags="协销购物车API")
 @RestController
 @RequiredArgsConstructor
-@RequestMapping("/order")
+@RequestMapping("/order/seller")
 public class CartSellerApi {
 
+    private final CartSellerService cartSellerService;
+
+    /**
+     * 协销购物车列表数据
+     */
+    @ApiOperation("协销购物车列表数据(旧:/seller/shoppingInfo)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = false, name = "serviceProviderId", value = "协销Id"),
+            @ApiImplicitParam(required = false, name = "clubId", value = "机构Id"),
+            @ApiImplicitParam(required = false, name = "againBuyProductIds", value = "再来一单商品Ids"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+    })
+    @GetMapping("/cart/list")
+    public ResponseJson<Map<String,Object>> getShoppingCarts(Integer serviceProviderId, Integer clubId, String againBuyProductIds,
+                                                                @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        if (null == serviceProviderId) {
+            return ResponseJson.error("协销Id不能为空!", null);
+        }
+        if (null == clubId) {
+            return ResponseJson.error("机构Id不能为空!", null);
+        }
+        return cartSellerService.getShoppingCarts(serviceProviderId, clubId, againBuyProductIds, pageNum, pageSize);
+    }
+
+
 }

+ 1 - 1
src/main/java/com/caimei365/order/mapper/CartMapper.java → src/main/java/com/caimei365/order/mapper/CartClubMapper.java

@@ -17,7 +17,7 @@ import java.util.List;
  * @date : 2021/6/25
  */
 @Mapper
-public interface CartMapper {
+public interface CartClubMapper {
     /**
      * 购物车供应商列表
      * @param userId 用户Id

+ 13 - 0
src/main/java/com/caimei365/order/mapper/CartSellerMapper.java

@@ -0,0 +1,13 @@
+package com.caimei365.order.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/6/29
+ */
+@Mapper
+public class CartSellerMapper {
+}

+ 1 - 1
src/main/java/com/caimei365/order/service/CartService.java → src/main/java/com/caimei365/order/service/CartClubService.java

@@ -11,7 +11,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/6/25
  */
-public interface CartService {
+public interface CartClubService {
 
     /**
      * 购物车列表详细数据

+ 24 - 0
src/main/java/com/caimei365/order/service/CartSellerService.java

@@ -0,0 +1,24 @@
+package com.caimei365.order.service;
+
+import com.caimei365.order.model.ResponseJson;
+import io.swagger.annotations.ApiImplicitParam;
+
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/6/29
+ */
+public interface CartSellerService {
+    /**
+     * 协销购物车列表数据
+     * @param serviceProviderId 协销Id
+     * @param clubId            机构Id
+     * @param againBuyProductIds 再来一单商品Ids
+     * @param pageNum            页码
+     * @param pageSize           每页数量
+     */
+    ResponseJson<Map<String, Object>> getShoppingCarts(Integer serviceProviderId, Integer clubId, String againBuyProductIds, int pageNum, int pageSize);
+}

+ 18 - 18
src/main/java/com/caimei365/order/service/impl/CartServiceImpl.java → src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -1,12 +1,12 @@
 package com.caimei365.order.service.impl;
 
 import com.caimei365.order.mapper.BaseMapper;
-import com.caimei365.order.mapper.CartMapper;
+import com.caimei365.order.mapper.CartClubMapper;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.CartDto;
 import com.caimei365.order.model.po.CartPo;
 import com.caimei365.order.model.vo.*;
-import com.caimei365.order.service.CartService;
+import com.caimei365.order.service.CartClubService;
 import com.caimei365.order.utils.MathUtil;
 import com.caimei365.order.utils.ProductUtil;
 import com.google.common.collect.Lists;
@@ -31,13 +31,13 @@ import java.util.stream.IntStream;
  */
 @Slf4j
 @Service
-public class CartServiceImpl implements CartService {
+public class CartClubServiceImpl implements CartClubService {
     @Value("${caimei.wwwDomain}")
     private String domain;
     @Resource
     private BaseMapper baseMapper;
     @Resource
-    private CartMapper cartMapper;
+    private CartClubMapper cartClubMapper;
 
     /**
      * 购物车列表详细数据
@@ -50,7 +50,7 @@ public class CartServiceImpl implements CartService {
          * 初始化返回数据
          */
         // 购物车供应商列表
-        List<CartShopVo> shopInfoList = cartMapper.getCartShops(userId);
+        List<CartShopVo> shopInfoList = cartClubMapper.getCartShops(userId);
         // 失效商品列表
         List<CartItemVo> invalidList = new ArrayList<>();
         // 商品总数量
@@ -81,9 +81,9 @@ public class CartServiceImpl implements CartService {
                 // 该供应商满减金额(供应商满减,单品满减)
                 AtomicDouble shopReducedPrice = new AtomicDouble(0);
                 // 供应商促销优惠活动
-                CartPromotionsVo shopPromotion = cartMapper.getPromotionByShopId(shop.getShopId());
+                CartPromotionsVo shopPromotion = cartClubMapper.getPromotionByShopId(shop.getShopId());
                 // 供应商下商品列表
-                List<CartItemVo> productList = cartMapper.getCartProductsByShopId(shop.getShopId(), userId);
+                List<CartItemVo> productList = cartClubMapper.getCartProductsByShopId(shop.getShopId(), userId);
 
                 // 迭代器设置商品信息
                 Iterator<CartItemVo> productIterator = productList.iterator();
@@ -105,7 +105,7 @@ public class CartServiceImpl implements CartService {
                             // 没有店铺促销时,商品促销才有效
                             if (null == shopPromotion) {
                                 // 获取商品促销信息
-                                promotions = cartMapper.getPromotionByProductId(cartItemVo.getProductId());
+                                promotions = cartClubMapper.getPromotionByProductId(cartItemVo.getProductId());
                                 /*
                                  * 设置商品促销优惠
                                  */
@@ -194,7 +194,7 @@ public class CartServiceImpl implements CartService {
                         // 店铺满赠
                         if (shopPromotion.getMode() == 3) {
                             // 获取赠品
-                            List<CartItemVo> giftList = cartMapper.getPromotionGifts(shopPromotion.getId());
+                            List<CartItemVo> giftList = cartClubMapper.getPromotionGifts(shopPromotion.getId());
                             shopPromotion.setGiftList(giftList);
                         }
                         // 设置该优惠下的商品列表
@@ -296,7 +296,7 @@ public class CartServiceImpl implements CartService {
         // 用户身份
         Integer userIdentity = baseMapper.getIdentityByUserId(userId);
         // 获取购物车商品列表(不区分供应商)
-        cartList = cartMapper.getCartProductList(userId);
+        cartList = cartClubMapper.getCartProductList(userId);
         if (null != cartList && cartList.size()>0) {
             // 移除价格不可见商品
             cartList.removeIf(cartItemVo -> !(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && userIdentity == 2)));
@@ -304,7 +304,7 @@ public class CartServiceImpl implements CartService {
                 // 设置商品图片及税费
                 boolean taxFlag = setCartItemImgAndTax(cartItemVo);
                 // 获取商品促销信息
-                CartPromotionsVo promotions = cartMapper.getPromotionByProductId(cartItemVo.getProductId());
+                CartPromotionsVo promotions = cartClubMapper.getPromotionByProductId(cartItemVo.getProductId());
                 /*
                  * 设置商品促销优惠
                  */
@@ -374,12 +374,12 @@ public class CartServiceImpl implements CartService {
      */
     @Override
     public ResponseJson<Integer> addShoppingCart(CartDto cartDto) {
-        CartPo cart = cartMapper.getCartPo(cartDto);
+        CartPo cart = cartClubMapper.getCartPo(cartDto);
         if (cart != null) {
             // 购物车已存在该商品,更新数量
             cart.setProductCount(cart.getProductCount() + cartDto.getProductCount());
             cart.setAddTime(new Date());
-            cartMapper.updateCart(cart);
+            cartClubMapper.updateCart(cart);
         } else {
             // 添加新购物车
             cart = new CartPo();
@@ -395,7 +395,7 @@ public class CartServiceImpl implements CartService {
                 cart.setReBuyFlag(0);
             }
             cart.setAddTime(new Date());
-            cartMapper.insertCart(cart);
+            cartClubMapper.insertCart(cart);
         }
         // 获取购物车数量(商品种类数)
         int cartCount = getCartCount(cartDto.getUserId());
@@ -418,7 +418,7 @@ public class CartServiceImpl implements CartService {
         cart.setProductId(cartDto.getProductId());
         cart.setProductCount(cartDto.getProductCount());
         cart.setAddTime(new Date());
-        cartMapper.updateCart(cart);
+        cartClubMapper.updateCart(cart);
         // 获取购物车数量(商品种类数)
         int cartCount = getCartCount(cartDto.getUserId());
         return ResponseJson.success("更新成功!返回购物车数量", cartCount);
@@ -443,7 +443,7 @@ public class CartServiceImpl implements CartService {
         } else {
             productIdList.add(Integer.parseInt(cartDto.getProductIds()));
         }
-        cartMapper.deleteCartByProductIds(cartDto.getUserId(), productIdList);
+        cartClubMapper.deleteCartByProductIds(cartDto.getUserId(), productIdList);
         // 获取购物车数量(商品种类数)
         int cartCount = getCartCount(cartDto.getUserId());
         return ResponseJson.success("删除成功!返回购物车数量", cartCount);
@@ -459,7 +459,7 @@ public class CartServiceImpl implements CartService {
             return 0;
         }
         // 获取购物车商品列表(不区分供应商)
-        List<CartItemVo> cartList = cartMapper.getCartProductList(userId);
+        List<CartItemVo> cartList = cartClubMapper.getCartProductList(userId);
         if (null != cartList && cartList.size()>0) {
             // 用户身份
             Integer userIdentity = baseMapper.getIdentityByUserId(userId);
@@ -579,7 +579,7 @@ public class CartServiceImpl implements CartService {
             promotionsIds.add(promotions.getId());
             if (promotions.getMode() == 3) {
                 // 获取赠品
-                List<CartItemVo> giftList = cartMapper.getPromotionGifts(promotions.getId());
+                List<CartItemVo> giftList = cartClubMapper.getPromotionGifts(promotions.getId());
                 promotions.setGiftList(giftList);
             }
             promotions.setProductList(promotionPriceList);

+ 43 - 0
src/main/java/com/caimei365/order/service/impl/CartSellerServiceImpl.java

@@ -0,0 +1,43 @@
+package com.caimei365.order.service.impl;
+
+import com.caimei365.order.mapper.BaseMapper;
+import com.caimei365.order.mapper.CartSellerMapper;
+import com.caimei365.order.model.ResponseJson;
+import com.caimei365.order.service.CartSellerService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/6/29
+ */
+@Slf4j
+@Service
+public class CartSellerServiceImpl implements CartSellerService {
+    @Value("${caimei.wwwDomain}")
+    private String domain;
+    @Resource
+    private BaseMapper baseMapper;
+    @Resource
+    private CartSellerMapper cartSellerMapper;
+
+    /**
+     * 协销购物车列表数据
+     *
+     * @param serviceProviderId  协销Id
+     * @param clubId             机构Id
+     * @param againBuyProductIds 再来一单商品Ids
+     * @param pageNum            页码
+     * @param pageSize           每页数量
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getShoppingCarts(Integer serviceProviderId, Integer clubId, String againBuyProductIds, int pageNum, int pageSize) {
+        return null;
+    }
+}

+ 1 - 1
src/main/resources/mapper/CartMapper.xml → src/main/resources/mapper/CartClubMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.caimei365.order.mapper.CartMapper">
+<mapper namespace="com.caimei365.order.mapper.CartClubMapper">
     <!-- 购物车供应商列表 -->
     <select id="getCartShops" resultType="com.caimei365.order.model.vo.CartShopVo">
         SELECT

+ 5 - 0
src/main/resources/mapper/CartSellerMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.order.mapper.CartSellerMapper">
+
+</mapper>