CeDo
2021-04-20 726f97c55b0937bf0d048313271bdd7a80cdd1f6
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
@@ -4,19 +4,21 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.shop.PageComShopGoodsDTO;
import com.panzhihua.common.model.dtos.shop.PageComShopStoreDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.shop.ComShopStoreVO;
import com.panzhihua.common.model.vos.shop.ShopGoodsVO;
import com.panzhihua.common.model.vos.shop.PageShopStoreVO;
import com.panzhihua.common.model.vos.shop.PageShopStoreVO;
import com.panzhihua.service_community.dao.ComShopGoodsDAO;
import com.panzhihua.common.model.vos.shop.PageShopStoreVO;
import com.panzhihua.common.model.vos.shop.ShopStoreVO;
import com.panzhihua.service_community.dao.ComShopStoreDAO;
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;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
 * @auther lyq
@@ -26,11 +28,47 @@
@Slf4j
@Service
public class ComShopStoreServiceImpl extends ServiceImpl<ComShopStoreDAO, ComShopStoreDO> implements ComShopStoreService {
    @Resource
    private ComShopGoodsDAO shopGoodsDAO;
    /**
     * 查询店铺列表
     * @param pageComShopStoreDTO   请求参数
     * @return  店铺列表
     */
    @Override
    public R pageStoreList(PageComShopStoreDTO pageComShopStoreDTO) {
        Page page = new Page<>(pageComShopStoreDTO.getPageNum(), pageComShopStoreDTO.getPageSize());
        IPage<ComShopStoreVO> comShopStoreVOIPage = this.baseMapper.pageShopStore(page, pageComShopStoreDTO);
        IPage<PageShopStoreVO> comShopStoreVOIPage = this.baseMapper.pageShopStore(page, pageComShopStoreDTO);
        return R.ok(comShopStoreVOIPage);
    }
    /**
     * 查询店铺详情
     * @param comShopStoreDTO   请求参数
     * @return  店铺详情
     */
    @Override
    public R shopStoreDetail(PageComShopStoreDTO comShopStoreDTO) {
        //查询店铺
        ComShopStoreDO storeDO = this.baseMapper.selectById(comShopStoreDTO.getStoreId());
        if (storeDO == null) {
            return R.fail(401,"店铺不存在");
        }
        if(storeDO.getStatus().equals(ComShopStoreDO.status.no)){
            return R.fail(402,"店铺已被禁用");
        }
        PageShopStoreVO shopStoreVO = new PageShopStoreVO();
        BeanUtils.copyProperties(storeDO, shopStoreVO);
        //查询店铺下商品信息
        Page page = new Page<>(comShopStoreDTO.getPageNum(), comShopStoreDTO.getPageSize());
        shopStoreVO.setGoodsList(shopGoodsDAO.pageShopGoodsByStoreId(page, comShopStoreDTO).getRecords());
        return R.ok(shopStoreVO);
    }
    @Override
@@ -59,10 +97,10 @@
    @Override
    public R deleteStore(Long[] id) {
        ComShopStoreDO storeDO = new ComShopStoreDO();
        storeDO.setDeleteStatus(2);
        LambdaQueryWrapper<ComShopStoreDO> query = new LambdaQueryWrapper<ComShopStoreDO>().eq(ComShopStoreDO::getId, id);
        int update = this.baseMapper.update(storeDO, query);
        LambdaQueryWrapper<ComShopStoreDO> query = new LambdaQueryWrapper<ComShopStoreDO>().in(ComShopStoreDO::getId, id);
        ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(query);
        comShopStoreDO.setDeleteStatus(2);
        int update = this.baseMapper.updateById(comShopStoreDO);
        return update > 0 ? R.ok() : R.fail();
    }
@@ -76,4 +114,15 @@
        BeanUtils.copyProperties(comShopStoreDO,shopStoreVO);
        return R.ok(shopStoreVO);
    }
    @Override
    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,"商铺不存在");
        }
        ShopStoreVO shopStoreVO = new ShopStoreVO();
        BeanUtils.copyProperties(comShopStoreDO,shopStoreVO);
        return R.ok(shopStoreVO);
    }
}