From 76bb1a5538a376d307fda90fa3ad7ee4a5887905 Mon Sep 17 00:00:00 2001
From: CeDo <cedoo@qq.com>
Date: 星期三, 21 四月 2021 20:41:24 +0800
Subject: [PATCH] bugfixed:限制商铺 订单发货方式

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 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 bb925ad..3ce3e4e 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
@@ -176,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();
     }

--
Gitblit v1.7.1