|
|
@@ -168,6 +168,9 @@ public class ProductServiceImpl implements ProductService {
|
|
|
@Autowired
|
|
|
private UASBatchPutOnPropertyService uasBatchPutOnPropertyService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductPersonDao productPersonDao;
|
|
|
+
|
|
|
private ConcurrentHashMap<String, Field> sortFields = new ConcurrentHashMap<String, Field>();
|
|
|
|
|
|
@Override
|
|
|
@@ -272,42 +275,47 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
|
@Override
|
|
|
public void deleteBatch(List<Long> ids) {
|
|
|
+ List<ProductPerson> personList = new ArrayList<>();
|
|
|
for (Long id : ids) {
|
|
|
Product product = productDao.findOne(id);
|
|
|
if (product == null)
|
|
|
throw new IllegalOperatorException("选择的产品不存在,请重新选择");
|
|
|
- //查看是否存在正常未取消的订单
|
|
|
- List<Goods> goodses = goodsDao.findByProductId(product.getId());
|
|
|
- Boolean isExistOrder = false;
|
|
|
- String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
- for (Goods goods : goodses) {
|
|
|
- List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(goods.getBatchCode());
|
|
|
- for (OrderDetail detail : orderList) {
|
|
|
- Order order = detail.getOrder();
|
|
|
- int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
- if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
- // 区分是否是假单,or_orderids 不为空
|
|
|
- if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
- isExistOrder = true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ personList = productPersonDao.findByProductId(product.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(personList)) {
|
|
|
+ throw new IllegalOperatorException("该产品中存在关联信息,不能删除");
|
|
|
+ }
|
|
|
+ //查看是否存在正常未取消的订单
|
|
|
+ List<Goods> goodses = goodsDao.findByProductId(product.getId());
|
|
|
+ Boolean isExistOrder = false;
|
|
|
+ String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
+ for (Goods goods : goodses) {
|
|
|
+ List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(goods.getBatchCode());
|
|
|
+ for (OrderDetail detail : orderList) {
|
|
|
+ Order order = detail.getOrder();
|
|
|
+ int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
+ if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
+ // 区分是否是假单,or_orderids 不为空
|
|
|
+ if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
+ isExistOrder = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- if (isExistOrder) {
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
- if (!isExistOrder) {
|
|
|
- //删除外键关联的匹配结果列表,不然删除product失败
|
|
|
- Set<ProductMatchResult> productMatchResultSet = product.getMatchresults();
|
|
|
- productMatchResultDao.delete(productMatchResultSet);
|
|
|
- goodsService.deleteGoods(goodses);
|
|
|
- productDao.delete(id);
|
|
|
- } else {
|
|
|
- throw new
|
|
|
- IllegalOperatorException("该产品中存在已下单的在售产品信息,不能删除");
|
|
|
+ if (isExistOrder) {
|
|
|
+ break;
|
|
|
}
|
|
|
+ }
|
|
|
+ if (!isExistOrder) {
|
|
|
+ //删除外键关联的匹配结果列表,不然删除product失败
|
|
|
+ Set<ProductMatchResult> productMatchResultSet = product.getMatchresults();
|
|
|
+ productMatchResultDao.delete(productMatchResultSet);
|
|
|
+ goodsService.deleteGoods(goodses);
|
|
|
+ productDao.delete(id);
|
|
|
+ } else {
|
|
|
+ throw new
|
|
|
+ IllegalOperatorException("该产品中存在已下单的在售产品信息,不能删除");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -319,6 +327,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
@Override
|
|
|
public ResultMap deleteBatch(String type) {
|
|
|
Integer standard = null;
|
|
|
+ List<ProductPerson> personList = new ArrayList<>();
|
|
|
Integer fail = 0;
|
|
|
Integer success = 0;
|
|
|
Long uu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
@@ -331,6 +340,11 @@ public class ProductServiceImpl implements ProductService {
|
|
|
Set<String> uuids = new HashSet<>();
|
|
|
for (Product product : products) {
|
|
|
try {
|
|
|
+ personList = productPersonDao.findByProductId(product.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(personList)) {
|
|
|
+ fail++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
//查看是否存在正常未取消的订单
|
|
|
List<Goods> goodses = goodsDao.findByProductId(product.getId());
|
|
|
Boolean isExistOrder = false;
|