From a3aa71fd0ba1b48fe52f080e8d2776f50c5ed514 Mon Sep 17 00:00:00 2001 From: CeDo <cedoogle@gmail.com> Date: 星期二, 27 四月 2021 11:32:36 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 50 insertions(+), 5 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java index 9e6e1c0..7ecccad 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java @@ -19,14 +19,20 @@ 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.ComShopOrderDO; import com.panzhihua.service_community.model.dos.ComShopStoreDO; +import com.panzhihua.service_community.service.ComShopOrderService; 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; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @auther lyq @@ -42,8 +48,9 @@ @Resource private ComShopGoodsAttrDAO comShopGoodsAttrDAO; @Resource + private ComShopOrderService orderService; + @Resource private UserService userService; - /** * 查询店铺列表 * @@ -55,6 +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(true); + }else{ + shopStoreVO.setOrderDone(false); + } + }); + } return R.ok(comShopStoreVOIPage); } @@ -133,8 +160,10 @@ ComShopStoreDO oldComShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>() .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.no)); if (oldComShopStoreDO != null) { - return R.fail("商家已注册"); + return R.fail("商家账号已注册"); } + //TODO 判断用户 + //this.baseMapper.select(storeVO.getPhone()); //新增店铺先判断是否拥有已删除的店铺 ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>() .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.yes)); @@ -185,13 +214,26 @@ .lambda().eq(ComShopGoodsDO::getStoreId,shopStoreDO.getId()) .eq(ComShopGoodsDO::getDeleteStatus,ComShopGoodsDO.deleteStatus.no) .eq(ComShopGoodsDO::getStatus,ComShopGoodsDO.status.sell)); - if(!shopGoodsList.isEmpty()){//如果有正常商品则提示无法删除 return R.fail("店铺下有商品正在出售,无法删除店铺"); } - + List<ComShopOrderDO> comShopOrderDOS = orderService.getBaseMapper().selectList(new LambdaQueryWrapper<ComShopOrderDO>() + .eq(ComShopOrderDO::getStoreId,shopStoreDO.getId())); + List<ComShopOrderDO> filterOrder = comShopOrderDOS.stream() + .filter(order -> order.getStatus() < ComShopOrderDO.status.dpj) + .collect(Collectors.toList()); + if(!filterOrder.isEmpty()){ + return R.fail("该商家还有订单未完成,不能删除"); + } + //删除商家下的订单 + comShopOrderDOS.forEach(order->{ + order.setDeleteStatus(ComShopOrderDO.deleteStatus.yes); + orderService.getBaseMapper().updateById(order); + }); shopStoreDO.setDeleteStatus(2); this.baseMapper.updateById(shopStoreDO); + //删除sys_user 物理删除 + this.baseMapper.deleteSysUserBySysUserId(shopStoreDO.getSysUserId()); } }else { return R.fail("未查询到店铺"); @@ -227,10 +269,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); -- Gitblit v1.7.1