浏览代码

采美sku bugfix

zhijiezhao 2 年之前
父节点
当前提交
886d3edcb0

+ 30 - 11
src/main/java/com/caimei365/order/controller/CartSellerApi.java

@@ -21,7 +21,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/6/28
  */
-@Api(tags="协销购物车API")
+@Api(tags = "协销购物车API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/order/seller")
@@ -29,6 +29,25 @@ public class CartSellerApi {
 
     private final CartSellerService cartSellerService;
 
+
+    @ApiOperation("协销购物车重选商品sku")
+    @PostMapping("/check/sku")
+    public ResponseJson checkOldCart(SellerCartDto sellerCartDto) {
+        if (null == sellerCartDto.getClubId()) {
+            return ResponseJson.error("机构Id不能为空!", null);
+        }
+        if (null == sellerCartDto.getServiceProviderId()) {
+            return ResponseJson.error("协销Id不能为空!", null);
+        }
+        if (null == sellerCartDto.getProductCount()) {
+            return ResponseJson.error("购买数量不能为空!", null);
+        }
+        if (null == sellerCartDto.getOldSkuId() || null == sellerCartDto.getNewSkuId()) {
+            return ResponseJson.error("skuId不能为空!", null);
+        }
+        return cartSellerService.checkClubSkuId(sellerCartDto);
+    }
+
     /**
      * 协销购物车列表数据
      */
@@ -41,9 +60,9 @@ public class CartSellerApi {
             @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) {
+    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);
         }
@@ -82,11 +101,11 @@ public class CartSellerApi {
      *                      skuId        单一商品skuId
      *                      productCount 单一商品数量
      *                      productInfo  组合商品信息:Json字符串格式[{"skuId":4351,"count":1},{}]
-     * }
+     *                      }
      */
     @ApiOperation("协销添加购物车(旧:/seller/addCart)(/seller/batchAddCart)")
     @PostMapping("/cart/add")
