mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 20:29:20 +08:00
Compare commits
4
Commits
3c16d538e0
...
7fa0729722
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fa0729722 | ||
|
|
aa87168437 | ||
|
|
e5050317ec | ||
|
|
68ef451ab3 |
-8
@@ -510,14 +510,6 @@ public class AgentCompanyLlmSettingsServiceImpl implements AgentCompanyLlmSettin
|
|||||||
.orderByAsc(AgentCompanyLlmProviderPO::getId));
|
.orderByAsc(AgentCompanyLlmProviderPO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AgentCompanyLlmModelPO> listModels(Long companyId) {
|
|
||||||
return modelMapper.selectList(new LambdaQueryWrapper<AgentCompanyLlmModelPO>()
|
|
||||||
.eq(AgentCompanyLlmModelPO::getCompanyId, companyId)
|
|
||||||
.orderByDesc(AgentCompanyLlmModelPO::getIsDefault)
|
|
||||||
.orderByAsc(AgentCompanyLlmModelPO::getProviderId)
|
|
||||||
.orderByAsc(AgentCompanyLlmModelPO::getId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 聊天/runtime:仅启用中的模型 */
|
/** 聊天/runtime:仅启用中的模型 */
|
||||||
private List<AgentCompanyLlmModelPO> listEnabledModels(Long companyId) {
|
private List<AgentCompanyLlmModelPO> listEnabledModels(Long companyId) {
|
||||||
return modelMapper.selectList(new LambdaQueryWrapper<AgentCompanyLlmModelPO>()
|
return modelMapper.selectList(new LambdaQueryWrapper<AgentCompanyLlmModelPO>()
|
||||||
|
|||||||
+1
-1
@@ -167,7 +167,7 @@ public class CatalogLookupAdapter {
|
|||||||
if (ids.isEmpty()) {
|
if (ids.isEmpty()) {
|
||||||
return Map.of();
|
return Map.of();
|
||||||
}
|
}
|
||||||
return productMapper.selectBatchIds(ids).stream()
|
return productMapper.selectByIds(ids).stream()
|
||||||
.filter(p -> companyId.equals(p.getCompanyId()))
|
.filter(p -> companyId.equals(p.getCompanyId()))
|
||||||
.collect(Collectors.toMap(ProductPO::getId, Function.identity(), (a, b) -> a));
|
.collect(Collectors.toMap(ProductPO::getId, Function.identity(), (a, b) -> a));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ public class PddGoodsLookupAdapter {
|
|||||||
return new Slice<>(List.of(), false);
|
return new Slice<>(List.of(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PddGoodsPO> goods = pddGoodsMapper.selectBatchIds(goodsRowIds).stream()
|
List<PddGoodsPO> goods = pddGoodsMapper.selectByIds(goodsRowIds).stream()
|
||||||
.filter(g -> companyId.equals(g.getCompanyId()))
|
.filter(g -> companyId.equals(g.getCompanyId()))
|
||||||
.filter(g -> !Integer.valueOf(1).equals(g.getIsPlatformDeleted()))
|
.filter(g -> !Integer.valueOf(1).equals(g.getIsPlatformDeleted()))
|
||||||
.filter(g -> shopId == null || shopId.equals(g.getShopId()))
|
.filter(g -> shopId == null || shopId.equals(g.getShopId()))
|
||||||
|
|||||||
+6
-6
@@ -10,7 +10,7 @@ import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
|||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatTemplateQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatRuleQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishShopCatQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishShopCatQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishSpecIdCreateDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishSpecIdCreateDTO;
|
||||||
@@ -19,7 +19,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.Pdd
|
|||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddGoodsPublishResultVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddGoodsPublishResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatAuthVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatAuthVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatTemplateVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatRuleVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishParentSpecVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishParentSpecVO;
|
||||||
@@ -68,11 +68,11 @@ public class PddGoodsPublishController {
|
|||||||
return ApiResponse.success("获取成功", publishService.getCostTemplateDetail(query));
|
return ApiResponse.success("获取成功", publishService.getCostTemplateDetail(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/meta/cat-template")
|
@PostMapping("/meta/cat-rule")
|
||||||
@RequirePermission(value = "channel:pdd:goods:create", description = "创建拼多多商品", allowSuper = true)
|
@RequirePermission(value = "channel:pdd:goods:create", description = "创建拼多多商品", allowSuper = true)
|
||||||
public ApiResponse<PddPublishCatTemplateVO> getCatTemplate(
|
public ApiResponse<PddPublishCatRuleVO> getCatRule(
|
||||||
@Valid @RequestBody PddPublishCatTemplateQueryDTO query) {
|
@Valid @RequestBody PddPublishCatRuleQueryDTO query) {
|
||||||
return ApiResponse.success("获取成功", publishService.getCatTemplate(query));
|
return ApiResponse.success("获取成功", publishService.getCatRule(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/meta/specs")
|
@PostMapping("/meta/specs")
|
||||||
|
|||||||
+4
-1
@@ -3,8 +3,11 @@ package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类目发布规则查询(pdd.goods.cat.rule.get)。
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class PddPublishCatTemplateQueryDTO {
|
public class PddPublishCatRuleQueryDTO {
|
||||||
|
|
||||||
@NotNull(message = "渠道店铺ID不能为空")
|
@NotNull(message = "渠道店铺ID不能为空")
|
||||||
private Long pddShopId;
|
private Long pddShopId;
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** 属性条件展示:父属性 refPid + 可选父属性值 vids。 */
|
||||||
|
@Data
|
||||||
|
public class PddPublishCatPropertyShowConditionVO {
|
||||||
|
|
||||||
|
private Long parentRefPid;
|
||||||
|
private List<Long> parentVids;
|
||||||
|
}
|
||||||
+22
-8
@@ -4,22 +4,36 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类目发布属性规则项(来自 cat.rule.get → goods_properties_rule.properties)。
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class PddPublishCatPropertyVO {
|
public class PddPublishCatPropertyVO {
|
||||||
|
|
||||||
private Long templatePid;
|
|
||||||
private String name;
|
private String name;
|
||||||
private String nameAlias;
|
|
||||||
private Long refPid;
|
private Long refPid;
|
||||||
private Long specId;
|
/** 销售属性对应的父规格 id */
|
||||||
private Long parentId;
|
private Long parentSpecId;
|
||||||
private Boolean required;
|
private Boolean required;
|
||||||
private Boolean sale;
|
private Boolean sale;
|
||||||
private Integer controlType;
|
/** SKU 维度属性(发品时入参在 sku 下) */
|
||||||
private Integer feature;
|
private Boolean sku;
|
||||||
private Integer valueType;
|
private Boolean important;
|
||||||
private String valueUnit;
|
private Boolean canNote;
|
||||||
|
/**
|
||||||
|
* 属性值类型:0 文本;1 数值;2 数值范围;3 二维乘积;4 三维乘积;
|
||||||
|
* 5/6 年月日单/双;7/8 年月单/双;9 材质成分表。
|
||||||
|
*/
|
||||||
|
private Integer propertyValueType;
|
||||||
|
private String maxValue;
|
||||||
|
private String minValue;
|
||||||
|
private Integer valuePrecision;
|
||||||
|
/** 可选单位列表 */
|
||||||
|
private List<String> valueUnits;
|
||||||
private Integer inputMaxNum;
|
private Integer inputMaxNum;
|
||||||
private Integer chooseMaxNum;
|
private Integer chooseMaxNum;
|
||||||
|
private Integer requiredRuleType;
|
||||||
|
private String requiredRule;
|
||||||
|
private List<PddPublishCatPropertyShowConditionVO> showCondition;
|
||||||
private List<PddPublishCatPropertyValueVO> values;
|
private List<PddPublishCatPropertyValueVO> values;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -11,6 +11,7 @@ public class PddPublishCatPropertyValueVO {
|
|||||||
private String value;
|
private String value;
|
||||||
private Long specId;
|
private Long specId;
|
||||||
private String extendInfo;
|
private String extendInfo;
|
||||||
private Boolean parent;
|
|
||||||
private List<Long> parentVids;
|
private List<Long> parentVids;
|
||||||
|
private Integer groupId;
|
||||||
|
private String groupName;
|
||||||
}
|
}
|
||||||
|
|||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类目发布规则(属性规则 + SKU 规则摘要)。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PddPublishCatRuleVO {
|
||||||
|
|
||||||
|
/** 多个销售属性是否需要同时传 */
|
||||||
|
private Boolean chooseAllQualifySpec;
|
||||||
|
|
||||||
|
/** 允许自定义的销售属性数量 */
|
||||||
|
private Long inputMaxSpecNum;
|
||||||
|
|
||||||
|
/** 同商品下规格值加和上限(goods_sku_rule.spec_num_limit) */
|
||||||
|
private Integer specNumLimit;
|
||||||
|
|
||||||
|
/** 团购价最高差倍率 */
|
||||||
|
private Double priceRangeRatio;
|
||||||
|
|
||||||
|
private List<PddPublishCatPropertyVO> properties;
|
||||||
|
}
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PddPublishCatTemplateVO {
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
private Long maxSkuNum;
|
|
||||||
private Long inputMaxSpecNum;
|
|
||||||
private Long singleSpecValueNum;
|
|
||||||
private Boolean singleItem;
|
|
||||||
private List<PddPublishCatPropertyVO> properties;
|
|
||||||
}
|
|
||||||
-15
@@ -70,18 +70,6 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
|||||||
}
|
}
|
||||||
List<PddGoodsPublishJobItemPO> items = jobItemMapper.selectList(qw);
|
List<PddGoodsPublishJobItemPO> items = jobItemMapper.selectList(qw);
|
||||||
|
|
||||||
int success = job.getSuccessCount() == null ? 0 : job.getSuccessCount();
|
|
||||||
int fail = onlyFailed ? 0 : (job.getFailCount() == null ? 0 : job.getFailCount());
|
|
||||||
if (onlyFailed) {
|
|
||||||
// 重试失败项:先把失败数扣回,下面按结果重算
|
|
||||||
fail = 0;
|
|
||||||
success = (job.getTotalCount() == null ? 0 : job.getTotalCount())
|
|
||||||
- items.size();
|
|
||||||
if (success < 0) {
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PddGoodsPublishJobItemPO item : items) {
|
for (PddGoodsPublishJobItemPO item : items) {
|
||||||
item.setStatus(PddGoodsPublishJobItemPO.STATUS_RUNNING);
|
item.setStatus(PddGoodsPublishJobItemPO.STATUS_RUNNING);
|
||||||
item.setErrorMessage(null);
|
item.setErrorMessage(null);
|
||||||
@@ -90,7 +78,6 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
|||||||
PddGoodsPublishDraftPO draft = draftMapper.selectById(item.getDraftId());
|
PddGoodsPublishDraftPO draft = draftMapper.selectById(item.getDraftId());
|
||||||
if (draft == null || !companyId.equals(draft.getCompanyId())) {
|
if (draft == null || !companyId.equals(draft.getCompanyId())) {
|
||||||
markItemFailed(item, "草稿不存在");
|
markItemFailed(item, "草稿不存在");
|
||||||
fail++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
draft.setStatus(PddGoodsPublishDraftPO.STATUS_PUBLISHING);
|
draft.setStatus(PddGoodsPublishDraftPO.STATUS_PUBLISHING);
|
||||||
@@ -109,7 +96,6 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
|||||||
item.setErrorMessage(null);
|
item.setErrorMessage(null);
|
||||||
jobItemMapper.updateById(item);
|
jobItemMapper.updateById(item);
|
||||||
// status / commitId / goodsId 由 publish(systemDraftId) 回写
|
// status / commitId / goodsId 由 publish(systemDraftId) 回写
|
||||||
success++;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = e.getMessage() == null ? "发布失败" : e.getMessage();
|
String msg = e.getMessage() == null ? "发布失败" : e.getMessage();
|
||||||
if (msg.length() > 900) {
|
if (msg.length() > 900) {
|
||||||
@@ -119,7 +105,6 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
|||||||
draft.setStatus(PddGoodsPublishDraftPO.STATUS_FAILED);
|
draft.setStatus(PddGoodsPublishDraftPO.STATUS_FAILED);
|
||||||
draft.setLastError(msg);
|
draft.setLastError(msg);
|
||||||
draftMapper.updateById(draft);
|
draftMapper.updateById(draft);
|
||||||
fail++;
|
|
||||||
log.warn("publish desk job item failed jobId={} draftId={}", jobId, item.getDraftId(), e);
|
log.warn("publish desk job item failed jobId={} draftId={}", jobId, item.getDraftId(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service;
|
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service;
|
||||||
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatTemplateQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatRuleQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
||||||
@@ -11,7 +11,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.Pdd
|
|||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishTransferImageDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishTransferImageDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddGoodsPublishResultVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddGoodsPublishResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatAuthVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatAuthVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatTemplateVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatRuleVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
||||||
@@ -34,7 +34,7 @@ public interface PddGoodsPublishService {
|
|||||||
|
|
||||||
PddPublishCostTemplateDetailVO getCostTemplateDetail(PddPublishCostTemplateDetailQueryDTO query);
|
PddPublishCostTemplateDetailVO getCostTemplateDetail(PddPublishCostTemplateDetailQueryDTO query);
|
||||||
|
|
||||||
PddPublishCatTemplateVO getCatTemplate(PddPublishCatTemplateQueryDTO query);
|
PddPublishCatRuleVO getCatRule(PddPublishCatRuleQueryDTO query);
|
||||||
|
|
||||||
List<PddPublishParentSpecVO> listParentSpecs(PddPublishSpecQueryDTO query);
|
List<PddPublishParentSpecVO> listParentSpecs(PddPublishSpecQueryDTO query);
|
||||||
|
|
||||||
|
|||||||
+38
-24
@@ -16,7 +16,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.Pdd
|
|||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishSkuPropertyDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishSkuPropertyDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatTemplateQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatRuleQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishShopCatQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishShopCatQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishSpecIdCreateDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishSpecIdCreateDTO;
|
||||||
@@ -29,7 +29,8 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddP
|
|||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatPropertyVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatPropertyVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatPropertyValueVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatPropertyValueVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatTemplateVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatPropertyShowConditionVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatRuleVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsTemplateVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsTemplateVO;
|
||||||
@@ -206,15 +207,15 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PddPublishCatTemplateVO getCatTemplate(PddPublishCatTemplateQueryDTO query) {
|
public PddPublishCatRuleVO getCatRule(PddPublishCatRuleQueryDTO query) {
|
||||||
ShopAuth ctx = requireShopAuth(query.getPddShopId());
|
ShopAuth ctx = requireShopAuth(query.getPddShopId());
|
||||||
try {
|
try {
|
||||||
var tpl = publishPopApiClient.getCatTemplate(ctx.mallId(), ctx.accessToken(), query.getCatId());
|
var rule = publishPopApiClient.getCatRule(ctx.mallId(), ctx.accessToken(), query.getCatId());
|
||||||
return mapCatTemplate(tpl);
|
return mapCatRule(rule);
|
||||||
} catch (BusinessException e) {
|
} catch (BusinessException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw wrapPop("查询类目属性模板失败", e);
|
throw wrapPop("查询类目发布规则失败", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,31 +696,43 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
|||||||
return parts.isEmpty() ? null : String.join(";", parts);
|
return parts.isEmpty() ? null : String.join(";", parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PddPublishCatTemplateVO mapCatTemplate(PddGoodsPublishPopApiClient.CatTemplate tpl) {
|
private PddPublishCatRuleVO mapCatRule(PddGoodsPublishPopApiClient.CatRule rule) {
|
||||||
PddPublishCatTemplateVO vo = new PddPublishCatTemplateVO();
|
PddPublishCatRuleVO vo = new PddPublishCatRuleVO();
|
||||||
vo.setId(tpl.id());
|
vo.setChooseAllQualifySpec(rule.chooseAllQualifySpec());
|
||||||
vo.setMaxSkuNum(tpl.maxSkuNum());
|
vo.setInputMaxSpecNum(rule.inputMaxSpecNum());
|
||||||
vo.setInputMaxSpecNum(tpl.inputMaxSpecNum());
|
vo.setSpecNumLimit(rule.specNumLimit());
|
||||||
vo.setSingleSpecValueNum(tpl.singleSpecValueNum());
|
vo.setPriceRangeRatio(rule.priceRangeRatio());
|
||||||
vo.setSingleItem(tpl.singleItem());
|
|
||||||
List<PddPublishCatPropertyVO> props = new ArrayList<>();
|
List<PddPublishCatPropertyVO> props = new ArrayList<>();
|
||||||
if (tpl.properties() != null) {
|
if (rule.properties() != null) {
|
||||||
for (var p : tpl.properties()) {
|
for (var p : rule.properties()) {
|
||||||
PddPublishCatPropertyVO pv = new PddPublishCatPropertyVO();
|
PddPublishCatPropertyVO pv = new PddPublishCatPropertyVO();
|
||||||
pv.setTemplatePid(p.templatePid());
|
|
||||||
pv.setName(p.name());
|
pv.setName(p.name());
|
||||||
pv.setNameAlias(p.nameAlias());
|
|
||||||
pv.setRefPid(p.refPid());
|
pv.setRefPid(p.refPid());
|
||||||
pv.setSpecId(p.specId());
|
pv.setParentSpecId(p.parentSpecId());
|
||||||
pv.setParentId(p.parentId());
|
|
||||||
pv.setRequired(p.required());
|
pv.setRequired(p.required());
|
||||||
pv.setSale(p.sale());
|
pv.setSale(p.sale());
|
||||||
pv.setControlType(p.controlType());
|
pv.setSku(p.sku());
|
||||||
pv.setFeature(p.feature());
|
pv.setImportant(p.important());
|
||||||
pv.setValueType(p.valueType());
|
pv.setCanNote(p.canNote());
|
||||||
pv.setValueUnit(p.valueUnit());
|
pv.setPropertyValueType(p.propertyValueType());
|
||||||
|
pv.setMaxValue(p.maxValue());
|
||||||
|
pv.setMinValue(p.minValue());
|
||||||
|
pv.setValuePrecision(p.valuePrecision());
|
||||||
|
pv.setValueUnits(p.valueUnits());
|
||||||
pv.setInputMaxNum(p.inputMaxNum());
|
pv.setInputMaxNum(p.inputMaxNum());
|
||||||
pv.setChooseMaxNum(p.chooseMaxNum());
|
pv.setChooseMaxNum(p.chooseMaxNum());
|
||||||
|
pv.setRequiredRuleType(p.requiredRuleType());
|
||||||
|
pv.setRequiredRule(p.requiredRule());
|
||||||
|
List<PddPublishCatPropertyShowConditionVO> showConds = new ArrayList<>();
|
||||||
|
if (p.showCondition() != null) {
|
||||||
|
for (var c : p.showCondition()) {
|
||||||
|
PddPublishCatPropertyShowConditionVO cv = new PddPublishCatPropertyShowConditionVO();
|
||||||
|
cv.setParentRefPid(c.parentRefPid());
|
||||||
|
cv.setParentVids(c.parentVids());
|
||||||
|
showConds.add(cv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pv.setShowCondition(showConds);
|
||||||
List<PddPublishCatPropertyValueVO> values = new ArrayList<>();
|
List<PddPublishCatPropertyValueVO> values = new ArrayList<>();
|
||||||
if (p.values() != null) {
|
if (p.values() != null) {
|
||||||
for (var v : p.values()) {
|
for (var v : p.values()) {
|
||||||
@@ -728,8 +741,9 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
|||||||
vv.setValue(v.value());
|
vv.setValue(v.value());
|
||||||
vv.setSpecId(v.specId());
|
vv.setSpecId(v.specId());
|
||||||
vv.setExtendInfo(v.extendInfo());
|
vv.setExtendInfo(v.extendInfo());
|
||||||
vv.setParent(v.parent());
|
|
||||||
vv.setParentVids(v.parentVids());
|
vv.setParentVids(v.parentVids());
|
||||||
|
vv.setGroupId(v.groupId());
|
||||||
|
vv.setGroupName(v.groupName());
|
||||||
values.add(vv);
|
values.add(vv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -27,7 +27,11 @@ public final class PddPopApiTypes {
|
|||||||
/** 平台全量类目树(无需 accessToken) */
|
/** 平台全量类目树(无需 accessToken) */
|
||||||
public static final String GOODS_CATS_GET = "pdd.goods.cats.get";
|
public static final String GOODS_CATS_GET = "pdd.goods.cats.get";
|
||||||
public static final String GOODS_LOGISTICS_TEMPLATE_GET = "pdd.goods.logistics.template.get";
|
public static final String GOODS_LOGISTICS_TEMPLATE_GET = "pdd.goods.logistics.template.get";
|
||||||
|
/** @deprecated 已废弃,请用 {@link #GOODS_CAT_RULE_GET} */
|
||||||
|
@Deprecated
|
||||||
public static final String GOODS_CAT_TEMPLATE_GET = "pdd.goods.cat.template.get";
|
public static final String GOODS_CAT_TEMPLATE_GET = "pdd.goods.cat.template.get";
|
||||||
|
/** 类目商品发布规则(含属性,替代 cat.template.get) */
|
||||||
|
public static final String GOODS_CAT_RULE_GET = "pdd.goods.cat.rule.get";
|
||||||
public static final String GOODS_SPEC_GET = "pdd.goods.spec.get";
|
public static final String GOODS_SPEC_GET = "pdd.goods.spec.get";
|
||||||
public static final String GOODS_SPEC_ID_GET = "pdd.goods.spec.id.get";
|
public static final String GOODS_SPEC_ID_GET = "pdd.goods.spec.id.get";
|
||||||
public static final String ONE_EXPRESS_COST_TEMPLATE = "pdd.one.express.cost.template";
|
public static final String ONE_EXPRESS_COST_TEMPLATE = "pdd.one.express.cost.template";
|
||||||
|
|||||||
+63
-38
@@ -4,7 +4,7 @@ import com.pdd.pop.sdk.http.api.pop.request.PddGoodsAddRequest;
|
|||||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsEditGoodsCommitRequest;
|
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsEditGoodsCommitRequest;
|
||||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsSubmitGoodsCommitRequest;
|
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsSubmitGoodsCommitRequest;
|
||||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsAuthorizationCatsRequest;
|
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsAuthorizationCatsRequest;
|
||||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsCatTemplateGetRequest;
|
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsCatRuleGetRequest;
|
||||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsImageUploadRequest;
|
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsImageUploadRequest;
|
||||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsLogisticsTemplateGetRequest;
|
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsLogisticsTemplateGetRequest;
|
||||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsSpecGetRequest;
|
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsSpecGetRequest;
|
||||||
@@ -14,7 +14,7 @@ import com.pdd.pop.sdk.http.api.pop.response.PddGoodsAddResponse;
|
|||||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsEditGoodsCommitResponse;
|
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsEditGoodsCommitResponse;
|
||||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsSubmitGoodsCommitResponse;
|
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsSubmitGoodsCommitResponse;
|
||||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsAuthorizationCatsResponse;
|
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsAuthorizationCatsResponse;
|
||||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsCatTemplateGetResponse;
|
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsCatRuleGetResponse;
|
||||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsImageUploadResponse;
|
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsImageUploadResponse;
|
||||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsLogisticsTemplateGetResponse;
|
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsLogisticsTemplateGetResponse;
|
||||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsSpecGetResponse;
|
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsSpecGetResponse;
|
||||||
@@ -32,7 +32,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品发布域 POP:类目/运费模板/属性模板/规格/传图/新增/平台草稿。
|
* 商品发布域 POP:类目/运费模板/发布规则(属性)/规格/传图/新增/平台草稿。
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -90,17 +90,17 @@ public class PddGoodsPublishPopApiClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 叶子类目属性模板。 */
|
/** 叶子类目发布规则(属性 + SKU 限制等)。 */
|
||||||
public CatTemplate getCatTemplate(Long mallId, String accessToken, Long catId) throws Exception {
|
public CatRule getCatRule(Long mallId, String accessToken, Long catId) throws Exception {
|
||||||
if (catId == null) {
|
if (catId == null) {
|
||||||
throw new BusinessException("类目ID不能为空");
|
throw new BusinessException("类目ID不能为空");
|
||||||
}
|
}
|
||||||
return invokeSupport.invoke(PddPopApiTypes.GOODS_CAT_TEMPLATE_GET, mallId, client -> {
|
return invokeSupport.invoke(PddPopApiTypes.GOODS_CAT_RULE_GET, mallId, client -> {
|
||||||
PddGoodsCatTemplateGetRequest request = new PddGoodsCatTemplateGetRequest();
|
PddGoodsCatRuleGetRequest request = new PddGoodsCatRuleGetRequest();
|
||||||
request.setCatId(catId);
|
request.setCatId(catId);
|
||||||
PddGoodsCatTemplateGetResponse response = client.syncInvoke(request, accessToken);
|
PddGoodsCatRuleGetResponse response = client.syncInvoke(request, accessToken);
|
||||||
invokeSupport.assertNoError(response, PddPopApiTypes.GOODS_CAT_TEMPLATE_GET);
|
invokeSupport.assertNoError(response, PddPopApiTypes.GOODS_CAT_RULE_GET);
|
||||||
return mapCatTemplate(response);
|
return mapCatRule(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,14 +555,17 @@ public class PddGoodsPublishPopApiClient {
|
|||||||
Collections.unmodifiableList(houseAreas));
|
Collections.unmodifiableList(houseAreas));
|
||||||
}
|
}
|
||||||
|
|
||||||
private CatTemplate mapCatTemplate(PddGoodsCatTemplateGetResponse response) {
|
private CatRule mapCatRule(PddGoodsCatRuleGetResponse response) {
|
||||||
if (response == null || response.getOpenApiResponse() == null) {
|
if (response == null || response.getCatRuleGetResponse() == null) {
|
||||||
return new CatTemplate(null, null, null, null, null, List.of());
|
return new CatRule(null, null, null, null, List.of());
|
||||||
}
|
}
|
||||||
var body = response.getOpenApiResponse();
|
var root = response.getCatRuleGetResponse();
|
||||||
|
var propRule = root.getGoodsPropertiesRule();
|
||||||
|
var skuRule = root.getGoodsSkuRule();
|
||||||
|
|
||||||
List<CatProperty> props = new ArrayList<>();
|
List<CatProperty> props = new ArrayList<>();
|
||||||
if (body.getProperties() != null) {
|
if (propRule != null && propRule.getProperties() != null) {
|
||||||
for (var p : body.getProperties()) {
|
for (var p : propRule.getProperties()) {
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -572,35 +575,52 @@ public class PddGoodsPublishPopApiClient {
|
|||||||
if (v == null) {
|
if (v == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Integer groupId = v.getGroup() != null ? v.getGroup().getId() : null;
|
||||||
|
String groupName = v.getGroup() != null ? v.getGroup().getName() : null;
|
||||||
values.add(new CatPropertyValue(
|
values.add(new CatPropertyValue(
|
||||||
v.getVid(), v.getValue(), v.getSpecId(), v.getExtendInfo(),
|
v.getVid(), v.getValue(), v.getSpecId(), v.getExtendInfo(),
|
||||||
v.getIsParent(), v.getParentVids()));
|
v.getParentVids(), groupId, groupName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<CatPropertyShowCondition> showConds = new ArrayList<>();
|
||||||
|
if (p.getShowCondition() != null) {
|
||||||
|
for (var c : p.getShowCondition()) {
|
||||||
|
if (c == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
showConds.add(new CatPropertyShowCondition(c.getParentRefPid(), c.getParentVids()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> units = p.getValueUnit() != null
|
||||||
|
? List.copyOf(p.getValueUnit())
|
||||||
|
: List.of();
|
||||||
props.add(new CatProperty(
|
props.add(new CatProperty(
|
||||||
p.getId(),
|
|
||||||
p.getName(),
|
p.getName(),
|
||||||
p.getNameAlias(),
|
|
||||||
p.getRefPid(),
|
p.getRefPid(),
|
||||||
p.getSpecId(),
|
p.getParentSpecId(),
|
||||||
p.getParentId(),
|
|
||||||
Boolean.TRUE.equals(p.getRequired()),
|
Boolean.TRUE.equals(p.getRequired()),
|
||||||
Boolean.TRUE.equals(p.getIsSale()),
|
Boolean.TRUE.equals(p.getIsSale()),
|
||||||
p.getControlType(),
|
Boolean.TRUE.equals(p.getIsSku()),
|
||||||
p.getFeature(),
|
Boolean.TRUE.equals(p.getIsImportant()),
|
||||||
p.getValueType(),
|
Boolean.TRUE.equals(p.getCanNote()),
|
||||||
p.getValueUnit(),
|
p.getPropertyValueType(),
|
||||||
|
p.getMaxValue(),
|
||||||
|
p.getMinValue(),
|
||||||
|
p.getValuePrecision(),
|
||||||
|
units,
|
||||||
p.getInputMaxNum(),
|
p.getInputMaxNum(),
|
||||||
p.getChooseMaxNum(),
|
p.getChooseMaxNum(),
|
||||||
|
p.getRequiredRuleType(),
|
||||||
|
p.getRequiredRule(),
|
||||||
|
Collections.unmodifiableList(showConds),
|
||||||
Collections.unmodifiableList(values)));
|
Collections.unmodifiableList(values)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new CatTemplate(
|
return new CatRule(
|
||||||
body.getId(),
|
propRule != null ? propRule.getChooseAllQualifySpec() : null,
|
||||||
body.getMaxSkuNum(),
|
propRule != null ? propRule.getInputMaxSpecNum() : null,
|
||||||
body.getInputMaxSpecNum(),
|
skuRule != null ? skuRule.getSpecNumLimit() : null,
|
||||||
body.getSingleSpecValueNum(),
|
skuRule != null ? skuRule.getPriceRangeRatio() : null,
|
||||||
body.getIsSingleItem(),
|
|
||||||
Collections.unmodifiableList(props));
|
Collections.unmodifiableList(props));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,18 +685,23 @@ public class PddGoodsPublishPopApiClient {
|
|||||||
String province, String city, String town) {
|
String province, String city, String town) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record CatTemplate(Long id, Long maxSkuNum, Long inputMaxSpecNum, Long singleSpecValueNum,
|
public record CatRule(Boolean chooseAllQualifySpec, Long inputMaxSpecNum, Integer specNumLimit,
|
||||||
Boolean singleItem, List<CatProperty> properties) {
|
Double priceRangeRatio, List<CatProperty> properties) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record CatProperty(Long templatePid, String name, String nameAlias, Long refPid, Long specId,
|
public record CatProperty(String name, Long refPid, Long parentSpecId, boolean required, boolean sale,
|
||||||
Long parentId, boolean required, boolean sale, Integer controlType,
|
boolean sku, boolean important, boolean canNote, Integer propertyValueType,
|
||||||
Integer feature, Integer valueType, String valueUnit,
|
String maxValue, String minValue, Integer valuePrecision,
|
||||||
Integer inputMaxNum, Integer chooseMaxNum, List<CatPropertyValue> values) {
|
List<String> valueUnits, Integer inputMaxNum, Integer chooseMaxNum,
|
||||||
|
Integer requiredRuleType, String requiredRule,
|
||||||
|
List<CatPropertyShowCondition> showCondition, List<CatPropertyValue> values) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public record CatPropertyShowCondition(Long parentRefPid, List<Long> parentVids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record CatPropertyValue(Long vid, String value, Long specId, String extendInfo,
|
public record CatPropertyValue(Long vid, String value, Long specId, String extendInfo,
|
||||||
Boolean parent, List<Long> parentVids) {
|
List<Long> parentVids, Integer groupId, String groupName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record ParentSpecItem(Long catId, Long parentSpecId, String parentSpecName) {
|
public record ParentSpecItem(Long catId, Long parentSpecId, String parentSpecName) {
|
||||||
|
|||||||
+1
-1
@@ -218,7 +218,7 @@ public class OpTeamServiceImpl extends ServiceImpl<OpTeamMapper, OpTeamPO> imple
|
|||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
Map<Long, String> names = new HashMap<>();
|
Map<Long, String> names = new HashMap<>();
|
||||||
for (UserPO user : userMapper.selectBatchIds(userIds)) {
|
for (UserPO user : userMapper.selectByIds(userIds)) {
|
||||||
names.put(user.getId(), user.getRealName());
|
names.put(user.getId(), user.getRealName());
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ pdd:
|
|||||||
shop-window-seconds: 60
|
shop-window-seconds: 60
|
||||||
app-burst-limit: 800
|
app-burst-limit: 800
|
||||||
app-burst-window-seconds: 10
|
app-burst-window-seconds: 10
|
||||||
pdd.goods.cat.template.get:
|
pdd.goods.cat.rule.get:
|
||||||
shop-limit: 6000
|
shop-limit: 6000
|
||||||
shop-window-seconds: 60
|
shop-window-seconds: 60
|
||||||
app-burst-limit: 800
|
app-burst-limit: 800
|
||||||
|
|||||||
@@ -73,12 +73,12 @@ export async function getPddPublishLogisticsTemplateDetailApi(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 类目属性模板 */
|
/** 类目发布规则(含属性) */
|
||||||
export async function getPddPublishCatTemplateApi(
|
export async function getPddPublishCatRuleApi(
|
||||||
data: PddGoodsPublishDTO.CatTemplateQuery,
|
data: PddGoodsPublishDTO.CatRuleQuery,
|
||||||
) {
|
) {
|
||||||
return requestClient.post<PddGoodsPublishVO.CatTemplate>(
|
return requestClient.post<PddGoodsPublishVO.CatRule>(
|
||||||
'/channel/pdd/goods/publish/meta/cat-template',
|
'/channel/pdd/goods/publish/meta/cat-rule',
|
||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export namespace PddGoodsPublishDTO {
|
|||||||
costTemplateId: number;
|
costTemplateId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CatTemplateQuery {
|
export interface CatRuleQuery {
|
||||||
pddShopId: number;
|
pddShopId: number;
|
||||||
catId: number;
|
catId: number;
|
||||||
}
|
}
|
||||||
@@ -174,40 +174,56 @@ export namespace PddGoodsPublishVO {
|
|||||||
areaText?: string;
|
areaText?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CatTemplate {
|
/** 类目发布规则(pdd.goods.cat.rule.get) */
|
||||||
id?: number;
|
export interface CatRule {
|
||||||
maxSkuNum?: number;
|
chooseAllQualifySpec?: boolean;
|
||||||
inputMaxSpecNum?: number;
|
inputMaxSpecNum?: number;
|
||||||
singleSpecValueNum?: number;
|
/** 规格值加和上限 */
|
||||||
singleItem?: boolean;
|
specNumLimit?: number;
|
||||||
|
priceRangeRatio?: number;
|
||||||
properties?: CatProperty[];
|
properties?: CatProperty[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CatProperty {
|
export interface CatProperty {
|
||||||
templatePid?: number;
|
|
||||||
name?: string;
|
name?: string;
|
||||||
nameAlias?: string;
|
|
||||||
refPid?: number;
|
refPid?: number;
|
||||||
specId?: number;
|
/** 销售属性对应的父规格 id */
|
||||||
parentId?: number;
|
parentSpecId?: number;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
sale?: boolean;
|
sale?: boolean;
|
||||||
controlType?: number;
|
/** SKU 维度属性 */
|
||||||
feature?: number;
|
sku?: boolean;
|
||||||
valueType?: number;
|
important?: boolean;
|
||||||
valueUnit?: string;
|
canNote?: boolean;
|
||||||
|
/**
|
||||||
|
* 0 文本;1 数值;2 范围;3/4 乘积;5–8 时间;9 材质表
|
||||||
|
*/
|
||||||
|
propertyValueType?: number;
|
||||||
|
maxValue?: string;
|
||||||
|
minValue?: string;
|
||||||
|
valuePrecision?: number;
|
||||||
|
valueUnits?: string[];
|
||||||
inputMaxNum?: number;
|
inputMaxNum?: number;
|
||||||
chooseMaxNum?: number;
|
chooseMaxNum?: number;
|
||||||
|
requiredRuleType?: number;
|
||||||
|
requiredRule?: string;
|
||||||
|
showCondition?: CatPropertyShowCondition[];
|
||||||
values?: CatPropertyValue[];
|
values?: CatPropertyValue[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CatPropertyShowCondition {
|
||||||
|
parentRefPid?: number;
|
||||||
|
parentVids?: number[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface CatPropertyValue {
|
export interface CatPropertyValue {
|
||||||
vid?: number;
|
vid?: number;
|
||||||
value?: string;
|
value?: string;
|
||||||
specId?: number;
|
specId?: number;
|
||||||
extendInfo?: string;
|
extendInfo?: string;
|
||||||
parent?: boolean;
|
|
||||||
parentVids?: number[];
|
parentVids?: number[];
|
||||||
|
groupId?: number;
|
||||||
|
groupName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ParentSpec {
|
export interface ParentSpec {
|
||||||
|
|||||||
+8
-24
@@ -44,6 +44,7 @@ import {
|
|||||||
|
|
||||||
import { getProductPageApi } from '#/api/ec/product';
|
import { getProductPageApi } from '#/api/ec/product';
|
||||||
|
|
||||||
|
import CatPropertyField from './components/CatPropertyField.vue';
|
||||||
import SpecAxesCard from './components/SpecAxesCard.vue';
|
import SpecAxesCard from './components/SpecAxesCard.vue';
|
||||||
import SkuTableCard from './components/SkuTableCard.vue';
|
import SkuTableCard from './components/SkuTableCard.vue';
|
||||||
import type { SpecAxis, SpecCatalogItem, SkuRow } from './types';
|
import type { SpecAxis, SpecCatalogItem, SkuRow } from './types';
|
||||||
@@ -122,7 +123,7 @@ const specs = usePublishSpecs({
|
|||||||
const sku = usePublishSku({
|
const sku = usePublishSku({
|
||||||
skuRows,
|
skuRows,
|
||||||
specAxes,
|
specAxes,
|
||||||
catTemplate: category.catTemplate,
|
catRule: category.catRule,
|
||||||
revokeUploadFiles: images.revokeUploadFiles,
|
revokeUploadFiles: images.revokeUploadFiles,
|
||||||
specHelpers: {
|
specHelpers: {
|
||||||
effectiveSpecSlots: specs.effectiveSpecSlots,
|
effectiveSpecSlots: specs.effectiveSpecSlots,
|
||||||
@@ -175,6 +176,7 @@ const draft = usePublishDraft({
|
|||||||
catAuthMessage: category.catAuthMessage,
|
catAuthMessage: category.catAuthMessage,
|
||||||
catAuthChecking: category.catAuthChecking,
|
catAuthChecking: category.catAuthChecking,
|
||||||
selectedCatPathLabel: category.selectedCatPathLabel,
|
selectedCatPathLabel: category.selectedCatPathLabel,
|
||||||
|
allNonSaleProps: category.allNonSaleProps,
|
||||||
nonSaleProps: category.nonSaleProps,
|
nonSaleProps: category.nonSaleProps,
|
||||||
productOptions,
|
productOptions,
|
||||||
loadProducts,
|
loadProducts,
|
||||||
@@ -692,32 +694,14 @@ function onSkuTableWrapRef(el: HTMLElement | null) {
|
|||||||
<div class="grid grid-cols-2 gap-3">
|
<div class="grid grid-cols-2 gap-3">
|
||||||
<Form.Item
|
<Form.Item
|
||||||
v-for="p in nonSaleProps"
|
v-for="p in nonSaleProps"
|
||||||
:key="String(p.templatePid ?? p.refPid)"
|
:key="String(p.refPid)"
|
||||||
:label="p.name"
|
:label="p.name"
|
||||||
:required="!!p.required"
|
:required="!!p.required"
|
||||||
>
|
>
|
||||||
<Select
|
<CatPropertyField
|
||||||
v-if="p.values?.length"
|
v-model:value="form.goodsPropValues[String(p.refPid)]"
|
||||||
v-model:value="
|
v-model:unit="form.goodsPropUnits[String(p.refPid)]"
|
||||||
form.goodsPropValues[String(p.templatePid ?? p.refPid)]
|
:property="p"
|
||||||
"
|
|
||||||
class="w-full"
|
|
||||||
allow-clear
|
|
||||||
show-search
|
|
||||||
option-filter-prop="label"
|
|
||||||
:options="
|
|
||||||
(p.values || []).map((v) => ({
|
|
||||||
label: v.value,
|
|
||||||
value: String(v.vid ?? v.value),
|
|
||||||
}))
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
<Input
|
|
||||||
v-else
|
|
||||||
v-model:value="
|
|
||||||
form.goodsPropValues[String(p.templatePid ?? p.refPid)]
|
|
||||||
"
|
|
||||||
allow-clear
|
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+345
@@ -0,0 +1,345 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 类目非销售属性控件:按 propertyValueType 渲染下拉/数值+单位/日期等。
|
||||||
|
*/
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
import type { PddGoodsPublishVO } from '#/api/channel/pdd/goods';
|
||||||
|
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import {
|
||||||
|
DatePicker,
|
||||||
|
Input,
|
||||||
|
InputNumber,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
TimePicker,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import {
|
||||||
|
effectiveValueUnits,
|
||||||
|
resolveCatPropControlKind,
|
||||||
|
} from '../utils/cat-property';
|
||||||
|
|
||||||
|
type CatProperty = PddGoodsPublishVO.CatProperty;
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
property: CatProperty;
|
||||||
|
value?: string;
|
||||||
|
unit?: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:value': [string | undefined];
|
||||||
|
'update:unit': [string | undefined];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const kind = computed(() => resolveCatPropControlKind(props.property));
|
||||||
|
const units = computed(() => effectiveValueUnits(props.property));
|
||||||
|
const multiSelect = computed(
|
||||||
|
() => (props.property.chooseMaxNum ?? 1) > 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
const selectValue = computed(() => {
|
||||||
|
if (!props.value) return multiSelect.value ? [] : undefined;
|
||||||
|
if (multiSelect.value) {
|
||||||
|
return props.value.split(',').filter(Boolean);
|
||||||
|
}
|
||||||
|
return props.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
const numberValue = computed(() => {
|
||||||
|
if (props.value == null || props.value === '') return undefined;
|
||||||
|
const n = Number(props.value);
|
||||||
|
return Number.isNaN(n) ? undefined : n;
|
||||||
|
});
|
||||||
|
|
||||||
|
const precision = computed(() => {
|
||||||
|
const p = props.property.valuePrecision;
|
||||||
|
return p != null && p > 0 ? p : undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
const dateValue = computed(() => {
|
||||||
|
if (!props.value) return undefined;
|
||||||
|
const d = dayjs(props.value, 'YYYY-MM-DD', true);
|
||||||
|
return d.isValid() ? d : undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
const monthValue = computed(() => {
|
||||||
|
if (!props.value) return undefined;
|
||||||
|
const d = dayjs(props.value, 'YYYY-MM', true);
|
||||||
|
return d.isValid() ? d : undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
const timeValue = computed(() => {
|
||||||
|
if (!props.value) return undefined;
|
||||||
|
const d = dayjs(props.value, 'HH:mm:ss', true);
|
||||||
|
return d.isValid() ? d : undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
const dateRangeValue = computed((): [Dayjs, Dayjs] | undefined => {
|
||||||
|
if (!props.value) return undefined;
|
||||||
|
const [a, b] = props.value.split(',');
|
||||||
|
if (!a?.trim() || !b?.trim()) return undefined;
|
||||||
|
const d1 = dayjs(a.trim(), 'YYYY-MM-DD', true);
|
||||||
|
const d2 = dayjs(b.trim(), 'YYYY-MM-DD', true);
|
||||||
|
if (!d1.isValid() || !d2.isValid()) return undefined;
|
||||||
|
return [d1, d2];
|
||||||
|
});
|
||||||
|
|
||||||
|
function emitValue(v: string | undefined) {
|
||||||
|
emit('update:value', v || undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSelectChange(v: unknown) {
|
||||||
|
if (Array.isArray(v)) {
|
||||||
|
const tokens = v.map((x) => String(x)).filter(Boolean);
|
||||||
|
emitValue(tokens.length ? tokens.join(',') : undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (v == null || v === '') {
|
||||||
|
emitValue(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emitValue(String(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onNumberChange(v: number | string | null | undefined) {
|
||||||
|
if (v == null || v === '') {
|
||||||
|
emitValue(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emitValue(String(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 逗号分隔多段数值(范围 / 乘积) */
|
||||||
|
function partAt(index: number): number | undefined {
|
||||||
|
const parts = (props.value ?? '').split(',');
|
||||||
|
const raw = parts[index]?.trim();
|
||||||
|
if (raw == null || raw === '') return undefined;
|
||||||
|
const n = Number(raw);
|
||||||
|
return Number.isNaN(n) ? undefined : n;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPart(
|
||||||
|
index: number,
|
||||||
|
expect: number,
|
||||||
|
v: number | string | null | undefined,
|
||||||
|
) {
|
||||||
|
const parts = Array.from({ length: expect }, (_, i) => {
|
||||||
|
return (props.value ?? '').split(',')[i]?.trim() ?? '';
|
||||||
|
});
|
||||||
|
parts[index] = v == null || v === '' ? '' : String(v);
|
||||||
|
emitValue(parts.every((x) => !x) ? undefined : parts.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDay(d: string | Dayjs | null | undefined, fmt: string) {
|
||||||
|
if (d == null || d === '') return undefined;
|
||||||
|
const parsed = typeof d === 'string' ? dayjs(d) : d;
|
||||||
|
return parsed.isValid() ? parsed.format(fmt) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDateChange(d: string | Dayjs | null | undefined) {
|
||||||
|
emitValue(formatDay(d, 'YYYY-MM-DD'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMonthChange(d: string | Dayjs | null | undefined) {
|
||||||
|
emitValue(formatDay(d, 'YYYY-MM'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTimeChange(d: string | Dayjs | null | undefined) {
|
||||||
|
emitValue(formatDay(d, 'HH:mm:ss'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDateRangeChange(
|
||||||
|
dates: [string, string] | [Dayjs, Dayjs] | null | undefined,
|
||||||
|
) {
|
||||||
|
if (!dates?.[0] || !dates?.[1]) {
|
||||||
|
emitValue(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const a = formatDay(dates[0], 'YYYY-MM-DD');
|
||||||
|
const b = formatDay(dates[1], 'YYYY-MM-DD');
|
||||||
|
emitValue(a && b ? `${a},${b}` : undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUnitChange(v: unknown) {
|
||||||
|
if (v == null || v === '') {
|
||||||
|
emit('update:unit', undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit('update:unit', String(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectOptions = computed(() =>
|
||||||
|
(props.property.values || []).map((v) => ({
|
||||||
|
label: v.value,
|
||||||
|
value: String(v.vid ?? v.value),
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
function popupContainer() {
|
||||||
|
return document.body;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<!--
|
||||||
|
半栏占满:左侧主控件包 flex-1 并强制 width:100%(覆盖 InputNumber 默认 90px),
|
||||||
|
右侧单位固定 88px,二者仅 gap-2,不会中间留白也不会互相挤扁。
|
||||||
|
-->
|
||||||
|
<div class="flex w-full min-w-0 items-center gap-2">
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<Select
|
||||||
|
v-if="kind === 'select'"
|
||||||
|
class="w-full"
|
||||||
|
allow-clear
|
||||||
|
show-search
|
||||||
|
option-filter-prop="label"
|
||||||
|
:mode="multiSelect ? 'multiple' : undefined"
|
||||||
|
:max-tag-count="multiSelect ? 'responsive' : undefined"
|
||||||
|
:value="selectValue"
|
||||||
|
:options="selectOptions"
|
||||||
|
@update:value="onSelectChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<InputNumber
|
||||||
|
v-else-if="kind === 'number'"
|
||||||
|
:style="{ width: '100%' }"
|
||||||
|
:value="numberValue"
|
||||||
|
:precision="precision"
|
||||||
|
:min="
|
||||||
|
property.minValue?.trim() ? Number(property.minValue) : undefined
|
||||||
|
"
|
||||||
|
:max="
|
||||||
|
property.maxValue?.trim() && Number(property.maxValue) > 0
|
||||||
|
? Number(property.maxValue)
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@update:value="onNumberChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Space v-else-if="kind === 'range'" :size="4">
|
||||||
|
<InputNumber
|
||||||
|
class="w-28"
|
||||||
|
:value="partAt(0)"
|
||||||
|
:precision="precision"
|
||||||
|
@update:value="(v) => setPart(0, 2, v)"
|
||||||
|
/>
|
||||||
|
<span>~</span>
|
||||||
|
<InputNumber
|
||||||
|
class="w-28"
|
||||||
|
:value="partAt(1)"
|
||||||
|
:precision="precision"
|
||||||
|
@update:value="(v) => setPart(1, 2, v)"
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<Space v-else-if="kind === 'product2'" :size="4">
|
||||||
|
<InputNumber
|
||||||
|
class="w-24"
|
||||||
|
:value="partAt(0)"
|
||||||
|
:precision="precision"
|
||||||
|
@update:value="(v) => setPart(0, 2, v)"
|
||||||
|
/>
|
||||||
|
<span>×</span>
|
||||||
|
<InputNumber
|
||||||
|
class="w-24"
|
||||||
|
:value="partAt(1)"
|
||||||
|
:precision="precision"
|
||||||
|
@update:value="(v) => setPart(1, 2, v)"
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<Space v-else-if="kind === 'product3'" :size="4">
|
||||||
|
<InputNumber
|
||||||
|
class="w-20"
|
||||||
|
:value="partAt(0)"
|
||||||
|
:precision="precision"
|
||||||
|
@update:value="(v) => setPart(0, 3, v)"
|
||||||
|
/>
|
||||||
|
<span>×</span>
|
||||||
|
<InputNumber
|
||||||
|
class="w-20"
|
||||||
|
:value="partAt(1)"
|
||||||
|
:precision="precision"
|
||||||
|
@update:value="(v) => setPart(1, 3, v)"
|
||||||
|
/>
|
||||||
|
<span>×</span>
|
||||||
|
<InputNumber
|
||||||
|
class="w-20"
|
||||||
|
:value="partAt(2)"
|
||||||
|
:precision="precision"
|
||||||
|
@update:value="(v) => setPart(2, 3, v)"
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<DatePicker
|
||||||
|
v-else-if="kind === 'date'"
|
||||||
|
class="w-full"
|
||||||
|
allow-clear
|
||||||
|
format="YYYY-MM-DD"
|
||||||
|
:value="dateValue"
|
||||||
|
:get-popup-container="popupContainer"
|
||||||
|
@update:value="onDateChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DatePicker.RangePicker
|
||||||
|
v-else-if="kind === 'dateRange'"
|
||||||
|
class="w-full"
|
||||||
|
allow-clear
|
||||||
|
format="YYYY-MM-DD"
|
||||||
|
:value="dateRangeValue"
|
||||||
|
:get-popup-container="popupContainer"
|
||||||
|
@update:value="onDateRangeChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DatePicker
|
||||||
|
v-else-if="kind === 'month'"
|
||||||
|
class="w-full"
|
||||||
|
picker="month"
|
||||||
|
allow-clear
|
||||||
|
format="YYYY-MM"
|
||||||
|
:value="monthValue"
|
||||||
|
:get-popup-container="popupContainer"
|
||||||
|
@update:value="onMonthChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TimePicker
|
||||||
|
v-else-if="kind === 'time'"
|
||||||
|
class="w-full"
|
||||||
|
allow-clear
|
||||||
|
format="HH:mm:ss"
|
||||||
|
:value="timeValue"
|
||||||
|
:get-popup-container="popupContainer"
|
||||||
|
@update:value="onTimeChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
v-else-if="kind === 'material' || kind === 'unsupported'"
|
||||||
|
class="w-full"
|
||||||
|
disabled
|
||||||
|
placeholder="该属性类型暂不支持在线填写"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
v-else
|
||||||
|
class="w-full"
|
||||||
|
allow-clear
|
||||||
|
:value="value"
|
||||||
|
@update:value="emitValue"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Select
|
||||||
|
v-if="units.length"
|
||||||
|
:style="{ width: '88px', flex: 'none' }"
|
||||||
|
allow-clear
|
||||||
|
:value="unit"
|
||||||
|
:options="units.map((u) => ({ label: u, value: u }))"
|
||||||
|
placeholder="单位"
|
||||||
|
@update:value="onUnitChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
+38
-17
@@ -8,7 +8,7 @@ import { message } from 'ant-design-vue';
|
|||||||
import type { PddGoodsPublishVO } from '#/api/channel/pdd/goods';
|
import type { PddGoodsPublishVO } from '#/api/channel/pdd/goods';
|
||||||
import {
|
import {
|
||||||
checkPddPublishCatAuthApi,
|
checkPddPublishCatAuthApi,
|
||||||
getPddPublishCatTemplateApi,
|
getPddPublishCatRuleApi,
|
||||||
getPddPublishLogisticsTemplateDetailApi,
|
getPddPublishLogisticsTemplateDetailApi,
|
||||||
listPddPublishCatsApi,
|
listPddPublishCatsApi,
|
||||||
listPddPublishLogisticsApi,
|
listPddPublishLogisticsApi,
|
||||||
@@ -28,9 +28,13 @@ import type {
|
|||||||
SpecAxis,
|
SpecAxis,
|
||||||
SpecCatalogItem,
|
SpecCatalogItem,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
import {
|
||||||
|
isCatPropVisible,
|
||||||
|
seedDefaultPropUnits,
|
||||||
|
} from '../utils/cat-property';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类目树 / Cascader / 发布权 / 模板与运费加载。
|
* 类目树 / Cascader / 发布权 / 类目规则与运费加载。
|
||||||
* 规格重建与 SKU 清空由壳层注入,避免与 specs/sku 环依赖。
|
* 规格重建与 SKU 清空由壳层注入,避免与 specs/sku 环依赖。
|
||||||
*/
|
*/
|
||||||
export function usePublishCategory(options: {
|
export function usePublishCategory(options: {
|
||||||
@@ -59,14 +63,21 @@ export function usePublishCategory(options: {
|
|||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
const costTemplateDetailLoading = ref(false);
|
const costTemplateDetailLoading = ref(false);
|
||||||
const catTemplate = ref<PddGoodsPublishVO.CatTemplate | null>(null);
|
const catRule = ref<PddGoodsPublishVO.CatRule | null>(null);
|
||||||
const parentSpecs = ref<PddGoodsPublishVO.ParentSpec[]>([]);
|
const parentSpecs = ref<PddGoodsPublishVO.ParentSpec[]>([]);
|
||||||
|
|
||||||
|
/** 商品级非销售属性(未按展示条件过滤,供默认单位等) */
|
||||||
|
const allNonSaleProps = computed(() =>
|
||||||
|
(catRule.value?.properties ?? []).filter((p) => !p.sale && !p.sku),
|
||||||
|
);
|
||||||
|
/** 当前可见的非销售属性(含 show_condition) */
|
||||||
const nonSaleProps = computed(() =>
|
const nonSaleProps = computed(() =>
|
||||||
(catTemplate.value?.properties ?? []).filter((p) => !p.sale),
|
allNonSaleProps.value.filter((p) =>
|
||||||
|
isCatPropVisible(p, form.goodsPropValues),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
const saleProps = computed(() =>
|
const saleProps = computed(() =>
|
||||||
(catTemplate.value?.properties ?? []).filter((p) => p.sale),
|
(catRule.value?.properties ?? []).filter((p) => p.sale),
|
||||||
);
|
);
|
||||||
|
|
||||||
const rootCatOptions = ref<CatCascaderNode[]>([]);
|
const rootCatOptions = ref<CatCascaderNode[]>([]);
|
||||||
@@ -444,10 +455,11 @@ export function usePublishCategory(options: {
|
|||||||
form.catPath = path;
|
form.catPath = path;
|
||||||
form.catId = catId;
|
form.catId = catId;
|
||||||
selectedCatPathLabel.value = pathLabel || '';
|
selectedCatPathLabel.value = pathLabel || '';
|
||||||
catTemplate.value = null;
|
catRule.value = null;
|
||||||
parentSpecs.value = [];
|
parentSpecs.value = [];
|
||||||
// 类目属性随模板变,需清空;规格/SKU 尽量沿用
|
// 类目属性随规则变,需清空;规格/SKU 尽量沿用
|
||||||
form.goodsPropValues = {};
|
form.goodsPropValues = {};
|
||||||
|
form.goodsPropUnits = {};
|
||||||
await refreshCatAuth(path);
|
await refreshCatAuth(path);
|
||||||
if (!form.pddShopId || !form.catId) return;
|
if (!form.pddShopId || !form.catId) return;
|
||||||
if (catAuthAuthorized.value === false) {
|
if (catAuthAuthorized.value === false) {
|
||||||
@@ -455,7 +467,7 @@ export function usePublishCategory(options: {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const [tpl, specs] = await Promise.all([
|
const [tpl, specs] = await Promise.all([
|
||||||
getPddPublishCatTemplateApi({
|
getPddPublishCatRuleApi({
|
||||||
pddShopId: form.pddShopId,
|
pddShopId: form.pddShopId,
|
||||||
catId: form.catId,
|
catId: form.catId,
|
||||||
}),
|
}),
|
||||||
@@ -464,11 +476,12 @@ export function usePublishCategory(options: {
|
|||||||
catId: form.catId,
|
catId: form.catId,
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
catTemplate.value = tpl;
|
catRule.value = tpl;
|
||||||
parentSpecs.value = specs ?? [];
|
parentSpecs.value = specs ?? [];
|
||||||
|
form.goodsPropUnits = seedDefaultPropUnits(tpl?.properties ?? []);
|
||||||
rebuildSpecCatalogPreservingUserData();
|
rebuildSpecCatalogPreservingUserData();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
message.error(e?.message || '加载类目模板失败');
|
message.error(e?.message || '加载类目发布规则失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,9 +556,10 @@ export function usePublishCategory(options: {
|
|||||||
pinnedSelectedCat.value = null;
|
pinnedSelectedCat.value = null;
|
||||||
catAuthAuthorized.value = null;
|
catAuthAuthorized.value = null;
|
||||||
catAuthMessage.value = '';
|
catAuthMessage.value = '';
|
||||||
catTemplate.value = null;
|
catRule.value = null;
|
||||||
parentSpecs.value = [];
|
parentSpecs.value = [];
|
||||||
form.goodsPropValues = {};
|
form.goodsPropValues = {};
|
||||||
|
form.goodsPropUnits = {};
|
||||||
clearSkuRows();
|
clearSkuRows();
|
||||||
specAxes.value = [];
|
specAxes.value = [];
|
||||||
specCatalog.value = [];
|
specCatalog.value = [];
|
||||||
@@ -625,7 +639,7 @@ export function usePublishCategory(options: {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const [tpl, specs] = await Promise.all([
|
const [tpl, specs] = await Promise.all([
|
||||||
getPddPublishCatTemplateApi({
|
getPddPublishCatRuleApi({
|
||||||
pddShopId: form.pddShopId,
|
pddShopId: form.pddShopId,
|
||||||
catId,
|
catId,
|
||||||
}),
|
}),
|
||||||
@@ -634,11 +648,16 @@ export function usePublishCategory(options: {
|
|||||||
catId,
|
catId,
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
catTemplate.value = tpl;
|
catRule.value = tpl;
|
||||||
parentSpecs.value = specs ?? [];
|
parentSpecs.value = specs ?? [];
|
||||||
|
// 回填后补默认单位,不覆盖草稿已存单位
|
||||||
|
form.goodsPropUnits = seedDefaultPropUnits(
|
||||||
|
tpl?.properties ?? [],
|
||||||
|
form.goodsPropUnits,
|
||||||
|
);
|
||||||
specCatalog.value = buildSpecCatalog();
|
specCatalog.value = buildSpecCatalog();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
message.error(e?.message || '加载类目模板失败');
|
message.error(e?.message || '加载类目发布规则失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,13 +679,14 @@ export function usePublishCategory(options: {
|
|||||||
catAuthMessage.value = '';
|
catAuthMessage.value = '';
|
||||||
form.costTemplateId = undefined;
|
form.costTemplateId = undefined;
|
||||||
costTemplateDetail.value = null;
|
costTemplateDetail.value = null;
|
||||||
catTemplate.value = null;
|
catRule.value = null;
|
||||||
parentSpecs.value = [];
|
parentSpecs.value = [];
|
||||||
clearSkuRows();
|
clearSkuRows();
|
||||||
specAxes.value = [];
|
specAxes.value = [];
|
||||||
specCatalog.value = [];
|
specCatalog.value = [];
|
||||||
logisticsOptions.value = [];
|
logisticsOptions.value = [];
|
||||||
form.goodsPropValues = {};
|
form.goodsPropValues = {};
|
||||||
|
form.goodsPropUnits = {};
|
||||||
catSearchHitOptions.value = [];
|
catSearchHitOptions.value = [];
|
||||||
catCascaderSearch.value = '';
|
catCascaderSearch.value = '';
|
||||||
rootCatOptions.value = [];
|
rootCatOptions.value = [];
|
||||||
@@ -687,7 +707,7 @@ export function usePublishCategory(options: {
|
|||||||
catAuthAuthorized.value = null;
|
catAuthAuthorized.value = null;
|
||||||
catAuthMessage.value = '';
|
catAuthMessage.value = '';
|
||||||
costTemplateDetail.value = null;
|
costTemplateDetail.value = null;
|
||||||
catTemplate.value = null;
|
catRule.value = null;
|
||||||
parentSpecs.value = [];
|
parentSpecs.value = [];
|
||||||
rootCatOptions.value = [];
|
rootCatOptions.value = [];
|
||||||
catSearchHitOptions.value = [];
|
catSearchHitOptions.value = [];
|
||||||
@@ -703,8 +723,9 @@ export function usePublishCategory(options: {
|
|||||||
logisticsOptions,
|
logisticsOptions,
|
||||||
costTemplateDetail,
|
costTemplateDetail,
|
||||||
costTemplateDetailLoading,
|
costTemplateDetailLoading,
|
||||||
catTemplate,
|
catRule,
|
||||||
parentSpecs,
|
parentSpecs,
|
||||||
|
allNonSaleProps,
|
||||||
nonSaleProps,
|
nonSaleProps,
|
||||||
saleProps,
|
saleProps,
|
||||||
rootCatOptions,
|
rootCatOptions,
|
||||||
|
|||||||
+40
-19
@@ -27,6 +27,12 @@ import {
|
|||||||
type SpecCatalogItem,
|
type SpecCatalogItem,
|
||||||
type SkuRow,
|
type SkuRow,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
import {
|
||||||
|
buildGoodsPropertyItems,
|
||||||
|
isCatPropVisible,
|
||||||
|
seedDefaultPropUnits,
|
||||||
|
validateCatPropValue,
|
||||||
|
} from '../utils/cat-property';
|
||||||
|
|
||||||
type EmitDraft = {
|
type EmitDraft = {
|
||||||
(e: 'draft-saved', draftId: number): void;
|
(e: 'draft-saved', draftId: number): void;
|
||||||
@@ -57,6 +63,7 @@ export function usePublishDraft(options: {
|
|||||||
catAuthMessage: Ref<string>;
|
catAuthMessage: Ref<string>;
|
||||||
catAuthChecking: Ref<boolean>;
|
catAuthChecking: Ref<boolean>;
|
||||||
selectedCatPathLabel: Ref<string>;
|
selectedCatPathLabel: Ref<string>;
|
||||||
|
allNonSaleProps: ComputedRef<PddGoodsPublishVO.CatProperty[]>;
|
||||||
nonSaleProps: ComputedRef<PddGoodsPublishVO.CatProperty[]>;
|
nonSaleProps: ComputedRef<PddGoodsPublishVO.CatProperty[]>;
|
||||||
// products
|
// products
|
||||||
productOptions: Ref<{ label: string; value: number; name: string }[]>;
|
productOptions: Ref<{ label: string; value: number; name: string }[]>;
|
||||||
@@ -101,6 +108,7 @@ export function usePublishDraft(options: {
|
|||||||
catAuthMessage,
|
catAuthMessage,
|
||||||
catAuthChecking,
|
catAuthChecking,
|
||||||
selectedCatPathLabel,
|
selectedCatPathLabel,
|
||||||
|
allNonSaleProps,
|
||||||
nonSaleProps,
|
nonSaleProps,
|
||||||
productOptions,
|
productOptions,
|
||||||
loadProducts,
|
loadProducts,
|
||||||
@@ -193,10 +201,15 @@ export function usePublishDraft(options: {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (const p of nonSaleProps.value) {
|
for (const p of nonSaleProps.value) {
|
||||||
if (!p.required) continue;
|
if (!isCatPropVisible(p, form.goodsPropValues)) continue;
|
||||||
const key = String(p.templatePid ?? p.refPid);
|
const key = String(p.refPid);
|
||||||
if (!form.goodsPropValues[key]) {
|
const err = validateCatPropValue(
|
||||||
message.warning(`请填写必填属性:${p.name || key}`);
|
p,
|
||||||
|
form.goodsPropValues[key],
|
||||||
|
form.goodsPropUnits[key],
|
||||||
|
);
|
||||||
|
if (err) {
|
||||||
|
message.warning(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,22 +259,18 @@ export function usePublishDraft(options: {
|
|||||||
detailFileIds: number[],
|
detailFileIds: number[],
|
||||||
thumbFileIdBySkuKey: Map<number, number>,
|
thumbFileIdBySkuKey: Map<number, number>,
|
||||||
): Promise<PddGoodsPublishDTO.Publish> {
|
): Promise<PddGoodsPublishDTO.Publish> {
|
||||||
// 非销售属性 → goods_properties(不传 parent_spec_id / spec_id)
|
// 非销售属性 → goods_properties(不传 parent_spec_id / spec_id;带 value_unit)
|
||||||
const goodsProperties: PddGoodsPublishDTO.GoodsProperty[] = [];
|
const goodsProperties: PddGoodsPublishDTO.GoodsProperty[] = [];
|
||||||
for (const p of nonSaleProps.value) {
|
for (const p of nonSaleProps.value) {
|
||||||
const key = String(p.templatePid ?? p.refPid);
|
if (!isCatPropVisible(p, form.goodsPropValues)) continue;
|
||||||
const raw = form.goodsPropValues[key];
|
const key = String(p.refPid);
|
||||||
if (!raw) continue;
|
goodsProperties.push(
|
||||||
const matched = p.values?.find(
|
...buildGoodsPropertyItems(
|
||||||
(v) => String(v.vid) === raw || v.value === raw,
|
p,
|
||||||
|
form.goodsPropValues[key],
|
||||||
|
form.goodsPropUnits[key],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
goodsProperties.push({
|
|
||||||
refPid: p.refPid,
|
|
||||||
templatePid: p.templatePid,
|
|
||||||
valueUnit: p.valueUnit,
|
|
||||||
vid: matched?.vid,
|
|
||||||
value: matched?.value ?? raw,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -312,7 +321,6 @@ export function usePublishDraft(options: {
|
|||||||
saleSpecSeen.add(dedupeKey);
|
saleSpecSeen.add(dedupeKey);
|
||||||
goodsProperties.push({
|
goodsProperties.push({
|
||||||
refPid: axis.refPid,
|
refPid: axis.refPid,
|
||||||
templatePid: axis.templatePid,
|
|
||||||
valueUnit: axis.valueUnit,
|
valueUnit: axis.valueUnit,
|
||||||
vid: matched?.vid,
|
vid: matched?.vid,
|
||||||
value: valueText,
|
value: valueText,
|
||||||
@@ -472,6 +480,19 @@ export function usePublishDraft(options: {
|
|||||||
...(es.goodsPropValues as Record<string, string>),
|
...(es.goodsPropValues as Record<string, string>),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
es.goodsPropUnits &&
|
||||||
|
typeof es.goodsPropUnits === 'object' &&
|
||||||
|
!Array.isArray(es.goodsPropUnits)
|
||||||
|
) {
|
||||||
|
form.goodsPropUnits = {
|
||||||
|
...(es.goodsPropUnits as Record<string, string>),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
form.goodsPropUnits = seedDefaultPropUnits(
|
||||||
|
allNonSaleProps.value,
|
||||||
|
form.goodsPropUnits,
|
||||||
|
);
|
||||||
|
|
||||||
const savedAxes = Array.isArray(es.specAxes)
|
const savedAxes = Array.isArray(es.specAxes)
|
||||||
? (es.specAxes as SpecAxis[])
|
? (es.specAxes as SpecAxis[])
|
||||||
@@ -675,6 +696,7 @@ export function usePublishDraft(options: {
|
|||||||
secondHand: form.secondHand,
|
secondHand: form.secondHand,
|
||||||
twoPiecesDiscount: form.twoPiecesDiscount,
|
twoPiecesDiscount: form.twoPiecesDiscount,
|
||||||
goodsPropValues: { ...form.goodsPropValues },
|
goodsPropValues: { ...form.goodsPropValues },
|
||||||
|
goodsPropUnits: { ...form.goodsPropUnits },
|
||||||
specAxes: specAxes.value.map((a) => ({
|
specAxes: specAxes.value.map((a) => ({
|
||||||
rowId: a.rowId,
|
rowId: a.rowId,
|
||||||
catalogKey: a.catalogKey,
|
catalogKey: a.catalogKey,
|
||||||
@@ -682,7 +704,6 @@ export function usePublishDraft(options: {
|
|||||||
name: a.name,
|
name: a.name,
|
||||||
parentSpecId: a.parentSpecId,
|
parentSpecId: a.parentSpecId,
|
||||||
refPid: a.refPid,
|
refPid: a.refPid,
|
||||||
templatePid: a.templatePid,
|
|
||||||
valueUnit: a.valueUnit,
|
valueUnit: a.valueUnit,
|
||||||
presetOptions: a.presetOptions.map((o) => ({ ...o })),
|
presetOptions: a.presetOptions.map((o) => ({ ...o })),
|
||||||
selectedValues: a.selectedValues.map((s) => ({
|
selectedValues: a.selectedValues.map((s) => ({
|
||||||
|
|||||||
+6
-5
@@ -34,11 +34,11 @@ export function usePublishSku(options: {
|
|||||||
/** 与 images 等共享同一 ref,由壳层创建 */
|
/** 与 images 等共享同一 ref,由壳层创建 */
|
||||||
skuRows: Ref<SkuRow[]>;
|
skuRows: Ref<SkuRow[]>;
|
||||||
specAxes: Ref<SpecAxis[]>;
|
specAxes: Ref<SpecAxis[]>;
|
||||||
catTemplate: Ref<PddGoodsPublishVO.CatTemplate | null>;
|
catRule: Ref<PddGoodsPublishVO.CatRule | null>;
|
||||||
revokeUploadFiles: (files?: UploadFile[]) => void;
|
revokeUploadFiles: (files?: UploadFile[]) => void;
|
||||||
specHelpers: SpecHelpers;
|
specHelpers: SpecHelpers;
|
||||||
}) {
|
}) {
|
||||||
const { skuRows, specAxes, catTemplate, revokeUploadFiles, specHelpers } =
|
const { skuRows, specAxes, catRule, revokeUploadFiles, specHelpers } =
|
||||||
options;
|
options;
|
||||||
const {
|
const {
|
||||||
effectiveSpecSlots,
|
effectiveSpecSlots,
|
||||||
@@ -289,10 +289,11 @@ export function usePublishSku(options: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const combos = cartesianProduct(slotLists);
|
const combos = cartesianProduct(slotLists);
|
||||||
const maxSku = Number(catTemplate.value?.maxSkuNum ?? 0);
|
const specNumLimit = Number(catRule.value?.specNumLimit ?? 0);
|
||||||
if (maxSku > 0 && combos.length > maxSku) {
|
const valueSum = slotLists.reduce((sum, list) => sum + list.length, 0);
|
||||||
|
if (specNumLimit > 0 && valueSum > specNumLimit) {
|
||||||
message.warning(
|
message.warning(
|
||||||
`规格组合共 ${combos.length} 个,超过类目上限 ${maxSku},请减少规格值`,
|
`规格值合计 ${valueSum} 个,超过类目上限 ${specNumLimit},请减少规格值`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-10
@@ -65,14 +65,15 @@ export function usePublishSpecs(options: {
|
|||||||
const parents = parentSpecs.value;
|
const parents = parentSpecs.value;
|
||||||
if (parents.length > 0) {
|
if (parents.length > 0) {
|
||||||
return parents.map((ps) => {
|
return parents.map((ps) => {
|
||||||
const matchedSale = sales.find((s) => s.name === ps.parentSpecName);
|
const matchedSale =
|
||||||
|
sales.find((s) => s.parentSpecId === ps.parentSpecId) ||
|
||||||
|
sales.find((s) => s.name === ps.parentSpecName);
|
||||||
return {
|
return {
|
||||||
catalogKey: `ps_${ps.parentSpecId}`,
|
catalogKey: `ps_${ps.parentSpecId}`,
|
||||||
name: ps.parentSpecName || `规格${ps.parentSpecId}`,
|
name: ps.parentSpecName || `规格${ps.parentSpecId}`,
|
||||||
parentSpecId: ps.parentSpecId,
|
parentSpecId: ps.parentSpecId,
|
||||||
refPid: matchedSale?.refPid,
|
refPid: matchedSale?.refPid,
|
||||||
templatePid: matchedSale?.templatePid,
|
valueUnit: matchedSale?.valueUnits?.[0],
|
||||||
valueUnit: matchedSale?.valueUnit,
|
|
||||||
presetOptions: (matchedSale?.values || []).map((v) => ({
|
presetOptions: (matchedSale?.values || []).map((v) => ({
|
||||||
label: v.value || String(v.vid),
|
label: v.value || String(v.vid),
|
||||||
value: String(v.vid ?? v.value),
|
value: String(v.vid ?? v.value),
|
||||||
@@ -84,15 +85,14 @@ export function usePublishSpecs(options: {
|
|||||||
}
|
}
|
||||||
const items: SpecCatalogItem[] = [];
|
const items: SpecCatalogItem[] = [];
|
||||||
for (const sp of sales) {
|
for (const sp of sales) {
|
||||||
const parentSpecId = sp.specId;
|
const parentSpecId = sp.parentSpecId;
|
||||||
if (parentSpecId == null) continue;
|
if (parentSpecId == null) continue;
|
||||||
items.push({
|
items.push({
|
||||||
catalogKey: String(sp.refPid ?? sp.templatePid ?? parentSpecId),
|
catalogKey: String(sp.refPid ?? parentSpecId),
|
||||||
name: sp.name || String(parentSpecId),
|
name: sp.name || String(parentSpecId),
|
||||||
parentSpecId,
|
parentSpecId,
|
||||||
refPid: sp.refPid,
|
refPid: sp.refPid,
|
||||||
templatePid: sp.templatePid,
|
valueUnit: sp.valueUnits?.[0],
|
||||||
valueUnit: sp.valueUnit,
|
|
||||||
presetOptions: (sp.values || []).map((v) => ({
|
presetOptions: (sp.values || []).map((v) => ({
|
||||||
label: v.value || String(v.vid),
|
label: v.value || String(v.vid),
|
||||||
value: String(v.vid ?? v.value),
|
value: String(v.vid ?? v.value),
|
||||||
@@ -112,7 +112,6 @@ export function usePublishSpecs(options: {
|
|||||||
name: item.name,
|
name: item.name,
|
||||||
parentSpecId: item.parentSpecId,
|
parentSpecId: item.parentSpecId,
|
||||||
refPid: item.refPid,
|
refPid: item.refPid,
|
||||||
templatePid: item.templatePid,
|
|
||||||
valueUnit: item.valueUnit,
|
valueUnit: item.valueUnit,
|
||||||
presetOptions: item.presetOptions.map((o) => ({ ...o })),
|
presetOptions: item.presetOptions.map((o) => ({ ...o })),
|
||||||
// 默认一条空输入,随时可编辑
|
// 默认一条空输入,随时可编辑
|
||||||
@@ -221,7 +220,6 @@ export function usePublishSpecs(options: {
|
|||||||
name: match.name,
|
name: match.name,
|
||||||
parentSpecId: match.parentSpecId,
|
parentSpecId: match.parentSpecId,
|
||||||
refPid: match.refPid,
|
refPid: match.refPid,
|
||||||
templatePid: match.templatePid,
|
|
||||||
valueUnit: match.valueUnit,
|
valueUnit: match.valueUnit,
|
||||||
presetOptions: match.presetOptions.map((o) => ({ ...o })),
|
presetOptions: match.presetOptions.map((o) => ({ ...o })),
|
||||||
selectedValues:
|
selectedValues:
|
||||||
@@ -287,7 +285,6 @@ export function usePublishSpecs(options: {
|
|||||||
axis.name = item.name;
|
axis.name = item.name;
|
||||||
axis.parentSpecId = item.parentSpecId;
|
axis.parentSpecId = item.parentSpecId;
|
||||||
axis.refPid = item.refPid;
|
axis.refPid = item.refPid;
|
||||||
axis.templatePid = item.templatePid;
|
|
||||||
axis.valueUnit = item.valueUnit;
|
axis.valueUnit = item.valueUnit;
|
||||||
axis.presetOptions = item.presetOptions.map((o) => ({ ...o }));
|
axis.presetOptions = item.presetOptions.map((o) => ({ ...o }));
|
||||||
axis.selectedValues = [createSpecValueSlot('')];
|
axis.selectedValues = [createSpecValueSlot('')];
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export type SpecCatalogItem = {
|
|||||||
name: string;
|
name: string;
|
||||||
parentSpecId: number;
|
parentSpecId: number;
|
||||||
refPid?: number;
|
refPid?: number;
|
||||||
templatePid?: number;
|
|
||||||
valueUnit?: string;
|
valueUnit?: string;
|
||||||
presetOptions: {
|
presetOptions: {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -63,7 +62,6 @@ export type SpecAxis = {
|
|||||||
name: string;
|
name: string;
|
||||||
parentSpecId?: number;
|
parentSpecId?: number;
|
||||||
refPid?: number;
|
refPid?: number;
|
||||||
templatePid?: number;
|
|
||||||
valueUnit?: string;
|
valueUnit?: string;
|
||||||
presetOptions: SpecCatalogItem['presetOptions'];
|
presetOptions: SpecCatalogItem['presetOptions'];
|
||||||
selectedValues: SpecValueSlot[];
|
selectedValues: SpecValueSlot[];
|
||||||
@@ -103,7 +101,10 @@ export type PublishFormFields = {
|
|||||||
secondHand: boolean;
|
secondHand: boolean;
|
||||||
/** 表单展示用折扣:0–10,9.5=9.5折;提交接口时 *10 */
|
/** 表单展示用折扣:0–10,9.5=9.5折;提交接口时 *10 */
|
||||||
twoPiecesDiscount: number;
|
twoPiecesDiscount: number;
|
||||||
|
/** 非销售属性取值,key=refPid */
|
||||||
goodsPropValues: Record<string, string>;
|
goodsPropValues: Record<string, string>;
|
||||||
|
/** 非销售属性单位(value_unit),key=refPid */
|
||||||
|
goodsPropUnits: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 表单折扣 → 拼多多接口整数(9.5 → 95) */
|
/** 表单折扣 → 拼多多接口整数(9.5 → 95) */
|
||||||
@@ -136,6 +137,7 @@ export function createEmptyPublishForm(): PublishFormFields {
|
|||||||
secondHand: false,
|
secondHand: false,
|
||||||
twoPiecesDiscount: 9.5,
|
twoPiecesDiscount: 9.5,
|
||||||
goodsPropValues: {},
|
goodsPropValues: {},
|
||||||
|
goodsPropUnits: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+198
@@ -0,0 +1,198 @@
|
|||||||
|
import type {
|
||||||
|
PddGoodsPublishDTO,
|
||||||
|
PddGoodsPublishVO,
|
||||||
|
} from '#/api/channel/pdd/goods';
|
||||||
|
|
||||||
|
type CatProperty = PddGoodsPublishVO.CatProperty;
|
||||||
|
|
||||||
|
/** 属性取值控件类型(按 propertyValueType) */
|
||||||
|
export type CatPropControlKind =
|
||||||
|
| 'select'
|
||||||
|
| 'text'
|
||||||
|
| 'number'
|
||||||
|
| 'range'
|
||||||
|
| 'product2'
|
||||||
|
| 'product3'
|
||||||
|
| 'date'
|
||||||
|
| 'dateRange'
|
||||||
|
| 'month'
|
||||||
|
| 'time'
|
||||||
|
| 'material'
|
||||||
|
| 'unsupported';
|
||||||
|
|
||||||
|
/** 非空单位列表 */
|
||||||
|
export function effectiveValueUnits(p: CatProperty): string[] {
|
||||||
|
return (p.valueUnits ?? []).map((u) => String(u).trim()).filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据规则字段决定控件形态;有枚举值时优先下拉 */
|
||||||
|
export function resolveCatPropControlKind(p: CatProperty): CatPropControlKind {
|
||||||
|
if (p.values?.length) return 'select';
|
||||||
|
switch (p.propertyValueType ?? 0) {
|
||||||
|
case 1:
|
||||||
|
return 'number';
|
||||||
|
case 2:
|
||||||
|
return 'range';
|
||||||
|
case 3:
|
||||||
|
return 'product2';
|
||||||
|
case 4:
|
||||||
|
return 'product3';
|
||||||
|
case 5:
|
||||||
|
return 'date';
|
||||||
|
case 6:
|
||||||
|
return 'dateRange';
|
||||||
|
case 7:
|
||||||
|
return 'month';
|
||||||
|
case 8:
|
||||||
|
return 'time';
|
||||||
|
case 9:
|
||||||
|
return 'material';
|
||||||
|
default:
|
||||||
|
return 'text';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** show_condition:未配置则始终展示;配置了则父属性需命中 parentVids */
|
||||||
|
export function isCatPropVisible(
|
||||||
|
p: CatProperty,
|
||||||
|
goodsPropValues: Record<string, string>,
|
||||||
|
): boolean {
|
||||||
|
const conds = p.showCondition;
|
||||||
|
if (!conds?.length) return true;
|
||||||
|
return conds.every((c) => {
|
||||||
|
if (c.parentRefPid == null) return true;
|
||||||
|
const raw = goodsPropValues[String(c.parentRefPid)]?.trim();
|
||||||
|
if (!raw) return false;
|
||||||
|
const parentVids = c.parentVids ?? [];
|
||||||
|
if (!parentVids.length) return true;
|
||||||
|
const selected = raw
|
||||||
|
.split(',')
|
||||||
|
.map((s) => Number(s.trim()))
|
||||||
|
.filter((n) => !Number.isNaN(n));
|
||||||
|
return parentVids.some((vid) => selected.includes(vid));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 切换类目后为数值+单位属性预填首个单位 */
|
||||||
|
export function seedDefaultPropUnits(
|
||||||
|
props: CatProperty[],
|
||||||
|
existing: Record<string, string> = {},
|
||||||
|
): Record<string, string> {
|
||||||
|
const next = { ...existing };
|
||||||
|
for (const p of props) {
|
||||||
|
if (p.sale || p.sku || p.refPid == null) continue;
|
||||||
|
const key = String(p.refPid);
|
||||||
|
if (next[key]) continue;
|
||||||
|
const units = effectiveValueUnits(p);
|
||||||
|
if (units[0]) next[key] = units[0];
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 单条非销售属性 → goods_properties 项(多选拆成多条) */
|
||||||
|
export function buildGoodsPropertyItems(
|
||||||
|
p: CatProperty,
|
||||||
|
rawValue: string | undefined,
|
||||||
|
valueUnit: string | undefined,
|
||||||
|
): PddGoodsPublishDTO.GoodsProperty[] {
|
||||||
|
const raw = rawValue?.trim();
|
||||||
|
if (!raw) return [];
|
||||||
|
const unit = valueUnit?.trim() || undefined;
|
||||||
|
const kind = resolveCatPropControlKind(p);
|
||||||
|
|
||||||
|
if (kind === 'select' && p.values?.length) {
|
||||||
|
const tokens = raw.split(',').map((s) => s.trim()).filter(Boolean);
|
||||||
|
const items: PddGoodsPublishDTO.GoodsProperty[] = [];
|
||||||
|
for (const token of tokens) {
|
||||||
|
const matched = p.values.find(
|
||||||
|
(v) => String(v.vid) === token || v.value === token,
|
||||||
|
);
|
||||||
|
items.push({
|
||||||
|
refPid: p.refPid,
|
||||||
|
valueUnit: unit,
|
||||||
|
vid: matched?.vid,
|
||||||
|
value: matched?.value ?? token,
|
||||||
|
groupId: matched?.groupId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
refPid: p.refPid,
|
||||||
|
valueUnit: unit,
|
||||||
|
value: raw,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验必填/单位/数值范围。
|
||||||
|
* @returns 失败提示文案;通过返回 null
|
||||||
|
*/
|
||||||
|
export function validateCatPropValue(
|
||||||
|
p: CatProperty,
|
||||||
|
rawValue: string | undefined,
|
||||||
|
valueUnit: string | undefined,
|
||||||
|
): string | null {
|
||||||
|
const label = p.name || String(p.refPid);
|
||||||
|
const raw = rawValue?.trim() ?? '';
|
||||||
|
const kind = resolveCatPropControlKind(p);
|
||||||
|
|
||||||
|
if (kind === 'material') {
|
||||||
|
if (p.required) return `属性「${label}」暂不支持材质表填写,请更换类目或联系运营`;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.required && !raw) {
|
||||||
|
return `请填写必填属性:${label}`;
|
||||||
|
}
|
||||||
|
if (!raw) return null;
|
||||||
|
|
||||||
|
const units = effectiveValueUnits(p);
|
||||||
|
if (units.length && !(valueUnit?.trim())) {
|
||||||
|
return `请选择属性「${label}」的单位`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kind === 'number') {
|
||||||
|
const n = Number(raw);
|
||||||
|
if (Number.isNaN(n)) return `属性「${label}」须为数字`;
|
||||||
|
const min = p.minValue?.trim();
|
||||||
|
const max = p.maxValue?.trim();
|
||||||
|
if (min !== undefined && min !== '' && n < Number(min)) {
|
||||||
|
return `属性「${label}」不能小于 ${min}`;
|
||||||
|
}
|
||||||
|
// maxValue 为 "0" 且无业务含义时常见于日期类;数值属性有上限才校验
|
||||||
|
if (max !== undefined && max !== '' && Number(max) > 0 && n > Number(max)) {
|
||||||
|
return `属性「${label}」不能大于 ${max}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kind === 'range' || kind === 'product2' || kind === 'product3') {
|
||||||
|
const parts = raw.split(',').map((s) => s.trim());
|
||||||
|
const expect =
|
||||||
|
kind === 'range' || kind === 'product2' ? 2 : 3;
|
||||||
|
if (parts.length !== expect || parts.some((x) => !x || Number.isNaN(Number(x)))) {
|
||||||
|
return `属性「${label}」请按要求填写完整数值`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kind === 'date' && !/^\d{4}-\d{2}-\d{2}$/.test(raw)) {
|
||||||
|
return `属性「${label}」请选择日期(YYYY-MM-DD)`;
|
||||||
|
}
|
||||||
|
if (kind === 'month' && !/^\d{4}-\d{2}$/.test(raw)) {
|
||||||
|
return `属性「${label}」请选择月份(YYYY-MM)`;
|
||||||
|
}
|
||||||
|
if (kind === 'dateRange') {
|
||||||
|
const parts = raw.split(',');
|
||||||
|
if (
|
||||||
|
parts.length !== 2 ||
|
||||||
|
!parts.every((x) => /^\d{4}-\d{2}-\d{2}$/.test(x.trim()))
|
||||||
|
) {
|
||||||
|
return `属性「${label}」请选择日期区间`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user