|
|
@@ -0,0 +1,645 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package org.springblade.salesPart.share.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.salesPart.brand.service.IBrandDescService;
|
|
|
+import org.springblade.salesPart.brand.service.IBrandFigureService;
|
|
|
+import org.springblade.salesPart.brand.service.IBrandFilesService;
|
|
|
+import org.springblade.salesPart.entity.*;
|
|
|
+import org.springblade.salesPart.excel.SharePutOnShelvesImportExcel;
|
|
|
+import org.springblade.salesPart.goods.service.IGoodsDescService;
|
|
|
+import org.springblade.salesPart.productLaunch.service.IProductLaunchFilesService;
|
|
|
+import org.springblade.salesPart.productLaunch.service.IProductLaunchService;
|
|
|
+import org.springblade.salesPart.share.entity.SharePutOnShelves;
|
|
|
+import org.springblade.salesPart.share.mapper.SharePutOnShelvesMapper;
|
|
|
+import org.springblade.salesPart.share.service.ISharePutOnShelvesService;
|
|
|
+import org.springblade.salesPart.share.vo.SharePutOnShelvesVO;
|
|
|
+import org.springblade.system.entity.Dept;
|
|
|
+import org.springblade.system.feign.ISysClient;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 轮胎商城-共享上架表 服务实现类
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2025-01-10
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class SharePutOnShelvesServiceImpl extends ServiceImpl<SharePutOnShelvesMapper, SharePutOnShelves> implements ISharePutOnShelvesService {
|
|
|
+
|
|
|
+
|
|
|
+ private final IProductLaunchService productLaunchService;
|
|
|
+
|
|
|
+ private final IGoodsDescService goodsDescService;
|
|
|
+
|
|
|
+ private final ISysClient iSysClient;
|
|
|
+
|
|
|
+ private final IBrandDescService brandDescService;
|
|
|
+
|
|
|
+ private final IProductLaunchFilesService productLaunchFilesService;
|
|
|
+
|
|
|
+ private final IBrandFilesService brandFilesService;
|
|
|
+
|
|
|
+ private final IBrandFigureService brandFigureService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<SharePutOnShelvesVO> selectSharePutOnShelvesPage(IPage<SharePutOnShelvesVO> page, SharePutOnShelvesVO sharePutOnShelves) {
|
|
|
+ return page.setRecords(baseMapper.selectSharePutOnShelvesPage(page, sharePutOnShelves));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R shareProductLaunchImport(List<PjProductLaunch> pjProductLaunchList) {
|
|
|
+ if (pjProductLaunchList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请选择导入共享商品");
|
|
|
+ }
|
|
|
+ List<PjProductLaunchFiles> pjProductLaunchFilesList = new ArrayList<>();
|
|
|
+ List<PjBrandFiles> pjBrandFilesList = new ArrayList<>();
|
|
|
+ List<BrandFigure> brandFigureList = new ArrayList<>();
|
|
|
+ List<Long> ids = pjProductLaunchList.stream().map(PjProductLaunch::getId).collect(Collectors.toList());
|
|
|
+ List<Long> brandIds = pjProductLaunchList.stream().map(PjProductLaunch::getBrandId).collect(Collectors.toList());
|
|
|
+ if (!ids.isEmpty()) {
|
|
|
+ pjProductLaunchFilesList = productLaunchFilesService.list(new QueryWrapper<PjProductLaunchFiles>()
|
|
|
+ .in("pid", ids).eq("is_deleted", 0));
|
|
|
+ }
|
|
|
+ if (!brandIds.isEmpty()) {
|
|
|
+ pjBrandFilesList = brandFilesService.list(new QueryWrapper<PjBrandFiles>()
|
|
|
+ .in("pid", brandIds).eq("is_deleted", 0));
|
|
|
+ brandFigureList = brandFigureService.list(new QueryWrapper<BrandFigure>()
|
|
|
+ .in("pid", brandIds).eq("is_deleted", 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SharePutOnShelves> sharePutOnShelvesList = new ArrayList<>();
|
|
|
+ for (PjProductLaunch item : pjProductLaunchList) {
|
|
|
+ item.setWhetherShare(1);
|
|
|
+ if (!pjProductLaunchFilesList.isEmpty()) {
|
|
|
+ List<PjProductLaunchFiles> list = pjProductLaunchFilesList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ item.setFilesList(list);
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotNull(item.getBrandId())) {
|
|
|
+ if (!brandFigureList.isEmpty()) {
|
|
|
+ List<BrandFigure> brandFigureList1 = brandFigureList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()) && e.getFigure().equals(item.getBrandItem()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!brandFigureList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(brandFigureList1, PjProductLaunchFiles.class));
|
|
|
+ } else {
|
|
|
+ if (!pjBrandFilesList.isEmpty()) {
|
|
|
+ List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjBarndFilesList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!pjBrandFilesList.isEmpty()) {
|
|
|
+ List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjBarndFilesList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotNull(item.getBrandId())) {
|
|
|
+ if (!brandFigureList.isEmpty()) {
|
|
|
+ List<BrandFigure> brandFigureList1 = brandFigureList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()) && e.getFigure().equals(item.getBrandItem()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!brandFigureList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(brandFigureList1, PjProductLaunchFiles.class));
|
|
|
+ } else {
|
|
|
+ if (!pjBrandFilesList.isEmpty()) {
|
|
|
+ List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjBarndFilesList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!pjBrandFilesList.isEmpty()) {
|
|
|
+ List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjBarndFilesList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SharePutOnShelves sharePutOnShelves = new SharePutOnShelves();
|
|
|
+ sharePutOnShelves.setCreateUser(AuthUtil.getUserId());
|
|
|
+ sharePutOnShelves.setCreateTime(new Date());
|
|
|
+ sharePutOnShelves.setTenantId(AuthUtil.getTenantId());
|
|
|
+ sharePutOnShelves.setGoodsId(item.getGoodsId());
|
|
|
+ sharePutOnShelves.setGoodsCode(item.getCode());
|
|
|
+ sharePutOnShelves.setGoodsName(item.getCname());
|
|
|
+ sharePutOnShelves.setGoodsInt(item.getCnameInt());
|
|
|
+ sharePutOnShelves.setSpecificationAndModel(item.getSpecificationAndModel());
|
|
|
+ sharePutOnShelves.setGoodsSize(item.getGoodsSize());
|
|
|
+ sharePutOnShelves.setBrandId(item.getBrandId());
|
|
|
+ sharePutOnShelves.setBrandName(item.getBrandName());
|
|
|
+ sharePutOnShelves.setGoodsDescription(item.getDetailsText());
|
|
|
+ sharePutOnShelves.setBrandItem(item.getBrandItem());
|
|
|
+ sharePutOnShelves.setPlaceProduction(item.getPlaceProduction());
|
|
|
+ sharePutOnShelves.setExplosionProof(item.getExplosionProof());
|
|
|
+ sharePutOnShelves.setOriginalFactory(item.getOriginalFactory());
|
|
|
+ sharePutOnShelves.setSelfRecovery(item.getSelfRecovery());
|
|
|
+ sharePutOnShelves.setSalesCompanyId(item.getSalesCompanyId());
|
|
|
+ sharePutOnShelves.setSalesCompanyName(item.getSalesCompanyName());
|
|
|
+ sharePutOnShelves.setInventory(item.getInventory());
|
|
|
+ sharePutOnShelves.setShareCost(item.getShareCost());
|
|
|
+ sharePutOnShelves.setPriceOne(item.getPriceOne());
|
|
|
+ sharePutOnShelves.setPriceTwo(item.getPriceTwo());
|
|
|
+ sharePutOnShelves.setPriceThree(item.getPriceThree());
|
|
|
+ sharePutOnShelves.setPriceFour(item.getPriceFour());
|
|
|
+ sharePutOnShelves.setProductLaunchId(item.getId());
|
|
|
+ sharePutOnShelves.setSrcTenantId(item.getTenantId());
|
|
|
+ sharePutOnShelves.setSrcSalesCompanyId(item.getSalesCompanyId());
|
|
|
+ sharePutOnShelves.setSrcSalesCompanyName(item.getSourceCompanyName());
|
|
|
+ sharePutOnShelves.setSrcGoodsId(item.getGoodsId());
|
|
|
+ sharePutOnShelves.setSrcGoodsCode(item.getCode());
|
|
|
+ sharePutOnShelves.setSrcGoodsName(item.getCname());
|
|
|
+ sharePutOnShelves.setSrcBrandId(item.getBrandId());
|
|
|
+ sharePutOnShelves.setSrcBrandName(item.getBrandName());
|
|
|
+ sharePutOnShelves.setBillType(0);
|
|
|
+ if (ObjectUtils.isNotNull(item.getFilesList()) && !item.getFilesList().isEmpty()) {
|
|
|
+ sharePutOnShelves.setUrl(item.getFilesList().get(0).getUrl());
|
|
|
+ }
|
|
|
+ sharePutOnShelvesList.add(sharePutOnShelves);
|
|
|
+ }
|
|
|
+ productLaunchService.updateBatchById(pjProductLaunchList);
|
|
|
+ this.saveOrUpdateBatch(sharePutOnShelvesList);
|
|
|
+ return R.data(sharePutOnShelvesList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R deleteByIds(List<Long> idList) {
|
|
|
+ List<SharePutOnShelves> sharePutOnShelvesList = baseMapper.selectList(new LambdaQueryWrapper<SharePutOnShelves>()
|
|
|
+ .in(SharePutOnShelves::getId, idList)
|
|
|
+ .eq(SharePutOnShelves::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(SharePutOnShelves::getIsDeleted, 0));
|
|
|
+ List<Long> productLaunchId = new ArrayList<>();
|
|
|
+ for (SharePutOnShelves item : sharePutOnShelvesList) {
|
|
|
+ if (0 == item.getBillType() && !"暂存".equals(item.getShareStatus())) {
|
|
|
+ throw new RuntimeException("商品:" + item.getGoodsName() + "已共享,请先取消共享后在操作");
|
|
|
+ } else if (1 == item.getBillType()) {
|
|
|
+ throw new RuntimeException("商品:" + item.getGoodsName() + "为共享商品,删除失败");
|
|
|
+ } else {
|
|
|
+ productLaunchId.add(item.getProductLaunchId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!productLaunchId.isEmpty()) {
|
|
|
+ List<PjProductLaunch> productLaunchList = productLaunchService.list(new LambdaQueryWrapper<PjProductLaunch>()
|
|
|
+ .eq(PjProductLaunch::getIsDeleted, 0)
|
|
|
+ .eq(PjProductLaunch::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(PjProductLaunch::getId, productLaunchId));
|
|
|
+ if (!productLaunchList.isEmpty()) {
|
|
|
+ for (PjProductLaunch item : productLaunchList) {
|
|
|
+ item.setWhetherShare(0);
|
|
|
+ }
|
|
|
+ productLaunchService.updateBatchById(productLaunchList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ baseMapper.deleteBatchIds(idList);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R batchConfirmSharing(String ids, String sharedCompany) {
|
|
|
+ List<SharePutOnShelves> sharePutOnShelvesList = baseMapper.selectList(new LambdaQueryWrapper<SharePutOnShelves>()
|
|
|
+ .eq(SharePutOnShelves::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(SharePutOnShelves::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(id,'" + ids + "')"));
|
|
|
+ if (sharePutOnShelvesList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请选择共享商品");
|
|
|
+ }
|
|
|
+ List<Dept> deptList = iSysClient.getDeptListByNames(sharedCompany);
|
|
|
+ if (deptList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请选择共享公司");
|
|
|
+ }
|
|
|
+ List<SharePutOnShelves> sharePutOnShelves = new ArrayList<>();
|
|
|
+ for (Dept deptItem : deptList) {
|
|
|
+ for (SharePutOnShelves item : sharePutOnShelvesList) {
|
|
|
+ if (0 != item.getBillType()) {
|
|
|
+ throw new RuntimeException(item.getGoodsName() + "商品为被共享商品,共享失败");
|
|
|
+ }
|
|
|
+ item.setShareStatus("已共享");
|
|
|
+ SharePutOnShelves shelves = new SharePutOnShelves();
|
|
|
+ shelves.setShareStatus("暂存");
|
|
|
+ shelves.setTenantId(deptItem.getTenantId());
|
|
|
+ shelves.setGoodsCode(item.getGoodsCode());
|
|
|
+ shelves.setGoodsName(item.getGoodsName());
|
|
|
+ shelves.setGoodsInt(item.getGoodsInt());
|
|
|
+ shelves.setSpecificationAndModel(item.getSpecificationAndModel());
|
|
|
+ shelves.setGoodsSize(item.getGoodsSize());
|
|
|
+ shelves.setBrandName(item.getBrandName());
|
|
|
+ shelves.setGoodsDescription(item.getGoodsDescription());
|
|
|
+ shelves.setBrandItem(item.getBrandItem());
|
|
|
+ shelves.setPlaceProduction(item.getPlaceProduction());
|
|
|
+ shelves.setExplosionProof(item.getExplosionProof());
|
|
|
+ shelves.setOriginalFactory(item.getOriginalFactory());
|
|
|
+ shelves.setSelfRecovery(item.getSelfRecovery());
|
|
|
+ shelves.setSalesCompanyId(deptItem.getId());
|
|
|
+ shelves.setSalesCompanyName(deptItem.getDeptName());
|
|
|
+ shelves.setInventory(item.getInventory());
|
|
|
+ shelves.setShareCost(item.getShareCost());
|
|
|
+ shelves.setPriceOne(item.getPriceOne());
|
|
|
+ shelves.setPriceTwo(item.getPriceTwo());
|
|
|
+ shelves.setPriceThree(item.getPriceThree());
|
|
|
+ shelves.setPriceFour(item.getPriceFour());
|
|
|
+ shelves.setProductLaunchId(item.getProductLaunchId());
|
|
|
+ shelves.setSrcTenantId(item.getSrcTenantId());
|
|
|
+ shelves.setSrcSalesCompanyId(item.getSrcSalesCompanyId());
|
|
|
+ shelves.setSrcSalesCompanyName(item.getSrcSalesCompanyName());
|
|
|
+ shelves.setSrcGoodsId(item.getGoodsId());
|
|
|
+ shelves.setSrcGoodsCode(item.getGoodsCode());
|
|
|
+ shelves.setSrcGoodsName(item.getGoodsName());
|
|
|
+ shelves.setSrcBrandId(item.getBrandId());
|
|
|
+ shelves.setSrcBrandName(item.getBrandName());
|
|
|
+ shelves.setBillType(1);
|
|
|
+ shelves.setSrcSharedId(item.getId());
|
|
|
+ shelves.setUrl(item.getUrl());
|
|
|
+ sharePutOnShelves.add(shelves);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.updateBatchById(sharePutOnShelvesList);
|
|
|
+ if (!sharePutOnShelves.isEmpty()) {
|
|
|
+ this.saveBatch(sharePutOnShelves);
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R batchRevokeSharing(String ids) {
|
|
|
+ List<SharePutOnShelves> sharePutOnShelvesList = baseMapper.selectList(new LambdaQueryWrapper<SharePutOnShelves>()
|
|
|
+ .eq(SharePutOnShelves::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(SharePutOnShelves::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(id,'" + ids + "')"));
|
|
|
+ if (sharePutOnShelvesList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请选择撤销共享商品");
|
|
|
+ }
|
|
|
+ for (SharePutOnShelves item : sharePutOnShelvesList) {
|
|
|
+ if (0 != item.getBillType()) {
|
|
|
+ throw new RuntimeException(item.getGoodsName() + "商品为被共享商品,撤销失败");
|
|
|
+ }
|
|
|
+ item.setShareStatus("暂存");
|
|
|
+ }
|
|
|
+ this.updateBatchById(sharePutOnShelvesList);
|
|
|
+ baseMapper.deleteBySharedId(ids);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R batchSharingConfirm(String ids) {
|
|
|
+ List<SharePutOnShelves> sharePutOnShelvesList = baseMapper.selectList(new LambdaQueryWrapper<SharePutOnShelves>()
|
|
|
+ .eq(SharePutOnShelves::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(SharePutOnShelves::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(id,'" + ids + "')"));
|
|
|
+ if (sharePutOnShelvesList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请选择商品");
|
|
|
+ }
|
|
|
+ String goodsCode = sharePutOnShelvesList.stream().map(SharePutOnShelves::getSrcGoodsCode).distinct().collect(Collectors.joining(","));
|
|
|
+ String brandName = sharePutOnShelvesList.stream().map(SharePutOnShelves::getSrcBrandName).distinct().collect(Collectors.joining(","));
|
|
|
+ List<PjGoodsDesc> goodsDescList = goodsDescService.list(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
|
+ .eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
+ .eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .apply("find_in_set(code,'" + goodsCode + "')"));
|
|
|
+ List<PjBrandDesc> brandDescList = brandDescService.list(new LambdaQueryWrapper<PjBrandDesc>()
|
|
|
+ .eq(PjBrandDesc::getIsDeleted, 0)
|
|
|
+ .eq(PjBrandDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .apply("find_in_set(cname,'" + brandName + "')"));
|
|
|
+
|
|
|
+ List<PjBrandDesc> brandDescListNew = new ArrayList<>();
|
|
|
+ for (SharePutOnShelves item : sharePutOnShelvesList) {
|
|
|
+ if (0 == item.getBillType()) {
|
|
|
+ throw new RuntimeException(item.getGoodsName() + "商品为共享商品,上架失败");
|
|
|
+ }
|
|
|
+ //品牌
|
|
|
+ PjBrandDesc brandDescSave = new PjBrandDesc();
|
|
|
+ brandDescSave.setCreateUser(AuthUtil.getUserId());
|
|
|
+ brandDescSave.setCreateDept(Long.parseLong(AuthUtil.getDeptId()));
|
|
|
+ brandDescSave.setCreateTime(new Date());
|
|
|
+ brandDescSave.setEnableOrNot(1);
|
|
|
+ brandDescSave.setCname(item.getSrcBrandName());
|
|
|
+ brandDescSave.setSalesCompanyId(item.getSalesCompanyId());
|
|
|
+ brandDescSave.setSalesCompanyName(item.getSalesCompanyName());
|
|
|
+ brandDescSave.setType("PP");
|
|
|
+ brandDescSave.setSort(1);
|
|
|
+ brandDescSave.setWhetherIntegral("0");
|
|
|
+ if (!brandDescList.isEmpty()) {
|
|
|
+ PjBrandDesc brandDesc = brandDescList.stream().filter(e -> e.getCname().equals(item.getSrcBrandName())).findFirst().orElse(null);
|
|
|
+ if (brandDesc == null) {
|
|
|
+ brandDescListNew.add(brandDescSave);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ brandDescListNew.add(brandDescSave);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!brandDescListNew.isEmpty()) {
|
|
|
+ brandDescService.saveBatch(brandDescListNew);
|
|
|
+ if (!brandDescList.isEmpty()) {
|
|
|
+ brandDescList.addAll(brandDescListNew);
|
|
|
+ } else {
|
|
|
+ brandDescList = brandDescListNew;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PjGoodsDesc> goodsDescListNew = new ArrayList<>();
|
|
|
+ for (SharePutOnShelves item : sharePutOnShelvesList) {
|
|
|
+ //商品
|
|
|
+ PjGoodsDesc goodsDesc = new PjGoodsDesc();
|
|
|
+ goodsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
+ goodsDesc.setCreateDept(Long.parseLong(AuthUtil.getDeptId()));
|
|
|
+ goodsDesc.setCreateTime(new Date());
|
|
|
+ goodsDesc.setCode(item.getSrcGoodsCode());
|
|
|
+ goodsDesc.setCname(item.getSrcGoodsName());
|
|
|
+ PjBrandDesc brandDesc = brandDescList.stream().filter(e -> e.getCname().equals(item.getSrcBrandName())).findFirst().orElse(null);
|
|
|
+ if (brandDesc != null) {
|
|
|
+ goodsDesc.setBrandId(brandDesc.getId());
|
|
|
+ goodsDesc.setBrandName(brandDesc.getCname());
|
|
|
+ }
|
|
|
+ goodsDesc.setSpecificationAndModel(item.getSpecificationAndModel());
|
|
|
+ goodsDesc.setBrandItem(item.getBrandItem());
|
|
|
+ goodsDesc.setPlaceProduction(item.getPlaceProduction());
|
|
|
+ goodsDesc.setCnameInt(item.getGoodsInt());
|
|
|
+ goodsDesc.setEnableOrNot(1);
|
|
|
+ goodsDesc.setGoodsDescription(item.getGoodsDescription());
|
|
|
+ goodsDesc.setSalesCompanyId(item.getSalesCompanyId());
|
|
|
+ goodsDesc.setSalesCompanyName(item.getSalesCompanyName());
|
|
|
+ goodsDesc.setExplosionProof(item.getExplosionProof());
|
|
|
+ goodsDesc.setOriginalFactory(item.getOriginalFactory());
|
|
|
+ goodsDesc.setSelfRecovery(item.getSelfRecovery());
|
|
|
+ goodsDesc.setWhetherIntegral("0");
|
|
|
+ goodsDesc.setGoodsSize(item.getGoodsSize());
|
|
|
+ if (!goodsDescList.isEmpty()) {
|
|
|
+ PjGoodsDesc goodsDetail = goodsDescList.stream().filter(e -> e.getCode().equals(item.getSrcGoodsCode())).findFirst().orElse(null);
|
|
|
+ if (goodsDetail == null) {
|
|
|
+ goodsDescListNew.add(goodsDesc);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ goodsDescListNew.add(goodsDesc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!goodsDescListNew.isEmpty()) {
|
|
|
+ goodsDescService.saveBatch(goodsDescListNew);
|
|
|
+ if (!goodsDescList.isEmpty()) {
|
|
|
+ goodsDescList.addAll(goodsDescListNew);
|
|
|
+ } else {
|
|
|
+ goodsDescList = goodsDescListNew;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (SharePutOnShelves item : sharePutOnShelvesList) {
|
|
|
+ item.setShareStatus("已确认");
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ if (!brandDescList.isEmpty()) {
|
|
|
+ PjBrandDesc brandDesc = brandDescList.stream().filter(e -> e.getCname().equals(item.getSrcBrandName())).findFirst().orElse(null);
|
|
|
+ if (brandDesc != null) {
|
|
|
+ item.setBrandId(brandDesc.getId());
|
|
|
+ item.setBrandName(brandDesc.getCname());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("品牌:" + item.getSrcBrandName() + "数据错误,请联系管理员");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("品牌:" + item.getSrcBrandName() + "数据错误,请联系管理员");
|
|
|
+ }
|
|
|
+ if (!goodsDescList.isEmpty()) {
|
|
|
+ PjGoodsDesc goodsDesc = goodsDescList.stream().filter(e -> e.getCode().equals(item.getSrcGoodsCode())).findFirst().orElse(null);
|
|
|
+ if (goodsDesc != null) {
|
|
|
+ item.setGoodsId(goodsDesc.getId());
|
|
|
+ item.setGoodsCode(goodsDesc.getCode());
|
|
|
+ item.setGoodsName(goodsDesc.getCname());
|
|
|
+ item.setGoodsInt(goodsDesc.getCnameInt());
|
|
|
+ item.setSpecificationAndModel(goodsDesc.getSpecificationAndModel());
|
|
|
+ item.setGoodsSize(goodsDesc.getGoodsSize());
|
|
|
+ item.setGoodsDescription(goodsDesc.getGoodsDescription());
|
|
|
+ item.setBrandItem(goodsDesc.getBrandItem());
|
|
|
+ item.setPlaceProduction(goodsDesc.getPlaceProduction());
|
|
|
+ item.setExplosionProof(goodsDesc.getExplosionProof());
|
|
|
+ item.setOriginalFactory(goodsDesc.getOriginalFactory());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("商品编码:" + item.getSrcGoodsCode() + "数据错误,请联系管理员");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("商品编码:" + item.getSrcGoodsCode() + "数据错误,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.updateBatchById(sharePutOnShelvesList);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R batchSharingRevoke(String ids) {
|
|
|
+ List<SharePutOnShelves> sharePutOnShelvesList = baseMapper.selectList(new LambdaQueryWrapper<SharePutOnShelves>()
|
|
|
+ .eq(SharePutOnShelves::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(SharePutOnShelves::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(id,'" + ids + "')"));
|
|
|
+ if (sharePutOnShelvesList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请选择撤销商品");
|
|
|
+ }
|
|
|
+ for (SharePutOnShelves item : sharePutOnShelvesList) {
|
|
|
+ if (0 == item.getBillType()) {
|
|
|
+ throw new RuntimeException(item.getGoodsName() + "商品为共享商品,撤销失败");
|
|
|
+ }
|
|
|
+ item.setShareStatus("暂存");
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ }
|
|
|
+ this.updateBatchById(sharePutOnShelvesList);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R importShareProductLaunch(List<SharePutOnShelvesImportExcel> excelList) {
|
|
|
+ String goodsName = excelList.stream().map(SharePutOnShelvesImportExcel::getGoodsName).collect(Collectors.joining(","));
|
|
|
+ List<PjProductLaunch> pjProductLaunchList = productLaunchService.list(new LambdaQueryWrapper<PjProductLaunch>()
|
|
|
+ .eq(PjProductLaunch::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjProductLaunch::getIsDeleted, 0)
|
|
|
+ .eq(PjProductLaunch::getWhetherIntegral, "0")
|
|
|
+ .eq(PjProductLaunch::getUpAndDownShelves, 1)
|
|
|
+ .apply("find_in_set(cname,'" + goodsName + "')"));
|
|
|
+ if (pjProductLaunchList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到上架数据");
|
|
|
+ }
|
|
|
+ List<PjProductLaunchFiles> pjProductLaunchFilesList = new ArrayList<>();
|
|
|
+ List<PjBrandFiles> pjBrandFilesList = new ArrayList<>();
|
|
|
+ List<BrandFigure> brandFigureList = new ArrayList<>();
|
|
|
+ List<Long> ids = pjProductLaunchList.stream().map(PjProductLaunch::getId).collect(Collectors.toList());
|
|
|
+ List<Long> brandIds = pjProductLaunchList.stream().map(PjProductLaunch::getBrandId).collect(Collectors.toList());
|
|
|
+ if (!ids.isEmpty()) {
|
|
|
+ pjProductLaunchFilesList = productLaunchFilesService.list(new QueryWrapper<PjProductLaunchFiles>()
|
|
|
+ .in("pid", ids).eq("is_deleted", 0));
|
|
|
+ }
|
|
|
+ if (!brandIds.isEmpty()) {
|
|
|
+ pjBrandFilesList = brandFilesService.list(new QueryWrapper<PjBrandFiles>()
|
|
|
+ .in("pid", brandIds).eq("is_deleted", 0));
|
|
|
+ brandFigureList = brandFigureService.list(new QueryWrapper<BrandFigure>()
|
|
|
+ .in("pid", brandIds).eq("is_deleted", 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SharePutOnShelves> sharePutOnShelvesList = new ArrayList<>();
|
|
|
+ List<PjProductLaunch> pjProductLaunchListNew = new ArrayList<>();
|
|
|
+ for (SharePutOnShelvesImportExcel excel : excelList) {
|
|
|
+ PjProductLaunch item = pjProductLaunchList.stream().filter(e -> e.getCname().equals(excel.getGoodsName())).findFirst().orElse(null);
|
|
|
+ if (item != null) {
|
|
|
+ item.setWhetherShare(1);
|
|
|
+ if (!pjProductLaunchFilesList.isEmpty()) {
|
|
|
+ List<PjProductLaunchFiles> list = pjProductLaunchFilesList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ item.setFilesList(list);
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotNull(item.getBrandId())) {
|
|
|
+ if (!brandFigureList.isEmpty()) {
|
|
|
+ List<BrandFigure> brandFigureList1 = brandFigureList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()) && e.getFigure().equals(item.getBrandItem()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!brandFigureList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(brandFigureList1, PjProductLaunchFiles.class));
|
|
|
+ } else {
|
|
|
+ if (!pjBrandFilesList.isEmpty()) {
|
|
|
+ List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjBarndFilesList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!pjBrandFilesList.isEmpty()) {
|
|
|
+ List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjBarndFilesList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotNull(item.getBrandId())) {
|
|
|
+ if (!brandFigureList.isEmpty()) {
|
|
|
+ List<BrandFigure> brandFigureList1 = brandFigureList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()) && e.getFigure().equals(item.getBrandItem()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!brandFigureList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(brandFigureList1, PjProductLaunchFiles.class));
|
|
|
+ } else {
|
|
|
+ if (!pjBrandFilesList.isEmpty()) {
|
|
|
+ List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjBarndFilesList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!pjBrandFilesList.isEmpty()) {
|
|
|
+ List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
+ .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjBarndFilesList1.isEmpty()) {
|
|
|
+ item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SharePutOnShelves sharePutOnShelves = new SharePutOnShelves();
|
|
|
+ sharePutOnShelves.setCreateUser(AuthUtil.getUserId());
|
|
|
+ sharePutOnShelves.setCreateTime(new Date());
|
|
|
+ sharePutOnShelves.setTenantId(AuthUtil.getTenantId());
|
|
|
+ sharePutOnShelves.setGoodsId(item.getGoodsId());
|
|
|
+ sharePutOnShelves.setGoodsCode(item.getCode());
|
|
|
+ sharePutOnShelves.setGoodsName(item.getCname());
|
|
|
+ sharePutOnShelves.setGoodsInt(item.getCnameInt());
|
|
|
+ sharePutOnShelves.setSpecificationAndModel(item.getSpecificationAndModel());
|
|
|
+ sharePutOnShelves.setGoodsSize(item.getGoodsSize());
|
|
|
+ sharePutOnShelves.setBrandId(item.getBrandId());
|
|
|
+ sharePutOnShelves.setBrandName(item.getBrandName());
|
|
|
+ sharePutOnShelves.setGoodsDescription(item.getDetailsText());
|
|
|
+ sharePutOnShelves.setBrandItem(item.getBrandItem());
|
|
|
+ sharePutOnShelves.setPlaceProduction(item.getPlaceProduction());
|
|
|
+ sharePutOnShelves.setExplosionProof(item.getExplosionProof());
|
|
|
+ sharePutOnShelves.setOriginalFactory(item.getOriginalFactory());
|
|
|
+ sharePutOnShelves.setSelfRecovery(item.getSelfRecovery());
|
|
|
+ sharePutOnShelves.setSalesCompanyId(item.getSalesCompanyId());
|
|
|
+ sharePutOnShelves.setSalesCompanyName(item.getSalesCompanyName());
|
|
|
+ sharePutOnShelves.setInventory(item.getInventory());
|
|
|
+ sharePutOnShelves.setShareCost(item.getShareCost());
|
|
|
+ sharePutOnShelves.setPriceOne(item.getPriceOne());
|
|
|
+ sharePutOnShelves.setPriceTwo(item.getPriceTwo());
|
|
|
+ sharePutOnShelves.setPriceThree(item.getPriceThree());
|
|
|
+ sharePutOnShelves.setPriceFour(item.getPriceFour());
|
|
|
+ sharePutOnShelves.setProductLaunchId(item.getId());
|
|
|
+ sharePutOnShelves.setSrcTenantId(item.getTenantId());
|
|
|
+ sharePutOnShelves.setSrcSalesCompanyId(item.getSalesCompanyId());
|
|
|
+ sharePutOnShelves.setSrcSalesCompanyName(item.getSourceCompanyName());
|
|
|
+ sharePutOnShelves.setSrcGoodsId(item.getGoodsId());
|
|
|
+ sharePutOnShelves.setSrcGoodsCode(item.getCode());
|
|
|
+ sharePutOnShelves.setSrcGoodsName(item.getCname());
|
|
|
+ sharePutOnShelves.setSrcBrandId(item.getBrandId());
|
|
|
+ sharePutOnShelves.setSrcBrandName(item.getBrandName());
|
|
|
+ sharePutOnShelves.setBillType(0);
|
|
|
+ if (ObjectUtils.isNotNull(item.getFilesList()) && !item.getFilesList().isEmpty()) {
|
|
|
+ sharePutOnShelves.setUrl(item.getFilesList().get(0).getUrl());
|
|
|
+ }
|
|
|
+ sharePutOnShelvesList.add(sharePutOnShelves);
|
|
|
+ pjProductLaunchListNew.add(item);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("商品:" + excel.getGoodsName() + "未查到上架数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ productLaunchService.updateBatchById(pjProductLaunchListNew);
|
|
|
+ this.saveOrUpdateBatch(sharePutOnShelvesList);
|
|
|
+ return R.data(sharePutOnShelvesList);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|