From faae303cd25f90b1c732b6bc737ede8b8ab714a0 Mon Sep 17 00:00:00 2001
From: 罗元桥 <2376770955@qq.com>
Date: 星期一, 27 九月 2021 16:56:28 +0800
Subject: [PATCH] Merge branch 'test' into 'test_bak'

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java
index ab37ec9..9fbaf17 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java
@@ -66,6 +66,9 @@
         ConvenientProductDO convenientProductDO = new ConvenientProductDO();
         BeanUtils.copyProperties(convenientProductDTO, convenientProductDO);
         Date nowDate = new Date();
+        if (convenientProductDTO.getOnShelf()) {
+            convenientProductDO.setOnShelfAt(nowDate);
+        }
         convenientProductDO.setCreatedAt(nowDate);
         this.baseMapper.insert(convenientProductDO);
         Long productId = convenientProductDO.getId();
@@ -91,16 +94,20 @@
         Long productId = convenientProductDTO.getId();
         Long updatedBy = convenientProductDTO.getUpdatedBy();
         ConvenientProductDO convenientProductDO = this.baseMapper.selectById(productId);
+        Boolean isOnShelf = convenientProductDO.getOnShelf();
         if (isNull(convenientProductDO)) {
             return R.fail("产品不存在");
         }
         BeanUtils.copyProperties(convenientProductDTO, convenientProductDO);
+        Date nowDate = new Date();
+        if (!isOnShelf && convenientProductDTO.getOnShelf()) {
+            convenientProductDO.setOnShelfAt(nowDate);
+        }
         convenientProductDO.setUpdatedBy(updatedBy);
         this.baseMapper.updateById(convenientProductDO);
         List<ConvenientProductSpecificationDTO> productSpecificationDTOList = convenientProductDTO.getProductSpecificationDTOList();
         List<Long> notNeedDelIds = productSpecificationDTOList.stream().filter(specificationDTO -> nonNull(specificationDTO.getId()))
                 .map(ConvenientProductSpecificationDTO::getId).collect(Collectors.toList());
-        Date nowDate = new Date();
         productSpecificationDTOList.forEach(specificationDTO -> {
             Long specificationId = specificationDTO.getId();
             if (isNull(specificationId)) {

--
Gitblit v1.7.1