|
@@ -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,7 +506,7 @@ 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
|
|
@@ -500,29 +524,29 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
// * 2.1不是Excel文件,直接返回提示信息
|
|
|
if (!(file.getOriginalFilename().contains("xls") || file.getOriginalFilename().contains("xlsx"))) {
|
|
|
// 格式错误
|
|
|
- throw new YamiShopBindException("文件格式错误");
|
|
|
+ throw new YamiShopBindException("文件格式错误");
|
|
|
}
|
|
|
|
|
|
//TODO 如果三级分类需要获取最底层的分类
|
|
|
// 获取平台分类map
|
|
|
List<Category> categories = categoryService.list(new LambdaQueryWrapper<Category>()
|
|
|
- .eq(Category::getShopId,0).eq(Category::getGrade,2));
|
|
|
+ .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<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<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<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));
|
|
|
+ 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<>();
|
|
@@ -541,15 +565,15 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
// 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)) {
|
|
|
+ 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;
|
|
@@ -580,30 +604,30 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
|
|
|
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[] 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))) {
|
|
|
+ if (Objects.nonNull(row.getCell(15))) {
|
|
|
row.getCell(15).setCellType(CellType.STRING);
|
|
|
- partyCode = row.getCell(15).getStringCellValue();
|
|
|
+ partyCode = row.getCell(15).getStringCellValue();
|
|
|
}
|
|
|
String modelId = "";
|
|
|
- if(Objects.nonNull(row.getCell(15))) {
|
|
|
+ if (Objects.nonNull(row.getCell(15))) {
|
|
|
row.getCell(16).setCellType(CellType.STRING);
|
|
|
- modelId = row.getCell(15).getStringCellValue();
|
|
|
+ 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;
|
|
|
+ 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);
|
|
@@ -624,7 +648,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
skuList.add(sku);
|
|
|
// 如果prodName为空并且为合并行则为一个prod
|
|
|
totalStocks += stocks;
|
|
|
- if(price > skuPrice) {
|
|
|
+ if (price > skuPrice) {
|
|
|
oriPrice = skuOriPrice;
|
|
|
price = skuPrice;
|
|
|
scorePrice = skuScorePrice;
|
|
@@ -641,34 +665,34 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
}
|
|
|
workBook.close();
|
|
|
//不为空批量导入
|
|
|
- if(CollectionUtils.isNotEmpty(products)){
|
|
|
+ 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);
|
|
|
+ skuMapper.insertBatch(productDb.getProdId(), skus);
|
|
|
// skus.forEach(sku -> sku.setProdId(product.getProdId()));
|
|
|
// skuDb.addAll(skus);
|
|
|
}
|
|
|
// skuMapper.save(skuDb);
|
|
|
- return "检查到" + insertRows + "条商品,成功导入" + products.size() + "条卡密!";
|
|
|
- }
|
|
|
+ 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 +723,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 +752,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 +771,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 +824,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");
|