From 59b3ada695c171762a9f34bafbd5cd46c9fc1709 Mon Sep 17 00:00:00 2001 From: ah-max150 Date: Fri, 9 Oct 2026 14:15:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8F=91=E5=93=81=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E4=B8=BB=E5=86=85=E9=83=A8=E5=95=86=E5=93=81=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=EF=BC=8C=E6=94=B9=E7=94=B1=E8=AE=A2=E5=8D=95=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=85=9C=E5=BA=95=E5=BB=BA=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/dto/publish/PddGoodsPublishDTO.java | 4 -- .../impl/PddGoodsPublishServiceImpl.java | 39 ++------------ .../api/channel/pdd/goods/types/publish.ts | 1 - .../goods/publish/editor/PddPublishEditor.vue | 53 ------------------- .../editor/composables/use-publish-draft.ts | 28 ---------- .../channel/pdd/goods/publish/editor/types.ts | 2 - 6 files changed, 4 insertions(+), 123 deletions(-) diff --git a/apps/server/src/main/java/top/xyquan/ecomdmbbackend/modules/channel/pdd/goods/model/dto/publish/PddGoodsPublishDTO.java b/apps/server/src/main/java/top/xyquan/ecomdmbbackend/modules/channel/pdd/goods/model/dto/publish/PddGoodsPublishDTO.java index 08a3d8d2..ed7e3176 100644 --- a/apps/server/src/main/java/top/xyquan/ecomdmbbackend/modules/channel/pdd/goods/model/dto/publish/PddGoodsPublishDTO.java +++ b/apps/server/src/main/java/top/xyquan/ecomdmbbackend/modules/channel/pdd/goods/model/dto/publish/PddGoodsPublishDTO.java @@ -24,10 +24,6 @@ public class PddGoodsPublishDTO { */ private Long systemDraftId; - /** 渠道商品绑定的主内部商品 */ - @NotNull(message = "主内部商品不能为空") - private Long primaryProductId; - @NotBlank(message = "商品标题不能为空") private String goodsName; diff --git a/apps/server/src/main/java/top/xyquan/ecomdmbbackend/modules/channel/pdd/goods/service/impl/PddGoodsPublishServiceImpl.java b/apps/server/src/main/java/top/xyquan/ecomdmbbackend/modules/channel/pdd/goods/service/impl/PddGoodsPublishServiceImpl.java index af2ff188..d76ca8de 100644 --- a/apps/server/src/main/java/top/xyquan/ecomdmbbackend/modules/channel/pdd/goods/service/impl/PddGoodsPublishServiceImpl.java +++ b/apps/server/src/main/java/top/xyquan/ecomdmbbackend/modules/channel/pdd/goods/service/impl/PddGoodsPublishServiceImpl.java @@ -41,14 +41,11 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po. import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsPublishService; import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsService; import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.support.PddGoodsImageTransfer; -import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.service.PddProductAutoCreateService; import top.xyquan.ecomdmbbackend.modules.channel.pdd.pop.PddAuthFailureException; import top.xyquan.ecomdmbbackend.modules.channel.pdd.pop.goods.PddGoodsPopApiClient; import top.xyquan.ecomdmbbackend.modules.channel.pdd.pop.goods.PddGoodsPublishPopApiClient; import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.mapper.PddShopMapper; import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.model.po.PddShopPO; -import top.xyquan.ecomdmbbackend.modules.ec.product.mapper.ProductMapper; -import top.xyquan.ecomdmbbackend.modules.ec.product.model.po.ProductPO; import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.po.ProductSkuPO; import top.xyquan.ecomdmbbackend.modules.ec.product.sku.service.ProductSkuService; import top.xyquan.ecomdmbbackend.utils.CurrentUserContext; @@ -73,11 +70,9 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService { private final PddGoodsPublishPopApiClient publishPopApiClient; private final PddGoodsPopApiClient goodsPopApiClient; private final PddGoodsImageTransfer imageTransfer; - private final ProductMapper productMapper; private final ProductSkuService productSkuService; private final PddGoodsService pddGoodsService; private final PddGoodsMapper pddGoodsMapper; - private final PddProductAutoCreateService productAutoCreateService; private final PddGoodsPublishDraftMapper publishDraftMapper; public PddGoodsPublishServiceImpl(CurrentUserContext currentUserContext, @@ -86,11 +81,9 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService { PddGoodsPublishPopApiClient publishPopApiClient, PddGoodsPopApiClient goodsPopApiClient, PddGoodsImageTransfer imageTransfer, - ProductMapper productMapper, ProductSkuService productSkuService, PddGoodsService pddGoodsService, PddGoodsMapper pddGoodsMapper, - PddProductAutoCreateService productAutoCreateService, PddGoodsPublishDraftMapper publishDraftMapper) { this.currentUserContext = currentUserContext; this.pddShopMapper = pddShopMapper; @@ -98,11 +91,9 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService { this.publishPopApiClient = publishPopApiClient; this.goodsPopApiClient = goodsPopApiClient; this.imageTransfer = imageTransfer; - this.productMapper = productMapper; this.productSkuService = productSkuService; this.pddGoodsService = pddGoodsService; this.pddGoodsMapper = pddGoodsMapper; - this.productAutoCreateService = productAutoCreateService; this.publishDraftMapper = publishDraftMapper; } @@ -290,13 +281,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService { throw new BusinessException("发布成功但拉取商品详情为空 goodsId=" + addResult.goodsId()); } - ProductPO primary = productMapper.selectById(dto.getPrimaryProductId()); - if (primary == null || !Objects.equals(primary.getCompanyId(), companyId)) { - throw new BusinessException("主内部商品不存在或不属于当前公司"); - } - - // 主商品下补缺失 SKU(外商品已有 sku_code 会跳过,不挪绑) - productAutoCreateService.ensureMissingSkus(companyId, primary.getId(), detailInfo); + // 不定主内部商品;缺 SKU 由订单同步等路径兜底建品 pddGoodsService.upsertFromGoodsDetail( companyId, ctx.shop().getId(), ctx.mallId(), detailInfo); @@ -317,8 +302,8 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService { result.setGoods(goodsVo); bindSystemDraftAfterPublish(companyId, dto.getSystemDraftId(), addResult.goodsCommitId(), addResult.goodsId()); - log.info("拼多多商品发布成功 companyId={} shopId={} goodsId={} primaryProductId={}", - companyId, ctx.shop().getId(), addResult.goodsId(), primary.getId()); + log.info("拼多多商品发布成功 companyId={} shopId={} goodsId={}", + companyId, ctx.shop().getId(), addResult.goodsId()); return result; } catch (BusinessException e) { throw e; @@ -365,22 +350,6 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService { */ private PddGoodsPublishPopApiClient.GoodsAddCommand assembleAddCommand( PddGoodsPublishDTO dto, Long companyId, ShopAuth ctx, boolean strict) throws Exception { - String outGoodsId = null; - if (dto.getPrimaryProductId() != null) { - ProductPO primary = productMapper.selectById(dto.getPrimaryProductId()); - if (primary == null || !Objects.equals(primary.getCompanyId(), companyId)) { - if (strict) { - throw new BusinessException("主内部商品不存在或不属于当前公司"); - } - } else if (StringUtils.hasText(primary.getProductCode())) { - outGoodsId = primary.getProductCode().trim(); - } else if (strict) { - throw new BusinessException("主内部商品缺少商品编码,无法写入 out_goods_id"); - } - } else if (strict) { - throw new BusinessException("主内部商品不能为空"); - } - List skuDtos = dto.getSkus() == null ? List.of() : dto.getSkus(); if (strict && skuDtos.isEmpty()) { throw new BusinessException("SKU列表不能为空"); @@ -486,7 +455,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService { dto.getTwoPiecesDiscount() == null ? 95 : dto.getTwoPiecesDiscount(), carousel, detail, - outGoodsId, + null, mainImage, goodsProps, skuAdds); diff --git a/apps/web/apps/web-antd/src/api/channel/pdd/goods/types/publish.ts b/apps/web/apps/web-antd/src/api/channel/pdd/goods/types/publish.ts index 506686a5..fddc467e 100644 --- a/apps/web/apps/web-antd/src/api/channel/pdd/goods/types/publish.ts +++ b/apps/web/apps/web-antd/src/api/channel/pdd/goods/types/publish.ts @@ -4,7 +4,6 @@ export namespace PddGoodsPublishDTO { pddShopId: number; /** 关联系统草稿:发布成功后回写 goods_commit_id */ systemDraftId?: number; - primaryProductId: number; goodsName: string; goodsDesc?: string; catId: number; diff --git a/apps/web/apps/web-antd/src/views/channel/pdd/goods/publish/editor/PddPublishEditor.vue b/apps/web/apps/web-antd/src/views/channel/pdd/goods/publish/editor/PddPublishEditor.vue index 2221bef3..79b28f39 100644 --- a/apps/web/apps/web-antd/src/views/channel/pdd/goods/publish/editor/PddPublishEditor.vue +++ b/apps/web/apps/web-antd/src/views/channel/pdd/goods/publish/editor/PddPublishEditor.vue @@ -2,8 +2,6 @@ /** * 拼多多发布编辑器壳:编排 form + composables + 卡片,不含业务算法细节。 */ -import type { ProductVO } from '#/api/ec/product/types'; - import { onBeforeUnmount, onMounted, @@ -39,11 +37,8 @@ import { Tag, Tooltip, Upload, - message, } from 'ant-design-vue'; -import { getProductPageApi } from '#/api/ec/product'; - import CatPropertyField from './components/CatPropertyField.vue'; import SpecAxesCard from './components/SpecAxesCard.vue'; import SkuTableCard from './components/SkuTableCard.vue'; @@ -83,9 +78,6 @@ const hydratingDraft = ref(false); const skuRows = ref([]); const specAxes = ref([]); const specCatalog = ref([]); -const productOptions = ref<{ label: string; value: number; name: string }[]>( - [], -); /** 环依赖:specs ↔ sku,用可变实现在装配后回填 */ let syncSkuRowsFromSpecsImpl: (opts?: { @@ -139,23 +131,6 @@ rebuildPreservingImpl = specs.rebuildSpecCatalogPreservingUserData; buildSpecCatalogImpl = specs.buildSpecCatalog; clearSkuRowsImpl = sku.clearSkuRows; -async function loadProducts(keyword = '') { - try { - const data = await getProductPageApi({ - page: 1, - pageSize: 50, - filters: keyword ? { keywords: keyword } : {}, - }); - productOptions.value = (data.records ?? []).map((p: ProductVO.Info) => ({ - label: `${p.name}${p.productCode ? ` (${p.productCode})` : ''}`, - value: p.id, - name: p.name, - })); - } catch { - message.error('加载内部商品失败'); - } -} - function handleClose() { resetAll(); emit('close'); @@ -178,8 +153,6 @@ const draft = usePublishDraft({ selectedCatPathLabel: category.selectedCatPathLabel, allNonSaleProps: category.allNonSaleProps, nonSaleProps: category.nonSaleProps, - productOptions, - loadProducts, specAxes, specCatalog, normalizeSpecValueSlots: specs.normalizeSpecValueSlots, @@ -216,17 +189,6 @@ const agent = usePublishAgent({ revokeUploadFiles: images.revokeUploadFiles, }); -watch( - () => form.primaryProductId, - (id) => { - if (!id) return; - const p = productOptions.value.find((x) => x.value === id); - if (p && !form.goodsName) { - form.goodsName = p.name; - } - }, -); - watch( () => props.open ?? true, (v) => { @@ -235,7 +197,6 @@ watch( form.pddShopId = props.presetPddShopId ?? undefined; } void category.loadShops(); - void loadProducts(); void sku.loadSkuCandidates(); if (props.draftId) { void draft.hydrateFromDraft(props.draftId); @@ -250,7 +211,6 @@ onMounted(() => { form.pddShopId = props.presetPddShopId ?? undefined; } void category.loadShops(); - void loadProducts(); void sku.loadSkuCandidates(); if (props.draftId) { void draft.hydrateFromDraft(props.draftId); @@ -492,19 +452,6 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
- -