mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	✨ ERP:增加 ERP 销售订单的实现 50%(详情)
新年快乐~
This commit is contained in:
		@@ -30,6 +30,19 @@ public class ErpSaleOrderPageReqVO extends PageParam {
 | 
			
		||||
     */
 | 
			
		||||
    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")
 | 
			
		||||
    private String no;
 | 
			
		||||
 | 
			
		||||
@@ -55,4 +68,7 @@ public class ErpSaleOrderPageReqVO extends PageParam {
 | 
			
		||||
    @Schema(description = "入库状态", example = "2")
 | 
			
		||||
    private Integer inStatus;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "退货状态", example = "2")
 | 
			
		||||
    private Integer returnStatus;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -23,22 +23,33 @@ public class ErpSaleOrderRespVO {
 | 
			
		||||
    @ExcelProperty("销售单编号")
 | 
			
		||||
    private String no;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
 | 
			
		||||
    @ExcelProperty("销售状态")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724")
 | 
			
		||||
    private Long customerId;
 | 
			
		||||
    @Schema(description = "客户名称", example = "芋道")
 | 
			
		||||
    @ExcelProperty("客户名称")
 | 
			
		||||
    private String customerName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @ExcelProperty("下单时间")
 | 
			
		||||
    private LocalDateTime orderTime;
 | 
			
		||||
    @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89")
 | 
			
		||||
    @ExcelProperty("结算账户编号")
 | 
			
		||||
    private Long accountId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "销售员编号", example = "1888")
 | 
			
		||||
    private Long saleUserId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89")
 | 
			
		||||
    @ExcelProperty("结算账户编号")
 | 
			
		||||
    private Long accountId;
 | 
			
		||||
    @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @ExcelProperty("下单时间")
 | 
			
		||||
    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")
 | 
			
		||||
    private BigDecimal totalProductPrice;
 | 
			
		||||
@@ -56,10 +67,6 @@ public class ErpSaleOrderRespVO {
 | 
			
		||||
    @NotNull(message = "定金金额,单位:元不能为空")
 | 
			
		||||
    private BigDecimal depositPrice;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
 | 
			
		||||
    @ExcelProperty("销售状态")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "附件地址", example = "https://www.iocoder.cn")
 | 
			
		||||
    @ExcelProperty("附件地址")
 | 
			
		||||
    private String fileUrl;
 | 
			
		||||
@@ -84,6 +91,16 @@ public class ErpSaleOrderRespVO {
 | 
			
		||||
    @ExcelProperty("产品信息")
 | 
			
		||||
    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
 | 
			
		||||
    public static class Item {
 | 
			
		||||
 | 
			
		||||
@@ -106,6 +123,9 @@ public class ErpSaleOrderRespVO {
 | 
			
		||||
        @Schema(description = "税率,百分比", example = "99.88")
 | 
			
		||||
        private BigDecimal taxPercent;
 | 
			
		||||
 | 
			
		||||
        @Schema(description = "税额,单位:元", example = "100.00")
 | 
			
		||||
        private BigDecimal taxPrice;
 | 
			
		||||
 | 
			
		||||
        @Schema(description = "备注", example = "随便")
 | 
			
		||||
        private String remark;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@@ -66,6 +67,13 @@ public class ErpStockController {
 | 
			
		||||
        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")
 | 
			
		||||
    @Operation(summary = "获得产品库存分页")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('erp:stock:query')")
 | 
			
		||||
 
 | 
			
		||||
@@ -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.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.stock.ErpStockOutItemDO;
 | 
			
		||||
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ERP 销售订单 Mapper
 | 
			
		||||
 *
 | 
			
		||||
@@ -27,9 +29,25 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> {
 | 
			
		||||
                .likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark())
 | 
			
		||||
                .eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator())
 | 
			
		||||
                .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) {
 | 
			
		||||
            query.leftJoin(ErpStockOutItemDO.class, ErpStockOutItemDO::getOutId, ErpSaleOrderDO::getId)
 | 
			
		||||
                    .eq(reqVO.getProductId() != null, ErpStockOutItemDO::getProductId, reqVO.getProductId())
 | 
			
		||||
            query.leftJoin(ErpSaleOrderItemDO.class, ErpSaleOrderItemDO::getOrderId, ErpSaleOrderDO::getId)
 | 
			
		||||
                    .eq(reqVO.getProductId() != null, ErpSaleOrderItemDO::getProductId, reqVO.getProductId())
 | 
			
		||||
                    .groupBy(ErpSaleOrderDO::getId); // 避免 1 对多查询,产生相同的 1
 | 
			
		||||
        }
 | 
			
		||||
        return selectJoinPage(reqVO, ErpSaleOrderDO.class, query);
 | 
			
		||||
 
 | 
			
		||||
@@ -105,6 +105,9 @@ public class ErpProductServiceImpl implements ErpProductService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) {
 | 
			
		||||
        if (CollUtil.isEmpty(ids)) {
 | 
			
		||||
            return Collections.emptyList();
 | 
			
		||||
        }
 | 
			
		||||
        List<ErpProductDO> list = productMapper.selectBatchIds(ids);
 | 
			
		||||
        return buildProductVOList(list);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,8 @@ public interface ErpStockService {
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得产品库存数量
 | 
			
		||||
     *
 | 
			
		||||
     * 如果不存在库存记录,则返回 0
 | 
			
		||||
     *
 | 
			
		||||
     * @param productId 产品编号
 | 
			
		||||
     * @return 产品库存数量
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,8 @@ public class ErpStockServiceImpl implements ErpStockService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public BigDecimal getStockCount(Long productId) {
 | 
			
		||||
        return stockMapper.selectSumByProductId(productId);
 | 
			
		||||
        BigDecimal count = stockMapper.selectSumByProductId(productId);
 | 
			
		||||
        return count != null ? count : BigDecimal.ZERO;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user