-    public ResponseJson<Integer> addSellerCart(SellerCartDto sellerCartDto){
+    public ResponseJson<Integer> addSellerCart(SellerCartDto sellerCartDto) {
         if (null == sellerCartDto.getServiceProviderId()) {
             return ResponseJson.error("协销Id不能为空!", null);
         }
@@ -124,7 +143,7 @@ public class CartSellerApi {
      */
     @ApiOperation("协销更新购物车(旧:/seller/addProductNum)")
     @PostMapping("/cart/update")
-    public ResponseJson<Integer> updateSellerCart(SellerCartDto sellerCartDto){
+    public ResponseJson<Integer> updateSellerCart(SellerCartDto sellerCartDto) {
         if (null == sellerCartDto.getServiceProviderId()) {
             return ResponseJson.error("协销Id不能为空!", null);
         }
@@ -143,11 +162,11 @@ public class CartSellerApi {
      * @param sellerCartDto {
      *                      serviceProviderId 协销Id
      *                      cartIds           购物车IDs
-     * }
+     *                      }
      */
     @ApiOperation("协销删除购物车(旧:/seller/deleteSellerCart)")
     @PostMapping("/cart/delete")
-    public ResponseJson<Integer> deleteSellerCart(SellerCartDto sellerCartDto){
+    public ResponseJson<Integer> deleteSellerCart(SellerCartDto sellerCartDto) {
         if (null == sellerCartDto.getServiceProviderId()) {
             return ResponseJson.error("协销Id不能为空!", null);
         }
@@ -191,7 +210,7 @@ public class CartSellerApi {
             @ApiImplicitParam(required = false, name = "productCount", value = "商品数量")
     })
     @GetMapping("/second/settlement")
-    public ResponseJson<Map<String, Object>> buyNowProduct(Integer serviceProviderId, Integer clubId, Integer productId, Integer productCount){
+    public ResponseJson<Map<String, Object>> buyNowProduct(Integer serviceProviderId, Integer clubId, Integer productId, Integer productCount) {
         if (null == serviceProviderId) {
             return ResponseJson.error("协销Id不能为空!", null);
         }
@@ -218,7 +237,7 @@ public class CartSellerApi {
      */
     @ApiOperation("协销再来一单(订单商品加入购物车)(旧:/seller/order/again)")
     @PostMapping("/cart/again")
-    public ResponseJson<Map<String, Object>> addCartBuyAgain(AgainBuyDto againBuyDto){
+    public ResponseJson<Map<String, Object>> addCartBuyAgain(AgainBuyDto againBuyDto) {
         if (null == againBuyDto.getServiceProviderId()) {
             return ResponseJson.error("协销Id不能为空!", null);
         }

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

@@ -105,4 +105,6 @@ public interface CartSellerMapper {
      * @param orderId 订单Id
      */
     List<CartItemVo> getOrderProductNum(Integer orderId);
+
+    void deleteClubCart(SellerCartDto sellerCartDto);
 }

+ 4 - 0
src/main/java/com/caimei365/order/model/dto/SellerCartDto.java

@@ -56,4 +56,8 @@ public class SellerCartDto implements Serializable {
      */
     @ApiModelProperty("购物车ids,删除购物车用,逗号分隔")
     private String cartIds;
+
+    private Integer oldSkuId;
+
+    private Integer newSkuId;
 }

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

@@ -95,4 +95,6 @@ public interface CartSellerService {
      *                    }
      */
     ResponseJson<Map<String, Object>> addCartBuyAgain(AgainBuyDto againBuyDto);
+
+    ResponseJson checkClubSkuId(SellerCartDto sellerCartDto);
 }

+ 25 - 1
src/main/java/com/caimei365/order/service/impl/CartSellerServiceImpl.java

@@ -55,6 +55,7 @@ public class CartSellerServiceImpl implements CartSellerService {
     private ProductService productService;
     @Resource
     private OrderClubMapper orderClubMapper;
+
     /**
      * 协销购物车列表数据
      *
@@ -526,7 +527,9 @@ public class CartSellerServiceImpl implements CartSellerService {
                                     // 当前促销活动的价格计算列表
                                     List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
                                     // 更新到总促销列表
-                                    productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList, floor);
+                                    if(MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1){
+                                        productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList, floor);
+                                    }
                                     //单品满减-计算供应商总价/满减金额
                                     if (promotions.getType() == 1 && promotions.getMode() == 2) {
                                         if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
@@ -891,4 +894,25 @@ public class CartSellerServiceImpl implements CartSellerService {
         resultData.put("productIds", againBuyProductIds);
         return ResponseJson.success(resultData);
     }
+
+    @Override
+    public ResponseJson checkClubSkuId(SellerCartDto sellerCartDto) {
+        cartSellerMapper.deleteClubCart(sellerCartDto);
+        sellerCartDto.setSkuId(sellerCartDto.getNewSkuId());
+        SellerCartPo cart = cartSellerMapper.getSellerCart(sellerCartDto);
+        if (cart != null) {
+            // 购物车已存在该商品,更新数量
+            cart.setNum(cart.getNum() + sellerCartDto.getProductCount());
+            cart.setAddTime(new Date());
+            cartSellerMapper.updateSellerCart(cart);
+        } else {
+            // 添加新购物车
+            Integer shopId = baseMapper.getShopIdByproductId(sellerCartDto.getSkuId());
+            cart.setShopId(shopId);
+            cart.setNum(sellerCartDto.getProductCount());
+            cart.setAddTime(new Date());
+            cartSellerMapper.insertSellerCart(cart);
+        }
+        return ResponseJson.success();
+    }
 }

+ 7 - 0
src/main/java/com/caimei365/order/service/impl/HeliPayServiceImpl.java

@@ -1173,6 +1173,13 @@ public class HeliPayServiceImpl implements HeliPayService {
                         orderProduct.setSvipPriceTag("¥" + orderProduct.getDiscountPrice());
                     }
                 }
+                //前端要求把price置为折后单价,totalAmount置为折后总价
+                if (null != orderProduct.getDiscountPrice()) {
+                    orderProduct.setPrice(orderProduct.getDiscountPrice());
+                }
+                if (null != orderProduct.getTotalFee()) {
+                    orderProduct.setTotalAmount(orderProduct.getTotalFee());
+                }
             });
             shopOrder.setObligation(MathUtil.sub(shopOrder.getRealPay(), shopOrder.getReceiptAmount()).doubleValue());
             if (998 == shopOrder.getShopId()) {

+ 6 - 1
src/main/resources/mapper/CartSellerMapper.xml

@@ -103,6 +103,12 @@
             #{skuId}
         </foreach>
     </delete>
+    <delete id="deleteClubCart">
+        delete from bp_order_product_cart
+        where skuId=#{oldSkuId}
+        and serviceProviderId=#{serviceProviderId}
+        and clubId=#{clubId}
+    </delete>
     <select id="getCartShopsByProductIds" resultType="com.caimei365.order.model.vo.CartShopVo">
         SELECT DISTINCT
         c.shopId,
@@ -207,5 +213,4 @@
         WHERE orderID = #{orderID}
         GROUP BY op.ProductID
     </select>
-
 </mapper>