|
@@ -1,14 +1,16 @@
|
|
|
package com.fs.live.service.impl;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
+import com.fs.his.domain.FsStoreProduct;
|
|
|
import com.fs.his.mapper.FsStoreProductMapper;
|
|
|
import com.fs.his.domain.FsStore;
|
|
|
import com.fs.his.service.IFsStoreService;
|
|
|
+import com.fs.live.vo.LiveGoodsVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.fs.live.mapper.LiveGoodsMapper;
|
|
@@ -113,6 +115,11 @@ public class LiveGoodsServiceImpl extends ServiceImpl<LiveGoodsMapper, LiveGoods
|
|
|
return fsStoreService.selectFsStoreByStoreId(storeId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<LiveGoodsVo> selectProductListByLiveId(LiveGoods liveGoods) {
|
|
|
+ return baseMapper.selectProductListByLiveId(liveGoods);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 批量新增直播商品
|
|
|
*
|
|
@@ -121,9 +128,34 @@ public class LiveGoodsServiceImpl extends ServiceImpl<LiveGoodsMapper, LiveGoods
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertLiveGoods(Map<String, Object> payload, CompanyUser user) {
|
|
|
- String liveId = (String) payload.get("liveId");
|
|
|
- String goodsIds = (String) payload.get("goodsIds");
|
|
|
-// fsStoreProductMapper.se
|
|
|
- return 0;
|
|
|
+ Long liveId = Long.valueOf((String) payload.get("liveId"));
|
|
|
+ String productsId = (String) payload.get("productsId");
|
|
|
+ List<String> productIdList = new ArrayList<>(Arrays.asList(productsId.split(",")));
|
|
|
+ if (productIdList.isEmpty()) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ // 查询商品信息列表(假设返回 List<StoreProduct>)
|
|
|
+ List<FsStoreProduct> productInfoList = fsStoreProductMapper.selectFsStoreProductByProductIds(productIdList);
|
|
|
+
|
|
|
+ // 转换为 LiveGoods 并批量插入
|
|
|
+ List<LiveGoods> liveGoodsList = productInfoList.stream()
|
|
|
+ .map(product -> {
|
|
|
+ LiveGoods liveGoods = new LiveGoods();
|
|
|
+ liveGoods.setLiveId(liveId);
|
|
|
+ liveGoods.setCompanyId(user.getCompanyId());
|
|
|
+ liveGoods.setCompanyUserId(user.getUserId());
|
|
|
+ liveGoods.setStoreId(product.getStoreId());
|
|
|
+ liveGoods.setProductId(product.getProductId());
|
|
|
+ liveGoods.setStatus(1);
|
|
|
+ liveGoods.setStock(Long.valueOf(product.getStock()));
|
|
|
+ liveGoods.setSort(product.getSort());
|
|
|
+ liveGoods.setCreateTime(DateUtils.getNowDate());
|
|
|
+ liveGoods.setCreateBy(String.valueOf(user.getUserId()));
|
|
|
+ return liveGoods;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+//
|
|
|
+// // 批量插入
|
|
|
+ return baseMapper.insertLiveGoodsList(liveGoodsList);
|
|
|
}
|
|
|
}
|