瀏覽代碼

fixed 租户信息的删除

fushengqian 5 月之前
父節點
當前提交
05c9460023

+ 16 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/MerchantServiceImpl.java

@@ -10,8 +10,10 @@ import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.repository.mapper.MtGoodsMapper;
 import com.fuint.repository.mapper.MtMerchantMapper;
 import com.fuint.repository.mapper.MtStoreMapper;
+import com.fuint.repository.model.MtGoods;
 import com.fuint.repository.model.MtMerchant;
 import com.fuint.repository.model.MtStore;
 import com.fuint.utils.StringUtil;
@@ -41,6 +43,8 @@ public class MerchantServiceImpl extends ServiceImpl<MtMerchantMapper, MtMerchan
 
     private MtStoreMapper mtStoreMapper;
 
+    private MtGoodsMapper mtGoodsMapper;
+
     private static final Logger logger = LoggerFactory.getLogger(MerchantServiceImpl.class);
 
     /**
@@ -211,6 +215,18 @@ public class MerchantServiceImpl extends ServiceImpl<MtMerchantMapper, MtMerchan
             throw new BusinessCheckException("该商户不存在.");
         }
 
+        // 如果是删除,检查是否有商品等数据
+        if (status.equals(StatusEnum.DISABLE.getKey())) {
+            Map<String, Object> params = new HashMap<>();
+            params.put("status", StatusEnum.ENABLED.getKey());
+            params.put("merchant_id", id);
+            List<MtGoods> goodsList = mtGoodsMapper.selectByMap(params);
+            if (goodsList != null && goodsList.size() > 0) {
+                logger.info("删除商户,连同商品一起删除", mtMerchant.getId());
+                mtGoodsMapper.removeMerchantGoods(mtMerchant.getId());
+            }
+        }
+
         mtMerchant.setStatus(status);
         mtMerchant.setUpdateTime(new Date());
         mtMerchant.setOperator(operator);

+ 3 - 1
fuint-repository/src/main/java/com/fuint/repository/mapper/MtGoodsMapper.java

@@ -23,10 +23,12 @@ public interface MtGoodsMapper extends BaseMapper<MtGoods> {
 
     MtGoods getByGoodsNo(@Param("merchantId") Integer merchantId, @Param("goodsNo") String goodsNo);
 
-    Boolean updateInitSale( @Param("goodsId") Integer goodsId);
+    Boolean updateInitSale(@Param("goodsId") Integer goodsId);
 
     List<GoodsBean> selectGoodsList(@Param("merchantId") Integer merchantId, @Param("storeId") Integer storeId, @Param("cateId") Integer cateId, @Param("keyword") String keyword);
 
     List<GoodsTopBean> getGoodsSaleTopList(@Param("merchantId") Integer merchantId, @Param("storeId") Integer storeId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
 
+    void removeMerchantGoods(@Param("merchantId") Integer merchantId);
+
 }

+ 4 - 0
fuint-repository/src/main/resources/mapper/MtGoodsMapper.xml

@@ -69,4 +69,8 @@
         </if>
         GROUP BY g.`ID` ORDER BY SUM(o.`NUM`) DESC LIMIT 10
     </select>
+
+    <update id="removeMerchantGoods">
+        update mt_goods t set t.STATUS = 'D' where t.MERCHANT_ID = #{merchantId}
+    </update>
 </mapper>