feat: 补充平台端库存管理模块

补齐平台端库存余额、流水、初始化和手工调整能力,并将快递发货接入库存扣减闭环,方便运营侧统一查账与审计。

Made-with: Cursor
This commit is contained in:
AriadenCaseblg
2026-04-19 23:43:46 +08:00
parent b097837aa3
commit 005bd968df
32 changed files with 61113 additions and 59368 deletions

View File

@@ -0,0 +1,75 @@
package com.zbkj.admin.controller.platform;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.zbkj.common.annotation.LogControllerAnnotation;
import com.zbkj.common.enums.MethodType;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.InventoryAdjustRequest;
import com.zbkj.common.request.InventoryInitRequest;
import com.zbkj.common.request.InventorySearchRequest;
import com.zbkj.common.response.InventoryPageResponse;
import com.zbkj.common.response.InventoryRecordPageResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.common.utils.SecurityUtil;
import com.zbkj.service.service.InventoryInitService;
import com.zbkj.service.service.ProductInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* 平台端库存控制器
*/
@Slf4j
@RestController
@RequestMapping("api/admin/platform/inventory")
@Api(tags = "平台端库存控制器")
@ApiSupport(order = 101)
public class PlatformInventoryController {
@Resource
private ProductInventoryService productInventoryService;
@Resource
private InventoryInitService inventoryInitService;
@PreAuthorize("hasAuthority('platform:inventory:page:list')")
@ApiOperation(value = "库存分页列表")
@GetMapping("/list")
public CommonResult<CommonPage<InventoryPageResponse>> getList(@Validated InventorySearchRequest request) {
return CommonResult.success(CommonPage.restPage(productInventoryService.getPlatformPage(request)));
}
@PreAuthorize("hasAuthority('platform:inventory:record:page:list')")
@ApiOperation(value = "库存流水分页列表")
@GetMapping("/record/list")
public CommonResult<CommonPage<InventoryRecordPageResponse>> getRecordList(@Validated InventorySearchRequest request) {
return CommonResult.success(CommonPage.restPage(productInventoryService.getRecordPage(request)));
}
@PreAuthorize("hasAuthority('platform:inventory:adjust')")
@LogControllerAnnotation(intoDB = true, methodType = MethodType.UPDATE, description = "平台端库存调整")
@ApiOperation(value = "库存调整")
@PostMapping("/adjust")
public CommonResult<String> adjust(@RequestBody @Validated InventoryAdjustRequest request) {
if (productInventoryService.adjust(request, SecurityUtil.getLoginUserVo().getUser())) {
return CommonResult.success();
}
return CommonResult.failed();
}
@PreAuthorize("hasAuthority('platform:inventory:init')")
@LogControllerAnnotation(intoDB = true, methodType = MethodType.UPDATE, description = "平台端库存初始化")
@ApiOperation(value = "库存初始化")
@PostMapping("/init")
public CommonResult<String> init(@RequestBody InventoryInitRequest request) {
if (inventoryInitService.initInventory(request, SecurityUtil.getLoginUserVo().getUser())) {
return CommonResult.success();
}
return CommonResult.failed();
}
}