Parcourir la source

APP购物车调整

FengChaoYu il y a 1 mois
Parent
commit
e87194cef6

+ 0 - 46
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/bean/goods/GoodsBean.java

@@ -29,61 +29,15 @@ public class GoodsBean extends Goods {
     @ApiModelProperty("是否收藏标记")
     private Boolean favorite;
 
-    @ApiModelProperty(value = "秒杀id")
-    private String secKillId;
-
-    @ApiModelProperty("团购活动id")
-    private String promotionGroupId;
-
-    @ApiModelProperty("团长id")
-    private String groupUserId;
-
-    @ApiModelProperty("团长昵称")
-    private String groupUserName;
-
-    @ApiModelProperty("团长头像")
-    private String groupPic;
-
-    @ApiModelProperty(value = "秒杀商品规格id")
-    private String secKillSpecId;
-
-    @ApiModelProperty(value = "秒杀商品库存")
-    private Integer secStockNum;
-
     @ApiModelProperty(value = "秒杀商品限制购买数量")
     private Integer limitBuy;
 
-    @ApiModelProperty(value = "场次结束时间")
-    private Integer endHour;
-
-    @ApiModelProperty(value = "秒杀价格")
-    private BigDecimal secPrice;
-
-    @ApiModelProperty(value = "是否正在秒杀商品,true:秒杀中,false:非秒杀")
-    private Boolean secType;
-
     @ApiModelProperty("商品模板")
     private CommonTemplate commonTemplate;
 
     @ApiModelProperty("公共商品模板")
     private PubTemplate pubCommonTemplate;
 
-    @ApiModelProperty("当前角色的佣金")
-    private BigDecimal shareAmount;
-
-    @ApiModelProperty("正常佣金")
-    private BigDecimal shareAmount1;
-    @ApiModelProperty("内部佣金")
-    private BigDecimal shareAmount2;
-
-    @ApiModelProperty("是否为商户账号")
-    private Boolean isMaster = false;
-
-    @ApiModelProperty("满几件最优惠(满件商品才有该字段)")
-    private Integer promotionFullPieceNum;
-    @ApiModelProperty("满件条件最优惠的单价(满件商品才有该字段)")
-    private BigDecimal promotionFullPiecePrice;
-
     private List<String> tags1;
     private List<String> tags2;
 

+ 2 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/bean/order/ShoppingCartBean.java

@@ -12,6 +12,8 @@ public class ShoppingCartBean {
 
     @ApiModelProperty("用户id")
     private String userId;
+    @ApiModelProperty("库存id")
+    private String storageId;
     @ApiModelProperty("购物清单")
     private List<BuyGood> buyGoods;
 

+ 3 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/bean/order/ShoppingCartList.java

@@ -26,6 +26,9 @@ public class ShoppingCartList extends ShoppingCart {
     @ApiModelProperty("满件打折商品")
     private Boolean promotionFullPiece;
 
+    @ApiModelProperty("库存数量")
+    private Integer stockQty;
+
 //    @ApiModelProperty("商品单位")
 //    private String measureUnit;
 

+ 1 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/AppMapper.java

@@ -20,7 +20,7 @@ public interface AppMapper {
      * @return
      */
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
-    public List<ShoppingCartList> queryShoppingCartList(@Param("userId") String userId);
+    public List<ShoppingCartList> queryShoppingCartList(@Param("userId") String userId, @Param("storageId") String storageId);
 
 
     /**

+ 2 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/goods/GoodsController.java

@@ -159,9 +159,9 @@ public class GoodsController {
             HttpServletRequest request,
             @ApiParam(value = "id",required = true) @RequestParam String goodsId,
             @ApiParam(value = "userId",required = false) @RequestParam(required = false) String userId,
-            @ApiParam(value = "wxSceneId",required = false) @RequestParam(required = false) String wxSceneId
+            @ApiParam(value = "storageId",required = true) @RequestParam(required = false) String storageId
     ) throws RemoteServiceException {
-        GoodsBean detail = goodsLogic.detail(request, goodsId,userId,wxSceneId);
+        GoodsBean detail = goodsLogic.detail(request, goodsId, userId, storageId);
         return ResponseHelper.success(detail);
     }
 

+ 10 - 7
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/order/ShoppingCartController.java

@@ -36,9 +36,10 @@ public class ShoppingCartController {
     @GetMapping("/list")
     @ApiOperation("购物车列表")
     public ResponseHelper<ShoppingCartDetail> list(
-            @ApiParam(value = "用户id",required = true) @RequestParam String userId
-    ) throws InterruptedException {
-        ShoppingCartDetail shoppingCartLists = shoppingCartLogic.queryShoppingCart(userId);
+            @ApiParam(value = "用户id",required = true) @RequestParam String userId,
+            @ApiParam(value = "库存id",required = true) @RequestParam String storageId
+    ) {
+        ShoppingCartDetail shoppingCartLists = shoppingCartLogic.queryShoppingCart(userId, storageId);
         return ResponseHelper.success(shoppingCartLists);
     }
 
@@ -53,16 +54,17 @@ public class ShoppingCartController {
     @PostMapping("/add")
     @ApiOperation("添加到购物车")
     public ResponseHelper<ShoppingCartDetail> addShoppingCart(HttpServletRequest request,@RequestBody ShoppingCartBean shoppingCartBean) throws RemoteServiceException, InterruptedException {
-        ShoppingCartDetail shoppingCartDetail = shoppingCartLogic.addShoppingCart(request , shoppingCartBean);
+        ShoppingCartDetail shoppingCartDetail = shoppingCartLogic.addShoppingCart(request, shoppingCartBean);
         return ResponseHelper.success(shoppingCartDetail);
     }
 
     @PostMapping("/clear")
     @ApiOperation("清空购物车")
     public ResponseHelper clearShoppingCart(
-            @ApiParam(value = "用户id",required = true) @RequestParam String userId
+            @ApiParam(value = "用户id",required = true) @RequestParam String userId,
+            @ApiParam(value = "库存id",required = true) @RequestParam String storageId
     ){
-        shoppingCartLogic.clearShoppingCart(userId);
+        shoppingCartLogic.clearShoppingCart(userId, storageId);
         return ResponseHelper.success();
     }
 
@@ -70,9 +72,10 @@ public class ShoppingCartController {
     @ApiOperation("删除购物车商品")
     public ResponseHelper<ShoppingCartDetail> clearShoppingCart(
             @ApiParam(value = "用户id",required = true) @RequestParam String userId,
+            @ApiParam(value = "库存id",required = true) @RequestParam String storageId,
             @ApiParam(value = "购物车ids",required = true) @RequestParam List<String> shoppingCartIds
     ) throws InterruptedException {
-        ShoppingCartDetail remove = shoppingCartLogic.remove(userId, shoppingCartIds);
+        ShoppingCartDetail remove = shoppingCartLogic.remove(userId, storageId, shoppingCartIds);
         return ResponseHelper.success(remove);
     }
 

+ 10 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/renovation/RenovationController.java

@@ -10,6 +10,7 @@ import com.gree.mall.miniapp.logic.renovation.RenovationLogic;
 import com.gree.mall.miniapp.plus.entity.AdminCompanyWechatTemplate;
 import com.gree.mall.miniapp.plus.entity.GoodsNewsCategory;
 import com.gree.mall.miniapp.plus.entity.OrderShare;
+import com.gree.mall.miniapp.plus.entity.Storage;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiOperation;
@@ -87,5 +88,13 @@ public class RenovationController {
         return ResponseHelper.success(orderShares);
     }
 
-
+    @ApiNotAuth
+    @GetMapping("/storage/list")
+    @ApiOperation("仓库列表")
+    public ResponseHelper<List<Storage>> storageList(
+            HttpServletRequest request
+    ) throws RemoteServiceException {
+        List<Storage> storageList = renovationLogic.storageList(request);
+        return ResponseHelper.success(storageList);
+    }
 }

+ 32 - 38
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/goods/GoodsLogic.java

@@ -58,6 +58,8 @@ public class GoodsLogic {
 
     @Autowired
     GoodsTagRelaService goodsTagRelaService;
+    @Resource
+    GoodsMaterialStorageService goodsMaterialStorageService;
 
     /**
      * 商品列表
@@ -112,18 +114,17 @@ public class GoodsLogic {
     /**
      * 商品详情
      */
-    public GoodsBean detail(HttpServletRequest request, String goodsId,String userId,String wxSceneId){
+    public GoodsBean detail(HttpServletRequest request, String goodsId, String userId, String storageId) {
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
 
         User user = userService.getById(userId);
 
-
-        GoodsBean goodsBean = this.commonDetail(goodsId, user,wxSceneId);
+        GoodsBean goodsBean = this.commonDetail(goodsId, user, storageId);
 
         //补充标签
         //查询上标签
         List<GoodsTagRela> list1 = goodsTagRelaService.lambdaQuery().eq(GoodsTagRela::getGoodsId, goodsBean.getGoodsId())
-                .eq(GoodsTagRela::getType,1).list();
+                .eq(GoodsTagRela::getType, 1).list();
         if (list1.size() > 0) {
             List<String> collect1 = list1.stream().map(GoodsTagRela::getGoodsTagName).collect(Collectors.toList());
             goodsBean.setTags1(collect1);
@@ -132,7 +133,7 @@ public class GoodsLogic {
         //查询活动专区标签 //查询下标签
         //活动商品
         List<GoodsTagRela> list2 = goodsTagRelaService.lambdaQuery().eq(GoodsTagRela::getGoodsId, goodsBean.getGoodsId())
-                .eq(GoodsTagRela::getType,2).list();
+                .eq(GoodsTagRela::getType, 2).list();
         if (list2.size() > 0) {
             List<String> collect1 = list2.stream().map(GoodsTagRela::getGoodsTagName).collect(Collectors.toList());
             goodsBean.setTags2(collect1);
@@ -140,17 +141,15 @@ public class GoodsLogic {
 
 
         //记录用户浏览记录
-        if(user != null) {
+        if (user != null) {
             GoodsVisit goodsVisit = new GoodsVisit();
             goodsVisit.setGoodsId(goodsId);
             goodsVisit.setGoodsName(goodsBean.getGoodsName());
             goodsVisit.setUserId(userId);
             goodsVisit.setUserName(user.getNickName());
             goodsVisit.setUserPhone(user.getMobile());
-            goodsVisit.setPromotionGroupId(goodsBean.getPromotionGroupId());
             goodsVisit.setGoodsPrice(goodsBean.getGoodsPrice());
             goodsVisit.setGoodsStatus(goodsBean.getStatus());
-            goodsVisit.setShareUserId(goodsBean.getGroupUserId());
             goodsVisit.setGoodsImg(goodsBean.getImgUrl());
             goodsVisit.setCompanyWechatId(currentCompanyWechat.getCurrentCompanyWechatId());
             goodsVisit.setCompanyName(currentCompanyWechat.getCurrentCompanyName());
@@ -167,18 +166,8 @@ public class GoodsLogic {
      * @param goodsId
      * @return
      */
-    public GoodsBean commonDetail(String goodsId,User user,String wxSceneId) throws RemoteServiceException {
-        User service = null;
-        String serviceId = null;
-        AdminCompanyWechat adminCompanyWechat = null;
-        if(user != null) {
-            serviceId = user.getServiceId();
-            if (user.getType().equals(UserTypeEnum.SERVICE.toString())) {
-                serviceId = user.getUserId();
-            }
-            service = userService.getById(serviceId);
-            adminCompanyWechat = commonLogic.getAdminCompanyWechat(user.getCompanyWechatId());
-        }
+    public GoodsBean commonDetail(String goodsId, User user, String storageId) throws RemoteServiceException {
+        AdminCompanyWechat adminCompanyWechat = commonLogic.getAdminCompanyWechat(user.getCompanyWechatId());
 
         Goods goods = goodsService.lambdaQuery()
                 .eq(Goods::getGoodsId, goodsId)
@@ -188,33 +177,38 @@ public class GoodsLogic {
         if (goods == null) {
             throw new RemoteServiceException("商品不存在或已下架");
         }
-        //商品规格(包含秒杀商品)
+        //商品规格
         List<GoodsSpecSecBean> goodsSpecs = goodsSpecDetailMapper.querySpecSec(goodsId);
-        //是否有收藏
-        Integer goodsFavoritesCount = 0;
-        if (Objects.nonNull(user)) {
-            // 有user对象再查找
-            goodsFavoritesCount = goodsFavoriteService.lambdaQuery()
-                    .eq(GoodsFavorite::getGoodsId, goodsId)
-                    .eq(GoodsFavorite::getUserId, user.getUserId())
-                    .count();
-        }
+        final List<String> goodsMaterialIds = goodsSpecs.stream().map(GoodsSpecSecBean::getGoodsCode).collect(Collectors.toList());
 
-        //商品库存
-        Integer goodsStock = goodsSpecs.stream().mapToInt(GoodsSpec::getStockNum).sum();
-        GoodsBean goodsBean = new GoodsBean();
-        BeanUtils.copyProperties(goods, goodsBean);
+        // 获取规格库存
+        final Map<String, Integer> goodsMaterialStorageMap = goodsMaterialStorageService.lambdaQuery()
+                .eq(GoodsMaterialStorage::getStorageId, storageId)
+                .in(GoodsMaterialStorage::getGoodsMaterialId, goodsMaterialIds)
+                .list()
+                .stream()
+                .collect(Collectors.toMap(GoodsMaterialStorage::getGoodsMaterialId, GoodsMaterialStorage::getStockQty));
+
+        //是否有收藏
+        Integer goodsFavoritesCount = goodsFavoriteService.lambdaQuery()
+                .eq(GoodsFavorite::getGoodsId, goodsId)
+                .eq(GoodsFavorite::getUserId, user.getUserId())
+                .count();
 
-        //内部人员、秒杀活动、让利分享 等对价格分佣金额产生的影响处理
         for (GoodsSpecSecBean goodsSpec : goodsSpecs) {
+            final Integer stockQty = goodsMaterialStorageMap.get(goodsSpec.getGoodsCode());
+            goodsSpec.setStockNum(Objects.isNull(stockQty) ? 0 : stockQty);
             if (goodsSpec.getOrgPrice().doubleValue() == 0) {
                 goodsSpec.setOrgPrice(goodsSpec.getOrgGoodsPrice());
             }
         }
 
-        if(adminCompanyWechat != null) {
-            goodsBean.setIsMaster(StringUtils.equals(adminCompanyWechat.getLinkPhone(), user.getMobile()));
-        }
+        // 总商品库存
+        Integer goodsStock = goodsSpecs.stream().mapToInt(GoodsSpec::getStockNum).sum();
+        GoodsBean goodsBean = new GoodsBean();
+        BeanUtils.copyProperties(goods, goodsBean);
+
+
         goodsBean.setGoodsSpecs(goodsSpecs);
         goodsBean.setImages(commonLogic.queryFileByObjId(goods.getGoodsId(), Constant.Img.GOODS_IMG));
         goodsBean.setFavorite(goodsFavoritesCount > 0);

+ 17 - 33
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/order/ShoppingCartLogic.java

@@ -46,9 +46,9 @@ public class ShoppingCartLogic {
     /**
      * 查询购物车商品数量
      */
-    public Integer total(String userId){
+    public Integer total(String userId, String storageId){
         try {
-            List<ShoppingCartList> shoppingCartLists = this.queryShoppingCart(userId).getShoppingCartLists();
+            List<ShoppingCartList> shoppingCartLists = this.queryShoppingCart(userId, storageId).getShoppingCartLists();
             if (shoppingCartLists.size() == 0) {
                 return 0;
             }
@@ -63,31 +63,13 @@ public class ShoppingCartLogic {
     /**
      * 查询购物车
      */
-    public ShoppingCartDetail queryShoppingCart(String userId) throws InterruptedException {
+    public ShoppingCartDetail queryShoppingCart(String userId, String storageId) {
 
-        List<ShoppingCartList> list = appMapper.queryShoppingCartList(userId);
+        List<ShoppingCartList> list = appMapper.queryShoppingCartList(userId, storageId);
         User user = userService.getById(userId);
-        String promotionGroupUserId = user.getPromotionGroupUserId();
-        if(user.getPromotionGroupLeader()){
-            promotionGroupUserId = user.getUserId();
-        }
         int totalNum = 0;
         BigDecimal totalAmount = new BigDecimal(0);
         for(ShoppingCartList shoppingCart : list){
-            String promotionGroupId = shoppingCart.getPromotionGroupId();
-            String secKillId = shoppingCart.getSecKillId();
-            String goodsSpecId = shoppingCart.getGoodsSpecId();
-            //团购活动商品
-            if(StringUtils.isNotBlank(promotionGroupId)){
-                PromotionGroupSpecUser promotionGroupSpecUser = null;
-                try {
-                    promotionGroupSpecUser = promotionGroupLogic.getStock(promotionGroupUserId, goodsSpecId, 0);
-                }catch(Exception e){}
-                if(promotionGroupSpecUser != null) {
-                    shoppingCart.setPrice(promotionGroupSpecUser.getGroupPrice());
-                    shoppingCart.setOrgPrice(promotionGroupSpecUser.getOrgGoodsPrice());
-                }
-            }
             totalNum += shoppingCart.getNum();
             totalAmount = totalAmount.add(shoppingCart.getPrice());
         }
@@ -96,9 +78,7 @@ public class ShoppingCartLogic {
         shoppingCartDetail.setTotalAmount(totalAmount);
         shoppingCartDetail.setTotalNum(totalNum);
         shoppingCartDetail.setShoppingCartLists(list);
-        //当前有效的满件打折活动
-        List<PromotionFullPieceItem> items = promotionFullPieceLogic.getItems();
-        shoppingCartDetail.setPromotionFullPieceItems(items);
+
         return shoppingCartDetail;
     }
 
@@ -107,8 +87,9 @@ public class ShoppingCartLogic {
      */
     public ShoppingCartDetail addShoppingCart(HttpServletRequest request , ShoppingCartBean shoppingCartBean) throws RemoteServiceException, InterruptedException {
         String userId = shoppingCartBean.getUserId();
+        final String storageId = shoppingCartBean.getStorageId();
         //先清空
-        this.clearShoppingCart(userId);
+        this.clearShoppingCart(userId, storageId);
         User user = userService.getById(userId);
         List<BuyGood> buyGoods = shoppingCartBean.getBuyGoods();
         if(buyGoods == null || buyGoods.size() == 0){
@@ -143,7 +124,7 @@ public class ShoppingCartLogic {
         }
         shoppingCartService.saveBatch(shoppingCarts);
 
-        return this.queryShoppingCart(userId);
+        return this.queryShoppingCart(userId, storageId);
     }
 
 
@@ -157,6 +138,7 @@ public class ShoppingCartLogic {
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
 
         String userId = shoppingCartBean.getUserId();
+        String storageId = shoppingCartBean.getStorageId();
         User user = userService.getById(userId);
 
         List<BuyGood> buyGoods = shoppingCartBean.getBuyGoods();
@@ -173,6 +155,7 @@ public class ShoppingCartLogic {
                 .eq(ShoppingCart::getGoodsId, goodsId)
                 .eq(ShoppingCart::getGoodsSpecId, goodsSpecId)
                 .eq(ShoppingCart::getUserId, userId)
+                .eq(ShoppingCart::getStorageId, storageId)
                 .one();
         if(shoppingCart == null){
             ShoppingCart bean = new ShoppingCart();
@@ -188,19 +171,20 @@ public class ShoppingCartLogic {
             }
             bean.setCompanyWechatId(currentCompanyWechat.getCurrentCompanyWechatId());
             bean.setCompanyName(currentCompanyWechat.getCurrentCompanyName());
+            bean.setStorageId(storageId);
             bean.insert();
         }else{
             shoppingCart.setNum(shoppingCart.getNum()+buyGood.getNum());
             shoppingCart.updateById();
         }
-        return this.queryShoppingCart(userId);
+        return this.queryShoppingCart(userId, storageId);
     }
 
     /**
      * 清空购物车
      */
-    public void clearShoppingCart(String userId){
-        shoppingCartService.lambdaUpdate().eq(ShoppingCart::getUserId,userId).remove();
+    public void clearShoppingCart(String userId, String storageId){
+        shoppingCartService.lambdaUpdate().eq(ShoppingCart::getUserId,userId).eq(ShoppingCart::getStorageId, storageId).remove();
     }
 
     /**
@@ -221,9 +205,9 @@ public class ShoppingCartLogic {
     /**
      * 删除选中的商品
      */
-    public ShoppingCartDetail remove(String userId,List<String> shoppingCartIds) throws InterruptedException {
-        shoppingCartService.lambdaUpdate().in(ShoppingCart::getShoppingCartId,shoppingCartIds).remove();
-        return this.queryShoppingCart(userId);
+    public ShoppingCartDetail remove(String userId, String storageId, List<String> shoppingCartIds) throws InterruptedException {
+        shoppingCartService.lambdaUpdate().in(ShoppingCart::getShoppingCartId,shoppingCartIds).eq(ShoppingCart::getStorageId, storageId).remove();
+        return this.queryShoppingCart(userId, storageId);
     }
 
     /**

+ 14 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/renovation/RenovationLogic.java

@@ -13,6 +13,7 @@ import com.gree.mall.miniapp.plus.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
@@ -35,6 +36,8 @@ public class RenovationLogic {
     GoodsTagRelaService goodsTagRelaService;
     @Autowired
     OrderShareService orderShareService;
+    @Resource
+    StorageService storageService;
 
     /**
      * 小程序首页装修模板
@@ -88,4 +91,15 @@ public class RenovationLogic {
     }
 
 
+    /**
+     * 仓库列表
+     * @param request
+     * @return
+     */
+    public List<Storage> storageList(HttpServletRequest request) {
+        CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
+        return storageService.lambdaQuery()
+                .eq(Storage::getCompanyWechatId, currentCompanyWechat.getCompanyWechatId())
+                .list();
+    }
 }

+ 2 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/user/UserLogic.java

@@ -556,7 +556,7 @@ public class UserLogic {
         String token = JwtUtils.createJWT(user.getUserId(), name, 7 * 24 * 60 * 60 * 1000);
         BeanUtils.copyProperties(user, userWxBean);
         userWxBean.setToken(token);
-        userWxBean.setShoppingCartNums(shoppingCartLogic.total(userWxBean.getUserId()));
+        userWxBean.setShoppingCartNums(shoppingCartLogic.total(userWxBean.getUserId(), null));
         redisUtil.set(Constant.RedisPrefix.TOKEN_WX + token, userWxBean.getUserId(), 7 * 24 * 60 * 60 * 1000);
         return userWxBean;
     }
@@ -835,7 +835,7 @@ public class UserLogic {
         }
         UserWxBean userWxBean = new UserWxBean();
         BeanUtils.copyProperties(user, userWxBean);
-        userWxBean.setShoppingCartNums(shoppingCartLogic.total(userWxBean.getUserId()));
+        userWxBean.setShoppingCartNums(shoppingCartLogic.total(userWxBean.getUserId(), null));
         //userWxBean.setServiceWorkerBean(userInfoMapper.queryWebsit(user.getUserId()));
         userWxBean.setCompanyWechatMobile(currentCompanyWechat.getLinkPhone());
         userWxBean.setModuleMaterialPart(currentCompanyWechat.getModuleMaterialPart());

+ 16 - 10
mall-miniapp-service/src/main/resources/mapper/AppMapper.xml

@@ -3,16 +3,22 @@
 <mapper namespace="com.gree.mall.miniapp.commonmapper.AppMapper">
 
     <select id="queryShoppingCartList" resultType="com.gree.mall.miniapp.bean.order.ShoppingCartList">
-        select a.*,
-               b.price,
-               c.goods_name,
-               b.spec_value,
-               b.org_price,
-               b.price * num as 'totalPrice', c.img_url 'goodsImg'
-        from shopping_cart a
-                 join goods_spec b on a.goods_spec_id = b.goods_spec_id
-                 join goods c on c.goods_id = a.goods_id
-        where a.user_id = #{userId}
+        SELECT
+            a.*,
+            b.price,
+            c.goods_name,
+            b.spec_value,
+            b.org_price,
+            b.price * num AS 'totalPrice', c.img_url 'goodsImg',
+            IFNULL(d.stock_qty, 0) AS stock_qty
+        FROM shopping_cart a
+                JOIN goods_spec b ON a.goods_spec_id = b.goods_spec_id
+                JOIN goods c ON c.goods_id = a.goods_id
+                LEFT JOIN goods_material_storage d ON b.goods_code = d.goods_material_id
+        WHERE a.user_id = #{userId}
+        <if test="storageId != null and storageId != ''">
+        AND a.storage_id = #{storageId}
+        </if>
     </select>