huanghongfa
2021-04-27 66e6e417d69c5ccebc61082519e4e65eff81b490
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
@@ -28,7 +28,9 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -45,6 +47,10 @@
    private ComShopGoodsDAO shopGoodsDAO;
    @Resource
    private ComShopGoodsAttrDAO comShopGoodsAttrDAO;
    @Resource
    private ComShopOrderService orderService;
    @Resource
    private UserService userService;
    /**
     * 查询店铺列表
     *
@@ -56,13 +62,26 @@
    public R pageStoreList(PageComShopStoreDTO pageComShopStoreDTO) {
        Page page = new Page<>(pageComShopStoreDTO.getPageNum(), pageComShopStoreDTO.getPageSize());
        IPage<PageShopStoreVO> comShopStoreVOIPage = this.baseMapper.pageShopStore(page, pageComShopStoreDTO);
        if(comShopStoreVOIPage!=null){
            Optional.ofNullable(comShopStoreVOIPage.getRecords()).orElse(new ArrayList<>()).forEach(shopStoreVO ->{
                List<Integer> notDoneOrderStatus = new ArrayList<>();
                notDoneOrderStatus.add(1);
                notDoneOrderStatus.add(2);
                notDoneOrderStatus.add(3);
                notDoneOrderStatus.add(4);
                Integer orderCount = orderService.getBaseMapper()
                        .selectCount(new LambdaQueryWrapper<ComShopOrderDO>()
                                .eq(ComShopOrderDO::getStoreId, shopStoreVO.getId())
                                .eq(ComShopOrderDO::getDeleteStatus, 1)
                                .in(ComShopOrderDO::getStatus, notDoneOrderStatus)
                        );
                if(orderCount!=null && orderCount.intValue()>0){
                    shopStoreVO.setOrderDone(false);
                }
            });
        }
        return R.ok(comShopStoreVOIPage);
    }
    @Resource
    private UserService userService;
    @Resource
    private ComShopOrderService orderService;
    /**
     * 查询店铺详情
@@ -246,10 +265,13 @@
            R<LoginUserInfoVO> loginUserInfoVOR = userService.getUserInfo(account+"_5");
            LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(JSONObject.toJSONString(loginUserInfoVOR.getData()), LoginUserInfoVO.class);
            if(loginUserInfoVO==null){
                return R.fail(500, "该账号不存在");
            }
            ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>()
                    .eq(ComShopStoreDO::getDeleteStatus, 1).eq(ComShopStoreDO::getSysUserId, loginUserInfoVO.getUserId()));
            if (comShopStoreDO == null) {
                R.fail(500, "商铺不存在");
                return  R.fail(500, "该账号不存在");
            }
            ShopStoreVO shopStoreVO = new ShopStoreVO();
            BeanUtils.copyProperties(comShopStoreDO, shopStoreVO);