springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ShopApi.java
@@ -74,6 +74,16 @@ return communityService.shopCartList(userId); } @ApiOperation(value = "查询用户购物车商品数量") @PostMapping("shopCartUserTotal") public R shopCartUserTotal() { Long userId = this.getUserId(); if(userId == null){ return R.fail("请重新登陆"); } return communityService.shopCartUserTotal(userId); } @ApiOperation(value = "购物车添加") @PostMapping("shopAddCart") public R shopAddCart(@RequestBody ComShopCartDTO comShopCartDTO) { springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -1918,6 +1918,14 @@ R shopCartList(@RequestParam("userId") Long userId); /** * 查询用户购物车数量 * @param userId 用户id * @return 用户购物车商品数量 */ @PostMapping("/shop/shopCartUserTotal") R shopCartUserTotal(@RequestParam("userId") Long userId); /** * 购物车添加 * @param comShopCartDTO 请求参数 * @return 购物车列表 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ShopApi.java
@@ -185,6 +185,16 @@ } /** * 查询用户购物车数量 * @param userId 用户id * @return 用户购物车商品数量 */ @PostMapping("shopCartUserTotal") public R shopCartUserTotal(@RequestParam("userId") Long userId) { return comShopCartService.shopCartUserTotal(userId); } /** * 购物车添加 * @param comShopCartDTO 请求参数 * @return 添加结果 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComShopStoreDAO.java
@@ -22,7 +22,7 @@ "select id,`name`,store_password,contacts,store_account,classify_id,logo,phone,delivery_type,remark,`status`," + "sale,sale_volume,store_detail,create_at from com_shop_store c" + " <where>" + "c.delete_status=1" + " and c.delete_status=1 and c.status = 1 " + "<if test='pageComShopStoreDTO.contacts != null and pageComShopStoreDTO.contacts.trim() != ""'>" + "and c.contacts like concat('%',#{pageComShopStoreDTO.contacts},'%') \n" + " </if> " + springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComShopCartService.java
@@ -43,6 +43,13 @@ */ R shopDelCart(List<Long> Ids); /** * 查询用户购物车商品数量 * @param userId 用户id * @return 用户购物车商品数量 */ R shopCartUserTotal(Long userId); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopCartServiceImpl.java
@@ -208,4 +208,28 @@ return R.fail("修改失败"); } } /** * 查询用户购物车商品数量 * @param userId 用户id * @return 用户购物车商品数量 */ public R shopCartUserTotal(Long userId){ int goodsNum = 0; //查询用户购物车所有商品集合 List<ComShopCartDO> shopCartDOList = this.baseMapper.selectList(new QueryWrapper<ComShopCartDO>().eq("user_id",userId)); if(!shopCartDOList.isEmpty()){ for (ComShopCartDO cartDO:shopCartDOList) { //查询当前商品是否是有效商品 ComShopGoodsDO goodsDO = shopGoodsDAO.selectOne(new QueryWrapper<ComShopGoodsDO>() .eq("id",cartDO.getGoodsId()).eq("delete_status",ComShopGoodsDO.deleteStatus.no) .eq("status",ComShopGoodsDO.status.sell)); if(goodsDO != null){ goodsNum++; } } } return R.ok(goodsNum); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
@@ -1,6 +1,7 @@ package com.panzhihua.service_community.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -11,6 +12,8 @@ import com.panzhihua.service_community.dao.ComShopGoodsAttrDAO; import com.panzhihua.service_community.dao.ComShopGoodsDAO; import com.panzhihua.service_community.dao.ComShopStoreDAO; import com.panzhihua.service_community.model.dos.ComShopGoodsAttrDO; import com.panzhihua.service_community.model.dos.ComShopGoodsDO; import com.panzhihua.service_community.model.dos.ComShopGoodsAttrDO; import com.panzhihua.service_community.model.dos.ComShopStoreDO; import com.panzhihua.service_community.service.ComShopStoreService; @@ -119,9 +122,23 @@ public R deleteStore(Long[] id) { LambdaQueryWrapper<ComShopStoreDO> query = new LambdaQueryWrapper<ComShopStoreDO>().in(ComShopStoreDO::getId, id); List<ComShopStoreDO> comShopStoreDO = this.baseMapper.selectList(query); for (ComShopStoreDO shopStoreDO:comShopStoreDO) { shopStoreDO.setDeleteStatus(2); int update = this.baseMapper.updateById(shopStoreDO); if(!comShopStoreDO.isEmpty()){ for (ComShopStoreDO shopStoreDO:comShopStoreDO) { //判断店铺下是否拥有正常的商品 List<ComShopGoodsDO> shopGoodsList = shopGoodsDAO.selectList(new QueryWrapper<ComShopGoodsDO>() .lambda().eq(ComShopGoodsDO::getStoreId,shopStoreDO.getId()) .eq(ComShopGoodsDO::getDeleteStatus,ComShopGoodsDO.deleteStatus.no) .eq(ComShopGoodsDO::getStatus,ComShopGoodsDO.status.sell)); if(!shopGoodsList.isEmpty()){//如果有正常商品则提示无法删除 return R.fail("店铺下有商品正在出售,无法删除店铺"); } shopStoreDO.setDeleteStatus(2); this.baseMapper.updateById(shopStoreDO); } }else { return R.fail("未查询到店铺"); } return R.ok(); }