|
|
@@ -1,461 +0,0 @@
|
|
|
-package shop.alien.store.service.impl;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import shop.alien.entity.result.CommonEnum;
|
|
|
-import shop.alien.entity.result.R;
|
|
|
-import shop.alien.entity.store.StoreProductBar;
|
|
|
-import shop.alien.entity.store.StoreProductDelicacies;
|
|
|
-import shop.alien.entity.store.StoreProductGym;
|
|
|
-import shop.alien.entity.store.StoreProductItem;
|
|
|
-import shop.alien.entity.store.vo.StoreProductItemGymVo;
|
|
|
-import shop.alien.entity.store.vo.StoreProductItemDelicaciesVo;
|
|
|
-import shop.alien.entity.store.vo.StoreProductDelicaciesVo;
|
|
|
-import shop.alien.entity.store.dto.StoreProductItemDto;
|
|
|
-import shop.alien.mapper.StoreProductItemMapper;
|
|
|
-import shop.alien.store.service.StoreProductBarService;
|
|
|
-import shop.alien.store.service.StoreProductDelicaciesService;
|
|
|
-import shop.alien.store.service.StoreProductGymService;
|
|
|
-import shop.alien.store.service.StoreProductItemService;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.function.BiConsumer;
|
|
|
-import java.util.function.Function;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * 商品表 服务实现类
|
|
|
- *
|
|
|
- * @author system
|
|
|
- * @since 2025-01-XX
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Transactional(rollbackFor = Exception.class)
|
|
|
-@Service
|
|
|
-@RequiredArgsConstructor
|
|
|
-public class StoreProductItemServiceImpl extends ServiceImpl<StoreProductItemMapper, StoreProductItem> implements StoreProductItemService {
|
|
|
-
|
|
|
- private final ObjectMapper objectMapper;
|
|
|
-
|
|
|
- private final StoreProductBarService storeProductBarService;
|
|
|
-
|
|
|
- private final StoreProductDelicaciesService storeProductDelicaciesService;
|
|
|
-
|
|
|
- private final StoreProductGymService storeProductGymService;
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<StoreProductItem> addStoreProductItemDto(StoreProductItemDto storeProductItemDto) {
|
|
|
- log.info("StoreProductItemServiceImpl.addStoreProductItem?storeProductItem={}", storeProductItemDto);
|
|
|
- StoreProductItem storeProductItem = new StoreProductItem();
|
|
|
- BeanUtils.copyProperties(storeProductItemDto, storeProductItem);
|
|
|
- // 先保存主商品,确保可以拿到自增的 id 作为子表 extId。
|
|
|
- this.save(storeProductItem);
|
|
|
- // 根据商品类型分发子表保存逻辑。
|
|
|
- processSubItems(storeProductItemDto, storeProductItem, false);
|
|
|
- return R.data(storeProductItem);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<StoreProductItem> editStoreProductItem(StoreProductItemDto storeProductItemDto) {
|
|
|
- log.info("StoreProductItemServiceImpl.editStoreProductItem?storeProductItem={}", storeProductItemDto);
|
|
|
- StoreProductItem storeProductItem = new StoreProductItem();
|
|
|
- BeanUtils.copyProperties(storeProductItemDto, storeProductItem);
|
|
|
- this.updateById(storeProductItem);
|
|
|
- // 统一的子表处理:先清理旧数据,再按商品类型重建。
|
|
|
- processSubItems(storeProductItemDto, storeProductItem, true);
|
|
|
- return R.data(storeProductItem);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增/编辑场景下的子表处理。
|
|
|
- *
|
|
|
- * @param storeProductItemDto 前端传入的数据,包含主表和子表信息
|
|
|
- * @param storeProductItem 已保存/更新的主表实体,需从中读取 id 作为子表 extId
|
|
|
- * @param replaceExisting 是否需要先删除同 extId 的旧数据(编辑场景)
|
|
|
- */
|
|
|
- private void processSubItems(StoreProductItemDto storeProductItemDto,
|
|
|
- StoreProductItem storeProductItem,
|
|
|
- boolean replaceExisting) {
|
|
|
- List<?> rawSubList = storeProductItemDto.getSubList();
|
|
|
- if (rawSubList == null || rawSubList.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Integer modelType = storeProductItemDto.getModelType();
|
|
|
- if (modelType == null) {
|
|
|
- log.warn("商品缺少 modelType,跳过子项处理");
|
|
|
- return;
|
|
|
- }
|
|
|
- Integer extId = storeProductItem.getId();
|
|
|
-
|
|
|
- // 编辑场景:删除当前商品 extId 对应的旧子表数据,避免脏数据。
|
|
|
- if (replaceExisting) {
|
|
|
- clearSubItemsByModelType(modelType, extId);
|
|
|
- }
|
|
|
-
|
|
|
- // 按商品类型把原始子项转换为目标实体并批量入库。
|
|
|
- if (CommonEnum.ModelType.BAR.getCode() == modelType) {
|
|
|
- convertAndSave(rawSubList, extId, StoreProductBar.class,
|
|
|
- (item, id) -> item.setExtId(id), storeProductBarService::saveBatch);
|
|
|
- } else if (CommonEnum.ModelType.DELICACY.getCode() == modelType) {
|
|
|
- convertAndSave(rawSubList, extId, StoreProductDelicacies.class,
|
|
|
- (item, id) -> item.setExtId(id), storeProductDelicaciesService::saveBatch);
|
|
|
- } else if (CommonEnum.ModelType.GYM.getCode() == modelType) {
|
|
|
- convertAndSave(rawSubList, extId, StoreProductGym.class,
|
|
|
- (item, id) -> {
|
|
|
- item.setExtId(id);
|
|
|
- if (item.getUsageCount() == null) {
|
|
|
- item.setUsageCount(0);
|
|
|
- }
|
|
|
- }, storeProductGymService::saveBatch);
|
|
|
- } else {
|
|
|
- log.warn("未知的商品 modelType:{},子项未处理", modelType);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据商品模块清理同一个 extId 的旧子表数据,防止编辑后出现重复/脏数据。
|
|
|
- */
|
|
|
- private void clearSubItemsByModelType(Integer modelType, Integer extId) {
|
|
|
- if (CommonEnum.ModelType.BAR.getCode() == modelType) {
|
|
|
- storeProductBarService.lambdaUpdate().eq(StoreProductBar::getExtId, extId).remove();
|
|
|
- } else if (CommonEnum.ModelType.DELICACY.getCode() == modelType) {
|
|
|
- storeProductDelicaciesService.lambdaUpdate().eq(StoreProductDelicacies::getExtId, extId).remove();
|
|
|
- } else if (CommonEnum.ModelType.GYM.getCode() == modelType) {
|
|
|
- storeProductGymService.lambdaUpdate().eq(StoreProductGym::getExtId, extId).remove();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通用转换 + 批量保存,保持原有异常行为。
|
|
|
- */
|
|
|
- private <T> void convertAndSave(List<?> rawSubList, Integer extId, Class<T> clazz,
|
|
|
- BiConsumer<T, Integer> extSetter,
|
|
|
- Function<List<T>, Boolean> saveBatchFunc) {
|
|
|
- List<T> subList = rawSubList.stream()
|
|
|
- .map(v -> objectMapper.convertValue(v, clazz))
|
|
|
- .peek(v -> extSetter.accept(v, extId))
|
|
|
- .collect(Collectors.toList());
|
|
|
- boolean subSaved = saveBatchFunc.apply(subList);
|
|
|
- if (!subSaved) {
|
|
|
- throw new RuntimeException("子项保存失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<Boolean> deleteStoreProductItem(Integer id) {
|
|
|
- log.info("StoreProductItemServiceImpl.deleteStoreProductItem?id={}", id);
|
|
|
- boolean result = this.removeById(id);
|
|
|
- storeProductBarService.lambdaUpdate().eq(StoreProductBar::getExtId, id).remove();
|
|
|
- storeProductDelicaciesService.lambdaUpdate().eq(StoreProductDelicacies::getExtId, id).remove();
|
|
|
- storeProductGymService.lambdaUpdate().eq(StoreProductGym::getExtId, id).remove();
|
|
|
- if (result) {
|
|
|
- return R.success("删除成功");
|
|
|
- }
|
|
|
- return R.fail("删除失败");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<List<StoreProductItemDto>> getStoreProductItemById(Integer id,Integer modelType) {
|
|
|
- log.info("StoreProductItemServiceImpl.getStoreProductItemById?id={}", id);
|
|
|
- StoreProductItem storeProductItem = this.getById(id);
|
|
|
- if (storeProductItem != null) {
|
|
|
- ArrayList<StoreProductItemDto> list = new ArrayList<>();
|
|
|
- StoreProductItemDto storeProductItemDto = new StoreProductItemDto();
|
|
|
- list.add(storeProductItemDto);
|
|
|
- BeanUtils.copyProperties(storeProductItem,storeProductItemDto);
|
|
|
- List<?> sublist =null;
|
|
|
- if (modelType == CommonEnum.ModelType.BAR.getCode()) {
|
|
|
- sublist = storeProductBarService.getByExtId(id);
|
|
|
- }else if (modelType == CommonEnum.ModelType.DELICACY.getCode()) {
|
|
|
- sublist = storeProductDelicaciesService.getByExtId(id);
|
|
|
- }else if (modelType == CommonEnum.ModelType.GYM.getCode()) {
|
|
|
- sublist = storeProductGymService.getByExtId(id);
|
|
|
- }
|
|
|
- storeProductItemDto.setSubList(sublist);
|
|
|
- return R.data(list);
|
|
|
- }
|
|
|
- return R.fail("未找到数据");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<List<StoreProductItem>> listByProdType(Integer prodType) {
|
|
|
- log.info("StoreProductItemServiceImpl.listByProdType?prodType={}", prodType);
|
|
|
- if (prodType == null) {
|
|
|
- return R.fail("prodType不能为空");
|
|
|
- }
|
|
|
- List<StoreProductItem> result = lambdaQuery().eq(StoreProductItem::getProdType, prodType)
|
|
|
- .orderByDesc(StoreProductItem::getCreatedTime).list();
|
|
|
- return R.data(result);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public IPage<StoreProductItem> pageStoreProductItems(int pageNum, int pageSize,
|
|
|
- Integer storeId, String prodName, Integer prodType,
|
|
|
- Integer status, Integer needReserve) {
|
|
|
- log.info("StoreProductItemServiceImpl.pageStoreProductItems?pageNum={}, pageSize={}, storeId={}, prodName={}, prodType={}, status={}, needReserve={}",
|
|
|
- pageNum, pageSize, storeId, prodName, prodType, status, needReserve);
|
|
|
- Page<StoreProductItem> page = new Page<>(pageNum, pageSize);
|
|
|
- LambdaQueryWrapper<StoreProductItem> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(storeId != null, StoreProductItem::getStoreId, storeId)
|
|
|
- .eq(prodType != null, StoreProductItem::getProdType, prodType)
|
|
|
- .eq(status != null, StoreProductItem::getStatus, status)
|
|
|
- .eq(needReserve != null, StoreProductItem::getNeedReserve, needReserve)
|
|
|
- .like(StringUtils.hasText(prodName), StoreProductItem::getProdName, prodName)
|
|
|
- .orderByDesc(StoreProductItem::getCreatedTime);
|
|
|
- return this.page(page, wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public IPage<StoreProductItemGymVo> getPageWithGym(int pageNum, int pageSize, Integer storeId, String prodName, Integer prodType) {
|
|
|
- log.info("StoreProductItemServiceImpl.getPageWithGym?pageNum={}, pageSize={}, storeId={}, prodName={}, prodType={}",
|
|
|
- pageNum, pageSize, storeId, prodName, prodType);
|
|
|
- Page<StoreProductItemGymVo> page = new Page<>(pageNum, pageSize);
|
|
|
- if(prodType == 0){
|
|
|
- return baseMapper.getPageWithGym(page, storeId, prodName, null);
|
|
|
- }else{
|
|
|
- return baseMapper.getPageWithGym(page, storeId, prodName, prodType);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<StoreProductItemGymVo> getDetailWithGym(Long id) {
|
|
|
- log.info("StoreProductItemServiceImpl.getDetailWithGym?id={}", id);
|
|
|
- if (id == null) {
|
|
|
- return R.fail("ID不能为空");
|
|
|
- }
|
|
|
- StoreProductItemGymVo detail = baseMapper.getDetailWithGym(id);
|
|
|
- if (detail != null) {
|
|
|
- return R.data(detail);
|
|
|
- }
|
|
|
- return R.fail("查询失败,数据不存在");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public IPage<StoreProductItemDelicaciesVo> getPageWithDelicacies(int pageNum, int pageSize,
|
|
|
- Integer storeId, String name,
|
|
|
- String category, String extGroup,
|
|
|
- Integer status, Integer packageType) {
|
|
|
- log.info("StoreProductItemServiceImpl.getPageWithDelicacies?pageNum={}, pageSize={}, storeId={}, name={}, category={}, extGroup={}, status={}, packageType={}",
|
|
|
- pageNum, pageSize, storeId, name, category, extGroup, status, packageType);
|
|
|
-
|
|
|
- // 1. 查询主表store_product_item中关于美食的数据(prodType = 4)
|
|
|
- LambdaQueryWrapper<StoreProductItem> itemWrapper = new LambdaQueryWrapper<>();
|
|
|
- itemWrapper.eq(StoreProductItem::getProdType, 4)
|
|
|
- .eq(StoreProductItem::getDeleteFlag, 0);
|
|
|
-
|
|
|
- if (storeId != null) {
|
|
|
- itemWrapper.eq(StoreProductItem::getStoreId, storeId);
|
|
|
- }
|
|
|
- if (StringUtils.hasText(name)) {
|
|
|
- itemWrapper.like(StoreProductItem::getProdName, name);
|
|
|
- }
|
|
|
- if (status != null) {
|
|
|
- itemWrapper.eq(StoreProductItem::getStatus, status);
|
|
|
- }
|
|
|
-
|
|
|
- // 查询所有主表数据(不分页,用于后续合并)
|
|
|
- List<StoreProductItem> allItemList = this.list(itemWrapper);
|
|
|
- List<Integer> allItemIds = allItemList != null ? allItemList.stream()
|
|
|
- .map(StoreProductItem::getId)
|
|
|
- .collect(Collectors.toList()) : new ArrayList<>();
|
|
|
-
|
|
|
- // 2. 查询所有关联的子表数据
|
|
|
- LambdaQueryWrapper<StoreProductDelicacies> relatedDelicaciesWrapper = new LambdaQueryWrapper<>();
|
|
|
- if (!allItemIds.isEmpty()) {
|
|
|
- relatedDelicaciesWrapper.in(StoreProductDelicacies::getExtId, allItemIds)
|
|
|
- .eq(StoreProductDelicacies::getDeleteFlag, 0);
|
|
|
- } else {
|
|
|
- // 如果没有主表数据,设置一个不可能的条件
|
|
|
- relatedDelicaciesWrapper.eq(StoreProductDelicacies::getExtId, -1)
|
|
|
- .eq(StoreProductDelicacies::getDeleteFlag, 0);
|
|
|
- }
|
|
|
-
|
|
|
- // 子表筛选条件
|
|
|
- if (StringUtils.hasText(name)) {
|
|
|
- relatedDelicaciesWrapper.like(StoreProductDelicacies::getName, name);
|
|
|
- }
|
|
|
- if (StringUtils.hasText(category)) {
|
|
|
- relatedDelicaciesWrapper.eq(StoreProductDelicacies::getCategory, category);
|
|
|
- }
|
|
|
- if (StringUtils.hasText(extGroup)) {
|
|
|
- relatedDelicaciesWrapper.eq(StoreProductDelicacies::getExtGroup, extGroup);
|
|
|
- }
|
|
|
- if (status != null) {
|
|
|
- relatedDelicaciesWrapper.eq(StoreProductDelicacies::getStatus, status);
|
|
|
- }
|
|
|
-
|
|
|
- List<StoreProductDelicacies> relatedDelicaciesList = storeProductDelicaciesService.list(relatedDelicaciesWrapper);
|
|
|
-
|
|
|
- // 3. 查询独立的子表数据(extId为null或不在主表ID列表中的)
|
|
|
- LambdaQueryWrapper<StoreProductDelicacies> independentDelicaciesWrapper = new LambdaQueryWrapper<>();
|
|
|
- independentDelicaciesWrapper.eq(StoreProductDelicacies::getDeleteFlag, 0);
|
|
|
-
|
|
|
- // 独立的子表:extId为null,或者extId不在主表ID列表中
|
|
|
- if (allItemIds.isEmpty()) {
|
|
|
- // 如果没有主表数据,查询所有extId为null的子表数据
|
|
|
- independentDelicaciesWrapper.isNull(StoreProductDelicacies::getExtId);
|
|
|
- } else {
|
|
|
- // extId为null,或者extId不在主表ID列表中
|
|
|
- independentDelicaciesWrapper.and(wrapper -> wrapper.isNull(StoreProductDelicacies::getExtId)
|
|
|
- .or().notIn(StoreProductDelicacies::getExtId, allItemIds));
|
|
|
- }
|
|
|
-
|
|
|
- // 子表筛选条件
|
|
|
- if (StringUtils.hasText(name)) {
|
|
|
- independentDelicaciesWrapper.like(StoreProductDelicacies::getName, name);
|
|
|
- }
|
|
|
- if (StringUtils.hasText(category)) {
|
|
|
- independentDelicaciesWrapper.eq(StoreProductDelicacies::getCategory, category);
|
|
|
- }
|
|
|
- if (StringUtils.hasText(extGroup)) {
|
|
|
- independentDelicaciesWrapper.eq(StoreProductDelicacies::getExtGroup, extGroup);
|
|
|
- }
|
|
|
- if (status != null) {
|
|
|
- independentDelicaciesWrapper.eq(StoreProductDelicacies::getStatus, status);
|
|
|
- }
|
|
|
-
|
|
|
- List<StoreProductDelicacies> independentDelicaciesList = storeProductDelicaciesService.list(independentDelicaciesWrapper);
|
|
|
-
|
|
|
- // 4. 按extId分组,构建关联子表数据映射
|
|
|
- Map<Integer, List<StoreProductDelicaciesVo>> delicaciesMap = relatedDelicaciesList.stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- StoreProductDelicacies::getExtId,
|
|
|
- Collectors.mapping(delicacies -> convertToDelicaciesVo(delicacies), Collectors.toList())
|
|
|
- ));
|
|
|
-
|
|
|
- // 5. 组装结果列表
|
|
|
- List<StoreProductItemDelicaciesVo> resultList = new ArrayList<>();
|
|
|
-
|
|
|
- // 5.1 添加主表数据及其关联的子表数据
|
|
|
- if (allItemList != null) {
|
|
|
- for (StoreProductItem item : allItemList) {
|
|
|
- StoreProductItemDelicaciesVo vo = convertItemToVo(item);
|
|
|
- // 设置子表列表(一对多关系)
|
|
|
- List<StoreProductDelicaciesVo> subList = delicaciesMap.getOrDefault(item.getId(), new ArrayList<>());
|
|
|
- vo.setDelicaciesList(subList);
|
|
|
- resultList.add(vo);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 5.2 添加独立的子表数据(作为独立的记录,主表字段为空)
|
|
|
- for (StoreProductDelicacies delicacies : independentDelicaciesList) {
|
|
|
- StoreProductItemDelicaciesVo vo = new StoreProductItemDelicaciesVo();
|
|
|
- // 主表字段为空或null
|
|
|
- vo.setId(null);
|
|
|
- vo.setStoreId(null);
|
|
|
- // 子表字段
|
|
|
- vo.setDelicaciesId(delicacies.getId());
|
|
|
- vo.setExtId(delicacies.getExtId());
|
|
|
- vo.setName(delicacies.getName());
|
|
|
- vo.setPrice(delicacies.getPrice());
|
|
|
- vo.setCostPrice(delicacies.getCostPrice());
|
|
|
- vo.setUnit(delicacies.getUnit());
|
|
|
- vo.setQuantity(delicacies.getQuantity());
|
|
|
- vo.setCategory(delicacies.getCategory());
|
|
|
- vo.setExtGroup(delicacies.getExtGroup());
|
|
|
- vo.setDelicaciesStatus(delicacies.getStatus());
|
|
|
- vo.setDelicaciesDeleteFlag(delicacies.getDeleteFlag());
|
|
|
- vo.setDelicaciesCreatedUserId(delicacies.getCreatedUserId());
|
|
|
- vo.setDelicaciesUpdatedUserId(delicacies.getUpdatedUserId());
|
|
|
- vo.setDelicaciesCreatedTime(delicacies.getCreatedTime());
|
|
|
- vo.setDelicaciesUpdatedTime(delicacies.getUpdatedTime());
|
|
|
- // 子表列表只包含自己
|
|
|
- List<StoreProductDelicaciesVo> subList = new ArrayList<>();
|
|
|
- subList.add(convertToDelicaciesVo(delicacies));
|
|
|
- vo.setDelicaciesList(subList);
|
|
|
- resultList.add(vo);
|
|
|
- }
|
|
|
-
|
|
|
- // 6. 按创建时间倒序排序(主表或子表的创建时间)
|
|
|
- resultList.sort((a, b) -> {
|
|
|
- Date dateA = a.getDelicaciesCreatedTime() != null ? a.getDelicaciesCreatedTime() : a.getCreatedTime();
|
|
|
- Date dateB = b.getDelicaciesCreatedTime() != null ? b.getDelicaciesCreatedTime() : b.getCreatedTime();
|
|
|
- if (dateA == null && dateB == null) return 0;
|
|
|
- if (dateA == null) return 1;
|
|
|
- if (dateB == null) return -1;
|
|
|
- return dateB.compareTo(dateA); // 倒序
|
|
|
- });
|
|
|
-
|
|
|
- // 7. 手动分页
|
|
|
- int total = resultList.size();
|
|
|
- int start = (pageNum - 1) * pageSize;
|
|
|
- int end = Math.min(start + pageSize, total);
|
|
|
-
|
|
|
- List<StoreProductItemDelicaciesVo> pageList = start < total ? resultList.subList(start, end) : new ArrayList<>();
|
|
|
-
|
|
|
- // 8. 构建分页结果
|
|
|
- Page<StoreProductItemDelicaciesVo> resultPage = new Page<>(pageNum, pageSize);
|
|
|
- resultPage.setRecords(pageList);
|
|
|
- resultPage.setTotal(total);
|
|
|
- resultPage.setPages((int) Math.ceil((double) total / pageSize));
|
|
|
- resultPage.setCurrent(pageNum);
|
|
|
- resultPage.setSize(pageSize);
|
|
|
-
|
|
|
- return resultPage;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 将StoreProductItem转换为VO
|
|
|
- */
|
|
|
- private StoreProductItemDelicaciesVo convertItemToVo(StoreProductItem item) {
|
|
|
- StoreProductItemDelicaciesVo vo = new StoreProductItemDelicaciesVo();
|
|
|
- vo.setId(item.getId());
|
|
|
- vo.setStoreId(item.getStoreId());
|
|
|
- vo.setProdName(item.getProdName());
|
|
|
- vo.setTotalPrice(item.getTotalPrice());
|
|
|
- vo.setProdType(item.getProdType());
|
|
|
- vo.setImages(item.getImages());
|
|
|
- vo.setImageContent(item.getImageContent());
|
|
|
- vo.setDetailContent(item.getDetailContent());
|
|
|
- vo.setExtraNote(item.getExtraNote());
|
|
|
- vo.setNeedReserve(item.getNeedReserve());
|
|
|
- vo.setReserveRule(item.getReserveRule());
|
|
|
- vo.setPeopleLimit(item.getPeopleLimit());
|
|
|
- vo.setUsageRule(item.getUsageRule());
|
|
|
- vo.setStatus(item.getStatus());
|
|
|
- vo.setRejectionReason(item.getRejectionReason());
|
|
|
- vo.setDeleteFlag(item.getDeleteFlag());
|
|
|
- vo.setCreatedUserId(item.getCreatedUserId());
|
|
|
- vo.setUpdatedUserId(item.getUpdatedUserId());
|
|
|
- vo.setCreatedTime(item.getCreatedTime());
|
|
|
- vo.setUpdatedTime(item.getUpdatedTime());
|
|
|
- return vo;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 将StoreProductDelicacies转换为VO
|
|
|
- */
|
|
|
- private StoreProductDelicaciesVo convertToDelicaciesVo(StoreProductDelicacies delicacies) {
|
|
|
- StoreProductDelicaciesVo vo = new StoreProductDelicaciesVo();
|
|
|
- vo.setId(delicacies.getId());
|
|
|
- vo.setExtId(delicacies.getExtId());
|
|
|
- vo.setName(delicacies.getName());
|
|
|
- vo.setPrice(delicacies.getPrice());
|
|
|
- vo.setCostPrice(delicacies.getCostPrice());
|
|
|
- vo.setUnit(delicacies.getUnit());
|
|
|
- vo.setQuantity(delicacies.getQuantity());
|
|
|
- vo.setCategory(delicacies.getCategory());
|
|
|
- vo.setExtGroup(delicacies.getExtGroup());
|
|
|
- vo.setStatus(delicacies.getStatus());
|
|
|
- vo.setDeleteFlag(delicacies.getDeleteFlag());
|
|
|
- vo.setCreatedUserId(delicacies.getCreatedUserId());
|
|
|
- vo.setUpdatedUserId(delicacies.getUpdatedUserId());
|
|
|
- vo.setCreatedTime(delicacies.getCreatedTime());
|
|
|
- vo.setUpdatedTime(delicacies.getUpdatedTime());
|
|
|
- return vo;
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|