mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 21:09:19 +08:00
refactor: 去掉拼多多商品手工增删改接口与删除入口
This commit is contained in:
+3
-24
@@ -6,13 +6,14 @@ import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
|||||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.CreatePddGoodsDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.PddGoodsFilterDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.PddGoodsFilterDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.UpdatePddGoodsDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsSyncResultVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsSyncResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsService;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼多多渠道商品:列表/详情/同步(入库靠同步与发布,不提供手工增删改)。
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/channel/pdd/goods")
|
@RequestMapping("/api/channel/pdd/goods")
|
||||||
public class PddGoodsController {
|
public class PddGoodsController {
|
||||||
@@ -23,28 +24,6 @@ public class PddGoodsController {
|
|||||||
this.pddGoodsService = pddGoodsService;
|
this.pddGoodsService = pddGoodsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@RequirePermission(value = "channel:pdd:goods:create", description = "创建拼多多商品", allowSuper = true)
|
|
||||||
public ApiResponse<PddGoodsVO> createPddGoods(@Valid @RequestBody CreatePddGoodsDTO createPddGoodsDTO) {
|
|
||||||
PddGoodsVO vo = pddGoodsService.createPddGoods(createPddGoodsDTO);
|
|
||||||
return ApiResponse.success("创建成功", vo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
|
||||||
@RequirePermission(value = "channel:pdd:goods:update", description = "更新拼多多商品", allowSuper = true)
|
|
||||||
public ApiResponse<PddGoodsVO> updatePddGoods(@Valid @RequestBody UpdatePddGoodsDTO updatePddGoodsDTO,
|
|
||||||
@PathVariable Long id) {
|
|
||||||
PddGoodsVO vo = pddGoodsService.updatePddGoods(updatePddGoodsDTO, id);
|
|
||||||
return ApiResponse.success("更新成功", vo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
|
||||||
@RequirePermission(value = "channel:pdd:goods:delete", description = "删除拼多多商品", allowSuper = true)
|
|
||||||
public ApiResponse<Void> deletePddGoods(@PathVariable Long id) {
|
|
||||||
pddGoodsService.deletePddGoods(id);
|
|
||||||
return ApiResponse.success("删除成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@RequirePermission(value = "channel:pdd:goods:read", description = "查询拼多多商品列表", allowSuper = true)
|
@RequirePermission(value = "channel:pdd:goods:read", description = "查询拼多多商品列表", allowSuper = true)
|
||||||
public ApiResponse<PageResultVO<PddGoodsVO>> getPddGoodsPage(
|
public ApiResponse<PageResultVO<PddGoodsVO>> getPddGoodsPage(
|
||||||
|
|||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class CreatePddGoodsDTO {
|
|
||||||
|
|
||||||
@NotNull(message = "渠道店铺ID不能为空")
|
|
||||||
private Long shopId;
|
|
||||||
|
|
||||||
@NotNull(message = "mall_id不能为空")
|
|
||||||
private Long mallId;
|
|
||||||
|
|
||||||
@NotBlank(message = "商品ID不能为空")
|
|
||||||
private String goodsId;
|
|
||||||
|
|
||||||
@NotBlank(message = "商品名称不能为空")
|
|
||||||
private String goodsName;
|
|
||||||
|
|
||||||
private Integer goodsQuantity;
|
|
||||||
|
|
||||||
private Integer goodsReserveQuantity;
|
|
||||||
|
|
||||||
private String imageUrl;
|
|
||||||
|
|
||||||
private String thumbUrl;
|
|
||||||
|
|
||||||
private Integer isMoreSku;
|
|
||||||
|
|
||||||
private Integer isOnsale;
|
|
||||||
|
|
||||||
private LocalDateTime pddCreatedAt;
|
|
||||||
|
|
||||||
private String rawResponse;
|
|
||||||
|
|
||||||
@NotNull(message = "同步时间不能为空")
|
|
||||||
private LocalDateTime lastSyncTime;
|
|
||||||
|
|
||||||
private List<CreatePddGoodsSkuDTO> skus;
|
|
||||||
}
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class CreatePddGoodsSkuDTO {
|
|
||||||
|
|
||||||
@NotBlank(message = "商品ID不能为空")
|
|
||||||
private String goodsId;
|
|
||||||
|
|
||||||
@NotBlank(message = "SKU ID不能为空")
|
|
||||||
private String skuId;
|
|
||||||
|
|
||||||
private String spec;
|
|
||||||
|
|
||||||
private String specDetails;
|
|
||||||
|
|
||||||
private Integer skuQuantity;
|
|
||||||
|
|
||||||
private Integer reserveQuantity;
|
|
||||||
|
|
||||||
private Integer isSkuOnsale;
|
|
||||||
|
|
||||||
private String outerGoodsId;
|
|
||||||
|
|
||||||
private String outerId;
|
|
||||||
}
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class UpdatePddGoodsDTO {
|
|
||||||
|
|
||||||
@NotNull(message = "渠道店铺ID不能为空")
|
|
||||||
private Long shopId;
|
|
||||||
|
|
||||||
@NotNull(message = "mall_id不能为空")
|
|
||||||
private Long mallId;
|
|
||||||
|
|
||||||
@NotBlank(message = "商品ID不能为空")
|
|
||||||
private String goodsId;
|
|
||||||
|
|
||||||
@NotBlank(message = "商品名称不能为空")
|
|
||||||
private String goodsName;
|
|
||||||
|
|
||||||
private Integer goodsQuantity;
|
|
||||||
|
|
||||||
private Integer goodsReserveQuantity;
|
|
||||||
|
|
||||||
private String imageUrl;
|
|
||||||
|
|
||||||
private String thumbUrl;
|
|
||||||
|
|
||||||
private Integer isMoreSku;
|
|
||||||
|
|
||||||
private Integer isOnsale;
|
|
||||||
|
|
||||||
private LocalDateTime pddCreatedAt;
|
|
||||||
|
|
||||||
private String rawResponse;
|
|
||||||
|
|
||||||
@NotNull(message = "同步时间不能为空")
|
|
||||||
private LocalDateTime lastSyncTime;
|
|
||||||
|
|
||||||
private List<CreatePddGoodsSkuDTO> skus;
|
|
||||||
}
|
|
||||||
-8
@@ -3,9 +3,7 @@ package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.CreatePddGoodsDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.PddGoodsFilterDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.PddGoodsFilterDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.UpdatePddGoodsDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.po.PddGoodsPO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.po.PddGoodsPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsSyncResultVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsSyncResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsVO;
|
||||||
@@ -13,12 +11,6 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.pop.goods.PddGoodsPopApiCli
|
|||||||
|
|
||||||
public interface PddGoodsService extends IService<PddGoodsPO> {
|
public interface PddGoodsService extends IService<PddGoodsPO> {
|
||||||
|
|
||||||
PddGoodsVO createPddGoods(CreatePddGoodsDTO createPddGoodsDTO);
|
|
||||||
|
|
||||||
PddGoodsVO updatePddGoods(UpdatePddGoodsDTO updatePddGoodsDTO, Long id);
|
|
||||||
|
|
||||||
void deletePddGoods(Long id);
|
|
||||||
|
|
||||||
PageResultVO<PddGoodsVO> getPddGoodsPage(PageQueryDTO<PddGoodsFilterDTO> pageQueryDTO);
|
PageResultVO<PddGoodsVO> getPddGoodsPage(PageQueryDTO<PddGoodsFilterDTO> pageQueryDTO);
|
||||||
|
|
||||||
PddGoodsVO getPddGoodsDetail(Long id);
|
PddGoodsVO getPddGoodsDetail(Long id);
|
||||||
|
|||||||
+1
-93
@@ -18,10 +18,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.auth.service.PddAuthTokenSe
|
|||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.ensure.PddGoodsEnsureService;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.ensure.PddGoodsEnsureService;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.mapper.PddGoodsMapper;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.mapper.PddGoodsMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.mapper.PddGoodsSkuMapper;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.mapper.PddGoodsSkuMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.CreatePddGoodsDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.CreatePddGoodsSkuDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.PddGoodsFilterDTO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.PddGoodsFilterDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.UpdatePddGoodsDTO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.po.PddGoodsPO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.po.PddGoodsPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.po.PddGoodsSkuPO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.po.PddGoodsSkuPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsSkuVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.PddGoodsSkuVO;
|
||||||
@@ -45,7 +42,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼多多渠道商品 CRUD 与列表同步;主表不定内部商品。
|
* 拼多多渠道商品查询与同步;主表不定内部商品。手工增删改已下线。
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@@ -78,87 +75,6 @@ public class PddGoodsServiceImpl extends ServiceImpl<PddGoodsMapper, PddGoodsPO>
|
|||||||
this.currentUserContext = currentUserContext;
|
this.currentUserContext = currentUserContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public PddGoodsVO createPddGoods(CreatePddGoodsDTO createPddGoodsDTO) {
|
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
|
||||||
|
|
||||||
LambdaQueryWrapper<PddGoodsPO> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(PddGoodsPO::getShopId, createPddGoodsDTO.getShopId())
|
|
||||||
.eq(PddGoodsPO::getGoodsId, createPddGoodsDTO.getGoodsId());
|
|
||||||
if (this.count(wrapper) > 0) {
|
|
||||||
throw new BusinessException("该商品已存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
PddGoodsPO goods = new PddGoodsPO();
|
|
||||||
BeanCopyUtils.copyProperties(createPddGoodsDTO, goods);
|
|
||||||
goods.setCompanyId(companyId);
|
|
||||||
this.save(goods);
|
|
||||||
|
|
||||||
if (createPddGoodsDTO.getSkus() != null && !createPddGoodsDTO.getSkus().isEmpty()) {
|
|
||||||
List<PddGoodsSkuPO> skus = createPddGoodsDTO.getSkus().stream()
|
|
||||||
.map(skuDTO -> convertToSkuPO(skuDTO, goods.getId(), companyId))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
skus.forEach(pddGoodsSkuMapper::insert);
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertToVO(goods);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public PddGoodsVO updatePddGoods(UpdatePddGoodsDTO updatePddGoodsDTO, Long id) {
|
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
|
||||||
|
|
||||||
PddGoodsPO existing = this.getById(id);
|
|
||||||
if (existing == null || !companyId.equals(existing.getCompanyId())) {
|
|
||||||
throw new BusinessException("商品不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
LambdaQueryWrapper<PddGoodsPO> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(PddGoodsPO::getShopId, updatePddGoodsDTO.getShopId())
|
|
||||||
.eq(PddGoodsPO::getGoodsId, updatePddGoodsDTO.getGoodsId())
|
|
||||||
.ne(PddGoodsPO::getId, id);
|
|
||||||
if (this.count(wrapper) > 0) {
|
|
||||||
throw new BusinessException("该商品已存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
PddGoodsPO goods = new PddGoodsPO();
|
|
||||||
BeanCopyUtils.copyProperties(updatePddGoodsDTO, goods);
|
|
||||||
goods.setId(id);
|
|
||||||
goods.setCompanyId(companyId);
|
|
||||||
this.updateById(goods);
|
|
||||||
|
|
||||||
LambdaQueryWrapper<PddGoodsSkuPO> deleteWrapper = new LambdaQueryWrapper<>();
|
|
||||||
deleteWrapper.eq(PddGoodsSkuPO::getGoodsRowId, id);
|
|
||||||
pddGoodsSkuMapper.delete(deleteWrapper);
|
|
||||||
|
|
||||||
if (updatePddGoodsDTO.getSkus() != null && !updatePddGoodsDTO.getSkus().isEmpty()) {
|
|
||||||
List<PddGoodsSkuPO> skus = updatePddGoodsDTO.getSkus().stream()
|
|
||||||
.map(skuDTO -> convertToSkuPO(skuDTO, id, companyId))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
skus.forEach(pddGoodsSkuMapper::insert);
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertToVO(this.getById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void deletePddGoods(Long id) {
|
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
|
||||||
PddGoodsPO existing = this.getById(id);
|
|
||||||
if (existing == null || !companyId.equals(existing.getCompanyId())) {
|
|
||||||
throw new BusinessException("商品不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
LambdaQueryWrapper<PddGoodsSkuPO> deleteWrapper = new LambdaQueryWrapper<>();
|
|
||||||
deleteWrapper.eq(PddGoodsSkuPO::getGoodsRowId, id);
|
|
||||||
pddGoodsSkuMapper.delete(deleteWrapper);
|
|
||||||
|
|
||||||
this.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<PddGoodsVO> getPddGoodsPage(PageQueryDTO<PddGoodsFilterDTO> pageQueryDTO) {
|
public PageResultVO<PddGoodsVO> getPddGoodsPage(PageQueryDTO<PddGoodsFilterDTO> pageQueryDTO) {
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
@@ -503,14 +419,6 @@ public class PddGoodsServiceImpl extends ServiceImpl<PddGoodsMapper, PddGoodsPO>
|
|||||||
return LocalDateTime.ofInstant(Instant.ofEpochSecond(epochSec), ZONE);
|
return LocalDateTime.ofInstant(Instant.ofEpochSecond(epochSec), ZONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PddGoodsSkuPO convertToSkuPO(CreatePddGoodsSkuDTO dto, Long goodsRowId, Long companyId) {
|
|
||||||
PddGoodsSkuPO sku = new PddGoodsSkuPO();
|
|
||||||
BeanCopyUtils.copyProperties(dto, sku);
|
|
||||||
sku.setGoodsRowId(goodsRowId);
|
|
||||||
sku.setCompanyId(companyId);
|
|
||||||
return sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PddGoodsVO convertToBriefVO(PddGoodsPO goods) {
|
private PddGoodsVO convertToBriefVO(PddGoodsPO goods) {
|
||||||
PddGoodsVO vo = new PddGoodsVO();
|
PddGoodsVO vo = new PddGoodsVO();
|
||||||
BeanCopyUtils.copyProperties(goods, vo);
|
BeanCopyUtils.copyProperties(goods, vo);
|
||||||
|
|||||||
+8
@@ -92,6 +92,14 @@ public class ProductSkuController {
|
|||||||
return ApiResponse.success("查询SKU成功", vo);
|
return ApiResponse.success("查询SKU成功", vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 按公司内 SKU 编码反查,返回所属内部商品信息 */
|
||||||
|
@GetMapping("/find-by-sku-code")
|
||||||
|
@RequirePermission(value = "ec:product:read", description = "根据SKU编码反查内部商品", allowSuper = true)
|
||||||
|
public ApiResponse<ProductSkuVO> getProductSkuBySkuCode(@RequestParam("skuCode") String skuCode) {
|
||||||
|
ProductSkuVO vo = productSkuService.getProductSkuBySkuCode(skuCode);
|
||||||
|
return ApiResponse.success("查询SKU成功", vo);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/find-by-product-and-skus")
|
@PostMapping("/find-by-product-and-skus")
|
||||||
@RequirePermission(value = "ec:product:read", description = "批量根据商品名称和SKU编码查询", allowSuper = true)
|
@RequirePermission(value = "ec:product:read", description = "批量根据商品名称和SKU编码查询", allowSuper = true)
|
||||||
public ApiResponse<List<ProductVO>> getProductSkusByProductAndSkus(@RequestBody List<ProductSkuQueryDTO> queries) {
|
public ApiResponse<List<ProductVO>> getProductSkusByProductAndSkus(@RequestBody List<ProductSkuQueryDTO> queries) {
|
||||||
|
|||||||
+5
@@ -33,6 +33,11 @@ public interface ProductSkuService extends IService<ProductSkuPO> {
|
|||||||
|
|
||||||
ProductSkuVO getProductSkuByProductAndSku(String productName, String skuCode);
|
ProductSkuVO getProductSkuByProductAndSku(String productName, String skuCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前公司内按 SKU 编码反查(含所属商品 id/名称)。
|
||||||
|
*/
|
||||||
|
ProductSkuVO getProductSkuBySkuCode(String skuCode);
|
||||||
|
|
||||||
List<ProductVO> getProductSkusByProductAndSkus(List<ProductSkuQueryDTO> queries);
|
List<ProductVO> getProductSkusByProductAndSkus(List<ProductSkuQueryDTO> queries);
|
||||||
|
|
||||||
ProductSkuPO getByCompanyIdAndSkuCode(Long companyId, String skuCode);
|
ProductSkuPO getByCompanyIdAndSkuCode(Long companyId, String skuCode);
|
||||||
|
|||||||
+20
@@ -288,6 +288,26 @@ public class ProductSkuServiceImpl extends ServiceImpl<ProductSkuMapper, Product
|
|||||||
return sku == null ? null : toVo(sku);
|
return sku == null ? null : toVo(sku);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProductSkuVO getProductSkuBySkuCode(String skuCode) {
|
||||||
|
if (skuCode == null || skuCode.isBlank()) {
|
||||||
|
throw new BusinessException("SKU编码不能为空");
|
||||||
|
}
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
ProductSkuPO sku = getByCompanyIdAndSkuCode(companyId, skuCode.trim());
|
||||||
|
if (sku == null) {
|
||||||
|
throw new BusinessException("未找到对应的内部SKU: " + skuCode.trim());
|
||||||
|
}
|
||||||
|
ProductSkuVO vo = toVo(sku);
|
||||||
|
if (sku.getProductId() != null) {
|
||||||
|
ProductPO product = productService.getById(sku.getProductId());
|
||||||
|
if (product != null) {
|
||||||
|
vo.setProductName(product.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProductSkuPO getByCompanyIdAndSkuCode(Long companyId, String skuCode) {
|
public ProductSkuPO getByCompanyIdAndSkuCode(Long companyId, String skuCode) {
|
||||||
if (companyId == null || skuCode == null || skuCode.isBlank()) {
|
if (companyId == null || skuCode == null || skuCode.isBlank()) {
|
||||||
|
|||||||
@@ -24,11 +24,6 @@ export async function getPddGoodsDetailApi(id: number) {
|
|||||||
return requestClient.get<PddGoodsVO.Info>(`/channel/pdd/goods/detail/${id}`);
|
return requestClient.get<PddGoodsVO.Info>(`/channel/pdd/goods/detail/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除拼多多商品及 SKU */
|
|
||||||
export async function deletePddGoodsApi(id: number) {
|
|
||||||
return requestClient.delete<void>(`/channel/pdd/goods/delete/${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 按渠道店铺同步商品 */
|
/** 按渠道店铺同步商品 */
|
||||||
export async function syncPddGoodsByShopApi(pddShopId: number) {
|
export async function syncPddGoodsByShopApi(pddShopId: number) {
|
||||||
return requestClient.post<PddGoodsVO.SyncResult>(
|
return requestClient.post<PddGoodsVO.SyncResult>(
|
||||||
|
|||||||
@@ -68,6 +68,16 @@ export async function getProductSkuByProductAndSkuApi(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按 SKU 编码反查内部 SKU(含所属商品 id/名称)
|
||||||
|
*/
|
||||||
|
export async function getProductSkuBySkuCodeApi(skuCode: string) {
|
||||||
|
return requestClient.get<ProductSkuVO.Info>(
|
||||||
|
'/ec/product/sku/find-by-sku-code',
|
||||||
|
{ params: { skuCode } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量根据商品名称和 SKU 编码查询商品 SKU
|
* 批量根据商品名称和 SKU 编码查询商品 SKU
|
||||||
*/
|
*/
|
||||||
|
|||||||
+59
-8
@@ -4,6 +4,7 @@ import type { PddGoodsVO } from '#/api/channel/pdd/goods';
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Button,
|
||||||
Descriptions,
|
Descriptions,
|
||||||
DescriptionsItem,
|
DescriptionsItem,
|
||||||
Drawer,
|
Drawer,
|
||||||
@@ -15,6 +16,8 @@ import {
|
|||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import { getPddGoodsDetailApi } from '#/api/channel/pdd/goods';
|
import { getPddGoodsDetailApi } from '#/api/channel/pdd/goods';
|
||||||
|
import { getProductSkuBySkuCodeApi } from '#/api/ec/product/sku';
|
||||||
|
import ProductDetailModal from '#/views/ec/product/list/components/ProductDetailModal.vue';
|
||||||
|
|
||||||
defineOptions({ name: 'PddGoodsDetailDrawer' });
|
defineOptions({ name: 'PddGoodsDetailDrawer' });
|
||||||
|
|
||||||
@@ -22,8 +25,18 @@ const openFlag = ref(false);
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const shopName = ref('');
|
const shopName = ref('');
|
||||||
const detail = ref<null | PddGoodsVO.Info>(null);
|
const detail = ref<null | PddGoodsVO.Info>(null);
|
||||||
|
const productDetailModalRef = ref<InstanceType<typeof ProductDetailModal>>();
|
||||||
|
const resolvingOuterId = ref<null | string>(null);
|
||||||
|
|
||||||
const skuColumns = [
|
const skuColumns = [
|
||||||
|
{
|
||||||
|
// POP outer_goods_id:商家外部商品编码(非内部商品)
|
||||||
|
title: '外部商品编码',
|
||||||
|
dataIndex: 'outerGoodsId',
|
||||||
|
key: 'outerGoodsId',
|
||||||
|
ellipsis: true,
|
||||||
|
width: 140,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '外部SKU',
|
title: '外部SKU',
|
||||||
dataIndex: 'outerId',
|
dataIndex: 'outerId',
|
||||||
@@ -40,13 +53,6 @@ const skuColumns = [
|
|||||||
width: 80,
|
width: 80,
|
||||||
},
|
},
|
||||||
{ title: '在架', key: 'isSkuOnsale', width: 80 },
|
{ title: '在架', key: 'isSkuOnsale', width: 80 },
|
||||||
{
|
|
||||||
title: '外部商品',
|
|
||||||
dataIndex: 'outerGoodsId',
|
|
||||||
key: 'outerGoodsId',
|
|
||||||
ellipsis: true,
|
|
||||||
width: 120,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
async function open(id: number, shopLabel?: string) {
|
async function open(id: number, shopLabel?: string) {
|
||||||
@@ -69,6 +75,31 @@ function close() {
|
|||||||
openFlag.value = false;
|
openFlag.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 点击外部 SKU:按 sku_code 反查并打开内部商品详情 */
|
||||||
|
async function openInternalProductByOuterId(outerId?: string) {
|
||||||
|
const code = outerId?.trim();
|
||||||
|
if (!code) {
|
||||||
|
message.warning('该规格无外部SKU编码');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (resolvingOuterId.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolvingOuterId.value = code;
|
||||||
|
try {
|
||||||
|
const sku = await getProductSkuBySkuCodeApi(code);
|
||||||
|
if (!sku?.productId) {
|
||||||
|
message.warning(`未匹配到内部商品:${code}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await productDetailModalRef.value?.openById(sku.productId, sku.productName);
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || `未找到内部SKU:${code}`);
|
||||||
|
} finally {
|
||||||
|
resolvingOuterId.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({ open, close });
|
defineExpose({ open, close });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -137,7 +168,25 @@ defineExpose({ open, close });
|
|||||||
:scroll="{ x: 700 }"
|
:scroll="{ x: 700 }"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.key === 'isSkuOnsale'">
|
<template v-if="column.key === 'outerGoodsId'">
|
||||||
|
<span :class="record.outerGoodsId ? '' : 'text-slate-400'">
|
||||||
|
{{ record.outerGoodsId || '-' }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'outerId'">
|
||||||
|
<Button
|
||||||
|
v-if="record.outerId"
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
class="!px-0"
|
||||||
|
:loading="resolvingOuterId === record.outerId"
|
||||||
|
@click="openInternalProductByOuterId(record.outerId)"
|
||||||
|
>
|
||||||
|
{{ record.outerId }}
|
||||||
|
</Button>
|
||||||
|
<span v-else class="text-slate-400">-</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'isSkuOnsale'">
|
||||||
<Tag :color="record.isSkuOnsale === 1 ? 'success' : 'default'">
|
<Tag :color="record.isSkuOnsale === 1 ? 'success' : 'default'">
|
||||||
{{ record.isSkuOnsale === 1 ? '在架' : '下架' }}
|
{{ record.isSkuOnsale === 1 ? '在架' : '下架' }}
|
||||||
</Tag>
|
</Tag>
|
||||||
@@ -146,5 +195,7 @@ defineExpose({ open, close });
|
|||||||
</Table>
|
</Table>
|
||||||
</template>
|
</template>
|
||||||
</Spin>
|
</Spin>
|
||||||
|
|
||||||
|
<ProductDetailModal ref="productDetailModalRef" :show-actions="false" />
|
||||||
</Drawer>
|
</Drawer>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -6,13 +6,10 @@ import type { PageQueryDTO } from '#/types/common';
|
|||||||
|
|
||||||
import { computed, onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { Button, Card, Image, Popconfirm, Space, Tag, message } from 'ant-design-vue';
|
import { Button, Card, Image, Tag, message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import { getPddGoodsPageApi } from '#/api/channel/pdd/goods';
|
||||||
deletePddGoodsApi,
|
|
||||||
getPddGoodsPageApi,
|
|
||||||
} from '#/api/channel/pdd/goods';
|
|
||||||
import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
import { getPddShopPageApi } from '#/api/channel/pdd/shop';
|
||||||
import { PermissionGate } from '#/components/permission';
|
import { PermissionGate } from '#/components/permission';
|
||||||
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
|
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
|
||||||
@@ -123,7 +120,7 @@ const gridOptions: VxeGridProps<PddGoodsVO.Info> = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 140,
|
width: 88,
|
||||||
fixed: 'right' as const,
|
fixed: 'right' as const,
|
||||||
showOverflow: false,
|
showOverflow: false,
|
||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
@@ -288,16 +285,6 @@ function openShopDetail(row: PddGoodsVO.Info) {
|
|||||||
shopDetailModalRef.value?.open(row.shopId);
|
shopDetailModalRef.value?.open(row.shopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDelete(row: PddGoodsVO.Info) {
|
|
||||||
try {
|
|
||||||
await deletePddGoodsApi(row.id);
|
|
||||||
message.success('已删除');
|
|
||||||
gridApi.reload();
|
|
||||||
} catch (error: any) {
|
|
||||||
message.error(error?.message || '删除失败');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadShopNames();
|
await loadShopNames();
|
||||||
});
|
});
|
||||||
@@ -373,19 +360,9 @@ onMounted(async () => {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #action="{ row }: { row: PddGoodsVO.Info }">
|
<template #action="{ row }: { row: PddGoodsVO.Info }">
|
||||||
<Space size="small" :wrap="false">
|
|
||||||
<Button type="link" size="small" @click="openDetail(row)">
|
<Button type="link" size="small" @click="openDetail(row)">
|
||||||
详情
|
详情
|
||||||
</Button>
|
</Button>
|
||||||
<PermissionGate code="channel:pdd:goods:delete">
|
|
||||||
<Popconfirm
|
|
||||||
title="确定删除该商品及全部 SKU 吗?"
|
|
||||||
@confirm="handleDelete(row)"
|
|
||||||
>
|
|
||||||
<Button type="link" size="small" danger>删除</Button>
|
|
||||||
</Popconfirm>
|
|
||||||
</PermissionGate>
|
|
||||||
</Space>
|
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+66
-2
@@ -8,15 +8,26 @@ import { useRouter } from 'vue-router';
|
|||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { Button, Image, Space, Table, Tooltip } from 'ant-design-vue';
|
import { Button, Image, Space, Spin, Table, Tooltip, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getProductSkuPageApi } from '#/api/ec/product/sku';
|
||||||
|
|
||||||
defineOptions({ name: 'ProductDetailModal' });
|
defineOptions({ name: 'ProductDetailModal' });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
/** 是否展示编辑/成本等操作按钮,渠道侧只读可关 */
|
||||||
|
showActions?: boolean;
|
||||||
|
}>(),
|
||||||
|
{ showActions: true },
|
||||||
|
);
|
||||||
|
|
||||||
const ChartIcon = createIconifyIcon('lucide:line-chart');
|
const ChartIcon = createIconifyIcon('lucide:line-chart');
|
||||||
const EditIcon = createIconifyIcon('lucide:square-pen');
|
const EditIcon = createIconifyIcon('lucide:square-pen');
|
||||||
const ImageIcon = createIconifyIcon('lucide:image');
|
const ImageIcon = createIconifyIcon('lucide:image');
|
||||||
|
|
||||||
const product = ref<ProductVO.Info | null>(null);
|
const product = ref<ProductVO.Info | null>(null);
|
||||||
|
const loading = ref(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -131,15 +142,60 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
footer: false,
|
footer: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 打开详情模态框 */
|
/** 打开详情模态框(已有完整商品对象) */
|
||||||
function open(record: ProductVO.Info) {
|
function open(record: ProductVO.Info) {
|
||||||
product.value = record;
|
product.value = record;
|
||||||
|
loading.value = false;
|
||||||
modalApi.setState({
|
modalApi.setState({
|
||||||
title: `商品详情 - ${record.name}`,
|
title: `商品详情 - ${record.name}`,
|
||||||
});
|
});
|
||||||
modalApi.open();
|
modalApi.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按内部商品 ID 加载后打开。
|
||||||
|
* @param productId 内部商品 ID
|
||||||
|
* @param fallbackName 列表侧已知名称(可选)
|
||||||
|
*/
|
||||||
|
async function openById(productId: number, fallbackName?: string) {
|
||||||
|
if (!productId) {
|
||||||
|
message.warning('未关联内部商品');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
product.value = null;
|
||||||
|
loading.value = true;
|
||||||
|
modalApi.setState({
|
||||||
|
title: fallbackName ? `商品详情 - ${fallbackName}` : '商品详情',
|
||||||
|
});
|
||||||
|
modalApi.open();
|
||||||
|
try {
|
||||||
|
const data = await getProductSkuPageApi({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 500,
|
||||||
|
filters: { productId },
|
||||||
|
});
|
||||||
|
const skus = (data.records ?? []) as ProductVO.SkuInfo[];
|
||||||
|
const first = skus[0];
|
||||||
|
const name = fallbackName || first?.productName || `商品#${productId}`;
|
||||||
|
product.value = {
|
||||||
|
id: productId,
|
||||||
|
companyId: first?.companyId ?? 0,
|
||||||
|
name,
|
||||||
|
mainImage: first?.imageUrl,
|
||||||
|
createTime: first?.createTime ?? '',
|
||||||
|
updateTime: first?.updateTime ?? '',
|
||||||
|
skus,
|
||||||
|
};
|
||||||
|
modalApi.setState({ title: `商品详情 - ${name}` });
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error(error);
|
||||||
|
message.error(error?.message || '加载内部商品详情失败');
|
||||||
|
modalApi.close();
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 跳转经营统计 */
|
/** 跳转经营统计 */
|
||||||
function goOverview() {
|
function goOverview() {
|
||||||
if (!product.value) return;
|
if (!product.value) return;
|
||||||
@@ -164,11 +220,13 @@ function handleManageCost() {
|
|||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
|
openById,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal>
|
<Modal>
|
||||||
|
<Spin :spinning="loading">
|
||||||
<div v-if="product" class="space-y-5">
|
<div v-if="product" class="space-y-5">
|
||||||
<!-- 商品基础信息 -->
|
<!-- 商品基础信息 -->
|
||||||
<div
|
<div
|
||||||
@@ -235,6 +293,7 @@ defineExpose({
|
|||||||
<div class="flex justify-end border-t border-slate-200 pt-4 dark:border-[hsl(240deg_3.7%_22%)]">
|
<div class="flex justify-end border-t border-slate-200 pt-4 dark:border-[hsl(240deg_3.7%_22%)]">
|
||||||
<Space>
|
<Space>
|
||||||
<Button @click="modalApi.close()">关闭</Button>
|
<Button @click="modalApi.close()">关闭</Button>
|
||||||
|
<template v-if="props.showActions">
|
||||||
<Button @click="goOverview">
|
<Button @click="goOverview">
|
||||||
<ChartIcon class="mr-1 h-4 w-4" />
|
<ChartIcon class="mr-1 h-4 w-4" />
|
||||||
经营统计
|
经营统计
|
||||||
@@ -244,8 +303,13 @@ defineExpose({
|
|||||||
<EditIcon class="mr-1 h-4 w-4" />
|
<EditIcon class="mr-1 h-4 w-4" />
|
||||||
编辑商品
|
编辑商品
|
||||||
</Button>
|
</Button>
|
||||||
|
</template>
|
||||||
</Space>
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="!loading" class="py-10 text-center text-slate-400">
|
||||||
|
暂无商品数据
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user