master:档口商品新增、编辑调整;

pull/1121/head
liujiang 2025-03-29 00:25:50 +08:00
parent d95c9038fe
commit 75f785e3db
15 changed files with 178 additions and 157 deletions

View File

@ -6,11 +6,16 @@ import com.ruoyi.common.core.controller.XktBaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.BeansUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.xkt.vo.storeProd.*;
import com.ruoyi.web.controller.xkt.vo.storeProd.StoreProdPageVO;
import com.ruoyi.web.controller.xkt.vo.storeProd.StoreProdResVO;
import com.ruoyi.web.controller.xkt.vo.storeProd.StoreProdStatusVO;
import com.ruoyi.web.controller.xkt.vo.storeProd.StoreProdVO;
import com.ruoyi.xkt.domain.StoreProduct;
import com.ruoyi.xkt.dto.storeProduct.*;
import com.ruoyi.xkt.dto.storeProduct.StoreProdDTO;
import com.ruoyi.xkt.dto.storeProduct.StoreProdPageDTO;
import com.ruoyi.xkt.dto.storeProduct.StoreProdPageResDTO;
import com.ruoyi.xkt.dto.storeProduct.StoreProdStatusDTO;
import com.ruoyi.xkt.service.IStoreProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -43,7 +48,7 @@ public class StoreProductController extends XktBaseController {
@GetMapping("/list")
public TableDataInfo list(StoreProdPageVO pageVO) {
startPage();
List<StoreProdPageResDTO> list = storeProductService.selectPage(ObjectUtils.isEmpty(pageVO) ? null : BeansUtils.convertObject(pageVO, StoreProdPageDTO.class));
List<StoreProdPageResDTO> list = storeProductService.selectPage(ObjectUtils.isEmpty(pageVO) ? null : BeanUtil.toBean(pageVO, StoreProdPageDTO.class));
// TODO 处理返回的VO
// TODO 处理返回的VO
// TODO 处理返回的VO
@ -68,7 +73,7 @@ public class StoreProductController extends XktBaseController {
@PreAuthorize("@ss.hasPermi('system:product:query')")
@GetMapping(value = "/{storeProdId}")
public R getInfo(@PathVariable("storeProdId") Long storeProdId) {
return success(BeansUtils.convertObject(storeProductService.selectStoreProductByStoreProdId(storeProdId), StoreProdResVO.class));
return success(BeanUtil.toBean(storeProductService.selectStoreProductByStoreProdId(storeProdId), StoreProdResVO.class));
}
/**
@ -78,7 +83,7 @@ public class StoreProductController extends XktBaseController {
@Log(title = "档口商品", businessType = BusinessType.INSERT)
@ApiOperation(value = "新增档口商品", httpMethod = "POST", response = R.class)
@PostMapping
public R add(@Validated @RequestBody StoreProdVO storeProdVO) {
public R add(@Validated @RequestBody StoreProdVO storeProdVO) {
return success(storeProductService.insertStoreProduct(BeanUtil.toBean(storeProdVO, StoreProdDTO.class)));
}
@ -88,9 +93,9 @@ public class StoreProductController extends XktBaseController {
@PreAuthorize("@ss.hasPermi('system:product:edit')")
@ApiOperation(value = "修改档口商品", httpMethod = "POST", response = R.class)
@Log(title = "档口商品", businessType = BusinessType.UPDATE)
@PutMapping
public R edit(@Validated @RequestBody StoreProdVO storeProdVO) {
return success(storeProductService.updateStoreProduct(BeansUtils.convertObject(storeProdVO, StoreProdDTO.class)));
@PutMapping("/{storeProdId}")
public R edit(@PathVariable Long storeProdId, @Validated @RequestBody StoreProdVO storeProdVO) {
return success(storeProductService.updateStoreProduct(storeProdId, BeanUtil.toBean(storeProdVO, StoreProdDTO.class)));
}
/**
@ -99,11 +104,10 @@ public class StoreProductController extends XktBaseController {
@PreAuthorize("@ss.hasPermi('system:product:edit')")
@Log(title = "档口商品", businessType = BusinessType.UPDATE)
@PutMapping("/prod-status")
public R editProdStatus(@Validated @RequestBody StoreProdStatusVO prodStatusVO) {
storeProductService.updateStoreProductStatus(BeansUtils.convertObject(prodStatusVO, StoreProdStatusDTO.class));
public R editProdStatus(@Validated @RequestBody StoreProdStatusVO prodStatusVO) {
storeProductService.updateStoreProductStatus(BeanUtil.toBean(prodStatusVO, StoreProdStatusDTO.class));
return success();
}
}

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.web.controller.xkt.vo.storePordColor.StoreProdColorVO;
import com.ruoyi.web.controller.xkt.vo.storeProdCateAttr.StoreProdCateAttrVO;
import com.ruoyi.web.controller.xkt.vo.storeProdColorPrice.StoreProdColorPriceVO;
import com.ruoyi.web.controller.xkt.vo.storeProdColorSize.StoreProdColorSizeVO;
import com.ruoyi.web.controller.xkt.vo.storeProdDetail.StoreProdDetailVO;
import com.ruoyi.web.controller.xkt.vo.storeProdSvc.StoreProdSvcVO;
import com.ruoyi.web.controller.xkt.vo.storeProductFile.StoreProdFileVO;
@ -13,6 +14,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
@ -29,20 +31,21 @@ import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreProdVO {
@ApiModelProperty("档口商品名称")
private Long storeProdId;
@ApiModelProperty("档口商品名称")
private String prodName;
@ApiModelProperty(name = "商品分类ID")
@NotNull(message = "商品分类ID不能为空!")
private Long prodCateId;
@ApiModelProperty(name = "工厂货号")
@Size(max = 15, message = "工厂货号不能超过60个字!")
private String factoryArtNum;
@ApiModelProperty(name = "商品货号")
@Size(max = 15, message = "商品货号不能超过60个字!")
@NotBlank(message = "商品货号不能为空!")
private String prodArtNum;
@ApiModelProperty(name = "商品标题")
@Size(max = 60, message = "商品标题不能超过60个字!")
@NotBlank(message = "商品标题不能为空!")
private String prodTitle;
@ApiModelProperty(name = "商品重量")
private BigDecimal prodWeight;
@ -53,7 +56,11 @@ public class StoreProdVO {
@ApiModelProperty(name = "发货时效")
private Integer deliveryTime;
@ApiModelProperty(name = "上架方式")
@NotBlank(message = "上架方式不能为空!")
private String listingWay;
@ApiModelProperty(name = "商品状态")
@NotBlank(message = "商品状态不能为空!")
private String prodStatus;
@ApiModelProperty(name = "定时发货时间(精确到小时)")
@JsonFormat(pattern = "yyyy-MM-dd HH")
private Date listingWaySchedule;
@ -69,6 +76,10 @@ public class StoreProdVO {
@Valid
@ApiModelProperty(name = "档口颜色列表")
private List<StoreProdColorVO> colorList;
@NotNull(message = "档口尺码列表不能为空!")
@Valid
@ApiModelProperty(name = "档口尺码列表")
private List<StoreProdColorSizeVO> sizeList;
@NotNull(message = "档口颜色价格列表不能为空!")
@Valid
@ApiModelProperty(name = "档口颜色价格列表")

View File

@ -0,0 +1,30 @@
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("档口商品当前尺码")
@Data
public class StoreProdColorSizeVO {
@NotNull(message = "档口颜色ID不能为空!")
@ApiModelProperty(name = "档口颜色ID")
private Long storeColorId;
@ApiModelProperty(name = "商品尺码")
@NotNull(message = "档口商品定价不能为空!")
private Integer size;
@NotBlank(message = "是否是标准尺码不能为空!")
@ApiModelProperty(name = "是否是标准尺码")
private String standard;
}

View File

@ -1,72 +0,0 @@
package com.ruoyi.common.utils;
import org.dozer.DozerBeanMapperBuilder;
import org.dozer.Mapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.beans.FeatureDescriptor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
/**
* @author Wenbo Huang
* @version 1.0
* @date 2021/3/31 10:35 AM
*/
public class BeansUtils {
/**
* default MAPPER without config
*/
private static final Mapper MAPPER = DozerBeanMapperBuilder.buildDefault();
/***
* @param listSrc Source object collection
* @param clazz Target object class type
*/
@SuppressWarnings("unchecked")
public static <TContent> List<TContent> convertList(List listSrc,
Class<TContent> clazz) {
List<TContent> listDes = new ArrayList<>();
if (listSrc.isEmpty()) {
return listDes;
}
listSrc.forEach(objSrc -> {
listDes.add(convertObject(objSrc, clazz));
});
return listDes;
}
/**
* Single object conversion
*
* @param content Source object
* @param clazz Target object class type
*/
public static <TContent> TContent convertObject(Object content,
Class<TContent> clazz) {
if (content == null) {
return null;
}
return MAPPER.map(content, clazz);
}
/**
* Exclude NUll value of source target
*
* @param source
* @param target
*/
public static void copyProperties(Object source, Object target) {
BeanWrapper wrappedSource = new BeanWrapperImpl(source);
String[] nullProperties = Stream.of(wrappedSource.getPropertyDescriptors())
.map(FeatureDescriptor::getName)
.filter(propertyName -> wrappedSource.getPropertyValue(propertyName) == null).toArray(String[]::new);
List<String> properties = new ArrayList<>();
properties.addAll(Arrays.asList(nullProperties));
BeanUtils.copyProperties(source, target, properties.toArray(new String[0]));
}
}

View File

@ -64,7 +64,9 @@ public class SysLoginService
public String login(String username, String password, String code, String uuid)
{
// 验证码校验
validateCaptcha(username, code, uuid);
// TODO 测试暂时注释掉
// validateCaptcha(username, code, uuid);
// TODO 测试暂时注释掉
// 登录前置校验
loginPreCheck(username, password);
// 用户验证

View File

@ -5,6 +5,7 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.XktBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -16,6 +17,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class StoreProductColorSize extends XktBaseEntity {
private static final long serialVersionUID = 1L;
@ -26,10 +28,10 @@ public class StoreProductColorSize extends XktBaseEntity {
private Long storeProdColorSizeId;
/**
* ID
* ID
*/
@Excel(name = "档口商品颜色ID")
private Long storeProdColorId;
@Excel(name = "档口颜色ID")
private Long storeColorId;
/**
* ID
@ -55,12 +57,11 @@ public class StoreProductColorSize extends XktBaseEntity {
@Excel(name = "是否是标准尺码", readConverterExp = "0=不是,1=是")
private String standard;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("storeProdColorSizeId", getStoreProdColorSizeId())
.append("storeProdColorId", getStoreProdColorId())
.append("storeColorId", getStoreColorId())
.append("storeProdId", getStoreProdId())
.append("size", getSize())
.append("barcodePrefix", getBarcodePrefix())

View File

@ -12,7 +12,6 @@ import lombok.RequiredArgsConstructor;
*/
@ApiModel("档口商品当前颜色")
@Data
@RequiredArgsConstructor
public class StoreProdColorDTO {
@ApiModelProperty(name = "档口颜色ID")

View File

@ -14,7 +14,6 @@ import java.math.BigDecimal;
*/
@ApiModel("档口商品当前颜色")
@Data
@RequiredArgsConstructor
public class StoreProdColorPriceDTO {
@ApiModelProperty(name = "档口商品颜色ID")

View File

@ -0,0 +1,27 @@
package com.ruoyi.xkt.dto.storeProdColorSize;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("档口商品当前尺码")
@Data
public class StoreProdColorSizeDTO {
@ApiModelProperty(name = "档口颜色ID")
private Long storeColorId;
@ApiModelProperty(name = "商品尺码")
private Integer size;
@ApiModelProperty(name = "是否是标准尺码")
private String standard;
}

View File

@ -1,15 +1,17 @@
package com.ruoyi.xkt.dto.storeProduct;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.xkt.dto.storeProdColor.StoreProdColorDTO;
import com.ruoyi.xkt.dto.storeProdCateAttr.StoreProdCateAttrDTO;
import com.ruoyi.xkt.dto.storeProdColor.StoreProdColorDTO;
import com.ruoyi.xkt.dto.storeProdColorPrice.StoreProdColorPriceDTO;
import com.ruoyi.xkt.dto.storeProdColorSize.StoreProdColorSizeDTO;
import com.ruoyi.xkt.dto.storeProdDetail.StoreProdDetailDTO;
import com.ruoyi.xkt.dto.storeProdSvc.StoreProdSvcDTO;
import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
@ -22,10 +24,9 @@ import java.util.List;
*/
@ApiModel("创建档口商品")
@Data
@Accessors(chain = true)
public class StoreProdDTO {
@ApiModelProperty("档口商品名称")
private Long storeProdId;
@ApiModelProperty("档口商品名称")
private String prodName;
@ApiModelProperty(name = "商品分类ID")
@ -46,6 +47,8 @@ public class StoreProdDTO {
private Integer deliveryTime;
@ApiModelProperty(name = "上架方式")
private String listingWay;
@ApiModelProperty(name = "商品状态")
private String prodStatus;
@ApiModelProperty(name = "定时发货时间(精确到小时)")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date listingWaySchedule;
@ -55,6 +58,8 @@ public class StoreProdDTO {
private List<StoreProdCateAttrDTO> cateAttrList;
@ApiModelProperty(name = "档口颜色列表")
private List<StoreProdColorDTO> colorList;
@ApiModelProperty(name = "档口尺码列表")
private List<StoreProdColorSizeDTO> sizeList;
@ApiModelProperty(name = "档口颜色列表")
private List<StoreProdColorPriceDTO> priceList;
@ApiModelProperty(name = "档口服务承诺")

View File

@ -59,4 +59,7 @@ public interface StoreProductColorSizeMapper extends BaseMapper<StoreProductColo
* @return
*/
public int deleteStoreProductColorSizeByStoreProdColorSizeIds(Long[] storeProdColorSizeIds);
void updateDelFlagByStoreProdId(Long storeProdId);
}

View File

@ -45,7 +45,7 @@ public interface IStoreProductService {
* @param storeProdDTO
* @return
*/
public int updateStoreProduct(StoreProdDTO storeProdDTO);
public int updateStoreProduct(Long storeProdId, StoreProdDTO storeProdDTO);
public void updateStoreProductStatus(StoreProdStatusDTO prodStatusDTO);

View File

@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.BeansUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.xkt.domain.*;
import com.ruoyi.xkt.dto.storeColor.StoreColorDTO;
@ -14,11 +13,12 @@ import com.ruoyi.xkt.dto.storeProdColorPrice.StoreProdColorPriceDTO;
import com.ruoyi.xkt.dto.storeProdDetail.StoreProdDetailDTO;
import com.ruoyi.xkt.dto.storeProdSvc.StoreProdSvcDTO;
import com.ruoyi.xkt.dto.storeProduct.*;
import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileDTO;
import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileResDTO;
import com.ruoyi.xkt.mapper.*;
import com.ruoyi.xkt.service.IStoreProductService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -45,6 +45,7 @@ public class StoreProductServiceImpl implements IStoreProductService {
final StoreProductColorPriceMapper storeProdColorPriceMapper;
final StoreColorMapper storeColorMapper;
final SysFileMapper fileMapper;
final StoreProductColorSizeMapper storeProdColorSizeMapper;
/**
@ -56,29 +57,29 @@ public class StoreProductServiceImpl implements IStoreProductService {
@Override
@Transactional(readOnly = true)
public StoreProdResDTO selectStoreProductByStoreProdId(Long storeProdId) {
StoreProduct storeProd = Optional.ofNullable( storeProdMapper.selectById(storeProdId)).orElseThrow(() -> new ServiceException("档口商品不存在!", HttpStatus.ERROR));
StoreProdResDTO storeProdResDTO = BeansUtils.convertObject(storeProd, StoreProdResDTO.class);
StoreProduct storeProd = Optional.ofNullable(storeProdMapper.selectById(storeProdId)).orElseThrow(() -> new ServiceException("档口商品不存在!", HttpStatus.ERROR));
StoreProdResDTO storeProdResDTO = BeanUtil.toBean(storeProd, StoreProdResDTO.class);
// 档口文件(商品主图、主图视频、下载的商品详情)
List<StoreProdFileResDTO> fileResList = this.storeProdFileMapper.selectListByStoreProdId(storeProdId);
storeProdResDTO.setFileList(CollectionUtils.isEmpty(fileResList) ? new ArrayList<>() : BeansUtils.convertList(fileResList, StoreProdFileResDTO.class));
storeProdResDTO.setFileList(CollectionUtils.isEmpty(fileResList) ? new ArrayList<>() : BeanUtil.copyToList(fileResList, StoreProdFileResDTO.class));
// 档口类目属性列表
List<StoreProdCateAttrDTO> cateAttrList = this.storeProdCateAttrMapper.selectListByStoreProdId(storeProdId);
storeProdResDTO.setCateAttrList(CollectionUtils.isEmpty(cateAttrList) ? new ArrayList<>() : BeansUtils.convertList(cateAttrList, StoreProdCateAttrDTO.class));
storeProdResDTO.setCateAttrList(CollectionUtils.isEmpty(cateAttrList) ? new ArrayList<>() : BeanUtil.copyToList(cateAttrList, StoreProdCateAttrDTO.class));
// 档口所有颜色列表
List<StoreColorDTO> allColorList = this.storeColorMapper.selectListByStoreProdId(storeProdId);
storeProdResDTO.setAllColorList(CollectionUtils.isEmpty(allColorList) ? new ArrayList<>() : BeansUtils.convertList(allColorList, StoreColorDTO.class));
storeProdResDTO.setAllColorList(CollectionUtils.isEmpty(allColorList) ? new ArrayList<>() : BeanUtil.copyToList(allColorList, StoreColorDTO.class));
// 档口当前商品颜色列表
List<StoreProdColorDTO> colorList = this.storeProdColorMapper.selectListByStoreProdId(storeProdId);
storeProdResDTO.setColorList(CollectionUtils.isEmpty(colorList) ? new ArrayList<>() : BeansUtils.convertList(colorList, StoreProdColorDTO.class));
storeProdResDTO.setColorList(CollectionUtils.isEmpty(colorList) ? new ArrayList<>() : BeanUtil.copyToList(colorList, StoreProdColorDTO.class));
// 档口颜色价格列表
List<StoreProdColorPriceDTO> priceList = this.storeProdColorPriceMapper.selectListByStoreProdId(storeProdId);
storeProdResDTO.setPriceList(CollectionUtils.isEmpty(priceList) ? new ArrayList<>() : BeansUtils.convertList(priceList, StoreProdColorPriceDTO.class));
storeProdResDTO.setPriceList(CollectionUtils.isEmpty(priceList) ? new ArrayList<>() : BeanUtil.copyToList(priceList, StoreProdColorPriceDTO.class));
// 档口详情
StoreProductDetail prodDetail = this.storeProdDetailMapper.selectByStoreProdId(storeProdId);
storeProdResDTO.setDetail(ObjectUtils.isEmpty(prodDetail) ? null : BeansUtils.convertObject(prodDetail, StoreProdDetailDTO.class));
storeProdResDTO.setDetail(ObjectUtils.isEmpty(prodDetail) ? null : BeanUtil.toBean(prodDetail, StoreProdDetailDTO.class));
// 档口服务承诺
StoreProductService storeProductSvc = this.storeProdSvcMapper.selectByStoreProdId(storeProdId);
storeProdResDTO.setSvc(ObjectUtils.isEmpty(storeProductSvc) ? null : BeansUtils.convertObject(storeProductSvc, StoreProdSvcDTO.class));
storeProdResDTO.setSvc(ObjectUtils.isEmpty(storeProductSvc) ? null : BeanUtil.toBean(storeProductSvc, StoreProdSvcDTO.class));
return storeProdResDTO;
}
@ -93,60 +94,59 @@ public class StoreProductServiceImpl implements IStoreProductService {
return storeProdMapper.selectStoreProductList(storeProduct);
}
/**
* DTO
*
* @param pageDTO DTO
* @return DTO
*/
@Override
public List<StoreProdPageResDTO> selectPage(StoreProdPageDTO pageDTO) {
// 调用Mapper方法查询商店产品分页信息
List<StoreProdPageResDTO> page = storeProdMapper.selectStoreProdPage(pageDTO);
// 如果查询结果为空,则直接返回空列表
if (CollectionUtils.isEmpty(page)) {
return new ArrayList<>();
/**
* DTO
*
* @param pageDTO DTO
* @return DTO
*/
@Override
public List<StoreProdPageResDTO> selectPage(StoreProdPageDTO pageDTO) {
// 调用Mapper方法查询商店产品分页信息
List<StoreProdPageResDTO> page = storeProdMapper.selectStoreProdPage(pageDTO);
// 如果查询结果为空,则直接返回空列表
if (CollectionUtils.isEmpty(page)) {
return new ArrayList<>();
}
// 提取查询结果中的商店产品ID列表
List<Long> storeProdIdList = page.stream().map(StoreProdPageResDTO::getStoreProdId).collect(Collectors.toList());
// 查找排名第一个商品主图列表
Map<Long, String> mainPicMap = this.storeProdFileMapper.selectMainPicByStoreProdIdList(storeProdIdList, "MAIN_PIC", 1);
// 查找档口商品的标准尺码
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<StoreProductColorSize>().in(StoreProductColorSize::getStoreProdId, storeProdIdList)
.eq(StoreProductColorSize::getDelFlag, "0").eq(StoreProductColorSize::getStandard, "1");
List<StoreProductColorSize> standardSizeList = this.storeProdColorPriceMapper.selectList(queryWrapper);
// 将标准尺码列表转换为映射,以便后续处理
Map<Long, List<Integer>> standardSizeMap = CollectionUtils.isEmpty(standardSizeList) ? new HashMap<>() : standardSizeList.stream().collect(Collectors
.groupingBy(StoreProductColorSize::getStoreProdId, Collectors.mapping(StoreProductColorSize::getSize, Collectors.toList())));
// 为每个产品设置主图URL和标准尺码列表
page.forEach(x -> x.setMainPicUrl(mainPicMap.get(x.getStoreProdId())).setStandardSizeList(standardSizeMap.get(x.getStoreProdId())));
// 打印查询结果
System.err.println(page);
return page;
}
// 提取查询结果中的商店产品ID列表
List<Long> storeProdIdList = page.stream().map(StoreProdPageResDTO::getStoreProdId).collect(Collectors.toList());
// 查找排名第一个商品主图列表
Map<Long, String> mainPicMap = this.storeProdFileMapper.selectMainPicByStoreProdIdList(storeProdIdList, "MAIN_PIC", 1);
// 查找档口商品的标准尺码
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<StoreProductColorSize>().in(StoreProductColorSize::getStoreProdId, storeProdIdList)
.eq(StoreProductColorSize::getDelFlag, "0").eq(StoreProductColorSize::getStandard, "1");
List<StoreProductColorSize> standardSizeList = this.storeProdColorPriceMapper.selectList(queryWrapper);
// 将标准尺码列表转换为映射,以便后续处理
Map<Long, List<Integer>> standardSizeMap = CollectionUtils.isEmpty(standardSizeList) ? new HashMap<>() : standardSizeList.stream().collect(Collectors
.groupingBy(StoreProductColorSize::getStoreProdId, Collectors.mapping(StoreProductColorSize::getSize, Collectors.toList())));
// 为每个产品设置主图URL和标准尺码列表
page.forEach(x -> x.setMainPicUrl(mainPicMap.get(x.getStoreProdId())).setStandardSizeList(standardSizeMap.get(x.getStoreProdId())));
// 打印查询结果
System.err.println(page);
return page;
}
@Override
@Transactional
public int insertStoreProduct(StoreProdDTO storeProdDTO) {
// 组装StoreProduct数据
StoreProduct storeProd = BeanUtil.toBean(storeProdDTO, StoreProduct.class)
.setProdStatus("ON_SALE").setVoucherDate(DateUtils.getNowDate());
StoreProduct storeProd = BeanUtil.toBean(storeProdDTO, StoreProduct.class).setVoucherDate(DateUtils.getNowDate());
int count = this.storeProdMapper.insert(storeProd);
// 上传的文件列表
final List<StoreProdFileDTO> fileDTOList = storeProdDTO.getFileList();
// 将文件插入到SysFile表中
List<SysFile> fileList = BeanUtil.copyToList(storeProdDTO.getFileList(), SysFile.class);
List<SysFile> fileList = BeanUtil.copyToList(fileDTOList, SysFile.class);
this.fileMapper.insert(fileList);
// 将文件名称和文件ID映射到Map中
Map<String, Long> fileMap = fileList.stream().collect(Collectors.toMap(SysFile::getFileName, SysFile::getFileId));
// 档口文件(商品主图、主图视频、下载的商品详情)
List<StoreProductFile> prodFileList = fileList.stream()
List<StoreProductFile> prodFileList = fileDTOList.stream()
.map(x -> BeanUtil.toBean(x, StoreProductFile.class).setFileId(fileMap.get(x.getFileName()))
.setStoreProdId(storeProd.getStoreProdId()))
.collect(Collectors.toList());
this.storeProdFileMapper.insert(prodFileList);
// 档口类目属性列表
List<StoreProductCategoryAttribute> cateAttrList = storeProdDTO.getCateAttrList().stream()
List<StoreProductCategoryAttribute> cateAttrList = storeProdDTO.getCateAttrList().stream()
.map(x -> BeanUtil.toBean(x, StoreProductCategoryAttribute.class)
.setStoreProdId(storeProd.getStoreProdId()))
.collect(Collectors.toList());
@ -157,6 +157,12 @@ public List<StoreProdPageResDTO> selectPage(StoreProdPageDTO pageDTO) {
.setStoreProdId(storeProd.getStoreProdId()))
.collect(Collectors.toList());
this.storeProdColorMapper.insert(colorList);
// 档口颜色尺码列表
List<StoreProductColorSize> sizeList = storeProdDTO.getSizeList().stream()
.map(x -> BeanUtil.toBean(x, StoreProductColorSize.class)
.setStoreProdId(storeProd.getStoreProdId()))
.collect(Collectors.toList());
this.storeProdColorSizeMapper.insert(sizeList);
// 档口颜色价格列表
List<StoreProductColorPrice> priceList = storeProdDTO.getPriceList().stream()
.map(x -> BeanUtil.toBean(x, StoreProductColorPrice.class)
@ -183,25 +189,27 @@ public List<StoreProdPageResDTO> selectPage(StoreProdPageDTO pageDTO) {
*/
@Override
@Transactional
public int updateStoreProduct(StoreProdDTO storeProdDTO) {
StoreProduct storeProd = Optional.ofNullable(this.storeProdMapper.selectById(storeProdDTO.getStoreProdId()))
public int updateStoreProduct(final Long storeProdId, StoreProdDTO storeProdDTO) {
StoreProduct storeProd = Optional.ofNullable(this.storeProdMapper.selectOne(new LambdaQueryWrapper<StoreProduct>()
.eq(StoreProduct::getStoreProdId, storeProdId).eq(StoreProduct::getDelFlag, "0")))
.orElseThrow(() -> new ServiceException("档口商品不存在!", HttpStatus.ERROR));
// 将档口商品的del_flag置为2
storeProd.setDelFlag("2");
storeProd.setUpdateTime(DateUtils.getNowDate());
this.storeProdMapper.updateById(storeProd);
// 档口文件商品主图、主图视频、下载的商品详情的del_flag置为2
this.storeProdFileMapper.updateDelFlagByStoreProdId(storeProdDTO.getStoreProdId());
this.storeProdFileMapper.updateDelFlagByStoreProdId(storeProdId);
// 档口类目属性列表的 del_flag置为2
this.storeProdCateAttrMapper.updateDelFlagByStoreProdId(storeProdDTO.getStoreProdId());
this.storeProdCateAttrMapper.updateDelFlagByStoreProdId(storeProdId);
// 档口颜色列表的del_flag置为2
this.storeProdColorMapper.updateDelFlagByStoreProdId(storeProdDTO.getStoreProdId());
this.storeProdColorMapper.updateDelFlagByStoreProdId(storeProdId);
// 档口颜色尺码列表的del_flag置为2
this.storeProdColorSizeMapper.updateDelFlagByStoreProdId(storeProdId);
// 档口颜色价格列表的del_flag置为2
this.storeProdColorPriceMapper.updateDelFlagByStoreProdId(storeProdDTO.getStoreProdId());
this.storeProdColorPriceMapper.updateDelFlagByStoreProdId(storeProdId);
// 档口详情内容的del_flag置为2
this.storeProdDetailMapper.updateDelFlagByStoreProdId(storeProdDTO.getStoreProdId());
this.storeProdDetailMapper.updateDelFlagByStoreProdId(storeProdId);
// 档口服务承诺的del_flag置为2
this.storeProdSvcMapper.updateDelFlagByStoreProdId(storeProdDTO.getStoreProdId());
this.storeProdSvcMapper.updateDelFlagByStoreProdId(storeProdId);
// 重新执行插入数据操作
return this.insertStoreProduct(storeProdDTO);
}

View File

@ -98,4 +98,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{storeProdColorSizeId}
</foreach>
</delete>
<update id="updateDelFlagByStoreProdId" parameterType="Long">
UPDATE store_product_color_size SET del_flag = 2 WHERE store_prod_id = #{storeProdId}
</update>
</mapper>

View File

@ -100,10 +100,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<update id="updateDelFlagByStoreProdId" parameterType="Long">
UPDATE store_product_detail SET del_flag = 2 WHERE store_prod_id = #{storeProdId}
UPDATE store_product_service SET del_flag = 2 WHERE store_prod_id = #{storeProdId}
</update>
<select id="selectByStoreProdId" parameterType="Long" resultMap="StoreProductServiceResult">
SELECT
custom_refund,