Commit 5fd23cacc7da16488aebd091d34967b8597e2fe4
1 parent
30de2176
✨ ERP:增加 ERP 销售订单的实现 50%(详情)
新年快乐~
Showing
7 changed files
with
82 additions
and
14 deletions
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderPageReqVO.java
| @@ -30,6 +30,19 @@ public class ErpSaleOrderPageReqVO extends PageParam { | @@ -30,6 +30,19 @@ public class ErpSaleOrderPageReqVO extends PageParam { | ||
| 30 | */ | 30 | */ |
| 31 | public static final Integer IN_STATUS_ALL = 2; | 31 | public static final Integer IN_STATUS_ALL = 2; |
| 32 | 32 | ||
| 33 | + /** | ||
| 34 | + * 退货状态 - 无 | ||
| 35 | + */ | ||
| 36 | + public static final Integer RETURN_STATUS_NONE = 0; | ||
| 37 | + /** | ||
| 38 | + * 退货状态 - 部分 | ||
| 39 | + */ | ||
| 40 | + public static final Integer RETURN_STATUS_PART = 1; | ||
| 41 | + /** | ||
| 42 | + * 退货状态 - 全部 | ||
| 43 | + */ | ||
| 44 | + public static final Integer RETURN_STATUS_ALL = 2; | ||
| 45 | + | ||
| 33 | @Schema(description = "销售单编号", example = "XS001") | 46 | @Schema(description = "销售单编号", example = "XS001") |
| 34 | private String no; | 47 | private String no; |
| 35 | 48 | ||
| @@ -55,4 +68,7 @@ public class ErpSaleOrderPageReqVO extends PageParam { | @@ -55,4 +68,7 @@ public class ErpSaleOrderPageReqVO extends PageParam { | ||
| 55 | @Schema(description = "入库状态", example = "2") | 68 | @Schema(description = "入库状态", example = "2") |
| 56 | private Integer inStatus; | 69 | private Integer inStatus; |
| 57 | 70 | ||
| 71 | + @Schema(description = "退货状态", example = "2") | ||
| 72 | + private Integer returnStatus; | ||
| 73 | + | ||
| 58 | } | 74 | } |
| 59 | \ No newline at end of file | 75 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderRespVO.java
| @@ -23,22 +23,33 @@ public class ErpSaleOrderRespVO { | @@ -23,22 +23,33 @@ public class ErpSaleOrderRespVO { | ||
| 23 | @ExcelProperty("销售单编号") | 23 | @ExcelProperty("销售单编号") |
| 24 | private String no; | 24 | private String no; |
| 25 | 25 | ||
| 26 | + @Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 27 | + @ExcelProperty("销售状态") | ||
| 28 | + private Integer status; | ||
| 29 | + | ||
| 26 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") | 30 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") |
| 27 | private Long customerId; | 31 | private Long customerId; |
| 28 | @Schema(description = "客户名称", example = "芋道") | 32 | @Schema(description = "客户名称", example = "芋道") |
| 29 | @ExcelProperty("客户名称") | 33 | @ExcelProperty("客户名称") |
| 30 | private String customerName; | 34 | private String customerName; |
| 31 | 35 | ||
| 32 | - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 33 | - @ExcelProperty("下单时间") | ||
| 34 | - private LocalDateTime orderTime; | 36 | + @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") |
| 37 | + @ExcelProperty("结算账户编号") | ||
| 38 | + private Long accountId; | ||
| 35 | 39 | ||
| 36 | @Schema(description = "销售员编号", example = "1888") | 40 | @Schema(description = "销售员编号", example = "1888") |
| 37 | private Long saleUserId; | 41 | private Long saleUserId; |
| 38 | 42 | ||
| 39 | - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") | ||
| 40 | - @ExcelProperty("结算账户编号") | ||
| 41 | - private Long accountId; | 43 | + @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 44 | + @ExcelProperty("下单时间") | ||
| 45 | + private LocalDateTime orderTime; | ||
| 46 | + | ||
| 47 | + @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") | ||
| 48 | + @ExcelProperty("合计数量") | ||
| 49 | + private BigDecimal totalCount; | ||
| 50 | + @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") | ||
| 51 | + @ExcelProperty("最终合计价格") | ||
| 52 | + private BigDecimal totalPrice; | ||
| 42 | 53 | ||
| 43 | @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") | 54 | @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") |
| 44 | private BigDecimal totalProductPrice; | 55 | private BigDecimal totalProductPrice; |
| @@ -56,10 +67,6 @@ public class ErpSaleOrderRespVO { | @@ -56,10 +67,6 @@ public class ErpSaleOrderRespVO { | ||
| 56 | @NotNull(message = "定金金额,单位:元不能为空") | 67 | @NotNull(message = "定金金额,单位:元不能为空") |
| 57 | private BigDecimal depositPrice; | 68 | private BigDecimal depositPrice; |
| 58 | 69 | ||
| 59 | - @Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 60 | - @ExcelProperty("销售状态") | ||
| 61 | - private Integer status; | ||
| 62 | - | ||
| 63 | @Schema(description = "附件地址", example = "https://www.iocoder.cn") | 70 | @Schema(description = "附件地址", example = "https://www.iocoder.cn") |
| 64 | @ExcelProperty("附件地址") | 71 | @ExcelProperty("附件地址") |
| 65 | private String fileUrl; | 72 | private String fileUrl; |
| @@ -84,6 +91,16 @@ public class ErpSaleOrderRespVO { | @@ -84,6 +91,16 @@ public class ErpSaleOrderRespVO { | ||
| 84 | @ExcelProperty("产品信息") | 91 | @ExcelProperty("产品信息") |
| 85 | private String productNames; | 92 | private String productNames; |
| 86 | 93 | ||
| 94 | + // ========== 销售入库 ========== | ||
| 95 | + | ||
| 96 | + @Schema(description = "销售入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | ||
| 97 | + private BigDecimal inCount; | ||
| 98 | + | ||
| 99 | + // ========== 销售退货(出库)) ========== | ||
| 100 | + | ||
| 101 | + @Schema(description = "销售退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | ||
| 102 | + private BigDecimal returnCount; | ||
| 103 | + | ||
| 87 | @Data | 104 | @Data |
| 88 | public static class Item { | 105 | public static class Item { |
| 89 | 106 | ||
| @@ -106,6 +123,9 @@ public class ErpSaleOrderRespVO { | @@ -106,6 +123,9 @@ public class ErpSaleOrderRespVO { | ||
| 106 | @Schema(description = "税率,百分比", example = "99.88") | 123 | @Schema(description = "税率,百分比", example = "99.88") |
| 107 | private BigDecimal taxPercent; | 124 | private BigDecimal taxPercent; |
| 108 | 125 | ||
| 126 | + @Schema(description = "税额,单位:元", example = "100.00") | ||
| 127 | + private BigDecimal taxPrice; | ||
| 128 | + | ||
| 109 | @Schema(description = "备注", example = "随便") | 129 | @Schema(description = "备注", example = "随便") |
| 110 | private String remark; | 130 | private String remark; |
| 111 | 131 |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockController.java
| @@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestParam; | @@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestParam; | ||
| 31 | import org.springframework.web.bind.annotation.RestController; | 31 | import org.springframework.web.bind.annotation.RestController; |
| 32 | 32 | ||
| 33 | import java.io.IOException; | 33 | import java.io.IOException; |
| 34 | +import java.math.BigDecimal; | ||
| 34 | import java.util.List; | 35 | import java.util.List; |
| 35 | import java.util.Map; | 36 | import java.util.Map; |
| 36 | 37 | ||
| @@ -66,6 +67,13 @@ public class ErpStockController { | @@ -66,6 +67,13 @@ public class ErpStockController { | ||
| 66 | return success(BeanUtils.toBean(stock, ErpStockRespVO.class)); | 67 | return success(BeanUtils.toBean(stock, ErpStockRespVO.class)); |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 70 | + @GetMapping("/get-count") | ||
| 71 | + @Operation(summary = "获得产品库存数量") | ||
| 72 | + @Parameter(name = "productId", description = "产品编号", example = "10") | ||
| 73 | + public CommonResult<BigDecimal> getStockCount(@RequestParam("productId") Long productId) { | ||
| 74 | + return success(stockService.getStockCount(productId)); | ||
| 75 | + } | ||
| 76 | + | ||
| 69 | @GetMapping("/page") | 77 | @GetMapping("/page") |
| 70 | @Operation(summary = "获得产品库存分页") | 78 | @Operation(summary = "获得产品库存分页") |
| 71 | @PreAuthorize("@ss.hasPermission('erp:stock:query')") | 79 | @PreAuthorize("@ss.hasPermission('erp:stock:query')") |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderMapper.java
| @@ -6,10 +6,12 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | @@ -6,10 +6,12 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 6 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 7 | import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; | 7 | import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; |
| 8 | import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; | 8 | import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; |
| 9 | -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; | 9 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; |
| 10 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 10 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 11 | import org.apache.ibatis.annotations.Mapper; | 11 | import org.apache.ibatis.annotations.Mapper; |
| 12 | 12 | ||
| 13 | +import java.util.Objects; | ||
| 14 | + | ||
| 13 | /** | 15 | /** |
| 14 | * ERP 销售订单 Mapper | 16 | * ERP 销售订单 Mapper |
| 15 | * | 17 | * |
| @@ -27,9 +29,25 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> { | @@ -27,9 +29,25 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> { | ||
| 27 | .likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark()) | 29 | .likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark()) |
| 28 | .eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator()) | 30 | .eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator()) |
| 29 | .orderByDesc(ErpSaleOrderDO::getId); | 31 | .orderByDesc(ErpSaleOrderDO::getId); |
| 32 | + // 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 in_count 错误 | ||
| 33 | + if (Objects.equals(reqVO.getInStatus(), ErpSaleOrderPageReqVO.IN_STATUS_NONE)) { | ||
| 34 | + query.eq(ErpSaleOrderDO::getInCount, 0); | ||
| 35 | + } else if (Objects.equals(reqVO.getInStatus(), ErpSaleOrderPageReqVO.IN_STATUS_PART)) { | ||
| 36 | + query.gt(ErpSaleOrderDO::getInCount, 0).apply("t.in_count < t.total_count"); | ||
| 37 | + } else if (Objects.equals(reqVO.getInStatus(), ErpSaleOrderPageReqVO.IN_STATUS_ALL)) { | ||
| 38 | + query.apply("t.in_count = t.total_count"); | ||
| 39 | + } | ||
| 40 | + // 退货状态 | ||
| 41 | + if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_NONE)) { | ||
| 42 | + query.eq(ErpSaleOrderDO::getReturnCount, 0); | ||
| 43 | + } else if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_PART)) { | ||
| 44 | + query.gt(ErpSaleOrderDO::getReturnCount, 0).apply("t.return_count < t.total_count"); | ||
| 45 | + } else if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_ALL)) { | ||
| 46 | + query.apply("t.return_count = t.total_count"); | ||
| 47 | + } | ||
| 30 | if (reqVO.getProductId() != null) { | 48 | if (reqVO.getProductId() != null) { |
| 31 | - query.leftJoin(ErpStockOutItemDO.class, ErpStockOutItemDO::getOutId, ErpSaleOrderDO::getId) | ||
| 32 | - .eq(reqVO.getProductId() != null, ErpStockOutItemDO::getProductId, reqVO.getProductId()) | 49 | + query.leftJoin(ErpSaleOrderItemDO.class, ErpSaleOrderItemDO::getOrderId, ErpSaleOrderDO::getId) |
| 50 | + .eq(reqVO.getProductId() != null, ErpSaleOrderItemDO::getProductId, reqVO.getProductId()) | ||
| 33 | .groupBy(ErpSaleOrderDO::getId); // 避免 1 对多查询,产生相同的 1 | 51 | .groupBy(ErpSaleOrderDO::getId); // 避免 1 对多查询,产生相同的 1 |
| 34 | } | 52 | } |
| 35 | return selectJoinPage(reqVO, ErpSaleOrderDO.class, query); | 53 | return selectJoinPage(reqVO, ErpSaleOrderDO.class, query); |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java
| @@ -105,6 +105,9 @@ public class ErpProductServiceImpl implements ErpProductService { | @@ -105,6 +105,9 @@ public class ErpProductServiceImpl implements ErpProductService { | ||
| 105 | 105 | ||
| 106 | @Override | 106 | @Override |
| 107 | public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) { | 107 | public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) { |
| 108 | + if (CollUtil.isEmpty(ids)) { | ||
| 109 | + return Collections.emptyList(); | ||
| 110 | + } | ||
| 108 | List<ErpProductDO> list = productMapper.selectBatchIds(ids); | 111 | List<ErpProductDO> list = productMapper.selectBatchIds(ids); |
| 109 | return buildProductVOList(list); | 112 | return buildProductVOList(list); |
| 110 | } | 113 | } |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockService.java
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockServiceImpl.java
| @@ -51,7 +51,8 @@ public class ErpStockServiceImpl implements ErpStockService { | @@ -51,7 +51,8 @@ public class ErpStockServiceImpl implements ErpStockService { | ||
| 51 | 51 | ||
| 52 | @Override | 52 | @Override |
| 53 | public BigDecimal getStockCount(Long productId) { | 53 | public BigDecimal getStockCount(Long productId) { |
| 54 | - return stockMapper.selectSumByProductId(productId); | 54 | + BigDecimal count = stockMapper.selectSumByProductId(productId); |
| 55 | + return count != null ? count : BigDecimal.ZERO; | ||
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | @Override | 58 | @Override |