ERP:增加 ERP 销售订单的实现 50%(详情)

新年快乐~
This commit is contained in:
YunaiV 2024-02-10 00:07:08 +08:00
parent 30de2176a4
commit 5fd23cacc7
7 changed files with 82 additions and 14 deletions

View File

@ -30,6 +30,19 @@ public class ErpSaleOrderPageReqVO extends PageParam {
*/ */
public static final Integer IN_STATUS_ALL = 2; public static final Integer IN_STATUS_ALL = 2;
/**
* 退货状态 -
*/
public static final Integer RETURN_STATUS_NONE = 0;
/**
* 退货状态 - 部分
*/
public static final Integer RETURN_STATUS_PART = 1;
/**
* 退货状态 - 全部
*/
public static final Integer RETURN_STATUS_ALL = 2;
@Schema(description = "销售单编号", example = "XS001") @Schema(description = "销售单编号", example = "XS001")
private String no; private String no;
@ -55,4 +68,7 @@ public class ErpSaleOrderPageReqVO extends PageParam {
@Schema(description = "入库状态", example = "2") @Schema(description = "入库状态", example = "2")
private Integer inStatus; private Integer inStatus;
@Schema(description = "退货状态", example = "2")
private Integer returnStatus;
} }

View File

@ -23,22 +23,33 @@ public class ErpSaleOrderRespVO {
@ExcelProperty("销售单编号") @ExcelProperty("销售单编号")
private String no; private String no;
@Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("销售状态")
private Integer status;
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724")
private Long customerId; private Long customerId;
@Schema(description = "客户名称", example = "芋道") @Schema(description = "客户名称", example = "芋道")
@ExcelProperty("客户名称") @ExcelProperty("客户名称")
private String customerName; private String customerName;
@Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89")
@ExcelProperty("下单时间") @ExcelProperty("结算账户编号")
private LocalDateTime orderTime; private Long accountId;
@Schema(description = "销售员编号", example = "1888") @Schema(description = "销售员编号", example = "1888")
private Long saleUserId; private Long saleUserId;
@Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("结算账户编号") @ExcelProperty("下单时间")
private Long accountId; private LocalDateTime orderTime;
@Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663")
@ExcelProperty("合计数量")
private BigDecimal totalCount;
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("最终合计价格")
private BigDecimal totalPrice;
@Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal totalProductPrice; private BigDecimal totalProductPrice;
@ -56,10 +67,6 @@ public class ErpSaleOrderRespVO {
@NotNull(message = "定金金额,单位:元不能为空") @NotNull(message = "定金金额,单位:元不能为空")
private BigDecimal depositPrice; private BigDecimal depositPrice;
@Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("销售状态")
private Integer status;
@Schema(description = "附件地址", example = "https://www.iocoder.cn") @Schema(description = "附件地址", example = "https://www.iocoder.cn")
@ExcelProperty("附件地址") @ExcelProperty("附件地址")
private String fileUrl; private String fileUrl;
@ -84,6 +91,16 @@ public class ErpSaleOrderRespVO {
@ExcelProperty("产品信息") @ExcelProperty("产品信息")
private String productNames; private String productNames;
// ========== 销售入库 ==========
@Schema(description = "销售入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
private BigDecimal inCount;
// ========== 销售退货出库 ==========
@Schema(description = "销售退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
private BigDecimal returnCount;
@Data @Data
public static class Item { public static class Item {
@ -106,6 +123,9 @@ public class ErpSaleOrderRespVO {
@Schema(description = "税率,百分比", example = "99.88") @Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent; private BigDecimal taxPercent;
@Schema(description = "税额,单位:元", example = "100.00")
private BigDecimal taxPrice;
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "随便")
private String remark; private String remark;

View File

@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -66,6 +67,13 @@ public class ErpStockController {
return success(BeanUtils.toBean(stock, ErpStockRespVO.class)); return success(BeanUtils.toBean(stock, ErpStockRespVO.class));
} }
@GetMapping("/get-count")
@Operation(summary = "获得产品库存数量")
@Parameter(name = "productId", description = "产品编号", example = "10")
public CommonResult<BigDecimal> getStockCount(@RequestParam("productId") Long productId) {
return success(stockService.getStockCount(productId));
}
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得产品库存分页") @Operation(summary = "获得产品库存分页")
@PreAuthorize("@ss.hasPermission('erp:stock:query')") @PreAuthorize("@ss.hasPermission('erp:stock:query')")

View File

@ -6,10 +6,12 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.Objects;
/** /**
* ERP 销售订单 Mapper * ERP 销售订单 Mapper
* *
@ -27,9 +29,25 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> {
.likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark()) .likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark())
.eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator()) .eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator())
.orderByDesc(ErpSaleOrderDO::getId); .orderByDesc(ErpSaleOrderDO::getId);
// 入库状态为什么需要 t. 的原因是因为联表查询时需要指定表名不然会报 in_count 错误
if (Objects.equals(reqVO.getInStatus(), ErpSaleOrderPageReqVO.IN_STATUS_NONE)) {
query.eq(ErpSaleOrderDO::getInCount, 0);
} else if (Objects.equals(reqVO.getInStatus(), ErpSaleOrderPageReqVO.IN_STATUS_PART)) {
query.gt(ErpSaleOrderDO::getInCount, 0).apply("t.in_count < t.total_count");
} else if (Objects.equals(reqVO.getInStatus(), ErpSaleOrderPageReqVO.IN_STATUS_ALL)) {
query.apply("t.in_count = t.total_count");
}
// 退货状态
if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_NONE)) {
query.eq(ErpSaleOrderDO::getReturnCount, 0);
} else if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_PART)) {
query.gt(ErpSaleOrderDO::getReturnCount, 0).apply("t.return_count < t.total_count");
} else if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_ALL)) {
query.apply("t.return_count = t.total_count");
}
if (reqVO.getProductId() != null) { if (reqVO.getProductId() != null) {
query.leftJoin(ErpStockOutItemDO.class, ErpStockOutItemDO::getOutId, ErpSaleOrderDO::getId) query.leftJoin(ErpSaleOrderItemDO.class, ErpSaleOrderItemDO::getOrderId, ErpSaleOrderDO::getId)
.eq(reqVO.getProductId() != null, ErpStockOutItemDO::getProductId, reqVO.getProductId()) .eq(reqVO.getProductId() != null, ErpSaleOrderItemDO::getProductId, reqVO.getProductId())
.groupBy(ErpSaleOrderDO::getId); // 避免 1 对多查询产生相同的 1 .groupBy(ErpSaleOrderDO::getId); // 避免 1 对多查询产生相同的 1
} }
return selectJoinPage(reqVO, ErpSaleOrderDO.class, query); return selectJoinPage(reqVO, ErpSaleOrderDO.class, query);

View File

@ -105,6 +105,9 @@ public class ErpProductServiceImpl implements ErpProductService {
@Override @Override
public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) { public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<ErpProductDO> list = productMapper.selectBatchIds(ids); List<ErpProductDO> list = productMapper.selectBatchIds(ids);
return buildProductVOList(list); return buildProductVOList(list);
} }

View File

@ -33,6 +33,8 @@ public interface ErpStockService {
/** /**
* 获得产品库存数量 * 获得产品库存数量
* *
* 如果不存在库存记录则返回 0
*
* @param productId 产品编号 * @param productId 产品编号
* @return 产品库存数量 * @return 产品库存数量
*/ */

View File

@ -51,7 +51,8 @@ public class ErpStockServiceImpl implements ErpStockService {
@Override @Override
public BigDecimal getStockCount(Long productId) { public BigDecimal getStockCount(Long productId) {
return stockMapper.selectSumByProductId(productId); BigDecimal count = stockMapper.selectSumByProductId(productId);
return count != null ? count : BigDecimal.ZERO;
} }
@Override @Override