mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 07:09:20 +08:00
refactor: 去掉拼多多商品手工增删改接口与删除入口
This commit is contained in:
+4
-25
@@ -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.vo.PageResultVO;
|
||||
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.UpdatePddGoodsDTO;
|
||||
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.service.PddGoodsService;
|
||||
|
||||
/**
|
||||
* 拼多多渠道商品:列表/详情/同步(入库靠同步与发布,不提供手工增删改)。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/channel/pdd/goods")
|
||||
public class PddGoodsController {
|
||||
@@ -23,28 +24,6 @@ public class PddGoodsController {
|
||||
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")
|
||||
@RequirePermission(value = "channel:pdd:goods:read", description = "查询拼多多商品列表", allowSuper = true)
|
||||
public ApiResponse<PageResultVO<PddGoodsVO>> getPddGoodsPage(
|
||||
@@ -63,7 +42,7 @@ public class PddGoodsController {
|
||||
@PostMapping("/sync/{pddShopId}")
|
||||
@RequirePermission(value = "channel:pdd:goods:sync", description = "同步拼多多商品", allowSuper = true)
|
||||
public ApiResponse<PddGoodsSyncResultVO> syncGoodsByPddShop(
|
||||
@PathVariable Long pddShopId) {
|
||||
@PathVariable Long pddShopId) {
|
||||
PddGoodsSyncResultVO result = pddGoodsService.syncGoodsByPddShop(pddShopId);
|
||||
return ApiResponse.success("同步完成", result);
|
||||
}
|
||||
|
||||
-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 top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
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.UpdatePddGoodsDTO;
|
||||
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.PddGoodsVO;
|
||||
@@ -13,12 +11,6 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.pop.goods.PddGoodsPopApiCli
|
||||
|
||||
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);
|
||||
|
||||
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.mapper.PddGoodsMapper;
|
||||
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.UpdatePddGoodsDTO;
|
||||
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.vo.PddGoodsSkuVO;
|
||||
@@ -45,7 +42,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 拼多多渠道商品 CRUD 与列表同步;主表不定内部商品。
|
||||
* 拼多多渠道商品查询与同步;主表不定内部商品。手工增删改已下线。
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -78,87 +75,6 @@ public class PddGoodsServiceImpl extends ServiceImpl<PddGoodsMapper, PddGoodsPO>
|
||||
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
|
||||
public PageResultVO<PddGoodsVO> getPddGoodsPage(PageQueryDTO<PddGoodsFilterDTO> pageQueryDTO) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
@@ -503,14 +419,6 @@ public class PddGoodsServiceImpl extends ServiceImpl<PddGoodsMapper, PddGoodsPO>
|
||||
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) {
|
||||
PddGoodsVO vo = new PddGoodsVO();
|
||||
BeanCopyUtils.copyProperties(goods, vo);
|
||||
|
||||
+8
@@ -92,6 +92,14 @@ public class ProductSkuController {
|
||||
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")
|
||||
@RequirePermission(value = "ec:product:read", description = "批量根据商品名称和SKU编码查询", allowSuper = true)
|
||||
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);
|
||||
|
||||
/**
|
||||
* 当前公司内按 SKU 编码反查(含所属商品 id/名称)。
|
||||
*/
|
||||
ProductSkuVO getProductSkuBySkuCode(String skuCode);
|
||||
|
||||
List<ProductVO> getProductSkusByProductAndSkus(List<ProductSkuQueryDTO> queries);
|
||||
|
||||
ProductSkuPO getByCompanyIdAndSkuCode(Long companyId, String skuCode);
|
||||
|
||||
+20
@@ -288,6 +288,26 @@ public class ProductSkuServiceImpl extends ServiceImpl<ProductSkuMapper, Product
|
||||
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
|
||||
public ProductSkuPO getByCompanyIdAndSkuCode(Long companyId, String skuCode) {
|
||||
if (companyId == null || skuCode == null || skuCode.isBlank()) {
|
||||
|
||||
Reference in New Issue
Block a user