CeDo
2021-04-22 037507bbe28ab8093c8cb20b4af85888f67be65a
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
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;
@@ -16,6 +17,8 @@
import com.panzhihua.service_community.dao.ComShopGoodsDAO;
import com.panzhihua.common.model.vos.shop.PageShopStoreVO;
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.ComShopStoreDO;
import com.panzhihua.service_community.service.ComShopStoreService;
import lombok.extern.slf4j.Slf4j;
@@ -173,9 +176,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();
    }
@@ -184,7 +201,7 @@
    public R getOneInfo(Long id) {
        ComShopStoreDO comShopStoreDO = this.baseMapper.selectById(id);
        if (comShopStoreDO == null) {
            R.fail(500, "商铺不存在");
            return R.fail(500, "商铺不存在");
        }
        ShopStoreVO shopStoreVO = new ShopStoreVO();
        BeanUtils.copyProperties(comShopStoreDO, shopStoreVO);
@@ -195,7 +212,7 @@
    public R getUserStoreInfo(Long userId) {
        ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>().eq(ComShopStoreDO::getDeleteStatus, 1).eq(ComShopStoreDO::getSysUserId, userId));
        if (comShopStoreDO == null) {
            R.fail(500, "商铺不存在");
            return R.fail(500, "商铺不存在");
        }
        ShopStoreVO shopStoreVO = new ShopStoreVO();
        BeanUtils.copyProperties(comShopStoreDO, shopStoreVO);