From d0f8d410875660b7c9060af4bf25ca494fba3b67 Mon Sep 17 00:00:00 2001 From: DESKTOP-71BH0QO\L、ming <172680469@qq.com> Date: 星期二, 27 四月 2021 13:48:50 +0800 Subject: [PATCH] fix:修改添加商家接口 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java | 75 ++++++++++++++++++++----------------- 1 files changed, 40 insertions(+), 35 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 4976771..0b7564e 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 @@ -15,7 +15,6 @@ import com.panzhihua.common.service.user.UserService; import com.panzhihua.service_community.dao.ComShopGoodsAttrDAO; 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; @@ -32,7 +31,6 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * @auther lyq @@ -51,6 +49,7 @@ private ComShopOrderService orderService; @Resource private UserService userService; + /** * 查询店铺列表 * @@ -62,8 +61,8 @@ 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 ->{ + if (comShopStoreVOIPage != null) { + Optional.ofNullable(comShopStoreVOIPage.getRecords()).orElse(new ArrayList<>()).forEach(shopStoreVO -> { List<Integer> notDoneOrderStatus = new ArrayList<>(); notDoneOrderStatus.add(1); notDoneOrderStatus.add(2); @@ -75,7 +74,7 @@ .eq(ComShopOrderDO::getDeleteStatus, 1) .in(ComShopOrderDO::getStatus, notDoneOrderStatus) ); - if(orderCount!=null && orderCount.intValue()>0){ + if (orderCount != null && orderCount.intValue() > 0) { shopStoreVO.setOrderDone(false); } }); @@ -106,11 +105,11 @@ Page page = new Page<>(comShopStoreDTO.getPageNum(), comShopStoreDTO.getPageSize()); List<ComShopGoodsVO> goodsList = shopGoodsDAO.pageShopGoodsByStoreId(page, comShopStoreDTO).getRecords(); - if(!goodsList.isEmpty()){ + if (!goodsList.isEmpty()) { //查询商品规格列表 goodsList.forEach(goods -> { List<ComShopGoodsAttrVO> goodsAttrList = comShopGoodsAttrDAO.getGoodsAttr(goods.getId()); - if(!goodsAttrList.isEmpty()){ + if (!goodsAttrList.isEmpty()) { goods.setGoodsAttrList(goodsAttrList); } }); @@ -127,7 +126,7 @@ } //判断店铺是否存在 ComShopStoreDO oldComShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>() - .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.no)); + .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus, ComShopStoreDO.deleteStatus.no)); if (oldComShopStoreDO != null) { return R.fail("商家已注册"); } @@ -153,23 +152,29 @@ return R.ok(); } - public R addStore(ShopStoreVO storeVO){ + public R addStore(ShopStoreVO storeVO) { //判断店铺是否存在 ComShopStoreDO oldComShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>() - .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.no)); + .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus, ComShopStoreDO.deleteStatus.no)); if (oldComShopStoreDO != null) { return R.fail("商家账号已注册"); } - //TODO 判断用户 - //this.baseMapper.select(storeVO.getPhone()); + int reasonable1 = this.baseMapper.reasonableUserByPhone(storeVO.getPhone()); + int reasonable2 = this.baseMapper.reasonableUserByAccount(storeVO.getStoreAccount()); + if (reasonable1 > 0) { + return R.fail("手机号:" + storeVO.getPhone() + "在系统用户中已存在"); + } + if (reasonable2 > 0) { + return R.fail("账号:" + storeVO.getStoreAccount() + "在系统用户中已存在"); + } //新增店铺先判断是否拥有已删除的店铺 ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>() - .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.yes)); - if(comShopStoreDO != null){ + .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus, ComShopStoreDO.deleteStatus.yes)); + if (comShopStoreDO != null) { //删除店铺规格信息 - comShopGoodsAttrDAO.delete(new QueryWrapper<ComShopGoodsAttrDO>().lambda().eq(ComShopGoodsAttrDO::getStoreId,comShopStoreDO.getId())); + comShopGoodsAttrDAO.delete(new QueryWrapper<ComShopGoodsAttrDO>().lambda().eq(ComShopGoodsAttrDO::getStoreId, comShopStoreDO.getId())); //删除店铺商品 - shopGoodsDAO.delete(new QueryWrapper<ComShopGoodsDO>().lambda().eq(ComShopGoodsDO::getStoreId,comShopStoreDO.getId())); + shopGoodsDAO.delete(new QueryWrapper<ComShopGoodsDO>().lambda().eq(ComShopGoodsDO::getStoreId, comShopStoreDO.getId())); //删除关联的sysUser用户权限 this.baseMapper.deleteSysRoleByAccount(Constants.SHOP_ROLE_KEY + comShopStoreDO.getStoreAccount()); //删除关联的sysUser用户 @@ -180,9 +185,9 @@ ComShopStoreDO storeDO = new ComShopStoreDO(); BeanUtils.copyProperties(storeVO, storeDO); storeDO.setSale(0); - if(this.baseMapper.insert(storeDO) > 0){ + if (this.baseMapper.insert(storeDO) > 0) { return R.ok(); - }else{ + } else { return R.fail(); } } @@ -190,13 +195,13 @@ @Override public R editStore(Long id, ShopStoreVO storeVO) { ComShopStoreDO storeDO = this.baseMapper.selectById(id); - if(storeDO == null){ + if (storeDO == null) { return R.fail("商家不存在"); } BeanUtils.copyProperties(storeVO, storeDO); - if(this.baseMapper.updateById(storeDO) > 0){ + if (this.baseMapper.updateById(storeDO) > 0) { return R.ok(); - }else{ + } else { return R.fail(); } } @@ -205,26 +210,26 @@ public R deleteStore(Long[] id) { LambdaQueryWrapper<ComShopStoreDO> query = new LambdaQueryWrapper<ComShopStoreDO>().in(ComShopStoreDO::getId, id); List<ComShopStoreDO> comShopStoreDO = this.baseMapper.selectList(query); - if(!comShopStoreDO.isEmpty()){ - for (ComShopStoreDO shopStoreDO:comShopStoreDO) { + 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()){//如果有正常商品则提示无法删除 + .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())); + .eq(ComShopOrderDO::getStoreId, shopStoreDO.getId())); List<ComShopOrderDO> filterOrder = comShopOrderDOS.stream() .filter(order -> order.getStatus() < ComShopOrderDO.status.dpj) .collect(Collectors.toList()); - if(!filterOrder.isEmpty()){ + if (!filterOrder.isEmpty()) { return R.fail("店铺下还有订单未完成"); } //删除商家下的订单 - comShopOrderDOS.forEach(order->{ + comShopOrderDOS.forEach(order -> { order.setDeleteStatus(ComShopOrderDO.deleteStatus.yes); orderService.getBaseMapper().updateById(order); }); @@ -233,7 +238,7 @@ //删除sys_user 物理删除 this.baseMapper.deleteSysUserBySysUserId(shopStoreDO.getSysUserId()); } - }else { + } else { return R.fail("未查询到店铺"); } return R.ok(); @@ -264,21 +269,21 @@ @Override public R getUserStoreInfo(String account) { try { - R<LoginUserInfoVO> loginUserInfoVOR = userService.getUserInfo(account+"_5"); + R<LoginUserInfoVO> loginUserInfoVOR = userService.getUserInfo(account + "_5"); LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(JSONObject.toJSONString(loginUserInfoVOR.getData()), LoginUserInfoVO.class); - if(loginUserInfoVO==null){ + 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) { - return R.fail(500, "该账号不存在"); + return R.fail(500, "该账号不存在"); } ShopStoreVO shopStoreVO = new ShopStoreVO(); BeanUtils.copyProperties(comShopStoreDO, shopStoreVO); return R.ok(shopStoreVO); - }catch (Exception e){ + } catch (Exception e) { return R.fail(); } } -- Gitblit v1.7.1