From e3c5378b79d23f4cebb4059c78bfbdd32cd5a2f9 Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期一, 26 四月 2021 14:02:46 +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 |   52 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 15 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 3ce3e4e..17701c2 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,7 +19,9 @@
 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;
@@ -27,6 +29,8 @@
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @auther lyq
@@ -41,9 +45,6 @@
     private ComShopGoodsDAO shopGoodsDAO;
     @Resource
     private ComShopGoodsAttrDAO comShopGoodsAttrDAO;
-    @Resource
-    private UserService userService;
-
     /**
      * 查询店铺列表
      *
@@ -54,9 +55,14 @@
     @Override
     public R pageStoreList(PageComShopStoreDTO pageComShopStoreDTO) {
         Page page = new Page<>(pageComShopStoreDTO.getPageNum(), pageComShopStoreDTO.getPageSize());
-        IPage<PageShopStoreVO> comShopStoreVOIPage = this.baseMapper.pageShopStoreByAdmin(page, pageComShopStoreDTO);
+        IPage<PageShopStoreVO> comShopStoreVOIPage = this.baseMapper.pageShopStore(page, pageComShopStoreDTO);
         return R.ok(comShopStoreVOIPage);
     }
+
+    @Resource
+    private UserService userService;
+    @Resource
+    private ComShopOrderService orderService;
 
     /**
      * 查询店铺详情
@@ -162,14 +168,16 @@
 
     @Override
     public R editStore(Long id, ShopStoreVO storeVO) {
-        if (storeVO == null) {
-            return R.ok("500", "数据为空!");
+        ComShopStoreDO storeDO = this.baseMapper.selectById(id);
+        if(storeDO == null){
+            return R.fail("商家不存在");
         }
-        LambdaQueryWrapper<ComShopStoreDO> query = new LambdaQueryWrapper<ComShopStoreDO>().eq(ComShopStoreDO::getId, id);
-        ComShopStoreDO storeDO = new ComShopStoreDO();
         BeanUtils.copyProperties(storeVO, storeDO);
-        int update = this.baseMapper.update(storeDO, query);
-        return update > 0 ? R.ok() : R.fail();
+        if(this.baseMapper.updateById(storeDO) > 0){
+            return R.ok();
+        }else{
+            return R.fail();
+        }
     }
 
     @Override
@@ -183,11 +191,22 @@
                         .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);
             }
@@ -201,7 +220,7 @@
     public R getOneInfo(Long id) {
         ComShopStoreDO comShopStoreDO = this.baseMapper.selectById(id);
         if (comShopStoreDO == null) {
-            R.fail(500, "商铺不存在");
+            return R.fail(500, "商铺不存在");
         }
         ShopStoreVO shopStoreVO = new ShopStoreVO();
         BeanUtils.copyProperties(comShopStoreDO, shopStoreVO);
@@ -212,7 +231,7 @@
     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, "商铺不存在");
+            return R.fail(500, "商铺不存在");
         }
         ShopStoreVO shopStoreVO = new ShopStoreVO();
         BeanUtils.copyProperties(comShopStoreDO, shopStoreVO);
@@ -225,10 +244,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