新增 增加库存接口和库存变更日志记录
This commit is contained in:
1 parent
4d51240c3d
commit
d1e0f7a972
18 files changed
+545
-7
No files matched your search
+3
@@ -61,4 +61,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode SUMMARY_NOT_EXISTS = new ErrorCode(1_008_010_000, "商品汇总不存在");
|
||||
ErrorCode SUMMARY_NOT_DUPLICATE = new ErrorCode(1_008_010_001, "订单明细中涉及多台贩卖机");
|
||||
|
||||
// ========== 商品库存日志 1-008-011-000 ==========
|
||||
ErrorCode STOCK_LOG_NOT_EXISTS = new ErrorCode(1_008_011_000, "商品库存日志不存在");
|
||||
|
||||
}
|
||||
+8
@@ -148,4 +148,12 @@ public class ProductSpuController {
|
||||
BeanUtils.toBean(list, ProductSpuRespVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/update-stock")
|
||||
@Operation(summary = "加库存 SPU Stock")
|
||||
@PreAuthorize("@ss.hasPermission('product:spu:update')")
|
||||
public CommonResult<Boolean> updateStock(@Valid @RequestBody ProductSkuUpdateStockReqVO updateReqVO) {
|
||||
productSpuService.updateSkuStock(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 商品 SKU Stock 更新 Request VO")
|
||||
@Data
|
||||
public class ProductSkuUpdateStockReqVO {
|
||||
|
||||
@Schema(description = "商品SKU编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "商品编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "库存数量不能为空")
|
||||
@InEnum(ProductSpuStatusEnum.class)
|
||||
private Integer stock;
|
||||
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.stocklog;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.stocklog.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.stocklog.StockLogDO;
|
||||
import cn.iocoder.yudao.module.product.service.stocklog.StockLogService;
|
||||
|
||||
@Tag(name = "管理后台 - 商品库存日志")
|
||||
@RestController
|
||||
@RequestMapping("/product/stock-log")
|
||||
@Validated
|
||||
public class StockLogController {
|
||||
|
||||
@Resource
|
||||
private StockLogService stockLogService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建商品库存日志")
|
||||
@PreAuthorize("@ss.hasPermission('product:stock-log:create')")
|
||||
public CommonResult<Long> createStockLog(@Valid @RequestBody StockLogSaveReqVO createReqVO) {
|
||||
return success(stockLogService.createStockLog(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新商品库存日志")
|
||||
@PreAuthorize("@ss.hasPermission('product:stock-log:update')")
|
||||
public CommonResult<Boolean> updateStockLog(@Valid @RequestBody StockLogSaveReqVO updateReqVO) {
|
||||
stockLogService.updateStockLog(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除商品库存日志")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('product:stock-log:delete')")
|
||||
public CommonResult<Boolean> deleteStockLog(@RequestParam("id") Long id) {
|
||||
stockLogService.deleteStockLog(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得商品库存日志")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('product:stock-log:query')")
|
||||
public CommonResult<StockLogRespVO> getStockLog(@RequestParam("id") Long id) {
|
||||
StockLogDO stockLog = stockLogService.getStockLog(id);
|
||||
return success(BeanUtils.toBean(stockLog, StockLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得商品库存日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:stock-log:query')")
|
||||
public CommonResult<PageResult<StockLogRespVO>> getStockLogPage(@Valid StockLogPageReqVO pageReqVO) {
|
||||
PageResult<StockLogDO> pageResult = stockLogService.getStockLogPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, StockLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出商品库存日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('product:stock-log:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportStockLogExcel(@Valid StockLogPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<StockLogDO> list = stockLogService.getStockLogPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "商品库存日志.xls", "数据", StockLogRespVO.class,
|
||||
BeanUtils.toBean(list, StockLogRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.stocklog.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 商品库存日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class StockLogPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "设备IMEI", example = "15445")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "SKU 的条形码")
|
||||
private String barCode;
|
||||
|
||||
@Schema(description = "商品名称", example = "赵六")
|
||||
private String spuName;
|
||||
|
||||
@Schema(description = "货道或柜门编号")
|
||||
private String cabinetChannel;
|
||||
|
||||
@Schema(description = "添加数量", example = "11106")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "原库存")
|
||||
private Integer oldStock;
|
||||
|
||||
@Schema(description = "当前库存")
|
||||
private Integer newStock;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.stocklog.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 商品库存日志 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class StockLogRespVO {
|
||||
|
||||
@Schema(description = "日志主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10218")
|
||||
@ExcelProperty("日志主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备IMEI", example = "15445")
|
||||
@ExcelProperty("设备IMEI")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "SKU 的条形码")
|
||||
@ExcelProperty("SKU 的条形码")
|
||||
private String barCode;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@ExcelProperty("商品名称")
|
||||
private String spuName;
|
||||
|
||||
@Schema(description = "货道或柜门编号")
|
||||
@ExcelProperty("货道或柜门编号")
|
||||
private String cabinetChannel;
|
||||
|
||||
@Schema(description = "添加数量", example = "11106")
|
||||
@ExcelProperty("添加数量")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "原库存")
|
||||
@ExcelProperty("原库存")
|
||||
private Integer oldStock;
|
||||
|
||||
@Schema(description = "当前库存")
|
||||
@ExcelProperty("当前库存")
|
||||
private Integer newStock;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.stocklog.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 商品库存日志新增/修改 Request VO")
|
||||
@Data
|
||||
public class StockLogSaveReqVO {
|
||||
|
||||
@Schema(description = "日志主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10218")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备IMEI", example = "15445")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "SKU 的条形码")
|
||||
private String barCode;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "商品名称不能为空")
|
||||
private String spuName;
|
||||
|
||||
@Schema(description = "货道或柜门编号")
|
||||
private String cabinetChannel;
|
||||
|
||||
@Schema(description = "添加数量", example = "11106")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "原库存")
|
||||
private Integer oldStock;
|
||||
|
||||
@Schema(description = "当前库存")
|
||||
private Integer newStock;
|
||||
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package cn.iocoder.yudao.module.product.dal.dataobject.stocklog;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 商品库存日志 DO
|
||||
*
|
||||
* @author 小如之家
|
||||
*/
|
||||
@TableName("product_stock_log")
|
||||
@KeySequence("product_stock_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StockLogDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 日志主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceId;
|
||||
/**
|
||||
* SKU 的条形码
|
||||
*/
|
||||
private String barCode;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String spuName;
|
||||
/**
|
||||
* 货道或柜门编号
|
||||
*/
|
||||
private String cabinetChannel;
|
||||
/**
|
||||
* 添加数量
|
||||
*/
|
||||
private Integer count;
|
||||
/**
|
||||
* 原库存
|
||||
*/
|
||||
private Integer oldStock;
|
||||
/**
|
||||
* 当前库存
|
||||
*/
|
||||
private Integer newStock;
|
||||
|
||||
}
|
||||
+8
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuStockReqDTO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuUpdateStockReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.summary.vo.SummaryRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
@@ -85,4 +86,11 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
default List<ProductSkuDO> getSkuListByCreator(Long creator){
|
||||
return selectList(ProductSkuDO::getCreator, creator);
|
||||
}
|
||||
|
||||
default int updateSkuStockById(ProductSkuUpdateStockReqVO updateReqVO){
|
||||
LambdaUpdateWrapper<ProductSkuDO> updateWrapper = new LambdaUpdateWrapper<ProductSkuDO>()
|
||||
.setSql(" stock = stock +" + updateReqVO.getStock())
|
||||
.eq(ProductSkuDO::getId, updateReqVO.getId());
|
||||
return update(null, updateWrapper);
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuUpdateStockReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuCreatorDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
@@ -15,7 +16,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -214,4 +214,11 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
||||
query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus());
|
||||
return selectList(query);
|
||||
}
|
||||
|
||||
default int updateSkuStock(ProductSkuUpdateStockReqVO updateReqVO){
|
||||
LambdaUpdateWrapper<ProductSpuDO> updateWrapper = new LambdaUpdateWrapper<ProductSpuDO>()
|
||||
.setSql(" stock = stock +" + updateReqVO.getStock())
|
||||
.eq(ProductSpuDO::getId, updateReqVO.getId());
|
||||
return update(null, updateWrapper);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.stocklog;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.stocklog.StockLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.stocklog.vo.*;
|
||||
|
||||
/**
|
||||
* 商品库存日志 Mapper
|
||||
*
|
||||
* @author 小如之家
|
||||
*/
|
||||
@Mapper
|
||||
public interface StockLogMapper extends BaseMapperX<StockLogDO> {
|
||||
|
||||
default PageResult<StockLogDO> selectPage(StockLogPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<StockLogDO>()
|
||||
.eqIfPresent(StockLogDO::getDeviceId, reqVO.getDeviceId())
|
||||
.eqIfPresent(StockLogDO::getBarCode, reqVO.getBarCode())
|
||||
.likeIfPresent(StockLogDO::getSpuName, reqVO.getSpuName())
|
||||
.eqIfPresent(StockLogDO::getCabinetChannel, reqVO.getCabinetChannel())
|
||||
.eqIfPresent(StockLogDO::getCount, reqVO.getCount())
|
||||
.eqIfPresent(StockLogDO::getOldStock, reqVO.getOldStock())
|
||||
.eqIfPresent(StockLogDO::getNewStock, reqVO.getNewStock())
|
||||
.betweenIfPresent(StockLogDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(StockLogDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
+3
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuStockReqDTO;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuUpdateStockReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -117,4 +118,6 @@ public interface ProductSkuService {
|
||||
List<ProductSkuRespDTO> getSkuListByBarCode(Collection<String> barCodes);
|
||||
|
||||
List<ProductSkuRespDTO> getSkuListByCreator(Long creator);
|
||||
|
||||
int updateSkuStockById(ProductSkuUpdateStockReqVO updateReqVO);
|
||||
}
|
||||
+6
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuStockReqDTO;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuUpdateStockReqVO;
|
||||
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
||||
@@ -228,6 +229,11 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
return BeanUtils.toBean(productSkus, ProductSkuRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSkuStockById(ProductSkuUpdateStockReqVO updateReqVO) {
|
||||
return productSkuMapper.updateSkuStockById(updateReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSkuList(Long spuId, List<ProductSkuSaveReqVO> skus) {
|
||||
|
||||
+3
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuUpdateStockReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuCreatorDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
@@ -147,4 +148,6 @@ public interface ProductSpuService {
|
||||
PageResult<ProductSpuCreatorDO> getSpuPageWithCreator(ProductSpuPageReqVO pageVO);
|
||||
|
||||
List<ProductSpuDO> getSpuListByCreator(String creator);
|
||||
|
||||
void updateSkuStock(ProductSkuUpdateStockReqVO updateReqVO);
|
||||
}
|
||||
+34
-4
@@ -7,12 +7,11 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.stocklog.vo.StockLogSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuCreatorDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper;
|
||||
@@ -20,6 +19,7 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||
import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
|
||||
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||
import cn.iocoder.yudao.module.product.service.stocklog.StockLogService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -56,6 +56,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
@Resource
|
||||
private ProductCategoryService categoryService;
|
||||
|
||||
@Resource
|
||||
private StockLogService stockLogService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@@ -173,6 +176,33 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
return productSpuMapper.getSpuListByCreator(creator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkuStock(ProductSkuUpdateStockReqVO updateReqVO) {
|
||||
//查询商品是否存在
|
||||
ProductSkuDO skuDO = productSkuService.getSku(updateReqVO.getId());
|
||||
if (skuDO == null) {
|
||||
throw exception(SKU_NOT_EXISTS);
|
||||
}
|
||||
ProductSpuDO productSpuDO = productSpuMapper.selectById(skuDO.getSpuId());
|
||||
// 更新 SKU 库存
|
||||
productSkuService.updateSkuStockById(updateReqVO);
|
||||
// 更新 SPU 库存
|
||||
int i =productSpuMapper.updateSkuStock(updateReqVO.setId(productSpuDO.getId()));
|
||||
if (i>0){
|
||||
AdminUserRespDTO user = adminUserApi.getUser(Long.valueOf(productSpuDO.getCreator()));
|
||||
//添加库存log
|
||||
StockLogSaveReqVO stockLogSaveReqVO = new StockLogSaveReqVO();
|
||||
stockLogSaveReqVO.setDeviceId(user.getDeviceId());
|
||||
stockLogSaveReqVO.setSpuName(productSpuDO.getName());
|
||||
stockLogSaveReqVO.setBarCode(skuDO.getBarCode());
|
||||
stockLogSaveReqVO.setCabinetChannel(skuDO.getCabinetChannel());
|
||||
stockLogSaveReqVO.setCount(updateReqVO.getStock());
|
||||
stockLogSaveReqVO.setOldStock(skuDO.getStock());
|
||||
stockLogSaveReqVO.setNewStock(skuDO.getStock()+updateReqVO.getStock());
|
||||
stockLogService.createStockLog(stockLogSaveReqVO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteSpu(Long id) {
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.product.service.stocklog;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.stocklog.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.stocklog.StockLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 商品库存日志 Service 接口
|
||||
*
|
||||
* @author 小如之家
|
||||
*/
|
||||
public interface StockLogService {
|
||||
|
||||
/**
|
||||
* 创建商品库存日志
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createStockLog(@Valid StockLogSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新商品库存日志
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateStockLog(@Valid StockLogSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除商品库存日志
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteStockLog(Long id);
|
||||
|
||||
/**
|
||||
* 获得商品库存日志
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 商品库存日志
|
||||
*/
|
||||
StockLogDO getStockLog(Long id);
|
||||
|
||||
/**
|
||||
* 获得商品库存日志分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 商品库存日志分页
|
||||
*/
|
||||
PageResult<StockLogDO> getStockLogPage(StockLogPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.product.service.stocklog;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.stocklog.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.stocklog.StockLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.stocklog.StockLogMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 商品库存日志 Service 实现类
|
||||
*
|
||||
* @author 小如之家
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class StockLogServiceImpl implements StockLogService {
|
||||
|
||||
@Resource
|
||||
private StockLogMapper stockLogMapper;
|
||||
|
||||
@Override
|
||||
public Long createStockLog(StockLogSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
StockLogDO stockLog = BeanUtils.toBean(createReqVO, StockLogDO.class);
|
||||
stockLogMapper.insert(stockLog);
|
||||
// 返回
|
||||
return stockLog.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStockLog(StockLogSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateStockLogExists(updateReqVO.getId());
|
||||
// 更新
|
||||
StockLogDO updateObj = BeanUtils.toBean(updateReqVO, StockLogDO.class);
|
||||
stockLogMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStockLog(Long id) {
|
||||
// 校验存在
|
||||
validateStockLogExists(id);
|
||||
// 删除
|
||||
stockLogMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateStockLogExists(Long id) {
|
||||
if (stockLogMapper.selectById(id) == null) {
|
||||
throw exception(STOCK_LOG_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockLogDO getStockLog(Long id) {
|
||||
return stockLogMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<StockLogDO> getStockLogPage(StockLogPageReqVO pageReqVO) {
|
||||
return stockLogMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -14,11 +14,11 @@ Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
### 获取订单销售统计数据 => 成功
|
||||
GET {{baseUrl}}/trade/order/sales-statistics?pageNo=1&pageSize=100&createTime[0]=2025-01-01 00:00:00&createTime[1]=2025-08-15 23:59:59
|
||||
GET {{baseUrl}}/trade/order/sales-statistics?pageNo=1&pageSize=100&createTime[0]=2025-01-01 00:00:00&createTime[1]=2025-08-30 23:59:59
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
### 获取订单销售统计详情 => 成功
|
||||
GET {{baseUrl}}/trade/order/statistics-detail?pageNo=1&pageSize=100&createTime[0]=2025-01-01 00:00:00&createTime[1]=2025-08-30 23:59:59&barCode=T20250711
|
||||
GET {{baseUrl}}/trade/order/statistics-detail?pageNo=1&pageSize=100&createTime[0]=2025-01-01 00:00:00&createTime[1]=2025-08-30 23:59:59
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
Reference in new issue
Block a user