|
@@ -1,6 +1,7 @@
|
|
|
package com.iamberry.rst.service.product;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.iamberry.rst.core.fm.InventoryInfo;
|
|
|
import com.iamberry.rst.core.order.Product;
|
|
|
import com.iamberry.rst.core.order.ProductAreaRela;
|
|
|
import com.iamberry.rst.core.order.ProductColor;
|
|
@@ -8,6 +9,7 @@ import com.iamberry.rst.core.order.ProductType;
|
|
|
import com.iamberry.rst.core.page.PagedResult;
|
|
|
import com.iamberry.rst.core.product.Gift;
|
|
|
import com.iamberry.rst.core.product.OrderGift;
|
|
|
+import com.iamberry.rst.faces.cm.InventoryService;
|
|
|
import com.iamberry.rst.faces.product.ProductService;
|
|
|
import com.iamberry.rst.service.product.mapper.ProductAreaRelaMapper;
|
|
|
import com.iamberry.rst.service.product.mapper.ProductColorMapper;
|
|
@@ -34,7 +36,8 @@ public class ProductServiceImpl implements ProductService {
|
|
|
private ProductColorMapper productColorMapper;
|
|
|
@Autowired
|
|
|
private ProductAreaRelaMapper productAreaRelaMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private InventoryService inventoryService;
|
|
|
@Override
|
|
|
public List<OrderGift> listGift() {
|
|
|
return productMapper.listGift(new OrderGift());
|
|
@@ -200,12 +203,32 @@ public class ProductServiceImpl implements ProductService {
|
|
|
List<ProductColor> productColorList = product.getColorList();
|
|
|
for (ProductColor productColor : productColorList) {
|
|
|
productColor.setColorProductId(product.getProductId());
|
|
|
+ flag = productColorMapper.save(productColor);
|
|
|
+ if(flag < 1){
|
|
|
+ throw new RuntimeException("添加颜色集合失败");
|
|
|
+ }
|
|
|
+ if(productColor.getInventoryGoodProductNum() != null && productColor.getInventoryGoodProductNum() > 0){
|
|
|
+ InventoryInfo inventoryInfo = new InventoryInfo();
|
|
|
+ inventoryInfo.setInventoryProductColorId(productColor.getColorId());
|
|
|
+ inventoryInfo.setInventoryProductName(product.getProductName());
|
|
|
+ inventoryInfo.setInventoryProductBar(productColor.getColorBar());
|
|
|
+ inventoryInfo.setInventoryRemainingNum(10000);
|
|
|
+ inventoryInfo.setInventoryState(1);
|
|
|
+ inventoryInfo.setWarehouseId(1);
|
|
|
+ inventoryInfo.setInventoryGoodProductNum(productColor.getInventoryGoodProductNum());
|
|
|
+ inventoryInfo.setInventoryDefectiveProductNum(0);
|
|
|
+ if(inventoryService.getByInventoryByBar(productColor.getColorBar(),1) !=null){
|
|
|
+ throw new RuntimeException("添加产品库存失败");
|
|
|
+ }
|
|
|
+ if(inventoryService.insert(inventoryInfo) < 1){
|
|
|
+ throw new RuntimeException("添加产品库存失败");
|
|
|
+ }
|
|
|
+ inventoryInfo.setWarehouseId(2);
|
|
|
+ if(inventoryService.insert(inventoryInfo) < 1){
|
|
|
+ throw new RuntimeException("添加产品售后仓库库存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- flag = productColorMapper.saveList(productColorList);
|
|
|
- if(flag < 1){
|
|
|
- throw new RuntimeException("添加颜色集合失败");
|
|
|
- }
|
|
|
-
|
|
|
//添加产品区域使用
|
|
|
if(product.getProductAreaRelaList() != null && product.getProductAreaRelaList().size() > 0){
|
|
|
for (ProductAreaRela productAreaRela:product.getProductAreaRelaList()) {
|
|
@@ -278,10 +301,31 @@ public class ProductServiceImpl implements ProductService {
|
|
|
if(addProductColorList.size() > 0){
|
|
|
for (ProductColor productColor : addProductColorList) {
|
|
|
productColor.setColorProductId(product.getProductId());
|
|
|
- }
|
|
|
- flag = productColorMapper.saveList(addProductColorList);
|
|
|
- if(flag < 1){
|
|
|
- throw new RuntimeException("添加颜色集合失败");
|
|
|
+ flag = productColorMapper.save(productColor);
|
|
|
+ if(flag < 1){
|
|
|
+ throw new RuntimeException("添加颜色集合失败");
|
|
|
+ }
|
|
|
+ if(productColor.getInventoryGoodProductNum() != null && productColor.getInventoryGoodProductNum() > 0){
|
|
|
+ InventoryInfo inventoryInfo = new InventoryInfo();
|
|
|
+ inventoryInfo.setInventoryProductColorId(productColor.getColorId());
|
|
|
+ inventoryInfo.setInventoryProductName(product.getProductName());
|
|
|
+ inventoryInfo.setInventoryProductBar(productColor.getColorBar());
|
|
|
+ inventoryInfo.setInventoryRemainingNum(10000);
|
|
|
+ inventoryInfo.setInventoryState(1);
|
|
|
+ inventoryInfo.setWarehouseId(1);
|
|
|
+ inventoryInfo.setInventoryGoodProductNum(productColor.getInventoryGoodProductNum());
|
|
|
+ inventoryInfo.setInventoryDefectiveProductNum(0);
|
|
|
+ if(inventoryService.getByInventoryByBar(productColor.getColorBar(),1) !=null){
|
|
|
+ throw new RuntimeException("添加产品库存失败");
|
|
|
+ }
|
|
|
+ if(inventoryService.insert(inventoryInfo) < 1){
|
|
|
+ throw new RuntimeException("添加产品库存失败");
|
|
|
+ }
|
|
|
+ inventoryInfo.setWarehouseId(2);
|
|
|
+ if(inventoryService.insert(inventoryInfo) < 1){
|
|
|
+ throw new RuntimeException("添加产品售后仓库库存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//添加颜色 -end
|