|
@@ -9,7 +9,6 @@ import cn.newfeifan.mall.module.product.controller.app.spu.vo.AppProductSpuPageR
|
|
import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
|
|
import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
|
|
import cn.newfeifan.mall.module.product.enums.ProductConstants;
|
|
import cn.newfeifan.mall.module.product.enums.ProductConstants;
|
|
import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
|
|
import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
@@ -76,6 +75,40 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
|
.notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()));
|
|
.notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询触发警戒库存的 SPU 数量
|
|
|
|
+ *
|
|
|
|
+ * @return 触发警戒库存的 SPU 数量
|
|
|
|
+ */
|
|
|
|
+ default Long selectCount(ProductSpuPageReqVO pageVO) {
|
|
|
|
+ LambdaQueryWrapperX<ProductSpuDO> queryWrapper = new LambdaQueryWrapperX<>();
|
|
|
|
+ // 库存小于等于警戒库存
|
|
|
|
+ queryWrapper
|
|
|
|
+ .likeIfPresent(ProductSpuDO::getName, pageVO.getName())
|
|
|
|
+ .eqIfPresent(ProductSpuDO::getShopId, pageVO.getShopId())
|
|
|
|
+ .eqIfPresent(ProductSpuDO::getCategoryId, pageVO.getCategoryId())
|
|
|
|
+ .eqIfPresent(ProductSpuDO::getMerchantId, pageVO.getMerchantId())
|
|
|
|
+ .inIfPresent(ProductSpuDO::getShopId, pageVO.getShopIds())
|
|
|
|
+ .betweenIfPresent(ProductSpuDO::getCreateTime, pageVO.getCreateTime())
|
|
|
|
+ .le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK)
|
|
|
|
+ // 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数
|
|
|
|
+ .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus())
|
|
|
|
+ ;
|
|
|
|
+ return selectCount(queryWrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ default Long selectCount(SFunction<ProductSpuDO, ?> field, Object value,ProductSpuPageReqVO pageVO) {
|
|
|
|
+ return selectCount(new LambdaQueryWrapperX<ProductSpuDO>()
|
|
|
|
+ .eq(field, value)
|
|
|
|
+ .likeIfPresent(ProductSpuDO::getName, pageVO.getName())
|
|
|
|
+ .eqIfPresent(ProductSpuDO::getShopId, pageVO.getShopId())
|
|
|
|
+ .eqIfPresent(ProductSpuDO::getCategoryId, pageVO.getCategoryId())
|
|
|
|
+ .eqIfPresent(ProductSpuDO::getMerchantId, pageVO.getMerchantId())
|
|
|
|
+ .inIfPresent(ProductSpuDO::getShopId, pageVO.getShopIds())
|
|
|
|
+ .betweenIfPresent(ProductSpuDO::getCreateTime, pageVO.getCreateTime())
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获得商品 SPU 分页,提供给用户 App 使用
|
|
* 获得商品 SPU 分页,提供给用户 App 使用
|
|
*/
|
|
*/
|