|
@@ -38,7 +38,7 @@ import com.yami.shop.common.exception.YamiShopBindException;
|
|
|
import com.yami.shop.common.util.Arith;
|
|
|
import com.yami.shop.common.util.Json;
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
|
-import com.yami.shop.common.util.PoiExcelUtil;
|
|
|
+//import com.yami.shop.common.util.PoiExcelUtil;
|
|
|
import com.yami.shop.dao.*;
|
|
|
import com.yami.shop.service.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -66,6 +66,7 @@ import java.util.stream.Collectors;
|
|
|
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
|
|
|
|
|
|
private final ProductMapper productMapper;
|
|
|
+ private final LabelMapper labelMapper;
|
|
|
private final BrandService brandService;
|
|
|
private final CategoryService categoryService;
|
|
|
private final ApplicationContext applicationContext;
|
|
@@ -73,6 +74,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
private final OfflineHandleEventService offlineHandleEventService;
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public Product getById(Long prodId, Integer platform) {
|
|
|
+ return productMapper.doGetById(prodId, platform);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void saveProduct(Product product) {
|
|
@@ -137,11 +143,15 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- @Cacheable(cacheNames = "product", key = "#prodId")
|
|
|
public Product getProductByProdId(Long prodId) {
|
|
|
return productMapper.selectById(prodId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Product getProductByProdId(Long prodId, Integer platform) {
|
|
|
+ return productMapper.doGetById(prodId, platform);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Caching(evict = {
|
|
@@ -193,7 +203,6 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public IPage<ProductDto> pageByTagId(Page<ProductDto> page, Long tagId) {
|
|
|
return productMapper.pageByTagId(page, tagId);
|
|
@@ -219,6 +228,21 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
}
|
|
|
IPage<SearchProdDto> searchProdDtoPage = productMapper.getSearchProdDtoPageByProdNameNew(page, searchParam, shopIds);
|
|
|
for (SearchProdDto searchProdDto : searchProdDtoPage.getRecords()) {
|
|
|
+ Long hotLabelId = searchProdDto.getHotLabelId();
|
|
|
+ Long selfLabelId = searchProdDto.getSelfLabelId();
|
|
|
+ Long returnLabelId = searchProdDto.getReturnLabelId();
|
|
|
+ if (null != hotLabelId) {
|
|
|
+ Label label = labelMapper.selectById(hotLabelId);
|
|
|
+ searchProdDto.setHotLabel(label.getName());
|
|
|
+ }
|
|
|
+ if (null != selfLabelId) {
|
|
|
+ Label label = labelMapper.selectById(selfLabelId);
|
|
|
+ searchProdDto.setSelfLabel(label.getName());
|
|
|
+ }
|
|
|
+ if (null != returnLabelId) {
|
|
|
+ Label label = labelMapper.selectById(returnLabelId);
|
|
|
+ searchProdDto.setReturnLabel(label.getName());
|
|
|
+ }
|
|
|
List<SkuDto> skuList = skuMapper.listByProdId(searchProdDto.getProdId()).stream().map((sku) -> SkuDto.builder()
|
|
|
.skuName(sku.getSkuName()).pic(sku.getPic()).skuScore(sku.getSkuScore()).price(sku.getPrice())
|
|
|
.stocks(sku.getStocks()).properties(sku.getProperties()).skuId(sku.getSkuId())
|
|
@@ -341,24 +365,24 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
|
|
|
@Override
|
|
|
public IPage<Product> getPageAngShopName(PageParam<Product> page, ProductParam product) {
|
|
|
- return productMapper.getPageAndShopName(page,product);
|
|
|
+ return productMapper.getPageAndShopName(page, product);
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void exportProd(ProductExportParam productParam, HttpServletResponse response, Long shopId) {
|
|
|
List<ProductExportParam> products = productMapper.listProdsByProdParam(productParam);
|
|
|
- createExcel(products,response,shopId);
|
|
|
+ createExcel(products, response, shopId);
|
|
|
}
|
|
|
|
|
|
- private void createExcel(List<ProductExportParam> products, HttpServletResponse response,Long shopId) {
|
|
|
+ private void createExcel(List<ProductExportParam> products, HttpServletResponse response, Long shopId) {
|
|
|
|
|
|
//通过工具类创建writer
|
|
|
ExcelWriter writer = ExcelUtil.getBigWriter();
|
|
|
// 待发货
|
|
|
- String[] hearder = { "产品名称", "平台分类", "店铺分类", "所属品牌", "产品卖点", "配送方式","运费设置","产品状态",
|
|
|
- "规格名称","商品名称", "销售属性组合字符串 格式是p1:v1;p2:v2", "原价", "价格", "积分价格",
|
|
|
- "库存","商家编码","商品条形码" ,"商品重量", "商品体积"};
|
|
|
+ String[] hearder = {"产品名称", "平台分类", "店铺分类", "所属品牌", "产品卖点", "配送方式", "运费设置", "产品状态",
|
|
|
+ "规格名称", "商品名称", "销售属性组合字符串 格式是p1:v1;p2:v2", "原价", "价格", "积分价格",
|
|
|
+ "库存", "商家编码", "商品条形码", "商品重量", "商品体积"};
|
|
|
Sheet sheet = writer.getSheet();
|
|
|
sheet.setColumnWidth(0, 60 * 256);
|
|
|
sheet.setColumnWidth(1, 20 * 256);
|
|
@@ -371,8 +395,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
writer.writeRow(Arrays.asList(hearder));
|
|
|
// 限制商家分类和平台分类
|
|
|
List<Category> categories = categoryService.list(new LambdaQueryWrapper<Category>()
|
|
|
- .eq(Category::getShopId,0L).eq(Category::getGrade,2));
|
|
|
- if(CollectionUtils.isNotEmpty(categories)) {
|
|
|
+ .eq(Category::getShopId, 0L).eq(Category::getGrade, 2));
|
|
|
+ if (CollectionUtils.isNotEmpty(categories)) {
|
|
|
String[] categoryName = new String[categories.size()];
|
|
|
for (int i = 0; i < categories.size(); i++) {
|
|
|
categoryName[i] = categories.get(i).getCategoryName();
|
|
@@ -380,7 +404,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
createDropDownList(sheet, categoryName, 2, 50000, 1, 1);
|
|
|
}
|
|
|
List<Category> shopCategories = categoryService.listByShopId(shopId);
|
|
|
- if(CollectionUtils.isNotEmpty(shopCategories)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(shopCategories)) {
|
|
|
String[] categoryName = new String[shopCategories.size()];
|
|
|
for (int i = 0; i < shopCategories.size(); i++) {
|
|
|
categoryName[i] = shopCategories.get(i).getCategoryName();
|
|
@@ -388,11 +412,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
createDropDownList(sheet, categoryName, 2, 50000, 2, 2);
|
|
|
}
|
|
|
// 限制物流方式
|
|
|
- String[] dvyTypes = {"商家邮寄","用户自提","同城配送","商家邮寄,用户自提","商家邮寄,同城配送","同城配送,用户自提","商家邮寄,用户自提,同城配送"};
|
|
|
+ String[] dvyTypes = {"商家邮寄", "用户自提", "同城配送", "商家邮寄,用户自提", "商家邮寄,同城配送", "同城配送,用户自提", "商家邮寄,用户自提,同城配送"};
|
|
|
createDropDownList(sheet, dvyTypes, 2, 50000, 5, 5);
|
|
|
// 限制品牌选择
|
|
|
List<Brand> brands = brandService.list(new LambdaQueryWrapper<Brand>().eq(Brand::getStatus, 1));
|
|
|
- if(CollectionUtils.isNotEmpty(brands)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(brands)) {
|
|
|
String[] categoryName = new String[brands.size()];
|
|
|
for (int i = 0; i < brands.size(); i++) {
|
|
|
categoryName[i] = brands.get(i).getBrandName();
|
|
@@ -400,17 +424,17 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
createDropDownList(sheet, categoryName, 2, 50000, 3, 3);
|
|
|
}
|
|
|
List<TransportParam> transportParams = new ArrayList<>();
|
|
|
- applicationContext.publishEvent(new GetTransportNamesEvent(transportParams,shopId));
|
|
|
- if(CollectionUtils.isNotEmpty(transportParams)) {
|
|
|
+ applicationContext.publishEvent(new GetTransportNamesEvent(transportParams, shopId));
|
|
|
+ if (CollectionUtils.isNotEmpty(transportParams)) {
|
|
|
List<String> transportNameList = new ArrayList<>();
|
|
|
transportParams.forEach(transportParam -> transportNameList.add(transportParam.getTransName()));
|
|
|
String[] transportNames = transportNameList.toArray(new String[transportNameList.size()]);
|
|
|
- createDropDownList(sheet,transportNames,2,50000,6,6);
|
|
|
+ createDropDownList(sheet, transportNames, 2, 50000, 6, 6);
|
|
|
}
|
|
|
- String[] statusStr = {"下架","上架"};
|
|
|
- createDropDownList(sheet,statusStr,2,50000,7,7);
|
|
|
+ String[] statusStr = {"下架", "上架"};
|
|
|
+ createDropDownList(sheet, statusStr, 2, 50000, 7, 7);
|
|
|
int row = 1;
|
|
|
- if(CollectionUtils.isNotEmpty(products)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(products)) {
|
|
|
for (ProductExportParam prod : products) {
|
|
|
List<Sku> skuList = prod.getSkuList();
|
|
|
int firstRow = row + 1;
|
|
@@ -429,7 +453,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
mergeIfNeed(writer, firstRow, lastRow, ++col, col, prod.getBrief());
|
|
|
Product.DeliveryModeVO deliveryModeVO = Json.parseObject(prod.getDeliveryMode(), Product.DeliveryModeVO.class);
|
|
|
StringBuilder deliveryMode = new StringBuilder();
|
|
|
- if(deliveryModeVO != null) {
|
|
|
+ if (deliveryModeVO != null) {
|
|
|
if (deliveryModeVO.getHasCityDelivery() != null && deliveryModeVO.getHasCityDelivery()) {
|
|
|
deliveryMode.append("同城配送,");
|
|
|
}
|
|
@@ -482,193 +506,197 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
|
|
|
@Override
|
|
|
public void downloadModel(HttpServletResponse response, Long shopId) {
|
|
|
- createExcel(null,response,shopId);
|
|
|
+ createExcel(null, response, shopId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object parseFile(MultipartFile file, Long shopId) throws Exception {
|
|
|
- //读取工作簿
|
|
|
- Workbook workBook = WorkbookFactory.create(file.getInputStream());
|
|
|
- //读取工作表
|
|
|
- Sheet sheet = workBook.getSheetAt(0);
|
|
|
- int rowNumber = sheet.getPhysicalNumberOfRows();
|
|
|
-
|
|
|
- //校验是否填写内容
|
|
|
- if (rowNumber <= 2) {
|
|
|
- throw new GlobalException("文件无内容!");
|
|
|
- }
|
|
|
- // * 2.1不是Excel文件,直接返回提示信息
|
|
|
- if (!(file.getOriginalFilename().contains("xls") || file.getOriginalFilename().contains("xlsx"))) {
|
|
|
- // 格式错误
|
|
|
- throw new YamiShopBindException("文件格式错误");
|
|
|
- }
|
|
|
-
|
|
|
- //TODO 如果三级分类需要获取最底层的分类
|
|
|
- // 获取平台分类map
|
|
|
- List<Category> categories = categoryService.list(new LambdaQueryWrapper<Category>()
|
|
|
- .eq(Category::getShopId,0).eq(Category::getGrade,2));
|
|
|
- // 如果重复的key取最后一个的值
|
|
|
- Map<String, Long> categoryMap = categories.stream().collect(Collectors.toMap(Category::getCategoryName, Category::getCategoryId,(key1 , key2)-> key2));
|
|
|
-
|
|
|
- // 获取店铺分类map
|
|
|
- List<Category> shopCategories = categoryService.listByShopId(shopId);
|
|
|
- // 如果重复的key取最后一个的值
|
|
|
- Map<String, Long> shopCategoryMap = shopCategories.stream().collect(Collectors.toMap(Category::getCategoryName, Category::getCategoryId,(key1 , key2)-> key2));
|
|
|
-
|
|
|
- // 获取品牌map
|
|
|
- List<Brand> brands = brandService.list(new LambdaQueryWrapper<Brand>().eq(Brand::getStatus, 1));
|
|
|
- Map<String, Long> brandMap = brands.stream().collect(Collectors.toMap(Brand::getBrandName, Brand::getBrandId,(key1 , key2)-> key2));
|
|
|
-
|
|
|
- // 获取运费模板map
|
|
|
- List<TransportParam> transportParams = new ArrayList<>();
|
|
|
- applicationContext.publishEvent(new GetTransportNamesEvent(transportParams,shopId));
|
|
|
- Map<String, Long> transportMap = transportParams.stream().collect(Collectors.toMap(TransportParam::getTransName, TransportParam::getTransportId,(key1 , key2)-> key2));
|
|
|
-
|
|
|
- List<Product> products = new ArrayList<>();
|
|
|
- List<Sku> skuList = new ArrayList<>();
|
|
|
- Date date = new Date();
|
|
|
- Integer totalStocks = 0;
|
|
|
- double price = 0.0;
|
|
|
- double oriPrice = 0.0;
|
|
|
- Integer scorePrice = 0;
|
|
|
- int insertRows = 0;
|
|
|
- Product product = new Product();
|
|
|
- //循环读取每一行数据并校验
|
|
|
- for (int i = 2; i < rowNumber; i++) {
|
|
|
- try {
|
|
|
- //读取行
|
|
|
- Row row = sheet.getRow(i);
|
|
|
-// String[] hearder = { "产品名称", "平台分类", "店铺分类", "所属品牌", "产品卖点", "配送方式","运费设置",
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+// @Override
|
|
|
+// public Object parseFile(MultipartFile file, Long shopId) throws Exception {
|
|
|
+// //读取工作簿
|
|
|
+// Workbook workBook = WorkbookFactory.create(file.getInputStream());
|
|
|
+// //读取工作表
|
|
|
+// Sheet sheet = workBook.getSheetAt(0);
|
|
|
+// int rowNumber = sheet.getPhysicalNumberOfRows();
|
|
|
+//
|
|
|
+// //校验是否填写内容
|
|
|
+// if (rowNumber <= 2) {
|
|
|
+// throw new GlobalException("文件无内容!");
|
|
|
+// }
|
|
|
+// // * 2.1不是Excel文件,直接返回提示信息
|
|
|
+// if (!(file.getOriginalFilename().contains("xls") || file.getOriginalFilename().contains("xlsx"))) {
|
|
|
+// // 格式错误
|
|
|
+// throw new YamiShopBindException("文件格式错误");
|
|
|
+// }
|
|
|
+//
|
|
|
+// //TODO 如果三级分类需要获取最底层的分类
|
|
|
+// // 获取平台分类map
|
|
|
+// List<Category> categories = categoryService.list(new LambdaQueryWrapper<Category>()
|
|
|
+// .eq(Category::getShopId,0).eq(Category::getGrade,2));
|
|
|
+// // 如果重复的key取最后一个的值
|
|
|
+// Map<String, Long> categoryMap = categories.stream().collect(Collectors.toMap(Category::getCategoryName, Category::getCategoryId,(key1 , key2)-> key2));
|
|
|
+//
|
|
|
+// // 获取店铺分类map
|
|
|
+// List<Category> shopCategories = categoryService.listByShopId(shopId);
|
|
|
+// // 如果重复的key取最后一个的值
|
|
|
+// Map<String, Long> shopCategoryMap = shopCategories.stream().collect(Collectors.toMap(Category::getCategoryName, Category::getCategoryId,(key1 , key2)-> key2));
|
|
|
+//
|
|
|
+// // 获取品牌map
|
|
|
+// List<Brand> brands = brandService.list(new LambdaQueryWrapper<Brand>().eq(Brand::getStatus, 1));
|
|
|
+// Map<String, Long> brandMap = brands.stream().collect(Collectors.toMap(Brand::getBrandName, Brand::getBrandId,(key1 , key2)-> key2));
|
|
|
+//
|
|
|
+// // 获取运费模板map
|
|
|
+// List<TransportParam> transportParams = new ArrayList<>();
|
|
|
+// applicationContext.publishEvent(new GetTransportNamesEvent(transportParams,shopId));
|
|
|
+// Map<String, Long> transportMap = transportParams.stream().collect(Collectors.toMap(TransportParam::getTransName, TransportParam::getTransportId,(key1 , key2)-> key2));
|
|
|
+//
|
|
|
+// List<Product> products = new ArrayList<>();
|
|
|
+// List<Sku> skuList = new ArrayList<>();
|
|
|
+// Date date = new Date();
|
|
|
+// Integer totalStocks = 0;
|
|
|
+// double price = 0.0;
|
|
|
+// double oriPrice = 0.0;
|
|
|
+// Integer scorePrice = 0;
|
|
|
+// int insertRows = 0;
|
|
|
+// Product product = new Product();
|
|
|
+// //循环读取每一行数据并校验
|
|
|
+// for (int i = 2; i < rowNumber; i++) {
|
|
|
+// try {
|
|
|
+// //读取行
|
|
|
+// Row row = sheet.getRow(i);
|
|
|
+//// String[] hearder = { "产品名称", "平台分类", "店铺分类", "所属品牌", "产品卖点", "配送方式","运费设置",
|
|
|
+//// "规格名称","商品名称", "销售属性组合字符串 格式是p1:v1;p2:v2", "原价", "价格", "积分价格",
|
|
|
+//// "库存","商家编码","商品条形码" ,"商品重量", "商品体积","产品状态"};
|
|
|
+// String prodName = Objects.isNull(row.getCell(0))? "":row.getCell(0).getStringCellValue();
|
|
|
+// String category = Objects.isNull(row.getCell(1))? "":row.getCell(1).getStringCellValue();
|
|
|
+// String shopCategory = Objects.isNull(row.getCell(2))? "":row.getCell(2).getStringCellValue();
|
|
|
+// String brandName = Objects.isNull(row.getCell(3))? "":row.getCell(3).getStringCellValue();
|
|
|
+// String brif = Objects.isNull(row.getCell(4))? "":row.getCell(4).getStringCellValue();
|
|
|
+// String dvyType = Objects.isNull(row.getCell(5))? "":row.getCell(5).getStringCellValue();
|
|
|
+// String transportName = Objects.isNull(row.getCell(6))? "":row.getCell(6).getStringCellValue();
|
|
|
+// String statusStr = Objects.isNull(row.getCell(7))? "":row.getCell(7).getStringCellValue();
|
|
|
+// if(StrUtil.isNotBlank(prodName) || !PoiExcelUtil.isMergedRegion(sheet,i,0)) {
|
|
|
+// skuList = new ArrayList<>();
|
|
|
+// product = new Product();
|
|
|
+// totalStocks = 0;
|
|
|
+// oriPrice = 0.0;
|
|
|
+// scorePrice = 0;
|
|
|
+// price = 0.0;
|
|
|
+// insertRows++;
|
|
|
+// product.setShopId(shopId);
|
|
|
+// product.setProdName(prodName);
|
|
|
+// product.setCategoryId(categoryMap.get(category));
|
|
|
+// product.setShopCategoryId(shopCategoryMap.get(shopCategory));
|
|
|
+// product.setBrandId(brandMap.get(brandName));
|
|
|
+// product.setBrief(brif);
|
|
|
+// product.setDeliveryMode(getDvyType(dvyType));
|
|
|
+// product.setDeliveryTemplateId(transportMap.get(transportName));
|
|
|
+// //TODO 差商品的图片
|
|
|
+// product.setStatus(Objects.equals(statusStr, "上架") ? ProdStatusEnums.NORMAL.getValue() : ProdStatusEnums.SHOP_OFFLINE.getValue());
|
|
|
+// product.setPutawayTime(Objects.equals(statusStr, "上架") ? date : null);
|
|
|
+// product.setCreateTime(date);
|
|
|
+// product.setUpdateTime(date);
|
|
|
+// product.setVersion(0);
|
|
|
+// // 商品销量设置为0
|
|
|
+// product.setSoldNum(0);
|
|
|
+// product.setProdType(ProdType.PROD_TYPE_NORMAL.value());
|
|
|
+// product.setActivityId(0L);
|
|
|
+// product.setPic("2020/07/f29c335ff19746cda1025f363dcc00cf.png");
|
|
|
+// product.setImgs("2020/07/f29c335ff19746cda1025f363dcc00cf.png");
|
|
|
+//
|
|
|
+// products.add(product);
|
|
|
+// }
|
|
|
+// String[] hearder = { "产品名称", "平台分类", "店铺分类", "所属品牌", "产品卖点", "配送方式","运费设置","产品状态",
|
|
|
// "规格名称","商品名称", "销售属性组合字符串 格式是p1:v1;p2:v2", "原价", "价格", "积分价格",
|
|
|
-// "库存","商家编码","商品条形码" ,"商品重量", "商品体积","产品状态"};
|
|
|
- String prodName = Objects.isNull(row.getCell(0))? "":row.getCell(0).getStringCellValue();
|
|
|
- String category = Objects.isNull(row.getCell(1))? "":row.getCell(1).getStringCellValue();
|
|
|
- String shopCategory = Objects.isNull(row.getCell(2))? "":row.getCell(2).getStringCellValue();
|
|
|
- String brandName = Objects.isNull(row.getCell(3))? "":row.getCell(3).getStringCellValue();
|
|
|
- String brif = Objects.isNull(row.getCell(4))? "":row.getCell(4).getStringCellValue();
|
|
|
- String dvyType = Objects.isNull(row.getCell(5))? "":row.getCell(5).getStringCellValue();
|
|
|
- String transportName = Objects.isNull(row.getCell(6))? "":row.getCell(6).getStringCellValue();
|
|
|
- String statusStr = Objects.isNull(row.getCell(7))? "":row.getCell(7).getStringCellValue();
|
|
|
- if(StrUtil.isNotBlank(prodName) || !PoiExcelUtil.isMergedRegion(sheet,i,0)) {
|
|
|
- skuList = new ArrayList<>();
|
|
|
- product = new Product();
|
|
|
- totalStocks = 0;
|
|
|
- oriPrice = 0.0;
|
|
|
- scorePrice = 0;
|
|
|
- price = 0.0;
|
|
|
- insertRows++;
|
|
|
- product.setShopId(shopId);
|
|
|
- product.setProdName(prodName);
|
|
|
- product.setCategoryId(categoryMap.get(category));
|
|
|
- product.setShopCategoryId(shopCategoryMap.get(shopCategory));
|
|
|
- product.setBrandId(brandMap.get(brandName));
|
|
|
- product.setBrief(brif);
|
|
|
- product.setDeliveryMode(getDvyType(dvyType));
|
|
|
- product.setDeliveryTemplateId(transportMap.get(transportName));
|
|
|
- //TODO 差商品的图片
|
|
|
- product.setStatus(Objects.equals(statusStr, "上架") ? ProdStatusEnums.NORMAL.getValue() : ProdStatusEnums.SHOP_OFFLINE.getValue());
|
|
|
- product.setPutawayTime(Objects.equals(statusStr, "上架") ? date : null);
|
|
|
- product.setCreateTime(date);
|
|
|
- product.setUpdateTime(date);
|
|
|
- product.setVersion(0);
|
|
|
- // 商品销量设置为0
|
|
|
- product.setSoldNum(0);
|
|
|
- product.setProdType(ProdType.PROD_TYPE_NORMAL.value());
|
|
|
- product.setActivityId(0L);
|
|
|
- product.setPic("2020/07/f29c335ff19746cda1025f363dcc00cf.png");
|
|
|
- product.setImgs("2020/07/f29c335ff19746cda1025f363dcc00cf.png");
|
|
|
-
|
|
|
- products.add(product);
|
|
|
- }
|
|
|
- String[] hearder = { "产品名称", "平台分类", "店铺分类", "所属品牌", "产品卖点", "配送方式","运费设置","产品状态",
|
|
|
- "规格名称","商品名称", "销售属性组合字符串 格式是p1:v1;p2:v2", "原价", "价格", "积分价格",
|
|
|
- "库存","商家编码","商品条形码" ,"商品重量", "商品体积"};
|
|
|
- String skuName = Objects.isNull(row.getCell(8))? "":row.getCell(8).getStringCellValue();
|
|
|
- String skuProdName = Objects.isNull(row.getCell(9))? "":row.getCell(9).getStringCellValue();
|
|
|
- String properties = Objects.isNull(row.getCell(10))? "":row.getCell(10).getStringCellValue();
|
|
|
- double skuOriPrice = Objects.isNull(row.getCell(11))? 0.0:row.getCell(11).getNumericCellValue();
|
|
|
- double skuPrice = Objects.isNull(row.getCell(12))? 0.0:row.getCell(12).getNumericCellValue();
|
|
|
- Integer skuScorePrice = Integer.valueOf(StrUtil.isBlank(row.getCell(13).getStringCellValue())? "0":row.getCell(13).getStringCellValue());
|
|
|
- Integer stocks = Objects.isNull(row.getCell(14))? 0:(int)(row.getCell(14).getNumericCellValue());
|
|
|
- String partyCode = "";
|
|
|
- if(Objects.nonNull(row.getCell(15))) {
|
|
|
- row.getCell(15).setCellType(CellType.STRING);
|
|
|
- partyCode = row.getCell(15).getStringCellValue();
|
|
|
- }
|
|
|
- String modelId = "";
|
|
|
- if(Objects.nonNull(row.getCell(15))) {
|
|
|
- row.getCell(16).setCellType(CellType.STRING);
|
|
|
- modelId = row.getCell(15).getStringCellValue();
|
|
|
- }
|
|
|
- double weight = Objects.isNull(row.getCell(17))? 0.0:row.getCell(17).getNumericCellValue();
|
|
|
- double volume = Objects.isNull(row.getCell(18))? 0.0:row.getCell(18).getNumericCellValue();
|
|
|
- oriPrice = Objects.equals(oriPrice ,0.0) ? skuOriPrice:oriPrice;
|
|
|
- price = Objects.equals(price ,0.0) ? skuPrice:price;
|
|
|
-
|
|
|
- Sku sku = new Sku();
|
|
|
- sku.setSkuName(skuName);
|
|
|
- sku.setProdName(skuProdName);
|
|
|
- sku.setProperties(properties);
|
|
|
- sku.setOriPrice(skuOriPrice);
|
|
|
- sku.setPrice(skuPrice);
|
|
|
- sku.setStocks(stocks);
|
|
|
- sku.setSkuScore(skuScorePrice);
|
|
|
- sku.setModelId(modelId);
|
|
|
- sku.setPartyCode(partyCode);
|
|
|
- sku.setVolume(volume);
|
|
|
- sku.setUpdateTime(date);
|
|
|
- sku.setWeight(weight);
|
|
|
- sku.setVersion(1);
|
|
|
- sku.setIsDelete(0);
|
|
|
- sku.setStatus(1);
|
|
|
- skuList.add(sku);
|
|
|
- // 如果prodName为空并且为合并行则为一个prod
|
|
|
- totalStocks += stocks;
|
|
|
- if(price > skuPrice) {
|
|
|
- oriPrice = skuOriPrice;
|
|
|
- price = skuPrice;
|
|
|
- scorePrice = skuScorePrice;
|
|
|
- }
|
|
|
- product.setOriPrice(oriPrice);
|
|
|
- product.setScorePrice(scorePrice);
|
|
|
- product.setPrice(price);
|
|
|
- product.setTotalStocks(totalStocks);
|
|
|
- product.setSkuList(skuList);
|
|
|
- } catch (Exception e) {
|
|
|
- //错误信息提示
|
|
|
- System.out.println("第" + (i + 1) + "行数据有错误," + e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- workBook.close();
|
|
|
- //不为空批量导入
|
|
|
- if(CollectionUtils.isNotEmpty(products)){
|
|
|
- saveBatch(products);
|
|
|
-// List<Sku> skuDb = new ArrayList<>();
|
|
|
- for (Product productDb : products) {
|
|
|
- List<Sku> skus = productDb.getSkuList();
|
|
|
- skuMapper.insertBatch(productDb.getProdId(),skus);
|
|
|
-// skus.forEach(sku -> sku.setProdId(product.getProdId()));
|
|
|
-// skuDb.addAll(skus);
|
|
|
- }
|
|
|
-// skuMapper.save(skuDb);
|
|
|
- return "检查到" + insertRows + "条商品,成功导入" + products.size() + "条卡密!";
|
|
|
- }
|
|
|
- return "数据错误!导入0条";
|
|
|
- }
|
|
|
+// "库存","商家编码","商品条形码" ,"商品重量", "商品体积"};
|
|
|
+// String skuName = Objects.isNull(row.getCell(8))? "":row.getCell(8).getStringCellValue();
|
|
|
+// String skuProdName = Objects.isNull(row.getCell(9))? "":row.getCell(9).getStringCellValue();
|
|
|
+// String properties = Objects.isNull(row.getCell(10))? "":row.getCell(10).getStringCellValue();
|
|
|
+// double skuOriPrice = Objects.isNull(row.getCell(11))? 0.0:row.getCell(11).getNumericCellValue();
|
|
|
+// double skuPrice = Objects.isNull(row.getCell(12))? 0.0:row.getCell(12).getNumericCellValue();
|
|
|
+// Integer skuScorePrice = Integer.valueOf(StrUtil.isBlank(row.getCell(13).getStringCellValue())? "0":row.getCell(13).getStringCellValue());
|
|
|
+// Integer stocks = Objects.isNull(row.getCell(14))? 0:(int)(row.getCell(14).getNumericCellValue());
|
|
|
+// String partyCode = "";
|
|
|
+// if(Objects.nonNull(row.getCell(15))) {
|
|
|
+// row.getCell(15).setCellType(CellType.STRING);
|
|
|
+// partyCode = row.getCell(15).getStringCellValue();
|
|
|
+// }
|
|
|
+// String modelId = "";
|
|
|
+// if(Objects.nonNull(row.getCell(15))) {
|
|
|
+// row.getCell(16).setCellType(CellType.STRING);
|
|
|
+// modelId = row.getCell(15).getStringCellValue();
|
|
|
+// }
|
|
|
+// double weight = Objects.isNull(row.getCell(17))? 0.0:row.getCell(17).getNumericCellValue();
|
|
|
+// double volume = Objects.isNull(row.getCell(18))? 0.0:row.getCell(18).getNumericCellValue();
|
|
|
+// oriPrice = Objects.equals(oriPrice ,0.0) ? skuOriPrice:oriPrice;
|
|
|
+// price = Objects.equals(price ,0.0) ? skuPrice:price;
|
|
|
+//
|
|
|
+// Sku sku = new Sku();
|
|
|
+// sku.setSkuName(skuName);
|
|
|
+// sku.setProdName(skuProdName);
|
|
|
+// sku.setProperties(properties);
|
|
|
+// sku.setOriPrice(skuOriPrice);
|
|
|
+// sku.setPrice(skuPrice);
|
|
|
+// sku.setStocks(stocks);
|
|
|
+// sku.setSkuScore(skuScorePrice);
|
|
|
+// sku.setModelId(modelId);
|
|
|
+// sku.setPartyCode(partyCode);
|
|
|
+// sku.setVolume(volume);
|
|
|
+// sku.setUpdateTime(date);
|
|
|
+// sku.setWeight(weight);
|
|
|
+// sku.setVersion(1);
|
|
|
+// sku.setIsDelete(0);
|
|
|
+// sku.setStatus(1);
|
|
|
+// skuList.add(sku);
|
|
|
+// // 如果prodName为空并且为合并行则为一个prod
|
|
|
+// totalStocks += stocks;
|
|
|
+// if(price > skuPrice) {
|
|
|
+// oriPrice = skuOriPrice;
|
|
|
+// price = skuPrice;
|
|
|
+// scorePrice = skuScorePrice;
|
|
|
+// }
|
|
|
+// product.setOriPrice(oriPrice);
|
|
|
+// product.setScorePrice(scorePrice);
|
|
|
+// product.setPrice(price);
|
|
|
+// product.setTotalStocks(totalStocks);
|
|
|
+// product.setSkuList(skuList);
|
|
|
+// } catch (Exception e) {
|
|
|
+// //错误信息提示
|
|
|
+// System.out.println("第" + (i + 1) + "行数据有错误," + e.getMessage());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// workBook.close();
|
|
|
+// //不为空批量导入
|
|
|
+// if(CollectionUtils.isNotEmpty(products)){
|
|
|
+// saveBatch(products);
|
|
|
+//// List<Sku> skuDb = new ArrayList<>();
|
|
|
+// for (Product productDb : products) {
|
|
|
+// List<Sku> skus = productDb.getSkuList();
|
|
|
+// skuMapper.insertBatch(productDb.getProdId(),skus);
|
|
|
+//// skus.forEach(sku -> sku.setProdId(product.getProdId()));
|
|
|
+//// skuDb.addAll(skus);
|
|
|
+// }
|
|
|
+//// skuMapper.save(skuDb);
|
|
|
+// return "检查到" + insertRows + "条商品,成功导入" + products.size() + "条卡密!";
|
|
|
+// }
|
|
|
+// return "数据错误!导入0条";
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public IPage<Product> pageProducts(PageParam<Product> page, ProductParam product) {
|
|
|
- return productMapper.pageProducts(page,product);
|
|
|
+ return productMapper.pageProducts(page, product);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public IPage<Product> listRelatedProducts(ListRelatedProductsDto listRelatedProductsDto) {
|
|
|
IPage<Product> products = null;
|
|
|
- if(null == listRelatedProductsDto.getProdName()){
|
|
|
+ if (null == listRelatedProductsDto.getProdName()) {
|
|
|
products = page(new Page<>(listRelatedProductsDto.getCurrent(), listRelatedProductsDto.getSize()), new LambdaQueryWrapper<Product>()
|
|
|
.eq(Product::getShopCategoryId, listRelatedProductsDto.getShopCategoryId())
|
|
|
.orderByDesc(Product::getCreateTime));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
products = page(new Page<>(listRelatedProductsDto.getCurrent(), listRelatedProductsDto.getSize()), new LambdaQueryWrapper<Product>()
|
|
|
.eq(Product::getShopCategoryId, listRelatedProductsDto.getShopCategoryId())
|
|
|
.orderByDesc(Product::getCreateTime)
|
|
@@ -699,24 +727,25 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
if (product != null) {
|
|
|
product.setShopCategoryId(shopCategoryId);
|
|
|
productMapper.updateById(product);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new GlobalException("关联失败!");
|
|
|
- }});
|
|
|
+ }
|
|
|
+ });
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public IPage<Product> listUnRelatedProducts(ListUnRelatedProductsDTO listUnRelatedProductsDTO) {
|
|
|
IPage<Product> products = null;
|
|
|
- if(null == listUnRelatedProductsDTO.getProdName()){
|
|
|
+ if (null == listUnRelatedProductsDTO.getProdName()) {
|
|
|
products = page(new Page<>(listUnRelatedProductsDTO.getCurrent(), listUnRelatedProductsDTO.getSize()), new LambdaQueryWrapper<Product>()
|
|
|
.eq(Product::getShopId, listUnRelatedProductsDTO.getShopId())
|
|
|
- .eq(Product::getShopCategoryId,0)
|
|
|
+ .eq(Product::getShopCategoryId, 0)
|
|
|
.orderByDesc(Product::getCreateTime));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
products = page(new Page<>(listUnRelatedProductsDTO.getCurrent(), listUnRelatedProductsDTO.getSize()), new LambdaQueryWrapper<Product>()
|
|
|
.eq(Product::getShopId, listUnRelatedProductsDTO.getShopId())
|
|
|
- .eq(Product::getShopCategoryId,0)
|
|
|
+ .eq(Product::getShopCategoryId, 0)
|
|
|
.orderByDesc(Product::getCreateTime)
|
|
|
.like(Product::getProdName, listUnRelatedProductsDTO.getProdName()));
|
|
|
}
|
|
@@ -727,7 +756,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
public IPage<Product> listProdByCategoryIdAndShopId(ProdByCategoryIdAndShopIdDTO prodByCategoryIdAndShopIdDTO) {
|
|
|
IPage<Product> productIPage = productMapper.listProdByCategoryIdAndShopId(new Page<>(prodByCategoryIdAndShopIdDTO.getCurrent(), prodByCategoryIdAndShopIdDTO.getSize()),
|
|
|
prodByCategoryIdAndShopIdDTO);
|
|
|
- if(productIPage.getRecords().isEmpty()){
|
|
|
+ if (productIPage.getRecords().isEmpty()) {
|
|
|
productIPage = productMapper.listProdByCategoryIdAndShopId2(new Page<>(prodByCategoryIdAndShopIdDTO.getCurrent(), prodByCategoryIdAndShopIdDTO.getSize()),
|
|
|
prodByCategoryIdAndShopIdDTO);
|
|
|
}
|
|
@@ -746,13 +775,13 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
mode.setHasUserPickUp(false);
|
|
|
mode.setHasCityDelivery(false);
|
|
|
for (String str : split) {
|
|
|
- if(StrUtil.equals(str,"商家邮寄")){
|
|
|
+ if (StrUtil.equals(str, "商家邮寄")) {
|
|
|
mode.setHasShopDelivery(true);
|
|
|
}
|
|
|
- if(StrUtil.equals(str,"用户自提")){
|
|
|
+ if (StrUtil.equals(str, "用户自提")) {
|
|
|
mode.setHasUserPickUp(true);
|
|
|
}
|
|
|
- if(StrUtil.equals(str,"同城配送")){
|
|
|
+ if (StrUtil.equals(str, "同城配送")) {
|
|
|
mode.setHasCityDelivery(true);
|
|
|
}
|
|
|
}
|
|
@@ -799,6 +828,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
private void writeExcel(HttpServletResponse response, ExcelWriter writer) {
|
|
|
//response为HttpServletResponse对象
|
|
|
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|