更改商品bug

This commit is contained in:
liuyingfang
2024-03-05 16:38:12 +08:00
parent 5463204fb5
commit c6744bc012
17 changed files with 72 additions and 56 deletions

View File

@@ -80,7 +80,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
TbProductGroup tbProductGroup = tbProductGroupRepository.findById(productGroup).orElseGet(TbProductGroup::new);
TbProductGroupDto dto = tbProductGroupMapper.toDto(tbProductGroup);
if (!CollectionUtils.isEmpty(dto.getProductIds())){
return tbProductRepository.findByIds(ListUtil.stringChangeIntegerList(dto.getProductIds()));
return tbProductRepository.findByIds(dto.getProductIds());
}
return new ArrayList<>();
}

View File

@@ -37,10 +37,13 @@ import cn.ysk.cashier.pojo.shop.TbShopUnit;
import cn.ysk.cashier.repository.shop.TbShopUnitRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import java.time.Instant;
import java.util.*;
@@ -68,7 +71,9 @@ public class TbProductServiceImpl implements TbProductService {
@Override
public Map<String,Object> queryAll(TbProductQueryCriteria criteria, Pageable pageable){
public Map<String,Object> queryAll(TbProductQueryCriteria criteria){
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
//查询商品数据
Page<TbProduct> page = tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
List<String> productId = new ArrayList<>();
@@ -147,7 +152,7 @@ public class TbProductServiceImpl implements TbProductService {
//单位
CompletableFuture<TbShopUnit> tbShopUnits = CompletableFuture.supplyAsync(() ->
tbShopUnitRepository.searchUnit(Integer.valueOf(tbProduct.getUnitId())));
tbShopUnitRepository.searchUnit(Integer.valueOf(StringUtils.isEmpty(tbProduct.getUnitId())? null:tbProduct.getUnitId() )));
//sku
CompletableFuture<List<TbProductSku>> tbProductSkus = CompletableFuture.supplyAsync(() ->
tbProductSkuRepository.searchSku(tbProduct.getId().toString()));
@@ -163,8 +168,6 @@ public class TbProductServiceImpl implements TbProductService {
if (tbProduct.getUnitId() == null){
tbProductVo.setUnitId(null);
tbProductVo.setUnitName(null);
}else {
tbProductVo.setUnitName(tbShopUnits.get().getName());
}
//套餐
if (tbProduct.getGroupSnap() == null){
@@ -203,7 +206,7 @@ public class TbProductServiceImpl implements TbProductService {
}
@Override
public List<TbProductDto> queryAll(TbProductQueryCriteria criteria){
public List<TbProductDto> queryAlls(TbProductQueryCriteria criteria){
return tbProductMapper.toDto(tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@@ -225,6 +228,7 @@ public class TbProductServiceImpl implements TbProductService {
if (resources.getCategoryId() == null){
throw new BadRequestException("必填内容未填写");
}
product.setImages(resources.getImages().toString());
product.setCategoryId(String.valueOf(resources.getCategoryId()));
product.setIsDel(0);
product.setIsDelete(0);

View File

@@ -60,7 +60,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
public Map<String,Object> queryAll(TbShopCategoryQueryCriteria criteria, Pageable pageable){
// Page<TbShopCategory> page = tbShopCategoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
PageRequest.of(0, 10, Sort.by("sort"));
PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort"));
Page<TbShopCategory> page = tbShopCategoryRepository.findAllBy(criteria.getShopId(), pageable);
tbShopCategoryRepository.findAllBy(criteria.getShopId(),pageable);
@@ -112,14 +112,16 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
resources.setUpdatedAt(Instant.now().toEpochMilli());
TbShopCategoryDto dto = tbShopCategoryMapper.toDto(tbShopCategoryRepository.save(resources));
if (resources.getName() != null){
throw new BadRequestException("分类名称重复");
}
if (resources.getPid() == null || "".equals(resources.getPid())){
resources.setTree(resources.getId());
}else {
resources.setTree(Integer.valueOf(resources.getPid().trim()));
}
ValidationUtil.isNull( dto.getId(),"TbShopCategory","id",resources.getId());
ValidationUtil.isNull(dto.getId(),"TbShopCategory","id",resources.getId());
tbShopCategoryRepository.save(resources);
return tbShopCategoryRepository.save(resources);
}
@@ -132,9 +134,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
throw new BadRequestException("必要参数为空");
}
TbShopCategory byName = tbShopCategoryRepository.findByName(resources.getName(), resources.getShopId());
if (byName != null){
throw new BadRequestException("分类名称重复");
}
resources.setUpdatedAt(Instant.now().toEpochMilli());
ValidationUtil.isNull( tbShopCategory.getId(),"TbShopCategory","id",resources.getId());
tbShopCategory.copy(resources);

View File

@@ -16,6 +16,7 @@
package cn.ysk.cashier.service.impl.shopimpl;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.pojo.product.TbShopCategory;
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository;
@@ -36,6 +37,8 @@ import cn.ysk.cashier.dto.shop.TbShopInfoDto;
import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria;
import cn.ysk.cashier.mapper.shop.TbShopInfoMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -73,11 +76,10 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
private final TbPlussShopStaffRepository shopStaffRepository;
@Override
public Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria, Pageable pageable){
// if (!"admin".equals(criteria.getAccount())){
// throw new BadRequestException("登录账号有误");
// }
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
public Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria){
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Pageable pageables = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageables);
List<TbShopInfo> content = page.getContent();
for (TbShopInfo data: content){
if (data.getProfiles() == null){
@@ -87,10 +89,10 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
return PageUtil.toPage(page);
}
@Override
public List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria){
return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
// @Override
// public List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria){
// return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
// }
@Override
@Transactional
@@ -178,6 +180,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
tbPlussShopStaff.setStatus(1);
tbPlussShopStaff.setCreatedAt(Instant.now().toEpochMilli());
tbPlussShopStaff.setUpdatedAt(Instant.now().toEpochMilli());
tbPlussShopStaff.setCode(save.getPhone());
shopStaffRepository.save(tbPlussShopStaff);
if (resources.getRegisterCode() != null){

View File

@@ -106,6 +106,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
resources.setCreatedAt(Instant.now().toEpochMilli());
resources.setUpdatedAt(Instant.now().toEpochMilli());
resources.setQrcode("");
resources.setStatus("closed");
return tbShopTableRepository.save(resources);
}

View File

@@ -36,17 +36,16 @@ public interface TbProductService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TbProductQueryCriteria criteria, Pageable pageable);
Map<String,Object> queryAll(TbProductQueryCriteria criteria);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TbProductDto>
*/
List<TbProductDto> queryAll(TbProductQueryCriteria criteria);
List<TbProductDto> queryAlls(TbProductQueryCriteria criteria);
/**
* 根据ID查询

View File

@@ -35,17 +35,16 @@ public interface TbShopInfoService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria, Pageable pageable);
Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TbShopInfoDto>
*/
List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria);
// List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria);
/**
* 根据ID查询