Compare commits

...
2 Commits
8 changed files with 357 additions and 284 deletions
@@ -14,6 +14,11 @@ API文档/商品API/pdd.goods.add
单个商品发布,需要配合pdd.goods.img.upload上传主图及商品详情图片。
> **与本系统 `PddGoodsPublishDTO` 对照**(勿与轮播混淆)
> - `carousel_gallery` → `carouselImages`(商品轮播图,1:1,必填)
> - `detail_gallery` → `detailImages`(商品详情图,必填)
> - `image_url` → `imageUrl`(**商品主图**,首页大图 750×352,非必填;部分活动必填)
### 公共参数
@@ -63,15 +63,24 @@ public class PddGoodsPublishDTO {
@Max(value = 100, message = "满两件折扣范围为0-100")
private Integer twoPiecesDiscount = 95;
/** 轮播图:本系统 fileId,或已是拼多多 CDN 的 URL */
/**
* 商品轮播图,对应开放平台 {@code carousel_gallery}(必填)。
* 入参为本系统 fileId 或已转传的拼多多 CDN URL;规格见 pdd.goods.add 文档。
*/
@NotEmpty(message = "轮播图不能为空")
private List<String> carouselImages;
/** 详情图 */
/**
* 商品详情图,对应开放平台 {@code detail_gallery}(必填)。
* 入参为本系统 fileId 或已转传的 URL;规格见 pdd.goods.add 文档。
*/
@NotEmpty(message = "详情图不能为空")
private List<String> detailImages;
/** 活动主图(可选):fileId 或 URL */
/**
* 商品主图,对应开放平台 {@code image_url}(非必填;参加部分活动则必填)。
* 与轮播图不同:首页大图 750×352 等约束见 pdd.goods.add 文档。入参为 fileId 或 URL。
*/
private String imageUrl;
/** 商品属性(类目模板非销售属性) */
@@ -37,7 +37,7 @@ public class PddGoodsPublishSkuDTO {
@NotNull(message = "重量不能为空")
private Long weight;
/** 缩略图:fileId 或 URL */
/** SKU 缩略图,对应 sku_list.thumb_url(必填);fileId 或已转传 URL */
@NotBlank(message = "SKU缩略图不能为空")
private String thumbImage;
@@ -344,6 +344,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
/**
* 组装 POP 商品命令。strict=true 走发布强校验;false 仅要求能组包,缺图/SKU 交给平台报错。
* 图片:carouselImages/detailImages/imageUrl 分别映射 carousel_gallery、detail_gallery、image_url(商品主图)。
*/
private PddGoodsPublishPopApiClient.GoodsAddCommand assembleAddCommand(
PddGoodsPublishDTO dto, Long companyId, ShopAuth ctx, boolean strict) throws Exception {
@@ -726,6 +726,11 @@ public class PddGoodsPublishPopApiClient {
String specIdList, List<SkuPropertyItem> skuProperties) {
}
/**
* pdd.goods.add / 草稿提交共用上行;字段名与开放平台一致。
* 与 {@link top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishDTO}
* 映射:carouselImages→carouselGallery,detailImages→detailGallery,imageUrl→imageUrl(商品主图)。
*/
public record GoodsAddCommand(
String goodsName,
String goodsDesc,
@@ -2,7 +2,7 @@
export namespace PddGoodsPublishDTO {
export interface Publish {
pddShopId: number;
/** 关联系统草稿:发布成功后回写 goods_commit_id */
/** 关联系统草稿 ID;正式发布成功后更新草稿状态并累加店铺发布次数 */
systemDraftId?: number;
goodsName: string;
goodsDesc?: string;
@@ -16,9 +16,11 @@ export namespace PddGoodsPublishDTO {
secondHand: boolean;
/** 满2件折扣 0-100,默认 95 */
twoPiecesDiscount: number;
/** fileId 字符串或已转传的 URL */
/** 轮播图 carousel_gallery(必填);fileId 或已转传 URL,规格见 pdd.goods.add */
carouselImages: string[];
/** 详情图 detail_gallery(必填);fileId 或已转传 URL */
detailImages: string[];
/** 商品主图 image_url(可选,部分活动必填);与轮播图不同,750×352 等见 pdd.goods.add */
imageUrl?: string;
goodsProperties?: GoodsProperty[];
skus: PublishSku[];
@@ -46,6 +48,7 @@ export namespace PddGoodsPublishDTO {
multiPriceFen: number;
quantity: number;
weight: number;
/** SKU 缩略图 thumb_url(必填);fileId 或已转传 URL */
thumbImage: string;
specIdList: string;
isOnsale?: number;
@@ -450,292 +450,303 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
</Teleport>
<div
class="min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-y-contain px-4 py-3"
class="publish-editor-sections min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-4 py-4"
>
<div
data-agent-field="goodsName"
:class="{ 'agent-typing-field': agentTypingField === 'goodsName' }"
>
<Form.Item label="商品标题" required>
<Input v-model:value="form.goodsName" :maxlength="60" show-count />
</Form.Item>
</div>
<div
data-agent-field="goodsDesc"
:class="{ 'agent-typing-field': agentTypingField === 'goodsDesc' }"
>
<Form.Item label="商品描述">
<Input.TextArea
v-model:value="form.goodsDesc"
:rows="2"
placeholder="可选,20-500 字"
/>
</Form.Item>
</div>
<Form.Item label="运费模板" required>
<Select
v-model:value="form.costTemplateId"
class="w-full"
:options="logisticsOptions"
placeholder="选择运费模板"
show-search
option-filter-prop="label"
:disabled="!form.pddShopId"
allow-clear
@change="(v: any) => loadCostTemplateDetail(v)"
/>
</Form.Item>
<Card
v-if="form.costTemplateId || costTemplateDetailLoading"
size="small"
class="mb-3"
title="运费模板详情"
>
<Spin :spinning="costTemplateDetailLoading">
<template v-if="costTemplateDetail">
<Descriptions bordered size="small" :column="2" class="mb-3">
<Descriptions.Item label="模板名称">
{{ costTemplateDetail.templateName || '-' }}
</Descriptions.Item>
<Descriptions.Item label="计费方式">
{{ costTemplateDetail.costTypeLabel || '-' }}
</Descriptions.Item>
<Descriptions.Item label="增值服务">
{{ costTemplateDetail.additionalServiceLabel || '-' }}
</Descriptions.Item>
<Descriptions.Item label="其它">
<Space :size="4" wrap>
<Tag v-if="costTemplateDetail.sfFree" color="success">
顺丰包邮
</Tag>
<Tag
v-if="costTemplateDetail.freeDeliverHouse"
color="processing"
>
包邮区送货上门
</Tag>
<span
v-if="
!costTemplateDetail.sfFree &&
!costTemplateDetail.freeDeliverHouse
"
>
-
</span>
</Space>
</Descriptions.Item>
<Descriptions.Item label="包邮省份" :span="2">
<div
v-if="costTemplateDetail.freeProvinces?.length"
class="free-province-tags"
>
<Tag
v-for="(p, idx) in costTemplateDetail.freeProvinces"
:key="`${p.provinceId}-${idx}`"
>
{{ p.province || p.provinceId }}
</Tag>
</div>
<span v-else>暂无</span>
</Descriptions.Item>
<Descriptions.Item
v-if="costTemplateDetail.freeDeliverHouseAreas?.length"
label="送货上门地区"
:span="2"
>
{{
costTemplateDetail.freeDeliverHouseAreas
.map((a) => a.areaText)
.filter(Boolean)
.join('、') || '-'
}}
</Descriptions.Item>
</Descriptions>
<Table
v-if="costTemplateDetail.paidRegions?.length"
size="small"
:pagination="false"
:data-source="costTemplateDetail.paidRegions"
:row-key="(_: any, i?: number) => `paid-${i ?? 0}`"
:columns="[
{ title: '买家付邮地区', dataIndex: 'provincesText' },
{ title: '首费规则', key: 'first', width: 160 },
{ title: '续费规则', key: 'add', width: 160 },
{ title: '条件包邮', dataIndex: 'freeRuleText', width: 160 },
]"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'first'">
首{{ record.firstStandard ?? '-'
}}{{ costTemplateDetail?.costType === 1 ? 'kg' : '件' }}
/ {{ record.firstCostYuan ?? '-' }}元
</template>
<template v-else-if="column.key === 'add'">
续{{ record.addStandard ?? '-'
}}{{ costTemplateDetail?.costType === 1 ? 'kg' : '件' }}
/ {{ record.addCostYuan ?? '-' }}元
</template>
</template>
</Table>
</template>
<Empty
v-else-if="!costTemplateDetailLoading"
description="暂无模板详情"
:image="Empty.PRESENTED_IMAGE_SIMPLE"
/>
</Spin>
</Card>
<div class="grid grid-cols-2 gap-3">
<Form.Item label="参考价(元)" required>
<InputNumber
v-model:value="form.marketPriceYuan"
class="w-full"
:min="0.01"
:precision="2"
/>
</Form.Item>
<Form.Item label="发货时限" required>
<Select
v-model:value="form.shipmentLimitSecond"
class="w-full"
:options="[
{ label: '24小时', value: 86400 },
{ label: '48小时', value: 172800 },
]"
/>
</Form.Item>
<Form.Item label="满两件折扣" required>
<InputNumber
v-model:value="form.twoPiecesDiscount"
class="w-full"
:min="0"
:max="10"
:precision="1"
:step="0.1"
placeholder="9.5 表示 9.5 折,0 取消"
/>
</Form.Item>
</div>
<div class="flex flex-wrap gap-6">
<Form.Item label="假一赔十" required>
<Switch v-model:checked="form.isFolt" />
</Form.Item>
<Form.Item label="7天无理由" required>
<Switch v-model:checked="form.isRefundable" />
</Form.Item>
<Form.Item label="预售" required>
<Switch v-model:checked="form.isPreSale" />
</Form.Item>
<Form.Item label="二手" required>
<Switch v-model:checked="form.secondHand" />
</Form.Item>
</div>
<template v-if="nonSaleProps.length">
<div class="mb-1 text-sm font-medium">类目属性</div>
<div class="grid grid-cols-2 gap-3">
<Form.Item
v-for="p in nonSaleProps"
:key="String(p.refPid)"
:label="p.name"
:required="!!p.required"
>
<CatPropertyField
v-model:value="form.goodsPropValues[String(p.refPid)]"
v-model:unit="form.goodsPropUnits[String(p.refPid)]"
:property="p"
<Card size="small" class="publish-editor-section" title="基础信息">
<div
data-agent-field="goodsName"
:class="{ 'agent-typing-field': agentTypingField === 'goodsName' }"
>
<Form.Item label="商品标题" required>
<Input v-model:value="form.goodsName" :maxlength="60" show-count />
</Form.Item>
</div>
<div
data-agent-field="goodsDesc"
:class="{ 'agent-typing-field': agentTypingField === 'goodsDesc' }"
>
<Form.Item label="商品描述">
<Input.TextArea
v-model:value="form.goodsDesc"
:rows="2"
placeholder="可选,20-500 字"
/>
</Form.Item>
</div>
</template>
<div class="grid grid-cols-2 gap-4">
<Form.Item label="轮播图" required>
<Upload
v-model:file-list="carouselFileList"
list-type="picture-card"
accept="image/jpeg,image/png,image/jpg"
:before-upload="beforeUploadCarousel"
:on-preview="onPreviewUploadFile"
:on-remove="onRemoveCarousel"
>
<div>
<PlusOutlined />
<div class="mt-1 text-xs">选择</div>
</div>
</Upload>
</Form.Item>
<Form.Item label="详情图" required>
<Upload
v-model:file-list="detailFileList"
list-type="picture-card"
accept="image/jpeg,image/png,image/jpg"
:before-upload="beforeUploadDetail"
:on-preview="onPreviewUploadFile"
:on-remove="onRemoveDetail"
>
<div>
<PlusOutlined />
<div class="mt-1 text-xs">选择</div>
</div>
</Upload>
</Form.Item>
</div>
<template v-if="nonSaleProps.length">
<div class="mb-1 text-sm font-medium">类目属性</div>
<div class="grid grid-cols-2 gap-3">
<Form.Item
v-for="p in nonSaleProps"
:key="String(p.refPid)"
:label="p.name"
:required="!!p.required"
>
<CatPropertyField
v-model:value="form.goodsPropValues[String(p.refPid)]"
v-model:unit="form.goodsPropUnits[String(p.refPid)]"
:property="p"
/>
</Form.Item>
</div>
</template>
<div
v-if="form.catId"
data-agent-field="spec"
class="space-y-4"
:class="{ 'agent-typing-field': agentTypingField === 'spec' }"
>
<SpecAxesCard
:spec-catalog="specCatalog"
:spec-axes="specAxes"
:can-add-spec-axis="canAddSpecAxis"
:catalog-options-for-axis="catalogOptionsForAxis"
:spec-value-display="specValueDisplay"
:spec-value-auto-options="specValueAutoOptions"
@set-list-ref="onSpecAxesListRef"
@axis-catalog-change="onAxisCatalogChange"
@spec-value-input="onSpecValueInput"
@spec-value-commit="onSpecValueCommit"
@spec-value-enter="onSpecValueEnter"
@add-spec-value="addSpecValueSlot"
@remove-spec-value="removeSpecValue"
@remove-spec-axis="removeSpecAxis"
@add-spec-axis="addSpecAxis"
<div class="grid grid-cols-2 gap-4">
<Form.Item label="轮播图" required>
<Upload
v-model:file-list="carouselFileList"
list-type="picture-card"
accept="image/jpeg,image/png,image/jpg"
:before-upload="beforeUploadCarousel"
:on-preview="onPreviewUploadFile"
:on-remove="onRemoveCarousel"
>
<div>
<PlusOutlined />
<div class="mt-1 text-xs">选择</div>
</div>
</Upload>
</Form.Item>
<Form.Item label="详情图" required>
<Upload
v-model:file-list="detailFileList"
list-type="picture-card"
accept="image/jpeg,image/png,image/jpg"
:before-upload="beforeUploadDetail"
:on-preview="onPreviewUploadFile"
:on-remove="onRemoveDetail"
>
<div>
<PlusOutlined />
<div class="mt-1 text-xs">选择</div>
</div>
</Upload>
</Form.Item>
</div>
</Card>
<Card size="small" class="publish-editor-section" title="规格与库存">
<div
v-if="form.catId"
data-agent-field="spec"
class="publish-editor-spec-stack"
:class="{ 'agent-typing-field': agentTypingField === 'spec' }"
>
<SpecAxesCard
:spec-catalog="specCatalog"
:spec-axes="specAxes"
:can-add-spec-axis="canAddSpecAxis"
:catalog-options-for-axis="catalogOptionsForAxis"
:spec-value-display="specValueDisplay"
:spec-value-auto-options="specValueAutoOptions"
@set-list-ref="onSpecAxesListRef"
@axis-catalog-change="onAxisCatalogChange"
@spec-value-input="onSpecValueInput"
@spec-value-commit="onSpecValueCommit"
@spec-value-enter="onSpecValueEnter"
@add-spec-value="addSpecValueSlot"
@remove-spec-value="removeSpecValue"
@remove-spec-axis="removeSpecAxis"
@add-spec-axis="addSpecAxis"
/>
<SkuTableCard
v-model:bind-pick-sku-ids="bindPickSkuIds"
:sku-select-options="skuSelectOptions"
:sku-rows="skuRows"
:spec-axes-length="specAxes.length"
:sku-table-columns="skuTableColumns"
:sku-table-scroll-x="skuTableScrollX"
:sku-spec-cell-display="skuSpecCellDisplay"
:sku-spec-cell-auto-options="skuSpecCellAutoOptions"
:before-upload-sku="beforeUploadSku"
:on-preview-upload-file="onPreviewUploadFile"
@search="debouncedLoadSkuCandidates"
@dropdown-visible-change="onSkuSelectDropdownOpen"
@apply-internal-skus="applyInternalSkusInOrder"
@clear-internal-skus="clearInternalSkuBindings"
@set-table-wrap-ref="onSkuTableWrapRef"
@sku-spec-input="onSkuSpecCellInput"
@sku-spec-commit="onSkuSpecCellCommit"
@out-sku-sn-change="onOutSkuSnChange"
@out-sku-sn-blur="onOutSkuSnBlur"
@bind-internal-sku="bindInternalSku"
@sku-thumb-file-list-change="onSkuThumbFileListChange"
@apply-batch="applySkuBatchFields"
/>
</div>
<Empty
v-else
description="请先选择叶子类目"
:image="Empty.PRESENTED_IMAGE_SIMPLE"
/>
</Card>
<SkuTableCard
v-model:bind-pick-sku-ids="bindPickSkuIds"
:sku-select-options="skuSelectOptions"
:sku-rows="skuRows"
:spec-axes-length="specAxes.length"
:sku-table-columns="skuTableColumns"
:sku-table-scroll-x="skuTableScrollX"
:sku-spec-cell-display="skuSpecCellDisplay"
:sku-spec-cell-auto-options="skuSpecCellAutoOptions"
:before-upload-sku="beforeUploadSku"
:on-preview-upload-file="onPreviewUploadFile"
@search="debouncedLoadSkuCandidates"
@dropdown-visible-change="onSkuSelectDropdownOpen"
@apply-internal-skus="applyInternalSkusInOrder"
@clear-internal-skus="clearInternalSkuBindings"
@set-table-wrap-ref="onSkuTableWrapRef"
@sku-spec-input="onSkuSpecCellInput"
@sku-spec-commit="onSkuSpecCellCommit"
@out-sku-sn-change="onOutSkuSnChange"
@out-sku-sn-blur="onOutSkuSnBlur"
@bind-internal-sku="bindInternalSku"
@sku-thumb-file-list-change="onSkuThumbFileListChange"
@apply-batch="applySkuBatchFields"
/>
</div>
<Card size="small" class="publish-editor-section" title="服务与承诺">
<Form.Item label="运费模板" required>
<Select
v-model:value="form.costTemplateId"
class="w-full"
:options="logisticsOptions"
placeholder="选择运费模板"
show-search
option-filter-prop="label"
:disabled="!form.pddShopId"
allow-clear
@change="(v: any) => loadCostTemplateDetail(v)"
/>
</Form.Item>
<Card
v-if="form.costTemplateId || costTemplateDetailLoading"
size="small"
class="cost-template-detail-card"
title="运费模板详情"
>
<Spin :spinning="costTemplateDetailLoading">
<template v-if="costTemplateDetail">
<Descriptions bordered size="small" :column="2" class="mb-3">
<Descriptions.Item label="模板名称">
{{ costTemplateDetail.templateName || '-' }}
</Descriptions.Item>
<Descriptions.Item label="计费方式">
{{ costTemplateDetail.costTypeLabel || '-' }}
</Descriptions.Item>
<Descriptions.Item label="增值服务">
{{ costTemplateDetail.additionalServiceLabel || '-' }}
</Descriptions.Item>
<Descriptions.Item label="其它">
<Space :size="4" wrap>
<Tag v-if="costTemplateDetail.sfFree" color="success">
顺丰包邮
</Tag>
<Tag
v-if="costTemplateDetail.freeDeliverHouse"
color="processing"
>
包邮区送货上门
</Tag>
<span
v-if="
!costTemplateDetail.sfFree &&
!costTemplateDetail.freeDeliverHouse
"
>
-
</span>
</Space>
</Descriptions.Item>
<Descriptions.Item label="包邮省份" :span="2">
<div
v-if="costTemplateDetail.freeProvinces?.length"
class="free-province-tags"
>
<Tag
v-for="(p, idx) in costTemplateDetail.freeProvinces"
:key="`${p.provinceId}-${idx}`"
>
{{ p.province || p.provinceId }}
</Tag>
</div>
<span v-else>暂无</span>
</Descriptions.Item>
<Descriptions.Item
v-if="costTemplateDetail.freeDeliverHouseAreas?.length"
label="送货上门地区"
:span="2"
>
{{
costTemplateDetail.freeDeliverHouseAreas
.map((a) => a.areaText)
.filter(Boolean)
.join('、') || '-'
}}
</Descriptions.Item>
</Descriptions>
<Table
v-if="costTemplateDetail.paidRegions?.length"
size="small"
:pagination="false"
:data-source="costTemplateDetail.paidRegions"
:row-key="(_: any, i?: number) => `paid-${i ?? 0}`"
:columns="[
{ title: '买家付邮地区', dataIndex: 'provincesText' },
{ title: '首费规则', key: 'first', width: 160 },
{ title: '续费规则', key: 'add', width: 160 },
{ title: '条件包邮', dataIndex: 'freeRuleText', width: 160 },
]"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'first'">
首{{ record.firstStandard ?? '-'
}}{{ costTemplateDetail?.costType === 1 ? 'kg' : '件' }}
/ {{ record.firstCostYuan ?? '-' }}元
</template>
<template v-else-if="column.key === 'add'">
续{{ record.addStandard ?? '-'
}}{{ costTemplateDetail?.costType === 1 ? 'kg' : '件' }}
/ {{ record.addCostYuan ?? '-' }}元
</template>
</template>
</Table>
</template>
<Empty
v-else-if="!costTemplateDetailLoading"
description="暂无模板详情"
:image="Empty.PRESENTED_IMAGE_SIMPLE"
/>
</Spin>
</Card>
<div class="grid grid-cols-2 gap-3">
<Form.Item label="参考价(元)" required>
<InputNumber
v-model:value="form.marketPriceYuan"
class="w-full"
:min="0.01"
:precision="2"
/>
</Form.Item>
<Form.Item label="发货时限" required>
<Select
v-model:value="form.shipmentLimitSecond"
class="w-full"
:options="[
{ label: '24小时', value: 86400 },
{ label: '48小时', value: 172800 },
]"
/>
</Form.Item>
<Form.Item label="满两件折扣" required>
<InputNumber
v-model:value="form.twoPiecesDiscount"
class="w-full"
:min="0"
:max="10"
:precision="1"
:step="0.1"
placeholder="9.5 表示 9.5 折,0 取消"
/>
</Form.Item>
</div>
<div class="flex flex-wrap gap-6">
<Form.Item label="假一赔十" required>
<Switch v-model:checked="form.isFolt" />
</Form.Item>
<Form.Item label="7天无理由" required>
<Switch v-model:checked="form.isRefundable" />
</Form.Item>
<Form.Item label="预售" required>
<Switch v-model:checked="form.isPreSale" />
</Form.Item>
<Form.Item label="二手" required>
<Switch v-model:checked="form.secondHand" />
</Form.Item>
</div>
</Card>
</div>
<div
@@ -785,6 +796,33 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
</template>
<style scoped>
/* 分区 Card 纵向间距(gap 比 space-y 对 ant-card 更稳定) */
.publish-editor-sections {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.publish-editor-sections :deep(.publish-editor-section.ant-card) {
margin-bottom: 0;
}
/* 规格与库存:销售规格 / SKU 子卡片间距 */
.publish-editor-spec-stack {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.publish-editor-spec-stack :deep(.ant-card) {
margin-bottom: 0;
}
/* 服务与承诺:运费模板详情与下方参考价等字段 */
.cost-template-detail-card {
margin-bottom: 1.5rem;
}
/* 智能体逐字改写时的轻量高亮,便于视线跟上 */
.agent-typing-field {
position: relative;
@@ -192,6 +192,7 @@ function onColumnBatchEnter(
</script>
<template>
<div class="sku-table-card-stack">
<Card size="small" title="内部 SKU 拉入">
<div class="flex flex-wrap items-center gap-2">
<Select
@@ -491,9 +492,20 @@ function onColumnBatchEnter(
/>
</div>
</Teleport>
</div>
</template>
<style scoped>
.sku-table-card-stack {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.sku-table-card-stack :deep(.ant-card) {
margin-bottom: 0;
}
.sku-batch-header {
display: inline-flex;
align-items: center;