package org.skyer.goods.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.skyer.core.cache.ProcessCacheValue;
import org.skyer.core.domain.Page;
import org.skyer.core.domain.PageInfo;
import org.skyer.core.exception.CommonException;
import org.skyer.core.oauth.CustomUserDetails;
import org.skyer.core.oauth.DetailsHelper;
import org.skyer.goods.api.dto.*;
import org.skyer.goods.app.service.SkuEsService;
import org.skyer.goods.app.service.SkuService;
import org.skyer.goods.domain.dto.AuditDTO;
import org.skyer.goods.domain.dto.SkuAuditDTO;
import org.skyer.goods.domain.entity.*;
import org.skyer.goods.domain.repository.*;
import org.skyer.goods.domain.vo.*;
import org.skyer.goods.infra.util.Md5Utils;
import org.skyer.mybatis.domian.Condition;
import org.skyer.mybatis.util.Sqls;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.skyer.goods.domain.entity.Sku.*;
/**
* 商品规格表应用服务默认实现
*
* @author chenzz 2021-07-06 10:35:43
*/
@Slf4j
@Service
public class SkuServiceImpl implements SkuService {
@Autowired
private SkuRepository skuRepository;
@Autowired
private SkuAttributeValueRepository skuAttributeValueRepository;
@Autowired
private SkuDraftRepository skuDraftRepository;
@Autowired
private SkuAttributeValueDraftRepository skuAttributeValueDraftRepository;
@Autowired
private SkuAuditSettingRepository skuAuditSettingRepository;
@Autowired
private SpuRepository spuRepository;
@Autowired
private CategoryRepository categoryRepository;
@Autowired
private MaterialRepository materialRepository;
@Autowired
private BrandRepository brandRepository;
@Autowired
private SkuEsService skuEsService;
@Autowired
private SkuPackageRepository skuPackageRepository;
@Override
public Page<GoodsSkuPageVO> listPage(GoodsSkuPageDTO goodsSkuPageDTO) {
if (CollUtil.isNotEmpty(goodsSkuPageDTO.getCategoryIdList())) {
goodsSkuPageDTO.setCategoryIdList(categoryRepository.getLaterCategoryId(goodsSkuPageDTO.getCategoryIdList()));
}
Page<Sku> pageList = skuRepository.pageSku(goodsSkuPageDTO);
List<Sku> skuList = pageList.getContent();
List<GoodsSkuPageVO> pageVOS = new ArrayList<>();
if (CollUtil.isNotEmpty(skuList)) {
// 找出所有的商品数据
Set<Long> goodsIds = skuList.stream().map(Sku::getSpuId).collect(Collectors.toSet());
List<Spu> spuList = spuRepository.selectByCondition(Condition.builder(Spu.class)
.andWhere(Sqls.custom()
.andIn(org.skyer.goods.domain.entity.Spu.ID, goodsIds, true)
.andEqualTo(org.skyer.goods.domain.entity.Spu.DELETE_FLAG, false))
.build());
// 找出所有素材
Set<Long> materialIds = spuList.stream().map(Spu::getMaterialId).collect(Collectors.toSet());
List<Material> materialList = materialRepository.selectByCondition(Condition.builder(Material.class)
.andWhere(Sqls.custom()
.andIn("id", materialIds, true)
.andEqualTo(org.skyer.goods.domain.entity.Spu.DELETE_FLAG, false))
.build());
//组装返回数据
skuList.forEach(o -> {
GoodsSkuPageVO skuPageVO = new GoodsSkuPageVO();
//复制id 价格等信息
BeanUtils.copyProperties(o, skuPageVO);
//找到与sku匹配的spu
Spu tempSpu = spuList.stream().filter(xx -> xx.getId().longValue() == o.getSpuId().longValue()).findFirst().orElse(null);
if (ObjectUtil.isNotNull(tempSpu)) {
//设置sku属性字段
skuPageVO.setMaterialId(tempSpu.getMaterialId());
skuPageVO.setSpuName(tempSpu.getName());
skuPageVO.setSpuCode(tempSpu.getSpuCode());
if (ObjectUtil.isNotNull(tempSpu.getRemark())) {
skuPageVO.setGoodsRemark(tempSpu.getRemark());
}
String categoryName = categoryRepository.getCategoryNameById(tempSpu.getCategoryId());
skuPageVO.setCategoryName(categoryName);
//匹配素材
if (ObjectUtil.isNotNull(tempSpu.getMaterialId())) {
skuPageVO.setMaterialId(tempSpu.getMaterialId());
Material tempMaterial = materialList.stream().filter(xx -> xx.getId().longValue() == skuPageVO.getMaterialId().longValue()).findFirst().orElse(null);
if (ObjectUtil.isNotNull(tempMaterial)) {
skuPageVO.setMaterialMainImages(Arrays.asList(Optional.ofNullable(tempMaterial.getMainImage()).orElse("").split(",")));
skuPageVO.setMaterialName(tempMaterial.getMaterialName());
}
}
//查询属性值 是带入初始属性 否放入到额外属性
List<SkuAttributeValue> skuAttrValueRelationList = skuAttributeValueRepository.selectByCondition(Condition.builder(SkuAttributeValue.class)
.andWhere(Sqls.custom().andEqualTo(SkuAttributeValue.FIELD_SKU_ID, o.getId(), true))
.build());
if (CollUtil.isNotEmpty(skuAttrValueRelationList)) {
List<SkuAttributeValue> originalAttributeList = skuAttrValueRelationList.stream().filter(SkuAttributeValue::getIsSku).collect(Collectors.toList());
skuPageVO.setSkuAttributeList(originalAttributeList);
List<SkuAttributeValue> attachedAttributeList = skuAttrValueRelationList.stream().filter(f -> !f.getIsSku()).collect(Collectors.toList());
skuPageVO.setOtherAttributeList(attachedAttributeList);
}
}
pageVOS.add(skuPageVO);
});
}
return new Page<>(pageVOS, new PageInfo(pageList.getTotalPages(), pageList.getSize()), pageList.getTotalElements());
}
@Override
public GoodsSkuDetailVO getDetail(Long id, boolean isEdit) {
Sku sku = skuRepository.selectByPrimaryKey(id);
GoodsSkuDetailVO goodsSkuVO = new GoodsSkuDetailVO();
if (ObjectUtil.isNotEmpty(sku)) {
BeanUtils.copyProperties(sku, goodsSkuVO);
//如果是审核被驳回 需要去副本里寻找数据
if (isEdit && Sku.STATUS_TAKE_EFFECT_REJECTED.equals(sku.getStatus())) {
SkuDraft skuDraft = skuDraftRepository.selectByPrimaryKey(sku.getId());
if (ObjectUtil.isNotEmpty(skuDraft)) {
//把草稿里的属性覆盖给vo显示
BeanUtils.copyProperties(skuDraft, goodsSkuVO);
}
}
Spu spu = spuRepository.selectByPrimaryKey(sku.getSpuId());
if (ObjectUtil.isNotNull(spu)) {
//设置sku属性字段
goodsSkuVO.setMaterialId(spu.getMaterialId());
goodsSkuV
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一站式的中台系统包括订单管理系统OMS/ERP、库存WMS统一管理系统和SAP财务管理系统等,实现快速部署,并帮助企业后续自主进行开发迭代,来帮助企业实现数字化转型,并有多个经典案例。系统包括:通用业务中台、强大的技术中台Springcloud/Istio、后续开发方案的设计,技术(K8S,SERVERLESS)及管理人员的培训等。
资源推荐
资源详情
资源评论
收起资源包目录
电商业务中台OMS全渠道订单管理系统 (2000个子文件)
order-send.bpmn 3KB
index.css 414KB
vue-treeselect.min.css 24KB
waves.css 825B
Dockerfile 260B
Dockerfile 218B
.gitignore 5KB
index.html 488B
loading.html 461B
SkuServiceImpl.java 56KB
AfterSaleHeaderRepositoryImpl.java 55KB
HeaderServiceImpl.java 40KB
EsBoolQueryUtil.java 21KB
EsBoolQueryUtil.java 21KB
EsBoolQueryUtil.java 21KB
SpuInstallServiceServiceImpl.java 20KB
SkuEsServiceImpl.java 20KB
OrderEsServiceImpl.java 18KB
CommonConstants.java 18KB
SpuSonMumServiceImpl.java 17KB
ItemLineServiceImpl.java 16KB
StockoutEsServiceImpl.java 16KB
CategoryManageServiceImpl.java 15KB
OrderServiceImpl.java 15KB
StockEsServiceImpl.java 15KB
SpuServiceImpl.java 15KB
AdjustRecordServiceImpl.java 14KB
ItemLineRepositoryImpl.java 14KB
SpuEsServiceImpl.java 13KB
ItemSnapshot.java 11KB
ThirdHeaderServiceImpl.java 11KB
ItemServiceImpl.java 11KB
AfterSaleHeaderServiceImpl.java 11KB
ThirdOrderEsServiceImpl.java 11KB
HpfmMsgCodeConstants.java 10KB
HpfmMsgCodeConstants.java 10KB
HpfmMsgCodeConstants.java 10KB
ResultRecordServiceImpl.java 10KB
ThirdPartyAfterSaleHeaderRepositoryImpl.java 10KB
PriceItemSettingController.java 10KB
InstallServiceServiceImpl.java 10KB
Header.java 10KB
SalesOrganizationServiceImpl.java 9KB
OnlineShopServiceImpl.java 9KB
OutboundDeliveryOrderServiceImpl.java 9KB
OrderReportServiceImpl.java 9KB
StorageAreaServiceImpl.java 8KB
OrderItemLineConvertor.java 8KB
ShopServiceImpl.java 8KB
OutboundDeliveryOrder.java 8KB
ItemLine.java 8KB
PhysicalShopServiceImpl.java 8KB
WarehouseWarrantServiceImpl.java 8KB
OrderLogistics.java 8KB
SkuGroupServiceImpl.java 8KB
MaterialServiceImpl.java 8KB
AfterSaleHeader.java 7KB
ItemRepositoryImpl.java 7KB
CategoryRepositoryImpl.java 7KB
OrderController.java 7KB
ReceiverInfo.java 7KB
Constants.java 7KB
AfterSaleHeaderController.java 7KB
Constants.java 7KB
Constants.java 7KB
Constants.java 7KB
WarehouseResultServiceImpl.java 7KB
ThirdPartyAfterSaleSagaReturnService.java 7KB
ResultRecord.java 7KB
Coupon.java 7KB
WarehouseWarrant.java 7KB
ObjectConstant.java 7KB
Item.java 6KB
ItemSnapshotServiceImpl.java 6KB
JsonUtils.java 6KB
JsonUtils.java 6KB
JsonUtils.java 6KB
JsonUtils.java 6KB
FndConstants.java 6KB
FndConstants.java 6KB
FndConstants.java 6KB
RemoteCustomizeServiceImpl.java 6KB
RemoteCustomizeServiceImpl.java 6KB
RemoteCustomizeServiceImpl.java 6KB
RemoteCustomizeServiceImpl.java 6KB
Sku.java 6KB
RemoteCustomizeServiceImpl.java 6KB
WarehouseResult.java 6KB
CollectorsUtil.java 6KB
ThirdHeader.java 6KB
ThirdRefundSagaService.java 6KB
LabelServiceImpl.java 5KB
SpuInstallService.java 5KB
BrandServiceImpl.java 5KB
GoodsSkuController.java 5KB
ThirdOrderForWardSagaService.java 5KB
OrderForwardSagaService.java 5KB
ItemPriceServiceImpl.java 5KB
SalesOrganizationController.java 5KB
AfterSaleHeaderRepository.java 5KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- 翘楚时代2024-06-03资源简直太好了,完美解决了当下遇到的难题,这样的资源很难不支持~
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6823
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功