master:档口商品更改状态,删除调整;
parent
951493d21a
commit
4832edbfd3
|
|
@ -113,21 +113,13 @@ public class StoreProductController extends XktBaseController {
|
|||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
|
||||
@Log(title = "修改档口商品状态", businessType = BusinessType.UPDATE)
|
||||
@ApiOperation(value = "修改档口商品状态", httpMethod = "PUT", response = R.class)
|
||||
@Log(title = "商品上架、下架、设为尾货、删除", businessType = BusinessType.UPDATE)
|
||||
@ApiOperation(value = "商品上架、下架、设为尾货、删除", httpMethod = "PUT", response = R.class)
|
||||
@PutMapping("/prod-status")
|
||||
public R<Integer> editProdStatus(@Validated @RequestBody StoreProdStatusVO prodStatusVO) throws IOException {
|
||||
return R.ok(storeProdService.updateStoreProductStatus(BeanUtil.toBean(prodStatusVO, StoreProdStatusDTO.class)));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
|
||||
@Log(title = "删除商品", businessType = BusinessType.DELETE)
|
||||
@ApiOperation(value = "删除商品", httpMethod = "DELETE", response = R.class)
|
||||
@DeleteMapping()
|
||||
public R<Integer> batchDelete(@Validated @RequestBody StoreProdDeleteVO deleteVO) throws IOException {
|
||||
return R.ok(storeProdService.batchDelete(BeanUtil.toBean(deleteVO, StoreProdDeleteDTO.class)));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
|
||||
@ApiOperation(value = "获取档口图片空间", httpMethod = "POST", response = R.class)
|
||||
@PostMapping(value = "/pic-space")
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProd;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口商品删除")
|
||||
@Data
|
||||
public class StoreProdDeleteVO {
|
||||
|
||||
@NotNull(message = "档口ID不能为空!")
|
||||
@ApiModelProperty(value = "档口ID", required = true)
|
||||
private Long storeId;
|
||||
@NotNull(message = "档口商品ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品ID", required = true)
|
||||
private List<Long> storeProdIdList;
|
||||
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ public class StoreProdStatusVO {
|
|||
@NotNull(message = "档口ID不能为空!")
|
||||
@ApiModelProperty(value = "档口ID", required = true)
|
||||
private Long storeId;
|
||||
@NotNull(message = "档口商品ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品ID", required = true)
|
||||
private List<Long> storeProdIdList;
|
||||
@NotNull(message = "档口商品颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品颜色ID", required = true)
|
||||
private List<Long> storeProdColorIdList;
|
||||
@NotNull(message = "档口商品状态不能为空!")
|
||||
@ApiModelProperty(value = "档口商品状态", required = true)
|
||||
private Integer prodStatus;
|
||||
|
|
|
|||
|
|
@ -3520,6 +3520,7 @@ CREATE TABLE `store_product_color`
|
|||
`store_id` bigint UNSIGNED NOT NULL COMMENT '档口ID',
|
||||
`color_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '颜色名称',
|
||||
`order_num` int UNSIGNED NOT NULL COMMENT '排序',
|
||||
`prod_status` tinyint UNSIGNED NULL DEFAULT NULL COMMENT '档口商品状态',
|
||||
`version` bigint UNSIGNED NOT NULL COMMENT '版本号',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '删除标志(0代表存在 2代表删除)',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
package com.ruoyi.xkt.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 档口当前商品颜色对象 store_product_color
|
||||
|
|
@ -30,47 +27,31 @@ public class StoreProductColor extends XktBaseEntity {
|
|||
/**
|
||||
* 档口颜色ID
|
||||
*/
|
||||
@Excel(name = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
|
||||
/**
|
||||
* 档口商品ID
|
||||
*/
|
||||
@Excel(name = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
|
||||
/**
|
||||
* 档口ID
|
||||
*/
|
||||
@Excel(name = "档口ID")
|
||||
private Long storeId;
|
||||
|
||||
/**
|
||||
* 颜色名称
|
||||
*/
|
||||
@Excel(name = "颜色名称")
|
||||
private String colorName;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Excel(name = "排序")
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* 商品状态 2:在售 3:尾货 4:已下架
|
||||
*/
|
||||
private Integer prodStatus;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("storeColorId", getStoreColorId())
|
||||
.append("storeProdId", getStoreProdId())
|
||||
.append("colorName", getColorName())
|
||||
.append("version", getVersion())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
package com.ruoyi.xkt.dto.storeProduct;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口商品删除")
|
||||
@Data
|
||||
public class StoreProdDeleteDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口ID", required = true)
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口商品ID", required = true)
|
||||
private List<Long> storeProdIdList;
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -17,9 +18,9 @@ public class StoreProdStatusDTO {
|
|||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty("档口商品名称")
|
||||
private List<Long> storeProdIdList;
|
||||
@ApiModelProperty("档口商品状态")
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private List<Long> storeProdColorIdList;
|
||||
@ApiModelProperty(value = "档口商品状态")
|
||||
private Integer prodStatus;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ public enum EProductStatus {
|
|||
ON_SALE(2, "在售"),
|
||||
TAIL_GOODS(3, "尾货"),
|
||||
OFF_SALE(4, "已下架"),
|
||||
REMOVED(5, "已删除");
|
||||
REMOVED(5, "已删除"),
|
||||
|
||||
;
|
||||
|
||||
private final Integer value;
|
||||
private final String label;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ import java.util.List;
|
|||
*/
|
||||
public interface StoreProductColorMapper extends BaseMapper<StoreProductColor> {
|
||||
|
||||
/**
|
||||
* 将商品颜色置为无效
|
||||
* @param storeProdId 档口商品ID
|
||||
*/
|
||||
void updateDelFlagByStoreProdId(Long storeProdId);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ import java.util.List;
|
|||
public interface StoreProductColorPriceMapper extends BaseMapper<StoreProductColorPrice> {
|
||||
|
||||
|
||||
/**
|
||||
* 商品列表编辑商品时 获取颜色列表
|
||||
* @param storeProdId 档口商品ID
|
||||
* @return List<StoreProdColorPriceSimpleDTO>
|
||||
*/
|
||||
List<StoreProdColorPriceSimpleDTO> selectListByStoreProdId(Long storeProdId);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public interface IStoreProductService {
|
|||
int update(Long storeProdId, StoreProdDTO storeProdDTO) throws IOException;
|
||||
|
||||
/**
|
||||
* 更新档口商品状态
|
||||
* 更新档口商品状态 更新档口商品颜色的状态 2在售 3尾货 4下架
|
||||
*
|
||||
* @param prodStatusDTO 更新状态入参
|
||||
*/
|
||||
|
|
@ -142,14 +142,6 @@ public interface IStoreProductService {
|
|||
*/
|
||||
List<StoreProdStatusCateCountResDTO> getStatusCateNum(StoreProdStatusCateNumDTO dto);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
* @param deleteDTO 删除商品入参
|
||||
* @return Integer
|
||||
*/
|
||||
Integer batchDelete(StoreProdDeleteDTO deleteDTO) throws IOException;
|
||||
|
||||
/**
|
||||
* 推广营销查询最近30天上新商品
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|||
import com.ruoyi.xkt.domain.*;
|
||||
import com.ruoyi.xkt.dto.storeProductFile.StoreProdMainPicDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.*;
|
||||
import com.ruoyi.xkt.enums.EProductStatus;
|
||||
import com.ruoyi.xkt.enums.FileType;
|
||||
import com.ruoyi.xkt.enums.ProductSizeStatus;
|
||||
import com.ruoyi.xkt.mapper.*;
|
||||
|
|
@ -170,7 +171,8 @@ public class ShoppingCartServiceImpl implements IShoppingCartService {
|
|||
.groupingBy(x -> x.getStoreProdId().toString() + x.getStoreColorId().toString()));
|
||||
// 获取商品颜色列表
|
||||
List<StoreProductColor> colorList = this.prodColorMapper.selectList(new LambdaQueryWrapper<StoreProductColor>()
|
||||
.eq(StoreProductColor::getStoreProdId, shoppingCart.getStoreProdId()).eq(StoreProductColor::getDelFlag, Constants.UNDELETED));
|
||||
.eq(StoreProductColor::getStoreProdId, shoppingCart.getStoreProdId()).eq(StoreProductColor::getDelFlag, Constants.UNDELETED)
|
||||
.in(StoreProductColor::getProdStatus, Arrays.asList(EProductStatus.ON_SALE.getValue(), EProductStatus.TAIL_GOODS.getValue())));
|
||||
// 档口商品颜色价格列表
|
||||
List<StoreProductColorPrice> colorPriceList = this.prodColorPriceMapper.selectList(new LambdaQueryWrapper<StoreProductColorPrice>()
|
||||
.eq(StoreProductColorPrice::getStoreProdId, shoppingCart.getStoreProdId()).eq(StoreProductColorPrice::getDelFlag, Constants.UNDELETED));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -45,7 +44,6 @@ public class StoreHomepageServiceImpl implements IStoreHomepageService {
|
|||
final StoreMapper storeMapper;
|
||||
final StoreProductMapper storeProdMapper;
|
||||
final StoreProductDetailMapper prodDetailMapper;
|
||||
final StoreProductColorMapper prodColorMapper;
|
||||
final StoreProductColorSizeMapper prodColorSizeMapper;
|
||||
final StoreProductStockMapper prodStockMapper;
|
||||
final StoreProductColorPriceMapper prodColorPriceMapper;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import com.ruoyi.xkt.service.IStoreProductService;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -407,7 +408,7 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
newColorPriceList.forEach(newColorPrice -> {
|
||||
Long storeColorId = storeColorMap.get(newColorPrice.getColorName());
|
||||
tempColorList.add(new StoreProductColor().setStoreProdId(storeProdId).setStoreColorId(storeColorMap.get(newColorPrice.getColorName()))
|
||||
.setColorName(newColorPrice.getColorName()).setOrderNum(newColorPrice.getOrderNum()).setStoreId(storeId));
|
||||
.setColorName(newColorPrice.getColorName()).setOrderNum(newColorPrice.getOrderNum()).setStoreId(storeId).setProdStatus(EProductStatus.ON_SALE.getValue()));
|
||||
storeColorPriceList.add(new StoreProductColorPrice().setStoreColorId(storeColorId).setPrice(newColorPrice.getPrice()).setStoreProdId(storeProdId));
|
||||
updateDTO.getSizeList().forEach(size -> storeColorSizeList.add(new StoreProductColorSize().setStoreColorId(storeColorId).setSize(size.getSize())
|
||||
.setStoreProdId(storeProdId).setStandard(size.getStandard()).setNextSn(0)));
|
||||
|
|
@ -480,7 +481,7 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
List<StoreProductColor> prodColorList = new ArrayList<>();
|
||||
createDTO.getColorPriceList().forEach(colorPrice -> {
|
||||
prodColorList.add(new StoreProductColor().setStoreProdId(storeProdId).setStoreColorId(storeColorMap.get(colorPrice.getColorName()))
|
||||
.setColorName(colorPrice.getColorName()).setOrderNum(colorPrice.getOrderNum()).setStoreId(storeId));
|
||||
.setColorName(colorPrice.getColorName()).setOrderNum(colorPrice.getOrderNum()).setStoreId(storeId).setProdStatus(EProductStatus.ON_SALE.getValue()));
|
||||
prodColorPriceList.add(new StoreProductColorPrice().setStoreProdId(storeProdId).setPrice(colorPrice.getPrice())
|
||||
.setStoreColorId(storeColorMap.get(colorPrice.getColorName())));
|
||||
prodColorSizeList.addAll(createDTO.getSizeList().stream().map(x -> new StoreProductColorSize().setSize(x.getSize()).setStoreProdId(storeProdId)
|
||||
|
|
@ -498,7 +499,7 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 更新档口商品的状态
|
||||
* 更新档口商品颜色的状态 2在售 3尾货 4下架
|
||||
*
|
||||
* @param prodStatusDTO 入参
|
||||
*/
|
||||
|
|
@ -511,45 +512,78 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
}
|
||||
// 判断商品状态是否不存在
|
||||
EProductStatus.of(prodStatusDTO.getProdStatus());
|
||||
// 根据商品ID列表查询数据库中的商品信息
|
||||
List<StoreProduct> storeProdList = Optional.ofNullable(this.storeProdMapper.selectList(new LambdaQueryWrapper<StoreProduct>()
|
||||
.in(StoreProduct::getId, prodStatusDTO.getStoreProdIdList()).eq(StoreProduct::getDelFlag, Constants.UNDELETED)))
|
||||
.orElseThrow(() -> new ServiceException("商品不存在!", HttpStatus.ERROR));
|
||||
storeProdList.forEach(x -> x.setProdStatus(prodStatusDTO.getProdStatus()));
|
||||
int count = this.storeProdMapper.updateById(storeProdList).size();
|
||||
// 更新ES中商品状态
|
||||
this.updateESProdStatus(prodStatusDTO);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
* @param deleteDTO 删除商品入参
|
||||
* @return Integer
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer batchDelete(StoreProdDeleteDTO deleteDTO) throws IOException {
|
||||
// 用户是否为档口管理者或子账户
|
||||
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(deleteDTO.getStoreId())) {
|
||||
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
|
||||
// 查询所有的商品颜色
|
||||
List<StoreProductColor> storeProdColorList = this.storeProdColorMapper.selectList(new LambdaQueryWrapper<StoreProductColor>()
|
||||
.in(StoreProductColor::getId, prodStatusDTO.getStoreProdColorIdList()).eq(StoreProductColor::getDelFlag, Constants.UNDELETED)
|
||||
.eq(StoreProductColor::getStoreId, prodStatusDTO.getStoreId()));
|
||||
if (CollectionUtils.isEmpty(storeProdColorList)) {
|
||||
throw new ServiceException("商品颜色不存在!", HttpStatus.ERROR);
|
||||
}
|
||||
storeProdColorList.forEach(x -> {
|
||||
x.setProdStatus(prodStatusDTO.getProdStatus());
|
||||
// 删除颜色
|
||||
if (Objects.equals(prodStatusDTO.getProdStatus(), EProductStatus.REMOVED.getValue())) {
|
||||
x.setDelFlag(DELETED);
|
||||
}
|
||||
});
|
||||
int count = this.storeProdColorMapper.updateById(storeProdColorList).size();
|
||||
final List<Long> storeProdIdList = storeProdColorList.stream().map(StoreProductColor::getStoreProdId).collect(Collectors.toList());
|
||||
List<StoreProduct> storeProdList = this.storeProdMapper.selectList(new LambdaQueryWrapper<StoreProduct>()
|
||||
.eq(StoreProduct::getDelFlag, Constants.UNDELETED).eq(StoreProduct::getStoreId, deleteDTO.getStoreId())
|
||||
.in(StoreProduct::getId, deleteDTO.getStoreProdIdList()));
|
||||
if (CollectionUtils.isEmpty(storeProdList)) {
|
||||
return 0;
|
||||
.in(StoreProduct::getId, storeProdIdList).eq(StoreProduct::getDelFlag, Constants.UNDELETED)
|
||||
.eq(StoreProduct::getStoreId, prodStatusDTO.getStoreId()));
|
||||
Map<Long, StoreProduct> storeProdMap = storeProdList.stream().collect(Collectors.toMap(StoreProduct::getId, Function.identity()));
|
||||
// 旧的商品状态map
|
||||
final Map<Long, Integer> storeProdStatusMap = storeProdList.stream().collect(Collectors.toMap(StoreProduct::getId, StoreProduct::getProdStatus));
|
||||
// 筛选所有的商品,判断商品的状态
|
||||
List<StoreProductColor> curProdColorList = this.storeProdColorMapper.selectList(new LambdaQueryWrapper<StoreProductColor>()
|
||||
.in(StoreProductColor::getStoreProdId, storeProdIdList).eq(StoreProductColor::getDelFlag, Constants.UNDELETED)
|
||||
.eq(StoreProductColor::getStoreId, prodStatusDTO.getStoreId()));
|
||||
Map<Long, List<StoreProductColor>> prodColorMap = curProdColorList.stream().collect(Collectors.groupingBy(StoreProductColor::getStoreProdId));
|
||||
List<StoreProduct> updateProdList = new ArrayList<>();
|
||||
prodColorMap.forEach((storeProdId, prodColorList) -> {
|
||||
StoreProduct storeProduct = Optional.ofNullable(storeProdMap.get(storeProdId)).orElseThrow(() -> new ServiceException("商品不存在!", HttpStatus.ERROR));
|
||||
// 商品颜色中只要有一个为在售,则商品状态为在售
|
||||
if (prodColorList.stream().anyMatch(x -> Objects.equals(x.getProdStatus(), EProductStatus.ON_SALE.getValue()))) {
|
||||
storeProduct.setProdStatus(EProductStatus.ON_SALE.getValue());
|
||||
// 商品颜色中只要有一个为尾货,则商品状态为尾货
|
||||
} else if (prodColorList.stream().anyMatch(x -> Objects.equals(x.getProdStatus(), EProductStatus.TAIL_GOODS.getValue()))) {
|
||||
storeProduct.setProdStatus(EProductStatus.TAIL_GOODS.getValue());
|
||||
// 商品颜色只有一个为下架,则商品状态为下架
|
||||
} else if (prodColorList.stream().anyMatch(x -> Objects.equals(x.getProdStatus(), EProductStatus.OFF_SALE.getValue()))) {
|
||||
storeProduct.setProdStatus(EProductStatus.OFF_SALE.getValue());
|
||||
// 商品颜色必须全部为已删除,则商品状态为已删除
|
||||
} else {
|
||||
storeProduct.setDelFlag(DELETED);
|
||||
storeProduct.setProdStatus(EProductStatus.REMOVED.getValue());
|
||||
}
|
||||
updateProdList.add(storeProduct);
|
||||
});
|
||||
this.storeProdMapper.updateById(updateProdList);
|
||||
// 非删除商品颜色,则更新ES
|
||||
if (!Objects.equals(prodStatusDTO.getProdStatus(), EProductStatus.REMOVED.getValue())) {
|
||||
// 需要更新状态的商品
|
||||
Map<Long, Integer> updateESProdStatusMap = updateProdList.stream().filter(x -> !Objects.equals(storeProdStatusMap.get(x.getId()), x.getProdStatus()))
|
||||
.collect(Collectors.toMap(StoreProduct::getId, StoreProduct::getProdStatus));
|
||||
// 没有需要更新商品状态的商品
|
||||
if (MapUtils.isEmpty(updateESProdStatusMap)) {
|
||||
return count;
|
||||
}
|
||||
// 更新ES中商品状态
|
||||
this.updateESProdStatus(updateESProdStatusMap);
|
||||
} else {
|
||||
// 需要删除的商品
|
||||
List<StoreProduct> deleteESProdList = updateProdList.stream().filter(x -> !Objects.equals(storeProdStatusMap.get(x.getId()), x.getProdStatus())).collect(Collectors.toList());
|
||||
List<Long> updateESProdIdList = deleteESProdList.stream().map(StoreProduct::getId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(updateESProdIdList)) {
|
||||
return count;
|
||||
}
|
||||
// 删除ES中商品
|
||||
this.deleteESDoc(updateESProdIdList);
|
||||
// 搜图服务同步
|
||||
updateESProdIdList.forEach(spId -> sync2ImgSearchServer(spId, ListUtil.empty()));
|
||||
// 新增消息通知
|
||||
this.offSaleOrReSaleProd(deleteESProdList, Boolean.TRUE, prodStatusDTO.getStoreId());
|
||||
}
|
||||
storeProdList.forEach(x -> x.setDelFlag(Constants.DELETED));
|
||||
int count = this.storeProdMapper.updateById(storeProdList).size();
|
||||
// 删除ES中商品
|
||||
this.deleteESDoc(deleteDTO.getStoreProdIdList());
|
||||
// 搜图服务同步
|
||||
deleteDTO.getStoreProdIdList().forEach(spId -> sync2ImgSearchServer(spId, ListUtil.empty()));
|
||||
// 新增消息通知
|
||||
this.offSaleOrReSaleProd(storeProdList, Boolean.TRUE, deleteDTO.getStoreId());
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
@ -1284,17 +1318,17 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param statusDTO 商品状态更新DTO
|
||||
* @param updateProdStatusMap 商品状态更新map
|
||||
* @throws IOException
|
||||
*/
|
||||
private void updateESProdStatus(StoreProdStatusDTO statusDTO) throws IOException {
|
||||
private void updateESProdStatus(Map<Long, Integer> updateProdStatusMap) throws IOException {
|
||||
// 构建一个批量数据集合
|
||||
List<BulkOperation> list = new ArrayList<>();
|
||||
statusDTO.getStoreProdIdList().forEach(storeProdId -> {
|
||||
updateProdStatusMap.forEach((storeProdId, prodStatus) -> {
|
||||
// 构建部分文档更新请求
|
||||
list.add(new BulkOperation.Builder().update(u -> u
|
||||
.action(a -> a.doc(new HashMap<String, Object>() {{
|
||||
put("prodStatus", statusDTO.getProdStatus());
|
||||
put("prodStatus", prodStatus);
|
||||
}}))
|
||||
.id(String.valueOf(storeProdId))
|
||||
.index(Constants.ES_IDX_PRODUCT_INFO))
|
||||
|
|
@ -1306,13 +1340,14 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
log.info("bulkResponse.result() = {}", bulkResponse.items());
|
||||
} catch (IOException | RuntimeException e) {
|
||||
// 记录日志并抛出或处理异常
|
||||
log.error("向ES更新商品状态失败,商品ID: {}, 错误信息: {}", statusDTO.getStoreProdIdList(), e.getMessage());
|
||||
log.error("向ES更新商品状态失败,商品ID: {}, 错误信息: {}", updateProdStatusMap.keySet(), e.getMessage());
|
||||
throw e; // 或者做其他补偿处理,比如异步重试
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装前端返回的map
|
||||
*
|
||||
* @param cateAttr 数据库类目属性
|
||||
* @return Map
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ public class UserFavoritesServiceImpl implements IUserFavoritesService {
|
|||
// 找到当前商品的颜色
|
||||
List<StoreProductColor> prodColorList = this.prodColorMapper.selectList(new LambdaQueryWrapper<StoreProductColor>()
|
||||
.in(StoreProductColor::getStoreProdId, notAddList.stream().map(UserFavBatchAddToShopCartDTO.BatchDTO::getStoreProdId).collect(Collectors.toList()))
|
||||
.in(StoreProductColor::getProdStatus, Arrays.asList(EProductStatus.ON_SALE.getValue(), EProductStatus.TAIL_GOODS.getValue()))
|
||||
.eq(StoreProductColor::getDelFlag, Constants.UNDELETED));
|
||||
// 按照storeProdId分组,若商品有多个颜色则任取其一
|
||||
Map<Long, StoreProductColor> prodColorMap = prodColorList.stream().collect(Collectors.toMap(StoreProductColor::getStoreProdId, Function.identity(), (x, y) -> x));
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND spf.file_type = 1 AND spf.order_num = 1 AND spf.del_flag = 0
|
||||
JOIN sys_file sf ON spf.file_id = sf.id
|
||||
WHERE
|
||||
spc.del_flag = 0 AND spc.store_id = #{storeId} AND sp.prod_status = #{prodStatus}
|
||||
spc.del_flag = 0 AND spc.prod_status = #{prodStatus} AND spc.store_id = #{storeId}
|
||||
<if test="prodArtNum != null and prodArtNum != ''"> and sp.prod_art_num like concat('%', #{prodArtNum}, '%')</if>
|
||||
<if test="prodCateId != null "> and sp.prod_cate_id = #{prodCateId}</if>
|
||||
ORDER BY
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
FROM
|
||||
store_product_color spc
|
||||
JOIN store_product sp ON spc.store_prod_id = sp.id
|
||||
JOIN store_product_color_price spcp ON spc.store_prod_id = spcp.store_prod_id
|
||||
AND spc.store_color_id = spcp.store_color_id
|
||||
JOIN store_product_color_price spcp ON spc.store_prod_id = spcp.store_prod_id AND spc.store_color_id = spcp.store_color_id
|
||||
WHERE
|
||||
spc.store_prod_id = #{storeProdId}
|
||||
AND spc.store_id = #{storeId}
|
||||
AND spc.prod_status IN ( 2, 3 )
|
||||
AND spc.store_prod_id = #{storeProdId}
|
||||
AND spc.store_id = #{storeId}
|
||||
</select>
|
||||
|
||||
<select id="selectStoreProdMinPriceList" resultType="com.ruoyi.xkt.dto.storeProdColorPrice.StoreProdMinPriceDTO">
|
||||
|
|
@ -39,7 +39,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
spcp.store_prod_id,
|
||||
MIN( spcp.price )
|
||||
FROM
|
||||
store_product_color_price spcp
|
||||
store_product_color_price spcp JOIN store_product_color spc ON spcp.store_prod_id = spc.store_prod_id
|
||||
AND spcp.store_color_id = spc.store_color_id AND spc.prod_status IN ( 2, 3 )
|
||||
WHERE
|
||||
spcp.del_flag = 0
|
||||
<if test="storeProdIdList != null and storeProdIdList.size() > 0">
|
||||
|
|
@ -64,16 +65,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sp.over_price
|
||||
FROM
|
||||
store_product_color_price spcp
|
||||
LEFT JOIN store_product sp ON spcp.store_prod_id = sp.id
|
||||
LEFT JOIN store_product_color spc ON spcp.store_prod_id = spc.store_prod_id
|
||||
AND spcp.store_color_id = spc.store_color_id
|
||||
JOIN store_product sp ON spcp.store_prod_id = sp.id
|
||||
JOIN store_product_color spc ON spcp.store_prod_id = spc.store_prod_id AND spcp.store_color_id = spc.store_color_id
|
||||
WHERE
|
||||
spcp.del_flag = 0 AND sp.store_id = #{storeId}
|
||||
<if test="prodArtNum != null and prodArtNum != ''">
|
||||
AND sp.prod_art_num like concat('%', #{prodArtNum}, '%')
|
||||
</if>
|
||||
<if test="prodStatusList != null and prodStatusList.size() > 0">
|
||||
AND sp.prod_status IN
|
||||
AND spc.prod_status IN
|
||||
<foreach item="item" collection="prodStatusList" separator="," open="(" close=")" index="">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
|
@ -96,11 +96,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
( SELECT sc.cus_name FROM store_customer sc WHERE sc.id = #{storeCusId} ) AS storeCusName
|
||||
FROM
|
||||
store_product_color_price spcp
|
||||
LEFT JOIN store_product sp ON spcp.store_prod_id = sp.id
|
||||
LEFT JOIN store_product_color spc ON spcp.store_prod_id = spc.store_prod_id
|
||||
AND spc.store_color_id = spcp.store_color_id AND spc.del_flag = 0
|
||||
LEFT JOIN store_customer_product_discount scpd ON scpd.store_prod_color_id = spc.id
|
||||
AND scpd.del_flag = 0
|
||||
JOIN store_product sp ON spcp.store_prod_id = sp.id
|
||||
JOIN store_product_color spc ON spcp.store_prod_id = spc.store_prod_id AND spc.store_color_id = spcp.store_color_id AND spc.del_flag = 0
|
||||
JOIN store_customer_product_discount scpd ON scpd.store_prod_color_id = spc.id AND scpd.del_flag = 0
|
||||
WHERE
|
||||
spcp.del_flag = 0
|
||||
AND spc.id = #{storeProdColorId}
|
||||
|
|
|
|||
|
|
@ -80,8 +80,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN store_product_color_size spcs ON spc.store_color_id = spcs.store_color_id AND spc.store_prod_id = spcs.store_prod_id AND spcs.del_flag = 0
|
||||
WHERE
|
||||
spc.del_flag = 0
|
||||
AND spcs.standard = 1
|
||||
AND spc.store_prod_id = #{storeProdId}
|
||||
AND spc.prod_status IN (2,3)
|
||||
AND spcs.standard = 1
|
||||
AND spc.store_prod_id = #{storeProdId}
|
||||
</select>
|
||||
|
||||
<select id="selectPriceAndMainPicList" resultType="com.ruoyi.xkt.dto.storeProduct.StoreProdPriceAndMainPicDTO">
|
||||
|
|
|
|||
Loading…
Reference in New Issue