商品模块代码提交
This commit is contained in:
@@ -76,7 +76,7 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addConsGroup(ConsGroupDTO dto) {
|
||||
public void addConsGroup(ConsGroupDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query().eq(ConsGroup::getName, dto.getName()).eq(ConsGroup::getShopId, shopId));
|
||||
if (exists) {
|
||||
@@ -88,7 +88,7 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
|
||||
super.save(entity);
|
||||
List<Long> consIds = dto.getConsIds();
|
||||
if (CollUtil.isEmpty(consIds)) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
for (Long consId : consIds) {
|
||||
ConsGroupRelation relation = new ConsGroupRelation();
|
||||
@@ -97,11 +97,10 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
|
||||
relation.setSort(consId.intValue());
|
||||
consGroupRelationMapper.insert(relation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateConsGroup(ConsGroupDTO dto) {
|
||||
public void updateConsGroup(ConsGroupDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(ConsGroup::getName, dto.getName()).eq(ConsGroup::getShopId, shopId).ne(ConsGroup::getId, dto.getId()));
|
||||
@@ -112,7 +111,7 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
|
||||
super.updateById(entity);
|
||||
List<Long> consIds = dto.getConsIds();
|
||||
if (CollUtil.isEmpty(consIds)) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
consGroupRelationMapper.deleteByQuery(query().eq(ConsGroupRelation::getGroupId, entity.getId()));
|
||||
for (Long consId : consIds) {
|
||||
@@ -122,19 +121,18 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
|
||||
relation.setSort(consId.intValue());
|
||||
consGroupRelationMapper.insert(relation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteConsGroup(Long id) {
|
||||
public void deleteConsGroup(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return super.remove(query().eq(ConsGroup::getId, id).eq(ConsGroup::getShopId, shopId));
|
||||
super.remove(query().eq(ConsGroup::getId, id).eq(ConsGroup::getShopId, shopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableConsGroup(Long id) {
|
||||
public void disableConsGroup(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ConsGroup.class)
|
||||
UpdateChain.of(ConsGroup.class)
|
||||
.set(ConsGroup::getStatus, StatusEnum.DISABLE.value())
|
||||
.eq(ConsGroup::getId, id)
|
||||
.eq(ConsGroup::getShopId, shopId)
|
||||
@@ -142,9 +140,9 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableConsGroup(Long id) {
|
||||
public void enableConsGroup(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ConsGroup.class)
|
||||
UpdateChain.of(ConsGroup.class)
|
||||
.set(ConsGroup::getStatus, StatusEnum.ENABLED.value())
|
||||
.eq(ConsGroup::getId, id)
|
||||
.eq(ConsGroup::getShopId, shopId)
|
||||
|
||||
@@ -143,9 +143,9 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableConsInfo(Long id) {
|
||||
public void disableConsInfo(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ConsInfo.class)
|
||||
UpdateChain.of(ConsInfo.class)
|
||||
.set(ConsInfo::getStatus, StatusEnum.DISABLE.value())
|
||||
.eq(ConsInfo::getId, id)
|
||||
.eq(ConsInfo::getShopId, shopId)
|
||||
@@ -153,9 +153,9 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableConsInfo(Long id) {
|
||||
public void enableConsInfo(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ConsInfo.class)
|
||||
UpdateChain.of(ConsInfo.class)
|
||||
.set(ConsInfo::getStatus, StatusEnum.ENABLED.value())
|
||||
.eq(ConsInfo::getId, id)
|
||||
.eq(ConsInfo::getShopId, shopId)
|
||||
@@ -163,12 +163,11 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOffConsInfo(Long id, Integer isStock) {
|
||||
public void onOffConsInfo(Long id, Integer isStock) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
ConsInfo entity = super.getOne(query().eq(ConsInfo::getId, id).eq(ConsInfo::getShopId, shopId));
|
||||
entity.setIsStock(isStock);
|
||||
super.updateById(entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ProdConsRelationServiceImpl extends ServiceImpl<ProdConsRelationMap
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean saveProdConsRelation(ProdConsBindDTO dto) {
|
||||
public void saveProdConsRelation(ProdConsBindDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
long count = productMapper.selectCountByQuery(query().eq(Product::getShopId, shopId).eq(Product::getId, dto.getId()));
|
||||
if (count == 0) {
|
||||
@@ -58,7 +58,7 @@ public class ProdConsRelationServiceImpl extends ServiceImpl<ProdConsRelationMap
|
||||
}
|
||||
super.remove(query().eq(ProdConsRelation::getShopId, shopId).eq(ProdConsRelation::getProductId, dto.getId()));
|
||||
if (CollUtil.isEmpty(dto.getConsList())) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
ValidatorUtil.validateEntityList(dto.getConsList(), DefaultGroup.class);
|
||||
List<ProdConsRelationDTO> consList = dto.getConsList();
|
||||
@@ -73,7 +73,7 @@ public class ProdConsRelationServiceImpl extends ServiceImpl<ProdConsRelationMap
|
||||
throw new CzgException("非法操作,绑定关系商品不一致");
|
||||
}
|
||||
List<ProdConsRelation> entityList = BeanUtil.copyToList(consList, ProdConsRelation.class);
|
||||
return super.saveBatch(entityList);
|
||||
super.saveBatch(entityList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addProdGroup(ProdGroupDTO dto) {
|
||||
public void addProdGroup(ProdGroupDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query().eq(ProdGroup::getName, dto.getName()).eq(ProdGroup::getShopId, shopId));
|
||||
if (exists) {
|
||||
@@ -103,12 +103,11 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
|
||||
prodGroupRelationMapper.insert(prodGroupRelation);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateProdGroup(ProdGroupDTO dto) {
|
||||
public void updateProdGroup(ProdGroupDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(ProdGroup::getName, dto.getName()).eq(ProdGroup::getShopId, shopId).ne(ProdGroup::getId, dto.getId()));
|
||||
@@ -130,22 +129,20 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
|
||||
prodGroupRelationMapper.insert(prodGroupRelation);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteProdGroup(Long id) {
|
||||
public void deleteProdGroup(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
super.remove(query().eq(ProdGroup::getId, id).eq(ProdGroup::getShopId, shopId));
|
||||
prodGroupRelationMapper.deleteByQuery(query().eq(ProdGroupRelation::getProdGroupId, id));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableProdGroup(Long id) {
|
||||
public void disableProdGroup(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ProdGroup.class)
|
||||
UpdateChain.of(ProdGroup.class)
|
||||
.set(ProdGroup::getStatus, StatusEnum.DISABLE.value())
|
||||
.eq(ProdGroup::getId, id)
|
||||
.eq(ProdGroup::getShopId, shopId)
|
||||
@@ -153,9 +150,9 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableProdGroup(Long id) {
|
||||
public void enableProdGroup(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ProdGroup.class)
|
||||
UpdateChain.of(ProdGroup.class)
|
||||
.set(ProdGroup::getStatus, StatusEnum.ENABLED.value())
|
||||
.eq(ProdGroup::getId, id)
|
||||
.eq(ProdGroup::getShopId, shopId)
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addProduct(ProductDTO dto) {
|
||||
public void addProduct(ProductDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query().eq(Product::getName, dto.getName()).eq(Product::getShopId, shopId));
|
||||
if (exists) {
|
||||
@@ -194,11 +194,10 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
}
|
||||
prodSkuMapper.insertBatch(prodSkuList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateProduct(ProductDTO dto) {
|
||||
public void updateProduct(ProductDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(Product::getName, dto.getName()).eq(Product::getShopId, shopId).ne(Product::getId, dto.getId()));
|
||||
@@ -249,13 +248,12 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
.eq(ProdSku::getShopId, shopId)
|
||||
.update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteProduct(Long id) {
|
||||
public void deleteProduct(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(Product.class)
|
||||
UpdateChain.of(Product.class)
|
||||
.set(Product::getIsDel, DeleteEnum.DELETED.value())
|
||||
.eq(Product::getId, id)
|
||||
.eq(Product::getShopId, shopId)
|
||||
@@ -264,7 +262,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean onOffProduct(ProductIsSaleParam param) {
|
||||
public void onOffProduct(ProductIsSaleParam param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
String type = param.getType();
|
||||
Long id = param.getId();
|
||||
@@ -280,12 +278,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
.eq(Product::getShopId, shopId)
|
||||
.update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean markProductIsSoldOut(ProductIsSoldOutParam param) {
|
||||
public void markProductIsSoldOut(ProductIsSoldOutParam param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
String type = param.getType();
|
||||
Long id = param.getId();
|
||||
@@ -301,7 +298,6 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
.eq(Product::getShopId, shopId)
|
||||
.update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addShopProdCategory(ShopProdCategoryDTO dto) {
|
||||
public void addShopProdCategory(ShopProdCategoryDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query().eq(ShopProdCategory::getName, dto.getName()).eq(ShopProdCategory::getShopId, shopId));
|
||||
if (exists) {
|
||||
@@ -67,16 +67,16 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
|
||||
ShopProdCategory entity = BeanUtil.copyProperties(dto, ShopProdCategory.class);
|
||||
// 简称
|
||||
entity.setShortName(dto.getName());
|
||||
if(entity.getStatus() == null){
|
||||
if (entity.getStatus() == null) {
|
||||
entity.setStatus(StatusEnum.ENABLED.value());
|
||||
}
|
||||
entity.setPid(0L);
|
||||
entity.setShopId(shopId);
|
||||
return super.save(entity);
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateShopProdCategory(ShopProdCategoryDTO dto) {
|
||||
public void updateShopProdCategory(ShopProdCategoryDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(ShopProdCategory::getName, dto.getName()).eq(ShopProdCategory::getShopId, shopId).ne(ShopProdCategory::getId, dto.getId()));
|
||||
@@ -84,19 +84,19 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
|
||||
throw new CzgException("商品分类已存在");
|
||||
}
|
||||
ShopProdCategory entity = BeanUtil.copyProperties(dto, ShopProdCategory.class);
|
||||
return super.updateById(entity);
|
||||
super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteShopProdCategory(Long id) {
|
||||
public void deleteShopProdCategory(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return super.remove(query().eq(ShopProdCategory::getId, id).eq(ShopProdCategory::getShopId, shopId));
|
||||
super.remove(query().eq(ShopProdCategory::getId, id).eq(ShopProdCategory::getShopId, shopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableShopProdCategory(Long id) {
|
||||
public void disableShopProdCategory(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ShopProdCategory.class)
|
||||
UpdateChain.of(ShopProdCategory.class)
|
||||
.set(ShopProdCategory::getStatus, StatusEnum.DISABLE.value())
|
||||
.eq(ShopProdCategory::getId, id)
|
||||
.eq(ShopProdCategory::getShopId, shopId)
|
||||
@@ -104,9 +104,9 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableShopProdCategory(Long id) {
|
||||
public void enableShopProdCategory(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ShopProdCategory.class)
|
||||
UpdateChain.of(ShopProdCategory.class)
|
||||
.set(ShopProdCategory::getStatus, StatusEnum.ENABLED.value())
|
||||
.eq(ShopProdCategory::getId, id)
|
||||
.eq(ShopProdCategory::getShopId, shopId)
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addShopProdUnit(ShopProdUnitDTO dto) {
|
||||
public void addShopProdUnit(ShopProdUnitDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName()).eq(ShopProdUnit::getShopId, shopId));
|
||||
if (exists) {
|
||||
@@ -74,11 +74,11 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
||||
entity.setIsSystem(YesNoEnum.NO.value());
|
||||
entity.setStatus(StatusEnum.ENABLED.value());
|
||||
entity.setShopId(shopId);
|
||||
return super.save(entity);
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateShopProdUnit(ShopProdUnitDTO dto) {
|
||||
public void updateShopProdUnit(ShopProdUnitDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName()).eq(ShopProdUnit::getShopId, shopId).ne(ShopProdUnit::getId, dto.getId()));
|
||||
@@ -86,19 +86,19 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
||||
throw new CzgException("单位名称已存在");
|
||||
}
|
||||
ShopProdUnit entity = BeanUtil.copyProperties(dto, ShopProdUnit.class);
|
||||
return super.updateById(entity);
|
||||
super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteShopProdUnit(Long id) {
|
||||
public void deleteShopProdUnit(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return super.remove(query().eq(ShopProdUnit::getId, id).eq(ShopProdUnit::getShopId, shopId));
|
||||
super.remove(query().eq(ShopProdUnit::getId, id).eq(ShopProdUnit::getShopId, shopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableShopProdUnit(Long id) {
|
||||
public void disableShopProdUnit(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ShopProdUnit.class)
|
||||
UpdateChain.of(ShopProdUnit.class)
|
||||
.set(ShopProdUnit::getStatus, StatusEnum.DISABLE.value())
|
||||
.eq(ShopProdUnit::getId, id)
|
||||
.eq(ShopProdUnit::getShopId, shopId)
|
||||
@@ -106,9 +106,9 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableShopProdUnit(Long id) {
|
||||
public void enableShopProdUnit(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ShopProdUnit.class)
|
||||
UpdateChain.of(ShopProdUnit.class)
|
||||
.set(ShopProdUnit::getStatus, StatusEnum.ENABLED.value())
|
||||
.eq(ShopProdUnit::getId, id)
|
||||
.eq(ShopProdUnit::getShopId, shopId)
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addShopProdSpec(ShopProdSpecDTO dto) {
|
||||
public void addShopProdSpec(ShopProdSpecDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query()
|
||||
.eq(ShopProdSpec::getName, dto.getName())
|
||||
@@ -100,12 +100,11 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
|
||||
entity.setShopId(shopId);
|
||||
super.save(entity);
|
||||
dto.setId(entity.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateShopProdSpec(ShopProdSpecDTO dto) {
|
||||
public void updateShopProdSpec(ShopProdSpecDTO dto) {
|
||||
//上级规格不能为自身
|
||||
if (dto.getId().equals(dto.getPid())) {
|
||||
throw new CzgException("上级规格不能为自身");
|
||||
@@ -137,31 +136,31 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
|
||||
.setRaw(ShopProdSpec::getFullName, StrUtil.format("replace(full_name, '{}', '{}')", oldName, entity.getName()))
|
||||
.like(ShopProdSpec::getPids, "," + entity.getId() + ",")
|
||||
.eq(ShopProdSpec::getShopId, entity.getShopId()).update();
|
||||
return super.updateById(entity);
|
||||
super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteShopProdSpec(Long id) {
|
||||
public void deleteShopProdSpec(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return super.remove(query()
|
||||
super.remove(query()
|
||||
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)
|
||||
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id + ","))))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableShopProdSpec(Long id) {
|
||||
public void disableShopProdSpec(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ShopProdSpec.class)
|
||||
UpdateChain.of(ShopProdSpec.class)
|
||||
.set(SHOP_PROD_SPEC.STATUS, StatusEnum.DISABLE.value())
|
||||
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)
|
||||
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id + ",")))).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableShopProdSpec(Long id) {
|
||||
public void enableShopProdSpec(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ShopProdSpec.class)
|
||||
UpdateChain.of(ShopProdSpec.class)
|
||||
.set(SHOP_PROD_SPEC.STATUS, StatusEnum.ENABLED.value())
|
||||
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)
|
||||
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id + ",")))).update();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addShopVendor(ShopVendorDTO dto) {
|
||||
public void addShopVendor(ShopVendorDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
boolean exists = super.exists(query().eq(ShopVendor::getName, dto.getName()).eq(ShopVendor::getShopId, shopId));
|
||||
if (exists) {
|
||||
@@ -68,11 +68,11 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
|
||||
ShopVendor entity = BeanUtil.copyProperties(dto, ShopVendor.class);
|
||||
entity.setIsDel(DeleteEnum.NORMAL.value());
|
||||
entity.setShopId(shopId);
|
||||
return super.save(entity);
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateShopVendor(ShopVendorDTO dto) {
|
||||
public void updateShopVendor(ShopVendorDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(ShopVendor::getName, dto.getName()).eq(ShopVendor::getShopId, shopId).ne(ShopVendor::getId, dto.getId()));
|
||||
@@ -80,13 +80,13 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
|
||||
throw new CzgException("供应商已存在");
|
||||
}
|
||||
ShopVendor entity = BeanUtil.copyProperties(dto, ShopVendor.class);
|
||||
return super.updateById(entity);
|
||||
super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteShopVendor(Long id) {
|
||||
public void deleteShopVendor(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
return UpdateChain.of(ShopVendor.class)
|
||||
UpdateChain.of(ShopVendor.class)
|
||||
.set(ShopVendor::getIsDel, DeleteEnum.DELETED.value())
|
||||
.eq(ShopVendor::getId, id)
|
||||
.eq(ShopVendor::getShopId, shopId)
|
||||
|
||||
@@ -7,40 +7,36 @@ import com.czg.enums.DeleteEnum;
|
||||
import com.czg.enums.StatusEnum;
|
||||
import com.czg.enums.YesNoEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.product.dto.ProdSkuDTO;
|
||||
import com.czg.product.dto.ProductDTO;
|
||||
import com.czg.product.entity.ProdGroup;
|
||||
import com.czg.product.entity.ProdGroupRelation;
|
||||
import com.czg.product.entity.ProdSku;
|
||||
import com.czg.product.entity.Product;
|
||||
import com.czg.product.param.MiniHomeProductParam;
|
||||
import com.czg.product.param.ShopProductSkuParam;
|
||||
import com.czg.product.service.UProductService;
|
||||
import com.czg.product.vo.*;
|
||||
import com.czg.product.vo.ShopGroupProductVo;
|
||||
import com.czg.product.vo.ShopProductInfoVo;
|
||||
import com.czg.product.vo.ShopProductSkuInfoVo;
|
||||
import com.czg.product.vo.ShopProductVo;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.product.mapper.ProdGroupMapper;
|
||||
import com.czg.service.product.mapper.ProdGroupRelationMapper;
|
||||
import com.czg.service.product.mapper.ProdSkuMapper;
|
||||
import com.czg.service.product.mapper.ProductMapper;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.czg.product.entity.table.ProductTableDef.PRODUCT;
|
||||
import static com.czg.product.entity.table.ShopProdCategoryTableDef.SHOP_PROD_CATEGORY;
|
||||
import static com.czg.product.entity.table.ShopProdSpecTableDef.SHOP_PROD_SPEC;
|
||||
import static com.czg.product.entity.table.ShopProdUnitTableDef.SHOP_PROD_UNIT;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
@@ -57,111 +53,6 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
|
||||
private final ProdGroupMapper prodGroupMapper;
|
||||
private final ProdGroupRelationMapper prodGroupRelationMapper;
|
||||
|
||||
private QueryWrapper buildQueryWrapper(MiniHomeProductParam param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
String weekDayEnName = getWeekDayEnName();
|
||||
LocalTime now = LocalTime.now().withNano(0);
|
||||
QueryWrapper queryWrapper = query();
|
||||
queryWrapper.select(PRODUCT.ALL_COLUMNS)
|
||||
.select(SHOP_PROD_UNIT.NAME.as(ProductDTO::getUnitName))
|
||||
.select(SHOP_PROD_CATEGORY.NAME.as(ProductDTO::getCategoryName))
|
||||
.select(SHOP_PROD_SPEC.NAME.as(ProductDTO::getSpecName), SHOP_PROD_SPEC.FULL_NAME.as(ProductDTO::getSpecFullName))
|
||||
.from(PRODUCT)
|
||||
.leftJoin(SHOP_PROD_UNIT).on(SHOP_PROD_UNIT.ID.eq(PRODUCT.UNIT_ID))
|
||||
.leftJoin(SHOP_PROD_CATEGORY).on(SHOP_PROD_CATEGORY.ID.eq(PRODUCT.CATEGORY_ID))
|
||||
.leftJoin(SHOP_PROD_SPEC).on(SHOP_PROD_SPEC.ID.eq(PRODUCT.SPEC_ID))
|
||||
.where(PRODUCT.SHOP_ID.eq(shopId))
|
||||
.and(PRODUCT.DAYS.like(weekDayEnName))
|
||||
.and(PRODUCT.START_TIME.le(now))
|
||||
.and(PRODUCT.END_TIME.ge(now))
|
||||
.and(PRODUCT.IS_DEL.eq(DeleteEnum.NORMAL.value()))
|
||||
.and(PRODUCT.IS_SALE.eq(YesNoEnum.YES.value()))
|
||||
.orderBy(PRODUCT.SORT, false)
|
||||
.orderBy(PRODUCT.ID, false);
|
||||
if (CollUtil.isNotEmpty(param.getProductIdList())) {
|
||||
queryWrapper.and(PRODUCT.ID.in(param.getProductIdList()));
|
||||
}
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
private QueryWrapper buildHotsQueryWrapper(MiniHomeProductParam param) {
|
||||
// 查询在可售时间内的热门商品
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
||||
queryWrapper.and(PRODUCT.IS_HOT.eq(YesNoEnum.YES.value()));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
private List<MiniAppHomeProductInfoVo> buildProductList(QueryWrapper queryWrapper) {
|
||||
List<ProductDTO> dtoList = productMapper.selectListByQueryAs(queryWrapper, ProductDTO.class);
|
||||
if (CollUtil.isEmpty(dtoList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Long> prodIdList = dtoList.stream().map(ProductDTO::getId).distinct().toList();
|
||||
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query()
|
||||
.in(ProdSku::getProductId, prodIdList)
|
||||
.eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value())
|
||||
.eq(ProdSku::getIsGrounding, YesNoEnum.YES.value())
|
||||
, ProdSkuDTO.class);
|
||||
Map<Long, List<ProdSkuDTO>> collect = skuList.stream().collect(Collectors.groupingBy(ProdSkuDTO::getProductId));
|
||||
List<MiniAppHomeProductInfoVo> products = new ArrayList<>();
|
||||
for (ProductDTO dto : dtoList) {
|
||||
MiniAppHomeProductInfoVo prod = new MiniAppHomeProductInfoVo();
|
||||
prod.setId(dto.getId());
|
||||
prod.setName(dto.getName());
|
||||
prod.setCoverImg(dto.getCoverImg());
|
||||
prod.setImages(dto.getImages());
|
||||
prod.setUnitName(dto.getUnitName());
|
||||
prod.setCategoryName(dto.getCategoryName());
|
||||
prod.setType(dto.getType());
|
||||
prod.setGroupType(dto.getGroupType());
|
||||
prod.setSelectSpecInfo(dto.getSelectSpecInfo());
|
||||
prod.setIsSoldStock(dto.getIsSoldStock());
|
||||
prod.setStockNumber(dto.getStockNumber());
|
||||
prod.setIsSale(dto.getIsSale());
|
||||
|
||||
List<ProdSkuDTO> list = collect.getOrDefault(dto.getId(), Collections.emptyList());
|
||||
Optional<BigDecimal> lowPriceIsPresent = list.stream().map(ProdSkuDTO::getSalePrice).min(BigDecimal::compareTo);
|
||||
lowPriceIsPresent.ifPresent(prod::setLowPrice);
|
||||
|
||||
Optional<BigDecimal> lowMemberPriceIsPresent = list.stream().map(ProdSkuDTO::getMemberPrice).min(BigDecimal::compareTo);
|
||||
lowMemberPriceIsPresent.ifPresent(prod::setLowMemberPrice);
|
||||
|
||||
prod.setSkuList(list);
|
||||
products.add(prod);
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniAppHomeProductVo queryProductForMiniAppHome(MiniHomeProductParam param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
MiniAppHomeProductVo vo = new MiniAppHomeProductVo();
|
||||
|
||||
List<MiniAppHomeProductInfoVo> hots = buildProductList(buildHotsQueryWrapper(param));
|
||||
vo.setHots(hots);
|
||||
// 查询可用商品分组,构建分组商品数据
|
||||
QueryWrapper queryWrapper = query()
|
||||
.eq(ProdGroup::getShopId, shopId)
|
||||
.eq(ProdGroup::getStatus, StatusEnum.ENABLED.value())
|
||||
.orderBy(ProdGroup::getSort, true);
|
||||
if (param.getProdGroupId() != null) {
|
||||
queryWrapper.eq(ProdGroup::getId, param.getProdGroupId());
|
||||
}
|
||||
List<MiniAppHomeProdGroupVo> groupList = prodGroupMapper.selectListByQueryAs(queryWrapper, MiniAppHomeProdGroupVo.class);
|
||||
for (MiniAppHomeProdGroupVo dto : groupList) {
|
||||
List<Long> productIdList = prodGroupRelationMapper.selectObjectListByQueryAs(query().select(ProdGroupRelation::getProductId).eq(ProdGroupRelation::getProdGroupId, dto.getId()).orderBy(ProdGroupRelation::getSort, true), Long.class);
|
||||
if (CollUtil.isNotEmpty(productIdList)) {
|
||||
param.setProductIdList(productIdList);
|
||||
List<MiniAppHomeProductInfoVo> products = buildProductList(buildQueryWrapper(param));
|
||||
dto.setProducts(products);
|
||||
} else {
|
||||
dto.setProducts(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
vo.setProductInfo(groupList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopProductVo> queryHotsProductList() {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
|
||||
Reference in New Issue
Block a user