Sfoglia il codice sorgente

fix(库存): 处理库存没有发布时间的问题。

yuj 7 anni fa
parent
commit
0882c830f1

+ 11 - 11
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java

@@ -1567,22 +1567,21 @@ public class GoodsServiceImpl implements GoodsService {
         if (resultMap.getCode() != CodeType.OK.code()) {
             return null;
         }
-        GoodsHistory history = goodsHistoryService.converTGoodsHist(nowGoods,
-                OperateType.Update.getPhrase(), false);
-        // 修改上下架状态并产生上下架历史
-        goodsHistoryService.save(history);
+        GoodsHistory history = null;
         if (!nowGoods.getStatus().equals(oldStatus)) {
-            GoodsHistory goodsHistory = null;
             //做上下架判断
             if ((oldStatus.equals(Status.REMOVED.value())) && (nowGoods.getStatus().equals(Status.AVAILABLE.value()) || nowGoods.getStatus().equals(Status.UNAVAILABLE.value()) || nowGoods.getStatus().equals(Status.NO_SHELVE.value()))) {
-                goodsHistory = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Publish.getPhrase(), false);
+                history = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Publish.getPhrase(), false);
                 nowGoods.setPublishTime(new Date());
             } else if ((nowGoods.getStatus().equals(Status.REMOVED.value())) && (oldStatus.equals(Status.UNAVAILABLE.value()) || oldStatus.equals(Status.AVAILABLE.value()) || oldStatus.equals(Status.NO_SHELVE.value()))) {
-                goodsHistory = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Down.getPhrase(), false);
-            }
-            if (null != goodsHistory) {
-                goodsHistoryService.save(goodsHistory);
+                history = goodsHistoryService.converTGoodsHist(nowGoods, OperateType.Down.getPhrase(), false);
             }
+        } else {
+             history = goodsHistoryService.converTGoodsHist(nowGoods,
+                    OperateType.Update.getPhrase(), false);
+        }
+        if (null != history) {
+            goodsHistoryService.save(history);
         }
 
         List<Order> orders = detailService.updateOrderDetailsByGoods(nowGoods);
@@ -3880,9 +3879,10 @@ public class GoodsServiceImpl implements GoodsService {
                 goods.adjustFragmentPrice();
                 Integer status = goods.getStatus();
                 goods.setStatus();
-                if ((Status.AVAILABLE.value() == goods.getStatus()) || (Status.UNAVAILABLE.value() == goods.getStatus() || Status.NO_SHELVE.value() == goods.getStatus()) && (Status.REMOVED.value() == status)) {
+                if ((Status.AVAILABLE.value() == goods.getStatus()) || (Status.UNAVAILABLE.value() == goods.getStatus() || Status.NO_SHELVE.value() == goods.getStatus()) && (Status.REMOVED.value() == status || status == null)) {
                     //如果现在是已上架,原先是未上架或者已下架,则做上架处理。否则做更新处理
                     list.add(goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false));
+                    goods.setPublishTime(new Date());
                 } else {
                     list.add(goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Update.getPhrase(), false));
                 }

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -2972,7 +2972,7 @@ public class ProductServiceImpl implements ProductService {
                 type = GoodsHistory.OperateType.Publish.getPhrase();
                 goods.setPublishTime(new Date());
             } else {
-                type = GoodsHistory.OperateType.INIT.getPhrase();
+                type = GoodsHistory.OperateType.Update.getPhrase();
             }
         }
         goodsHistory = goodsHistoryService.converTGoodsHist(goods, type, false);

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -1921,7 +1921,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 								prids.add(releaseProductByBatch.getProductid());
 								Integer status = g.getStatus();
 								g.updateGoodsByReleaseProductByBatch(releaseProductByBatch, delayTime, ignoreImport);
-								if ((Status.AVAILABLE.value() == g.getStatus() || Status.UNAVAILABLE.value() == g.getStatus() || Status.NO_SHELVE.value() == g.getStatus()) &&  Status.REMOVED.value() == status) {
+								if ((Status.AVAILABLE.value() == g.getStatus() || Status.UNAVAILABLE.value() == g.getStatus() || Status.NO_SHELVE.value() == g.getStatus()) &&  Status.REMOVED.value() == status || status == null) {
 									//如果现在是已上架,原先是未上架或者已下架,则做上架处理。否则做更新处理
 									goodsHistoryList.add(goodsHistoryService.converTGoodsHist(g, GoodsHistory.OperateType.Publish.getPhrase(), false));
 									g.setPublishTime(new Date());