Jelajahi Sumber

Merge branch 'dev/2024/0806/update-business-Y' of Harper/feifan-backend-zx-business into master

平台审核商品申请
Yangzw 7 bulan lalu
induk
melakukan
c9d12aa175

+ 9 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spuapply/SpuApplyController.java

@@ -1,5 +1,6 @@
 package cn.newfeifan.mall.module.product.controller.admin.spuapply;
 
+import cn.newfeifan.mall.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import org.springframework.validation.annotation.Validated;
@@ -58,6 +59,14 @@ public class SpuApplyController {
     public CommonResult<SpuApplyRespVO> getSpuApply(@RequestParam("id") Long id) {
         return success(spuApplyService.getSpuApplyDetail(id));
     }
+    @PutMapping("/update-status")
+    @Operation(summary = "更新商品 SPUApply Status")
+    @PreAuthorize("@ss.hasPermission('product:spu:update')")
+    public CommonResult<Boolean> updateStatus(@Valid @RequestBody ProductSpuUpdateStatusReqVO updateReqVO) {
+        spuApplyService.updateSpuStatus(updateReqVO);
+        return success(true);
+    }
+
 
     @GetMapping("/page")
     @Operation(summary = "获得商品spu申请分页")

+ 6 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spu/ProductSpuService.java

@@ -146,4 +146,10 @@ public interface ProductSpuService {
      * @return spu
      */
     ProductSpuDO getSpuByApplyId(Long applyId);
+
+    /**
+     * 更新商品
+     * @param spu 商品
+     */
+    void updateById(ProductSpuDO spu);
 }

+ 5 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spu/ProductSpuServiceImpl.java

@@ -204,6 +204,11 @@ public class ProductSpuServiceImpl implements ProductSpuService {
         return productSpuMapper.selectOne(ProductSpuDO::getSpuApplyId, applyId);
     }
 
+    @Override
+    public void updateById(ProductSpuDO spu) {
+        productSpuMapper.updateById(spu);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void deleteSpu(Long id) {

+ 8 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spuapply/SpuApplyService.java

@@ -2,6 +2,7 @@ package cn.newfeifan.mall.module.product.service.spuapply;
 
 import javax.validation.*;
 
+import cn.newfeifan.mall.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
 import cn.newfeifan.mall.module.product.controller.admin.spuapply.vo.*;
 import cn.newfeifan.mall.module.product.dal.dataobject.spuapply.SpuApplyDO;
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
@@ -66,4 +67,11 @@ public interface SpuApplyService {
      * @return 申请详情
      */
     SpuApplyRespVO getSpuApplyDetail(Long id);
+
+    /**
+     * 更新 SPU 状态
+     *
+     * @param updateReqVO 更新请求
+     */
+    void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO);
 }

+ 15 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spuapply/SpuApplyServiceImpl.java

@@ -2,6 +2,7 @@ package cn.newfeifan.mall.module.product.service.spuapply;
 
 import cn.newfeifan.mall.module.product.controller.admin.skuapply.vo.SkuApplySaveReqVO;
 import cn.newfeifan.mall.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO;
+import cn.newfeifan.mall.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
 import cn.newfeifan.mall.module.product.convert.spuapply.SpuApplyConvert;
 import cn.newfeifan.mall.module.product.dal.dataobject.skuapply.SkuApplyDO;
 import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
@@ -327,4 +328,18 @@ public class SpuApplyServiceImpl implements SpuApplyService {
         return convert;
     }
 
+    @Override
+    public void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO) {
+        // 校验存在
+        validateSpuApplyExists(updateReqVO.getId());
+        // TODO 非繁人:【可选】参与活动中的商品,不允许下架???
+
+        // 更新状态
+        SpuApplyDO productSpuDO = spuApplyMapper.selectById(updateReqVO.getId()).setStatus(updateReqVO.getStatus());
+        spuApplyMapper.updateById(productSpuDO);
+
+        ProductSpuDO spu = spuService.getSpuByApplyId(updateReqVO.getId()).setStatus(updateReqVO.getStatus());
+        spuService.updateById(spu);
+    }
+
 }