fix:bug
This commit is contained in:
1 parent
c59d1a241f
commit
ccf944bd85
20 files changed
+341
-24
No files matched your search
@@ -60,4 +60,25 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/*.xlsx</exclude>
|
||||
<exclude>**/*.xls</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>**/*.xlsx</include>
|
||||
<include>**/*.xls</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+43
-5
@@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.spu;
|
||||
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@@ -12,21 +14,27 @@ import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
|
||||
import cn.iocoder.yudao.module.system.enums.common.SexEnum;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@@ -36,6 +44,7 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
@RestController
|
||||
@RequestMapping("/product/spu")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class ProductSpuController {
|
||||
|
||||
@Resource
|
||||
@@ -129,7 +138,7 @@ public class ProductSpuController {
|
||||
@PreAuthorize("@ss.hasPermission('product:spu:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportSpuList(@Validated ProductSpuPageReqVO reqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
reqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
List<ProductSpuDO> list = productSpuService.getSpuPage(reqVO).getList();
|
||||
// 导出 Excel
|
||||
@@ -137,4 +146,33 @@ public class ProductSpuController {
|
||||
BeanUtils.toBean(list, ProductSpuRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获得导入商品模板")
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/商品导入-模版.xlsx")).build()) {
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
excelWriter.fill(map, writeSheet);
|
||||
excelWriter.fill(new ArrayList<>(), fillConfig, writeSheet);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("|获得导入商品模板|意外的错误:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入商品")
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('system:user:import')")
|
||||
public CommonResult<List<ProductImportExcelResVO>> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
List<ProductImportExcelVO> list = ExcelUtils.read(file, ProductImportExcelVO.class);
|
||||
return success(productSpuService.importProductList(list));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false)
|
||||
public class ProductImportExcelResVO {
|
||||
|
||||
/**
|
||||
* 行号
|
||||
*/
|
||||
private Integer lineNumber;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
private List<String> errors;
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false)
|
||||
public class ProductImportExcelVO {
|
||||
|
||||
@ExcelProperty("商品名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("商品分类")
|
||||
private String categoryStr;
|
||||
|
||||
/**
|
||||
* 商品分类编号
|
||||
*/
|
||||
private Long categoryId;
|
||||
|
||||
@ExcelProperty("商品品牌")
|
||||
private String brandStr;
|
||||
|
||||
/**
|
||||
* 品牌编号
|
||||
*/
|
||||
private Long brandId;
|
||||
|
||||
@ExcelProperty("商品关键字")
|
||||
private String keyword;
|
||||
|
||||
@ExcelProperty("商品简介")
|
||||
private String introduction;
|
||||
|
||||
@ExcelProperty("销售价")
|
||||
private BigDecimal price;
|
||||
|
||||
@ExcelProperty("市场价")
|
||||
private BigDecimal marketPrice;
|
||||
|
||||
@ExcelProperty("成本价")
|
||||
private BigDecimal costPrice;
|
||||
|
||||
@ExcelProperty("库存")
|
||||
private Integer stock;
|
||||
|
||||
@ExcelProperty("重量(kg)")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ExcelProperty("体积(m^3)")
|
||||
private BigDecimal volume;
|
||||
|
||||
}
|
||||
+3
-1
@@ -53,6 +53,8 @@ public interface ProductBrandService {
|
||||
*/
|
||||
List<ProductBrandDO> getBrandList(Collection<Long> ids);
|
||||
|
||||
List<ProductBrandDO> getBrandListByNames(Collection<String> names);
|
||||
|
||||
/**
|
||||
* 获得品牌列表
|
||||
*
|
||||
@@ -80,7 +82,7 @@ public interface ProductBrandService {
|
||||
* 获取指定状态的品牌列表
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 返回品牌列表
|
||||
* @return 返回品牌列表
|
||||
*/
|
||||
List<ProductBrandDO> getBrandListByStatus(Integer status);
|
||||
}
|
||||
+7
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.service.brand;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO;
|
||||
@@ -15,6 +16,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -93,6 +95,11 @@ public class ProductBrandServiceImpl implements ProductBrandService {
|
||||
return brandMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductBrandDO> getBrandListByNames(Collection<String> names) {
|
||||
return brandMapper.selectList(new LambdaQueryWrapperX<ProductBrandDO>().in(ProductBrandDO::getName, names));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductBrandDO> getBrandList(ProductBrandListReqVO listReqVO) {
|
||||
return brandMapper.selectList(listReqVO);
|
||||
|
||||
+5
@@ -68,6 +68,11 @@ public interface ProductCategoryService {
|
||||
*/
|
||||
List<ProductCategoryDO> getCategoryList(ProductCategoryListReqVO listReqVO);
|
||||
|
||||
/**
|
||||
* 获取一级分类
|
||||
*/
|
||||
List<ProductCategoryDO> getStairCategoryList(List<String> names);
|
||||
|
||||
/**
|
||||
* 获得开启状态的商品分类列表
|
||||
*
|
||||
|
||||
+10
-4
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
@@ -14,10 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
||||
@@ -171,6 +169,14 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|
||||
return productCategoryMapper.selectList(listReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductCategoryDO> getStairCategoryList(List<String> names) {
|
||||
return productCategoryMapper.selectList(new LambdaQueryWrapperX<ProductCategoryDO>()
|
||||
.in(ProductCategoryDO::getName, names)
|
||||
.eq(ProductCategoryDO::getParentId, PARENT_ID_NULL)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductCategoryDO> getEnableCategoryList() {
|
||||
return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
|
||||
+5
-3
@@ -2,9 +2,7 @@ package cn.iocoder.yudao.module.product.service.spu;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
|
||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -143,4 +141,8 @@ public interface ProductSpuService {
|
||||
@Async
|
||||
void updateBrowseCount(Long id, int incrCount);
|
||||
|
||||
/**
|
||||
* 导入商品
|
||||
*/
|
||||
List<ProductImportExcelResVO> importProductList(List<ProductImportExcelVO> list);
|
||||
}
|
||||
+111
-5
@@ -7,26 +7,30 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
|
||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper;
|
||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||
import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
|
||||
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
@@ -38,12 +42,15 @@ import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
|
||||
@Resource
|
||||
private ProductSpuMapper productSpuMapper;
|
||||
@Resource
|
||||
private ProductSkuMapper productSkuMapper;
|
||||
|
||||
@Resource
|
||||
@Lazy // 循环依赖,避免报错
|
||||
@@ -154,7 +161,106 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
|
||||
@Override
|
||||
public void updateBrowseCount(Long id, int incrCount) {
|
||||
productSpuMapper.updateBrowseCount(id , incrCount);
|
||||
productSpuMapper.updateBrowseCount(id, incrCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入商品
|
||||
*/
|
||||
@Override
|
||||
public List<ProductImportExcelResVO> importProductList(List<ProductImportExcelVO> list) {
|
||||
List<ProductImportExcelResVO> resList = new ArrayList<>();
|
||||
if (ObjectUtil.isEmpty(list)) return resList;
|
||||
// excel品牌
|
||||
List<String> excelBrandStrList = list.stream().map(ProductImportExcelVO::getBrandStr).distinct().filter(ObjectUtil::isNotEmpty).map(s -> s.replaceAll("\\s+", "")).collect(Collectors.toList());
|
||||
// excel所有的一级分类
|
||||
List<String> excelCategoryStrList = list.stream().map(ProductImportExcelVO::getCategoryStr).distinct().filter(ObjectUtil::isNotEmpty).map(s -> s.replaceAll("\\s+", "")).map(s -> s.split("-")[0]).collect(Collectors.toList());
|
||||
// db品牌
|
||||
List<ProductBrandDO> brandList = brandService.getBrandListByNames(excelBrandStrList);
|
||||
// db一级分类
|
||||
List<ProductCategoryDO> categoryList = categoryService.getStairCategoryList(excelCategoryStrList);
|
||||
// 新增的商品
|
||||
List<ProductImportExcelVO> addList = new ArrayList<>();
|
||||
try {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ProductImportExcelVO v = list.get(i);
|
||||
List<String> errors = new ArrayList<>();
|
||||
ProductImportExcelResVO entity = new ProductImportExcelResVO();
|
||||
entity.setLineNumber(i + 1);
|
||||
// 开始处理导入数据
|
||||
ProductBrandDO targetBrand = brandList.stream().filter(item -> ObjectUtil.equals(v.getBrandStr(), item.getName())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isEmpty(targetBrand)) {
|
||||
errors.add("品牌[" + v.getBrandStr() + "]不存在,请添加后再导入");
|
||||
} else {
|
||||
v.setBrandId(targetBrand.getId());
|
||||
}
|
||||
List<String> categoryStrs = Arrays.asList(v.getCategoryStr().split("-"));
|
||||
// 查询一级分类
|
||||
ProductCategoryDO targetCategory = categoryList.stream().filter(item -> ObjectUtil.equals(categoryStrs.get(0), item.getName())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNull(targetCategory)) {
|
||||
errors.add("一级分类[" + v.getCategoryStr() + "]不存在,请添加后再导入");
|
||||
} else {
|
||||
v.setCategoryId(targetCategory.getId());
|
||||
}
|
||||
// 如果有二级分类
|
||||
if (categoryStrs.size() > 1) {
|
||||
ProductCategoryDO targetCategory2 = categoryList.stream().filter(item -> ObjectUtil.equals(categoryStrs.get(1), item.getName())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNull(targetCategory2)) {
|
||||
errors.add("二级分类[" + v.getCategoryStr() + "]不存在,请添加后再导入");
|
||||
} else {
|
||||
v.setCategoryId(targetCategory2.getId());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(errors)) {
|
||||
entity.setErrors(errors);
|
||||
resList.add(entity);
|
||||
continue;
|
||||
}
|
||||
addList.add(v);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(resList)) return resList;
|
||||
// 新增商品
|
||||
for (ProductImportExcelVO v : addList) {
|
||||
int price = v.getPrice().multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).intValue();
|
||||
int marketPrice = v.getMarketPrice().multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).intValue();
|
||||
int costPrice = v.getCostPrice().multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).intValue();
|
||||
ProductSpuDO spuObj = new ProductSpuDO();
|
||||
spuObj.setName(v.getName());
|
||||
spuObj.setKeyword(v.getKeyword());
|
||||
spuObj.setCategoryId(v.getCategoryId());
|
||||
spuObj.setBrandId(v.getBrandId());
|
||||
spuObj.setPicUrl("");
|
||||
spuObj.setSliderPicUrls(new ArrayList<>());
|
||||
spuObj.setSort(0);
|
||||
spuObj.setStatus(ProductSpuStatusEnum.ENABLE.getStatus());
|
||||
spuObj.setSpecType(false);
|
||||
spuObj.setPrice(price);
|
||||
spuObj.setMarketPrice(marketPrice);
|
||||
spuObj.setCostPrice(costPrice);
|
||||
spuObj.setStock(v.getStock());
|
||||
spuObj.setDeliveryTypes(new ArrayList<>());
|
||||
productSpuMapper.insert(spuObj);
|
||||
// 插入
|
||||
List<ProductSkuSaveReqVO> skuList = new ArrayList<>();
|
||||
ProductSkuSaveReqVO skuObj = new ProductSkuSaveReqVO();
|
||||
skuObj.setName(v.getName());
|
||||
skuObj.setPrice(price);
|
||||
skuObj.setMarketPrice(marketPrice);
|
||||
skuObj.setCostPrice(costPrice);
|
||||
skuObj.setBarCode("");
|
||||
skuObj.setPicUrl("");
|
||||
skuObj.setStock(v.getStock());
|
||||
skuObj.setWeight(v.getWeight().doubleValue());
|
||||
skuObj.setVolume(v.getVolume().doubleValue());
|
||||
productSkuService.validateSkuList(skuList, false);
|
||||
productSkuService.updateSkuList(spuObj.getId(), skuList);
|
||||
skuList.add(skuObj);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|导入商品|意外的错误f:{}", e.getMessage());
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -29,7 +29,7 @@ public class PhotoPageReqVO extends PageParam {
|
||||
private PhotoResourceTypeEnum resourceType;
|
||||
|
||||
@Schema(description = "资源地址")
|
||||
private Long address;
|
||||
private String address;
|
||||
|
||||
@Schema(description = "tag_json")
|
||||
private String tagJson;
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class PhotoRespVO {
|
||||
|
||||
@Schema(description = "资源地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("资源地址")
|
||||
private Long address;
|
||||
private String address;
|
||||
|
||||
@Schema(description = "tag")
|
||||
@ExcelProperty("tag-json")
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class PhotoSaveReqVO {
|
||||
|
||||
@Schema(description = "资源地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "资源地址不能为空")
|
||||
private Long address;
|
||||
private String address;
|
||||
|
||||
@Schema(description = "tag")
|
||||
private String tagJson;
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class AppUploadReqVo {
|
||||
|
||||
@Schema(description = "资源地址")
|
||||
@NotNull(message = "资源地址不能为空")
|
||||
private Long address;
|
||||
private String address;
|
||||
|
||||
@Schema(description = "发布-经度")
|
||||
private Double issueLong;
|
||||
|
||||
+20
@@ -1,10 +1,14 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.user.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.member.enums.photo.PhotoResourceTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 会员用户更新 Request VO")
|
||||
@Data
|
||||
@@ -32,4 +36,20 @@ public class AppMemberUserUpdateReqVO {
|
||||
@Schema(description = "个人介绍")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "用户相册")
|
||||
private List<UploadReqVo> photo;
|
||||
|
||||
@Data
|
||||
public static class UploadReqVo {
|
||||
|
||||
@Schema(description = "资源类型")
|
||||
@NotEmpty(message = "上传途径不能为空")
|
||||
private PhotoResourceTypeEnum resourceType;
|
||||
|
||||
@Schema(description = "资源地址")
|
||||
@NotNull(message = "资源地址不能为空")
|
||||
private String address;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class PhotoDO extends BaseDO {
|
||||
/**
|
||||
* 资源地址
|
||||
*/
|
||||
private Long address;
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* tag-json
|
||||
|
||||
+19
@@ -13,8 +13,12 @@ import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateR
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.*;
|
||||
import cn.iocoder.yudao.module.member.convert.auth.AuthConvert;
|
||||
import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.photo.PhotoDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.photo.PhotoMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.photo.PhotoBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.enums.photo.PhotoResourceTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.mq.producer.user.MemberUserProducer;
|
||||
import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi;
|
||||
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
|
||||
@@ -34,6 +38,8 @@ import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
@@ -51,6 +57,8 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
|
||||
@Resource
|
||||
private MemberUserMapper memberUserMapper;
|
||||
@Resource
|
||||
private PhotoMapper photoMapper;
|
||||
|
||||
@Resource
|
||||
private SmsCodeApi smsCodeApi;
|
||||
@@ -144,6 +152,17 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
public void updateUser(Long userId, AppMemberUserUpdateReqVO reqVO) {
|
||||
MemberUserDO updateObj = BeanUtils.toBean(reqVO, MemberUserDO.class).setId(userId);
|
||||
memberUserMapper.updateById(updateObj);
|
||||
if (ObjectUtil.isNotEmpty(reqVO.getPhoto())) {
|
||||
List<PhotoDO> photoList = reqVO.getPhoto().stream().map(item -> {
|
||||
PhotoDO entity = new PhotoDO();
|
||||
entity.setMemberId(userId);
|
||||
entity.setBizType(PhotoBizTypeEnum.USER_PHOTO.getType());
|
||||
entity.setResourceType(item.getResourceType().getType());
|
||||
entity.setAddress(item.getAddress());
|
||||
return entity;
|
||||
}).collect(Collectors.toList());
|
||||
photoMapper.insert(photoList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
@@ -77,6 +77,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 钱包用户转账模块 1-007-010-000 ==========
|
||||
ErrorCode WALLET_USER_TRANSFER_NOT_FOUND = new ErrorCode(1_007_010_000, "用户转账单不存在");
|
||||
ErrorCode WALLET_USER_TRANSFER_NOT_SELF = new ErrorCode(1_007_010_001, "自己不能给自己送出礼物");
|
||||
|
||||
// ========== 示例订单 1-007-900-000 ==========
|
||||
ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1_007_900_000, "示例订单不存在");
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
public Long sendGift(AppPayWalletGiftSendReqVo dto) {
|
||||
// 自己不能给自己送出礼物
|
||||
if (ObjectUtil.equals(dto.getTargetMemberId(), dto.getOperationMemberId())) {
|
||||
throw new RuntimeException("自己不能给自己送出礼物");
|
||||
throw exception(WALLET_USER_TRANSFER_NOT_SELF);
|
||||
}
|
||||
|
||||
// 查询目标用户钱包
|
||||
|
||||
Reference in new issue
Block a user