|
|
|
@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
import com.ruoyi.mall.domain.*;
|
|
|
|
import com.ruoyi.mall.domain.*;
|
|
|
|
import com.ruoyi.mall.domain.query.ProductQuery;
|
|
|
|
import com.ruoyi.mall.domain.query.ProductQuery;
|
|
|
|
@ -21,7 +23,6 @@ import com.ruoyi.mall.mapper.SkuMapper;
|
|
|
|
import com.ruoyi.system.domain.AppUser;
|
|
|
|
import com.ruoyi.system.domain.AppUser;
|
|
|
|
import com.ruoyi.system.service.YjAppUserService;
|
|
|
|
import com.ruoyi.system.service.YjAppUserService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -86,64 +87,19 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
|
|
|
|
if (page != null) {
|
|
|
|
if (page != null) {
|
|
|
|
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
|
|
|
|
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QueryWrapper<Product> qw = new QueryWrapper<>();
|
|
|
|
SysUser loginUser=SecurityUtils.getLoginUser().getUser();
|
|
|
|
if (StringUtils.isNoneEmpty(query.getOrderField())){
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(query.getOrderSort()) && "desc".equalsIgnoreCase(query.getOrderSort())) {
|
|
|
|
|
|
|
|
qw.orderByDesc(query.getOrderField());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
qw.orderByAsc(query.getOrderField());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
qw.orderByDesc("publish_status");
|
|
|
|
|
|
|
|
qw.orderByAsc("sort");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Long categoryId = query.getCategoryId();
|
|
|
|
|
|
|
|
if (categoryId != null) {
|
|
|
|
|
|
|
|
qw.eq("category_id", categoryId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Long brandId = query.getBrandId();
|
|
|
|
|
|
|
|
if (categoryId != null) {
|
|
|
|
|
|
|
|
qw.eq("brand_id", brandId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Integer publishStatus = query.getPublishStatus();
|
|
|
|
|
|
|
|
if (publishStatus != null) {
|
|
|
|
|
|
|
|
qw.eq("publish_status", publishStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String search = query.getSearch();
|
|
|
|
|
|
|
|
if (StringUtils.isNoneEmpty(search)){
|
|
|
|
|
|
|
|
qw.like("name", "%".concat(query.getSearch().trim()).concat("%"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(query.getExcludeProductIds())) {
|
|
|
|
|
|
|
|
qw.notIn("id",query.getExcludeProductIds());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(query.getIds())) {
|
|
|
|
|
|
|
|
qw.in("id",query.getIds());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String nameLike = query.getNameLike();
|
|
|
|
|
|
|
|
if (StringUtils.isNoneEmpty(nameLike)){
|
|
|
|
|
|
|
|
qw.like("name", "%".concat(nameLike).concat("%"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(query.getIsCourse())){
|
|
|
|
|
|
|
|
qw.eq("is_course", query.getIsCourse());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(query.getOutProductId())){
|
|
|
|
//租户管理员 查全部商品
|
|
|
|
qw.eq("out_product_id", query.getOutProductId());
|
|
|
|
if (loginUser.getRoles().stream().anyMatch(it -> it.getRoleId().equals(new Long(100)))){
|
|
|
|
}
|
|
|
|
query.setTenantId(loginUser.tenantId);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
if (StringUtils.isNotEmpty(query.getBrandNameLike())){
|
|
|
|
//店员 查本店
|
|
|
|
qw.like("brand_name", "%".concat(query.getBrandNameLike()).concat("%"));
|
|
|
|
query.setStoreId(SecurityUtils.getDeptId());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(query.getProductCategoryNameLike())){
|
|
|
|
|
|
|
|
qw.like("product_category_name", "%".concat(query.getProductCategoryNameLike()).concat("%"));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
qw.eq("store_id",SecurityUtils.getDeptId());
|
|
|
|
return productMapper.selectByEntity(query);
|
|
|
|
|
|
|
|
|
|
|
|
return productMapper.selectList(qw);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getIds(ProductQuery query){
|
|
|
|
public void getIds(ProductQuery query){
|
|
|
|
@ -183,7 +139,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public int insert(ProductVO productVO) {
|
|
|
|
public int insert(ProductVO productVO) {
|
|
|
|
|
|
|
|
LoginUser loginUser= SecurityUtils.getLoginUser();
|
|
|
|
Product product = BeanUtil.toBean(productVO,Product.class);
|
|
|
|
Product product = BeanUtil.toBean(productVO,Product.class);
|
|
|
|
product.setCreateTime(LocalDateTime.now());
|
|
|
|
product.setCreateTime(LocalDateTime.now());
|
|
|
|
product.setStoreId(SecurityUtils.getDeptId());
|
|
|
|
product.setStoreId(SecurityUtils.getDeptId());
|
|
|
|
@ -191,7 +147,14 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
|
|
|
|
setProductManager(productVO,product);
|
|
|
|
setProductManager(productVO,product);
|
|
|
|
|
|
|
|
|
|
|
|
List<Sku> skuList = productVO.getSkuList();
|
|
|
|
List<Sku> skuList = productVO.getSkuList();
|
|
|
|
|
|
|
|
if(loginUser.getPermissions().contains("pms:review:list")
|
|
|
|
|
|
|
|
||loginUser.getPermissions().contains("*:*:*")){
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(productVO.getCategoryId())){
|
|
|
|
|
|
|
|
throw new RuntimeException("请选择商品分类");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
product.setCategoryId(1l);//默认为场馆商品
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
productMapper.insert(product);
|
|
|
|
productMapper.insert(product);
|
|
|
|
if(skuList!=null){
|
|
|
|
if(skuList!=null){
|
|
|
|
|