|
|
@@ -1273,6 +1273,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Override
|
|
|
public ResultMap putOn(Long id) {
|
|
|
Goods goods = goodsDao.findOne(id);
|
|
|
+ return putOnGoods(goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ResultMap putOnGoods(Goods goods) {
|
|
|
if (goods != null) {
|
|
|
setGoodsDefault(goods);
|
|
|
ResultMap resultMap = checkGoods(goods);
|
|
|
@@ -3133,4 +3137,36 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsDao.save(goodses);
|
|
|
return String.valueOf(goodses.size());
|
|
|
}
|
|
|
+
|
|
|
+ public ResultMap batchOnSale(List<Long> idList) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ List<Integer> statusList = Arrays.asList(Status.AVAILABLE.value(), Status.UNAVAILABLE.value());
|
|
|
+ for (Long id : idList) {
|
|
|
+ Product aProduct = productDao.findOne(id);
|
|
|
+ if (aProduct == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ProductDetail detail = productDetailDao.findByProductId(id);
|
|
|
+ if (detail != null) {
|
|
|
+ // 判断是否已有上架商品
|
|
|
+ List<Goods> goodsList = goodsDao.findByProductIdInStatus(id, statusList);
|
|
|
+ if (CollectionUtils.isEmpty(goodsList)) {
|
|
|
+ // 生成Goods信息
|
|
|
+ Goods goods = fillDataInGoods(detail);
|
|
|
+ ResultMap resultMap = putOnGoods(goods);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultMap.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 填充相应字段
|
|
|
+ * @param detail
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Goods fillDataInGoods(ProductDetail detail) {
|
|
|
+ Goods goods = new Goods();
|
|
|
+ return goods;
|
|
|
+ }
|
|
|
}
|