Browse Source

【物料私有属性】修改私有属性,私有属性记录不存在时新增记录方法修改

dongbw 7 years ago
parent
commit
b0c3f11f47

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

@@ -1704,6 +1704,8 @@ public class GoodsServiceImpl implements GoodsService {
             ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
             if (productPrivate == null) {
                 productPrivate = new ProductPrivate();
+                productPrivate.setPrId(product.getId());
+                productPrivate.setB2cEnabled(IntegerConstant.YES_INT);
             }
             Integer count = productPrivate.getBatchCount();
             productPrivate.setBatchCount(count ==
@@ -3192,6 +3194,8 @@ public class GoodsServiceImpl implements GoodsService {
                     ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
                     if (productPrivate == null) {
                         productPrivate = new ProductPrivate();
+                        productPrivate.setPrId(product.getId());
+                        productPrivate.setB2cEnabled(IntegerConstant.YES_INT);
                     }
                     Integer count = productPrivate.getBatchCount();
                     productPrivate.setBatchCount(--count);
@@ -3484,6 +3488,8 @@ public class GoodsServiceImpl implements GoodsService {
                 ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
                 if (productPrivate == null) {
                     productPrivate = new ProductPrivate();
+                    productPrivate.setPrId(product.getId());
+                    productPrivate.setB2cEnabled(IntegerConstant.YES_INT);
                 }
                 Integer count = productPrivate.getBatchCount();
                 productPrivate.setBatchCount(--count);
@@ -3566,6 +3572,8 @@ public class GoodsServiceImpl implements GoodsService {
                     ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
                     if (productPrivate == null) {
                         productPrivate = new ProductPrivate();
+                        productPrivate.setPrId(product.getId());
+                        productPrivate.setB2cEnabled(IntegerConstant.YES_INT);
                     }
                     Integer count = productPrivate.getBatchCount();
                     if (null == count){
@@ -3673,6 +3681,8 @@ public class GoodsServiceImpl implements GoodsService {
                 ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
                 if (productPrivate == null) {
                     productPrivate = new ProductPrivate();
+                    productPrivate.setPrId(product.getId());
+                    productPrivate.setB2cEnabled(IntegerConstant.YES_INT);
                 }
                 productPrivate.setBatchCount(goods.size());
                 productPrivateDao.save(productPrivate);

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

@@ -529,6 +529,7 @@ public class ProductServiceImpl implements ProductService {
                     ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
                     if (productPrivate == null) {
                         productPrivate = new ProductPrivate();
+                        productPrivate.setPrId(product.getId());
                     }
                     productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
                     productPrivateDao.save(productPrivate);
@@ -605,11 +606,16 @@ public class ProductServiceImpl implements ProductService {
                     goodsService.deleteGoods(goodses);
                     //productDao.delete(product.getId());
                     ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
-                    if (productPrivate.getB2cEnabled().equals(IntegerConstant.NO_SHORT)) {
-                        fail++;
-                        isHave++;
+                    if (null == productPrivate) {
+                        productPrivate = new ProductPrivate();
+                        productPrivate.setPrId(product.getId());
                     } else {
-                        success++;
+                        if (productPrivate.getB2cEnabled().equals(IntegerConstant.NO_SHORT)) {
+                            fail++;
+                            isHave++;
+                        } else {
+                            success++;
+                        }
                     }
                     productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
                     productPrivateDao.save(productPrivate);
@@ -1086,6 +1092,7 @@ public class ProductServiceImpl implements ProductService {
             ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
             if (productPrivate == null) {
                 productPrivate = new ProductPrivate();
+                productPrivate.setPrId(product.getId());
             }
             productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
             productPrivate.setBatchCount(0);
@@ -1114,6 +1121,7 @@ public class ProductServiceImpl implements ProductService {
         ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(beforeProduct.getId());
         if (productPrivate == null) {
             productPrivate = new ProductPrivate();
+            productPrivate.setPrId(beforeProduct.getId());
         }
         productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
         productPrivateDao.save(productPrivate);
@@ -1188,6 +1196,8 @@ public class ProductServiceImpl implements ProductService {
         ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
         if (productPrivate == null) {
             productPrivate = new ProductPrivate();
+            productPrivate.setPrId(product.getId());
+            productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
         }
         Integer count = productPrivate.getBatchCount();
         productPrivate.setBatchCount(count + saveList.size());
@@ -1337,6 +1347,7 @@ public class ProductServiceImpl implements ProductService {
                         ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
                         if (productPrivate == null) {
                             productPrivate = new ProductPrivate();
+                            productPrivate.setPrId(product.getId());
                         }
                         if (CollectionUtils.isEmpty(products)) {
                             productPrivate.setB2cEnabled(1);