|
@@ -243,9 +243,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
// if(!PatternUtil.matchChineseAndEnglish(goods.getTag())) {
|
|
// if(!PatternUtil.matchChineseAndEnglish(goods.getTag())) {
|
|
|
// throw new IllegalOperatorException("自定义标签的信息只能包含中文和英文");
|
|
// throw new IllegalOperatorException("自定义标签的信息只能包含中文和英文");
|
|
|
// }
|
|
// }
|
|
|
- if (goods.getPackaging() == null) {
|
|
|
|
|
|
|
+ /*if (goods.getPackaging() == null) {
|
|
|
throw new IllegalOperatorException("包装信息为空");
|
|
throw new IllegalOperatorException("包装信息为空");
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
// if (goods.getPackaging().length() > 10) {
|
|
// if (goods.getPackaging().length() > 10) {
|
|
|
// throw new IllegalOperatorException("包装信息操作约定的10个字符");
|
|
// throw new IllegalOperatorException("包装信息操作约定的10个字符");
|
|
|
// }
|
|
// }
|
|
@@ -1618,7 +1618,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
reserve = NumberUtil.add(reserve, oldGoods.getReserve());
|
|
reserve = NumberUtil.add(reserve, oldGoods.getReserve());
|
|
|
reserve = NumberUtil.sub(reserve, nowGoods.getReserve());
|
|
reserve = NumberUtil.sub(reserve, nowGoods.getReserve());
|
|
|
if (NumberUtil.compare(reserve, DoubleConstant.zero) < 0) {
|
|
if (NumberUtil.compare(reserve, DoubleConstant.zero) < 0) {
|
|
|
- throw new IllegalOperatorException("总在售库存量超过空闲库存量");
|
|
|
|
|
|
|
+ // 下架这部分的库存
|
|
|
|
|
+ //throw new IllegalOperatorException("总在售库存量超过空闲库存量");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2457,10 +2458,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setStatus(Status.REMOVED.value());
|
|
goods.setStatus(Status.REMOVED.value());
|
|
|
|
|
|
|
|
//检查对应产品库信息
|
|
//检查对应产品库信息
|
|
|
- Product product = productDao.findOne(goods.getProductid());
|
|
|
|
|
- if (product == null) {
|
|
|
|
|
- throw new IllegalOperatorException("产品库信息丢失");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// Product product = productDao.findOne(goods.getProductid());
|
|
|
|
|
+// if (product == null) {
|
|
|
|
|
+// throw new IllegalOperatorException("产品库信息丢失");
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
logger.info(String.format("%s 商城测试下架时间记录 转历史库存 开始", dateFormat.format(new Date())));
|
|
logger.info(String.format("%s 商城测试下架时间记录 转历史库存 开始", dateFormat.format(new Date())));
|
|
|
GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods,
|
|
GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods,
|
|
@@ -2469,19 +2470,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次下架");
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次下架");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
goodsHistoryService.save(goodsHist);
|
|
|
|
|
|
|
|
-// ProductStandardPutOnInfo standardPutOnInfo = productStandardPutOnInfoDao.findOne(goods.getStandprodid());
|
|
|
|
|
-// if(standardPutOnInfo != null) {
|
|
|
|
|
-// standardPutOnInfo.setStatus(Status.REMOVED.value());
|
|
|
|
|
-// standardPutOnInfo.setAvailableOnSale(NumberUtil.add(standardPutOnInfo.getAvailableOnSale(), standardPutOnInfo.getOnSaleQty()));
|
|
|
|
|
-// standardPutOnInfo.setOnSaleQty(0.0d);
|
|
|
|
|
-// productStandardPutOnInfoDao.save(standardPutOnInfo);
|
|
|
|
|
-//
|
|
|
|
|
-// Product product = productDao.findOne(standardPutOnInfo.getProductid());
|
|
|
|
|
-// product.setAvailableOnSale(standardPutOnInfo.getAvailableOnSale());
|
|
|
|
|
-// product.setOnSaleQty(standardPutOnInfo.getOnSaleQty());
|
|
|
|
|
-// productDao.save(product);
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
Goods updateGoods = goodsDao.save(goods);
|
|
Goods updateGoods = goodsDao.save(goods);
|
|
|
//下架对应的批次 目前确定下架之后不做删除动作。
|
|
//下架对应的批次 目前确定下架之后不做删除动作。
|
|
|
// goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
// goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
@@ -2623,6 +2611,68 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return goods;
|
|
return goods;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<Goods> getGoodsByEnuu(String keyword, Boolean isSelfSupport) {
|
|
|
|
|
+ final PageInfo page = new PageInfo();
|
|
|
|
|
+ page.setPageNumber(1);
|
|
|
|
|
+ page.setPageSize(10);
|
|
|
|
|
+ Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
|
|
+ page.expression(PredicateUtils.eq("enUU", enUU, true));
|
|
|
|
|
+ page.sorting("createdDate", Sort.Direction.DESC);
|
|
|
|
|
+
|
|
|
|
|
+ SimpleExpression status1 = PredicateUtils.eq("status", Status.AVAILABLE.value(), true);
|
|
|
|
|
+ SimpleExpression status2 = PredicateUtils.eq("status", Status.UNAVAILABLE.value(), true);
|
|
|
|
|
+ SimpleExpression[] expressions2 = new SimpleExpression[] {status1, status2};
|
|
|
|
|
+ LogicalExpression logicalExpression2 = PredicateUtils.or(expressions2);
|
|
|
|
|
+ page.expression(logicalExpression2);
|
|
|
|
|
+
|
|
|
|
|
+ List<StoreIn> storeIns = storeInDao.findByEnUU(enUU);
|
|
|
|
|
+ String uuid = null;
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(storeIns)) {
|
|
|
|
|
+ uuid = storeIns.get(0).getUuid();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uuid = "null";
|
|
|
|
|
+ }
|
|
|
|
|
+ // 过滤自营店铺上架商品
|
|
|
|
|
+ if (isSelfSupport != null && isSelfSupport && StringUtils.hasText(uuid)) {
|
|
|
|
|
+ SimpleExpression[] simpleExpressions = new SimpleExpression[3];
|
|
|
|
|
+ simpleExpressions[0] = PredicateUtils.eq("storeid", uuid, true);
|
|
|
|
|
+ simpleExpressions[1] = PredicateUtils.ne("storeName", "优软测试二", true);
|
|
|
|
|
+ simpleExpressions[2] = PredicateUtils.ne("storeName", "优软商城", true);
|
|
|
|
|
+ page.expression(PredicateUtils.and(simpleExpressions));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 过滤寄售商品
|
|
|
|
|
+ if (isSelfSupport != null && !isSelfSupport && StringUtils.hasText(uuid)) {
|
|
|
|
|
+ String[] storeNames = new String[]{"优软测试二", "优软商城"};
|
|
|
|
|
+ LogicalExpression logicalExpression = PredicateUtils.in("storeName", storeNames, true);
|
|
|
|
|
+ if (!"null".equals(uuid)) {
|
|
|
|
|
+ SimpleExpression simpleExpression = PredicateUtils.ne("storeid", uuid, true);
|
|
|
|
|
+ page.expression(PredicateUtils.or(simpleExpression, logicalExpression));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ page.expression(logicalExpression);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 过滤关键词
|
|
|
|
|
+ if (StringUtils.hasText(keyword)) {
|
|
|
|
|
+ SimpleExpression code = like("code", keyword, true, true);
|
|
|
|
|
+ SimpleExpression brandNameEn = like("brandNameEn", keyword, true, true);
|
|
|
|
|
+ SimpleExpression batchCode = PredicateUtils.like("prodNum", keyword, true, true);
|
|
|
|
|
+ SimpleExpression[] expressions3 = new SimpleExpression[]{code, brandNameEn, batchCode};
|
|
|
|
|
+ LogicalExpression logicalExpression3 = PredicateUtils.or(expressions3);
|
|
|
|
|
+ page.expression(logicalExpression2);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return goodsDao.findAll(new Specification<Goods>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Predicate toPredicate(Root<Goods> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
|
|
+ query.where(page.getPredicates(root, query, cb));
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }, page.getSort());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public String isSelfSupport(String storeid) {
|
|
public String isSelfSupport(String storeid) {
|
|
|
if(StringUtils.isEmpty(storeid)) {
|
|
if(StringUtils.isEmpty(storeid)) {
|
|
|
return "";
|
|
return "";
|
|
@@ -2796,6 +2846,112 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return ResultMap.success(false);
|
|
return ResultMap.success(false);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ResultMap downNowEnterpriseGoods(Long enUU) {
|
|
|
|
|
+ List<Integer> statusList = Arrays.asList(Status.AVAILABLE.value(), Status.UNAVAILABLE.value());
|
|
|
|
|
+ List<Goods> goodsList = goodsDao.findByEnUUAndInStatus(enUU, statusList);
|
|
|
|
|
+ List<GoodsHistory> histories = new ArrayList<>(goodsList.size());
|
|
|
|
|
+ List<Goods> goodsUpdate = new ArrayList<>(goodsList.size());
|
|
|
|
|
+ List<String> uuids = new ArrayList<>(goodsList.size());
|
|
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
|
|
+ goods.setStatus(Status.REMOVED.value());
|
|
|
|
|
+
|
|
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, "批量下架公司产品");
|
|
|
|
|
+ goodsHistory.setMessage(goodsHistory.getMessage() + "该批次下架");
|
|
|
|
|
+ goodsHistoryService.save(goodsHistory);
|
|
|
|
|
+ histories.add(goodsHistory);
|
|
|
|
|
+ goodsUpdate.add(goods);
|
|
|
|
|
+
|
|
|
|
|
+ uuids.add(goods.getUuid());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ goodsDao.save(goodsUpdate);
|
|
|
|
|
+ goodsHistoryDao.save(histories);
|
|
|
|
|
+ for (String uuid : uuids) {
|
|
|
|
|
+ updateComponentTradeInfos(uuid);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultMap.success(goodsUpdate.size());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Map<Object, Object> deleteGoodsList(List<Goods> goodsList) {
|
|
|
|
|
+ Map<Object, Object> map = new HashMap<>();
|
|
|
|
|
+ int fail = 0;
|
|
|
|
|
+ // 保存批次号,以便下架推荐产品
|
|
|
|
|
+ Set<String> set = new HashSet<>();
|
|
|
|
|
+ String storeId = null;
|
|
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
|
|
+ boolean isExistOrder = validateExistOrder(goods.getBatchCode());
|
|
|
|
|
+
|
|
|
|
|
+ if (isExistOrder) {
|
|
|
|
|
+ fail++;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (storeId == null) {
|
|
|
|
|
+ storeId = goods.getStoreid();
|
|
|
|
|
+ }
|
|
|
|
|
+ set.add(goods.getBatchCode());
|
|
|
|
|
+
|
|
|
|
|
+ List<Order> orders = detailService.updateOrderDetailsByGoods(goods);
|
|
|
|
|
+ orderService.save(orders);
|
|
|
|
|
+
|
|
|
|
|
+ Boolean aBoolean = floorsService.updateHomeInfo(goods.getBatchCode());
|
|
|
|
|
+ List<GoodsHistory> histories = new ArrayList<>();
|
|
|
|
|
+ if (goods.getStatus().equals(Status.AVAILABLE.value()) || goods.getStatus().equals(Status.UNAVAILABLE.value())) {
|
|
|
|
|
+ //先做下架记录
|
|
|
|
|
+ goods.setStatus(Status.REMOVED.value());
|
|
|
|
|
+ GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase());
|
|
|
|
|
+ histories.add(goodsHistoryRemoved);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ goods.setStatus(Status.GOODS_DELETE.value());
|
|
|
|
|
+ //删除库存信息
|
|
|
|
|
+ GoodsHistory goodsHistoryDelete = goodsHistoryService.converTGoodsHist(goods, OperateType.DELETE.getPhrase());
|
|
|
|
|
+ histories.add(goodsHistoryDelete);
|
|
|
|
|
+ goodsHistoryService.save(histories);
|
|
|
|
|
+
|
|
|
|
|
+ goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
|
|
|
+ if (goods.getProductid() != null) {
|
|
|
|
|
+ Product product = productDao.findOne(goods.getProductid());
|
|
|
|
|
+ if (product != null) {
|
|
|
|
|
+ ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
|
|
+ if (productPrivate == null) {
|
|
|
|
|
+ productPrivate = new ProductPrivate();
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer count = productPrivate.getBatchCount();
|
|
|
|
|
+ productPrivate.setBatchCount(--count);
|
|
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //统计器件的信息
|
|
|
|
|
+ if (!StringUtils.isEmpty(goods.getUuid())) {
|
|
|
|
|
+ updateComponentTradeInfos(goods.getUuid());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ recommendProductService.deleteProductsWhenSellerUpdateReserve(storeId, set);
|
|
|
|
|
+ map.put("total", goodsList.size());
|
|
|
|
|
+ map.put("success", goodsList.size() - fail);
|
|
|
|
|
+ map.put("fail", fail);
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public ResultMap batchDeleteGoods(List<Long> idList) {
|
|
|
|
|
+ List<Goods> goodsList = goodsDao.findGoodsInIdList(idList);
|
|
|
|
|
+ Map<Object, Object> map = deleteGoodsList(goodsList);
|
|
|
|
|
+ return ResultMap.success(map);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public ResultMap deleteGoodsByEnUU(Long enUU) {
|
|
|
|
|
+ List<Integer> statusList = Arrays.asList(Status.AVAILABLE.value(), Status.UNAVAILABLE.value());
|
|
|
|
|
+ List<Goods> goodsList = goodsDao.findByEnUUAndInStatus(enUU, statusList);
|
|
|
|
|
+ Map<Object, Object> map = deleteGoodsList(goodsList);
|
|
|
|
|
+ return ResultMap.success(map);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 下架该公司所有的商品信息
|
|
* 下架该公司所有的商品信息
|
|
|
*
|
|
*
|
|
@@ -3018,19 +3174,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if(goods == null) {
|
|
if(goods == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- boolean isExistOrder = false;
|
|
|
|
|
- List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(goods.getBatchCode());
|
|
|
|
|
- String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
|
|
- for (OrderDetail detail : orderList) {
|
|
|
|
|
- Order order = detail.getOrder();
|
|
|
|
|
- int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
|
|
- if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
|
|
- if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
|
|
- isExistOrder = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ boolean isExistOrder = validateExistOrder(goods.getBatchCode());
|
|
|
|
|
+
|
|
|
if (isExistOrder) {
|
|
if (isExistOrder) {
|
|
|
throw new IllegalOperatorException("该商品已经被购买了,不能删除");
|
|
throw new IllegalOperatorException("该商品已经被购买了,不能删除");
|
|
|
}
|
|
}
|
|
@@ -3057,9 +3202,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsHistoryService.save(histories);
|
|
goodsHistoryService.save(histories);
|
|
|
|
|
|
|
|
goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
|
- if(goods.getProductid() != null) {
|
|
|
|
|
|
|
+ if (goods.getProductid() != null) {
|
|
|
Product product = productDao.findOne(goods.getProductid());
|
|
Product product = productDao.findOne(goods.getProductid());
|
|
|
- if(product != null) {
|
|
|
|
|
|
|
+ if (product != null) {
|
|
|
ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
if (productPrivate == null) {
|
|
if (productPrivate == null) {
|
|
|
productPrivate = new ProductPrivate();
|
|
productPrivate = new ProductPrivate();
|
|
@@ -3077,6 +3222,28 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return goods;
|
|
return goods;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据批次号查询是否有订单
|
|
|
|
|
+ * @param batchCode
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean validateExistOrder(String batchCode) {
|
|
|
|
|
+ boolean isExistOrder = false;
|
|
|
|
|
+ List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(batchCode);
|
|
|
|
|
+ String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
|
|
+ for (OrderDetail detail : orderList) {
|
|
|
|
|
+ Order order = detail.getOrder();
|
|
|
|
|
+ int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
|
|
+ if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
|
|
+ if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
|
|
+ isExistOrder = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return isExistOrder;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<Goods> deleteGoods(List<Goods> goodses) {
|
|
public List<Goods> deleteGoods(List<Goods> goodses) {
|
|
|
List<Order> orders = new ArrayList<>();
|
|
List<Order> orders = new ArrayList<>();
|
|
@@ -3090,19 +3257,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (goods == null) {
|
|
if (goods == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- boolean isExistOrder = false;
|
|
|
|
|
- List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(goods.getBatchCode());
|
|
|
|
|
- String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
|
|
- for (OrderDetail detail : orderList) {
|
|
|
|
|
- Order order = detail.getOrder();
|
|
|
|
|
- int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
|
|
- if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
|
|
- if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
|
|
- isExistOrder = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ boolean isExistOrder = validateExistOrder(goods.getBatchCode());
|
|
|
if (isExistOrder) {
|
|
if (isExistOrder) {
|
|
|
throw new IllegalOperatorException("存在商品已经被购买了,不能删除");
|
|
throw new IllegalOperatorException("存在商品已经被购买了,不能删除");
|
|
|
}
|
|
}
|