mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 10:29:19 +08:00
refactor: 发品去掉主内部商品绑定,改由订单同步兜底建品
This commit is contained in:
-4
@@ -24,10 +24,6 @@ public class PddGoodsPublishDTO {
|
||||
*/
|
||||
private Long systemDraftId;
|
||||
|
||||
/** 渠道商品绑定的主内部商品 */
|
||||
@NotNull(message = "主内部商品不能为空")
|
||||
private Long primaryProductId;
|
||||
|
||||
@NotBlank(message = "商品标题不能为空")
|
||||
private String goodsName;
|
||||
|
||||
|
||||
+4
-35
@@ -41,14 +41,11 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsPublishService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.support.PddGoodsImageTransfer;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.service.PddProductAutoCreateService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.pop.PddAuthFailureException;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.pop.goods.PddGoodsPopApiClient;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.pop.goods.PddGoodsPublishPopApiClient;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.mapper.PddShopMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.model.po.PddShopPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.product.mapper.ProductMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.product.model.po.ProductPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.po.ProductSkuPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.service.ProductSkuService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
@@ -73,11 +70,9 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
private final PddGoodsPublishPopApiClient publishPopApiClient;
|
||||
private final PddGoodsPopApiClient goodsPopApiClient;
|
||||
private final PddGoodsImageTransfer imageTransfer;
|
||||
private final ProductMapper productMapper;
|
||||
private final ProductSkuService productSkuService;
|
||||
private final PddGoodsService pddGoodsService;
|
||||
private final PddGoodsMapper pddGoodsMapper;
|
||||
private final PddProductAutoCreateService productAutoCreateService;
|
||||
private final PddGoodsPublishDraftMapper publishDraftMapper;
|
||||
|
||||
public PddGoodsPublishServiceImpl(CurrentUserContext currentUserContext,
|
||||
@@ -86,11 +81,9 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
PddGoodsPublishPopApiClient publishPopApiClient,
|
||||
PddGoodsPopApiClient goodsPopApiClient,
|
||||
PddGoodsImageTransfer imageTransfer,
|
||||
ProductMapper productMapper,
|
||||
ProductSkuService productSkuService,
|
||||
PddGoodsService pddGoodsService,
|
||||
PddGoodsMapper pddGoodsMapper,
|
||||
PddProductAutoCreateService productAutoCreateService,
|
||||
PddGoodsPublishDraftMapper publishDraftMapper) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.pddShopMapper = pddShopMapper;
|
||||
@@ -98,11 +91,9 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
this.publishPopApiClient = publishPopApiClient;
|
||||
this.goodsPopApiClient = goodsPopApiClient;
|
||||
this.imageTransfer = imageTransfer;
|
||||
this.productMapper = productMapper;
|
||||
this.productSkuService = productSkuService;
|
||||
this.pddGoodsService = pddGoodsService;
|
||||
this.pddGoodsMapper = pddGoodsMapper;
|
||||
this.productAutoCreateService = productAutoCreateService;
|
||||
this.publishDraftMapper = publishDraftMapper;
|
||||
}
|
||||
|
||||
@@ -290,13 +281,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
throw new BusinessException("发布成功但拉取商品详情为空 goodsId=" + addResult.goodsId());
|
||||
}
|
||||
|
||||
ProductPO primary = productMapper.selectById(dto.getPrimaryProductId());
|
||||
if (primary == null || !Objects.equals(primary.getCompanyId(), companyId)) {
|
||||
throw new BusinessException("主内部商品不存在或不属于当前公司");
|
||||
}
|
||||
|
||||
// 主商品下补缺失 SKU(外商品已有 sku_code 会跳过,不挪绑)
|
||||
productAutoCreateService.ensureMissingSkus(companyId, primary.getId(), detailInfo);
|
||||
// 不定主内部商品;缺 SKU 由订单同步等路径兜底建品
|
||||
pddGoodsService.upsertFromGoodsDetail(
|
||||
companyId, ctx.shop().getId(), ctx.mallId(), detailInfo);
|
||||
|
||||
@@ -317,8 +302,8 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
result.setGoods(goodsVo);
|
||||
bindSystemDraftAfterPublish(companyId, dto.getSystemDraftId(),
|
||||
addResult.goodsCommitId(), addResult.goodsId());
|
||||
log.info("拼多多商品发布成功 companyId={} shopId={} goodsId={} primaryProductId={}",
|
||||
companyId, ctx.shop().getId(), addResult.goodsId(), primary.getId());
|
||||
log.info("拼多多商品发布成功 companyId={} shopId={} goodsId={}",
|
||||
companyId, ctx.shop().getId(), addResult.goodsId());
|
||||
return result;
|
||||
} catch (BusinessException e) {
|
||||
throw e;
|
||||
@@ -365,22 +350,6 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
*/
|
||||
private PddGoodsPublishPopApiClient.GoodsAddCommand assembleAddCommand(
|
||||
PddGoodsPublishDTO dto, Long companyId, ShopAuth ctx, boolean strict) throws Exception {
|
||||
String outGoodsId = null;
|
||||
if (dto.getPrimaryProductId() != null) {
|
||||
ProductPO primary = productMapper.selectById(dto.getPrimaryProductId());
|
||||
if (primary == null || !Objects.equals(primary.getCompanyId(), companyId)) {
|
||||
if (strict) {
|
||||
throw new BusinessException("主内部商品不存在或不属于当前公司");
|
||||
}
|
||||
} else if (StringUtils.hasText(primary.getProductCode())) {
|
||||
outGoodsId = primary.getProductCode().trim();
|
||||
} else if (strict) {
|
||||
throw new BusinessException("主内部商品缺少商品编码,无法写入 out_goods_id");
|
||||
}
|
||||
} else if (strict) {
|
||||
throw new BusinessException("主内部商品不能为空");
|
||||
}
|
||||
|
||||
List<PddGoodsPublishSkuDTO> skuDtos = dto.getSkus() == null ? List.of() : dto.getSkus();
|
||||
if (strict && skuDtos.isEmpty()) {
|
||||
throw new BusinessException("SKU列表不能为空");
|
||||
@@ -486,7 +455,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
dto.getTwoPiecesDiscount() == null ? 95 : dto.getTwoPiecesDiscount(),
|
||||
carousel,
|
||||
detail,
|
||||
outGoodsId,
|
||||
null,
|
||||
mainImage,
|
||||
goodsProps,
|
||||
skuAdds);
|
||||
|
||||
Reference in New Issue
Block a user