Commit 2d43c1f9beac3a67fc4f358e89759d4997caa6b1

Authored by YunaiV
1 parent 2d024307

✨ ERP:采购订单的 paymentPrice 调整,为接入财务的付款单做准备

Showing 13 changed files with 63 additions and 57 deletions
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInPageReqVO.java
... ... @@ -17,6 +17,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
17 17 @ToString(callSuper = true)
18 18 public class ErpPurchaseInPageReqVO extends PageParam {
19 19  
  20 + public static final Integer PAYMENT_STATUS_NONE = 0;
  21 + public static final Integer PAYMENT_STATUS_PART = 1;
  22 + public static final Integer PAYMENT_STATUS_ALL = 2;
  23 +
20 24 @Schema(description = "采购单编号", example = "XS001")
21 25 private String no;
22 26  
... ... @@ -45,8 +49,11 @@ public class ErpPurchaseInPageReqVO extends PageParam {
45 49 @Schema(description = "结算账号编号", example = "1")
46 50 private Long accountId;
47 51  
48   - @Schema(description = "是否欠款", example = "true")
49   - private Boolean debtStatus;
  52 + @Schema(description = "付款状态", example = "1")
  53 + private Integer paymentStatus;
  54 +
  55 + @Schema(description = "是否可付款", example = "true")
  56 + private Boolean paymentEnable; // 对应 paymentStatus = [0, 1]
50 57  
51 58 @Schema(description = "采购单号", example = "1")
52 59 private String orderNo;
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInRespVO.java
... ... @@ -52,6 +52,8 @@ public class ErpPurchaseInRespVO {
52 52 @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
53 53 @ExcelProperty("最终合计价格")
54 54 private BigDecimal totalPrice;
  55 + @Schema(description = "已付款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
  56 + private BigDecimal paymentPrice;
55 57  
56 58 @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
57 59 private BigDecimal totalProductPrice;
... ... @@ -68,11 +70,6 @@ public class ErpPurchaseInRespVO {
68 70 @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
69 71 private BigDecimal otherPrice;
70 72  
71   - @Schema(description = "本次付款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
72   - private BigDecimal refundPrice;
73   - @Schema(description = "本次欠款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
74   - private BigDecimal debtPrice;
75   -
76 73 @Schema(description = "附件地址", example = "https://www.iocoder.cn")
77 74 @ExcelProperty("附件地址")
78 75 private String fileUrl;
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInSaveReqVO.java
... ... @@ -32,10 +32,6 @@ public class ErpPurchaseInSaveReqVO {
32 32 @Schema(description = "其它金额,单位:元", example = "7127")
33 33 private BigDecimal otherPrice;
34 34  
35   - @Schema(description = "本次付款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
36   - @NotNull(message = "本次付款不能为空")
37   - private BigDecimal refundPrice;
38   -
39 35 @Schema(description = "附件地址", example = "https://www.iocoder.cn")
40 36 private String fileUrl;
41 37  
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnPageReqVO.java
... ... @@ -17,6 +17,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
17 17 @ToString(callSuper = true)
18 18 public class ErpPurchaseReturnPageReqVO extends PageParam {
19 19  
  20 + public static final Integer REFUND_STATUS_NONE = 0;
  21 + public static final Integer REFUND_STATUS_PART = 1;
  22 + public static final Integer REFUND_STATUS_ALL = 2;
  23 +
20 24 @Schema(description = "采购单编号", example = "XS001")
21 25 private String no;
22 26  
... ... @@ -48,4 +52,10 @@ public class ErpPurchaseReturnPageReqVO extends PageParam {
48 52 @Schema(description = "采购单号", example = "1")
49 53 private String orderNo;
50 54  
  55 + @Schema(description = "退款状态", example = "1")
  56 + private Integer refundStatus;
  57 +
  58 + @Schema(description = "是否可退款", example = "true")
  59 + private Boolean refundEnable; // 对应 refundStatus = [0, 1]
  60 +
51 61 }
52 62 \ No newline at end of file
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnRespVO.java
... ... @@ -52,6 +52,8 @@ public class ErpPurchaseReturnRespVO {
52 52 @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
53 53 @ExcelProperty("最终合计价格")
54 54 private BigDecimal totalPrice;
  55 + @Schema(description = "已退款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
  56 + private BigDecimal refundPrice;
55 57  
56 58 @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
57 59 private BigDecimal totalProductPrice;
... ... @@ -68,11 +70,6 @@ public class ErpPurchaseReturnRespVO {
68 70 @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
69 71 private BigDecimal otherPrice;
70 72  
71   - @Schema(description = "本次退款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
72   - private BigDecimal refundPrice;
73   - @Schema(description = "本次欠款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
74   - private BigDecimal debtPrice;
75   -
76 73 @Schema(description = "附件地址", example = "https://www.iocoder.cn")
77 74 @ExcelProperty("附件地址")
78 75 private String fileUrl;
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnSaveReqVO.java
... ... @@ -32,10 +32,6 @@ public class ErpPurchaseReturnSaveReqVO {
32 32 @Schema(description = "其它金额,单位:元", example = "7127")
33 33 private BigDecimal otherPrice;
34 34  
35   - @Schema(description = "本次退款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
36   - @NotNull(message = "本次退款不能为空")
37   - private BigDecimal refundPrice;
38   -
39 35 @Schema(description = "附件地址", example = "https://www.iocoder.cn")
40 36 private String fileUrl;
41 37  
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInDO.java
... ... @@ -77,9 +77,15 @@ public class ErpPurchaseInDO extends BaseDO {
77 77 /**
78 78 * 最终合计价格,单位:元
79 79 *
80   - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice
  80 + * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice
81 81 */
82 82 private BigDecimal totalPrice;
  83 + /**
  84 + * 已支付金额,单位:元
  85 + *
  86 + * 目的:和 TODO erp_finance_payment 结合,记录已支付金额
  87 + */
  88 + private BigDecimal paymentPrice;
83 89  
84 90 /**
85 91 * 合计产品价格,单位:元
... ... @@ -105,17 +111,6 @@ public class ErpPurchaseInDO extends BaseDO {
105 111 private BigDecimal otherPrice;
106 112  
107 113 /**
108   - * 本次退款,单位:元
109   - *
110   - * refundPrice = totalPrice + otherPrice - debtPrice
111   - */
112   - private BigDecimal refundPrice;
113   - /**
114   - * 本次欠款,单位:元
115   - */
116   - private BigDecimal debtPrice;
117   -
118   - /**
119 114 * 附件地址
120 115 */
121 116 private String fileUrl;
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnDO.java
... ... @@ -77,9 +77,15 @@ public class ErpPurchaseReturnDO extends BaseDO {
77 77 /**
78 78 * 最终合计价格,单位:元
79 79 *
80   - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice
  80 + * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice
81 81 */
82 82 private BigDecimal totalPrice;
  83 + /**
  84 + * 已退款金额,单位:元
  85 + *
  86 + * 目的:和 TODO erp_finance_payment 结合,记录已退款金额
  87 + */
  88 + private BigDecimal refundPrice;
83 89  
84 90 /**
85 91 * 合计产品价格,单位:元
... ... @@ -105,17 +111,6 @@ public class ErpPurchaseReturnDO extends BaseDO {
105 111 private BigDecimal otherPrice;
106 112  
107 113 /**
108   - * 本次退款,单位:元
109   - *
110   - * refundPrice = totalPrice + otherPrice - debtPrice
111   - */
112   - private BigDecimal refundPrice;
113   - /**
114   - * 本次欠款,单位:元
115   - */
116   - private BigDecimal debtPrice;
117   -
118   - /**
119 114 * 附件地址
120 115 */
121 116 private String fileUrl;
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutDO.java
... ... @@ -110,6 +110,7 @@ public class ErpSaleOutDO extends BaseDO {
110 110 */
111 111 private BigDecimal otherPrice;
112 112  
  113 + // TODO 芋艿:receiptPrice
113 114 /**
114 115 * 本次收款,单位:元
115 116 *
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInMapper.java
... ... @@ -10,8 +10,8 @@ import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO;
10 10 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
11 11 import org.apache.ibatis.annotations.Mapper;
12 12  
13   -import java.math.BigDecimal;
14 13 import java.util.List;
  14 +import java.util.Objects;
15 15  
16 16 /**
17 17 * ERP 采购入库 Mapper
... ... @@ -32,10 +32,16 @@ public interface ErpPurchaseInMapper extends BaseMapperX<ErpPurchaseInDO> {
32 32 .eqIfPresent(ErpPurchaseInDO::getAccountId, reqVO.getAccountId())
33 33 .likeIfPresent(ErpPurchaseInDO::getOrderNo, reqVO.getOrderNo())
34 34 .orderByDesc(ErpPurchaseInDO::getId);
35   - if (Boolean.TRUE.equals(reqVO.getDebtStatus())) {
36   - query.gt(ErpPurchaseInDO::getDebtPrice, BigDecimal.ZERO);
37   - } else if (Boolean.FALSE.equals(reqVO.getDebtStatus())) {
38   - query.eq(ErpPurchaseInDO::getDebtPrice, BigDecimal.ZERO);
  35 + // 付款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误
  36 + if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_NONE)) {
  37 + query.eq(ErpPurchaseInDO::getPaymentPrice, 0);
  38 + } else if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_PART)) {
  39 + query.gt(ErpPurchaseInDO::getPaymentPrice, 0).apply("t.payment_price < t.total_price");
  40 + } else if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_ALL)) {
  41 + query.apply("t.payment_price = t.total_price");
  42 + }
  43 + if (Boolean.TRUE.equals(reqVO.getPaymentEnable())) {
  44 + query.apply("t.payment_price < t.total_price");
39 45 }
40 46 if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
41 47 query.leftJoin(ErpPurchaseInItemDO.class, ErpPurchaseInItemDO::getInId, ErpPurchaseInDO::getId)
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnMapper.java
... ... @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
10 10 import org.apache.ibatis.annotations.Mapper;
11 11  
12 12 import java.util.List;
  13 +import java.util.Objects;
13 14  
14 15 /**
15 16 * ERP 采购退货 Mapper
... ... @@ -30,6 +31,17 @@ public interface ErpPurchaseReturnMapper extends BaseMapperX&lt;ErpPurchaseReturnDO
30 31 .eqIfPresent(ErpPurchaseReturnDO::getAccountId, reqVO.getAccountId())
31 32 .likeIfPresent(ErpPurchaseReturnDO::getOrderNo, reqVO.getOrderNo())
32 33 .orderByDesc(ErpPurchaseReturnDO::getId);
  34 + // 退款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误
  35 + if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_NONE)) {
  36 + query.eq(ErpPurchaseReturnDO::getRefundPrice, 0);
  37 + } else if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_PART)) {
  38 + query.gt(ErpPurchaseReturnDO::getRefundPrice, 0).apply("t.refund_price < t.total_price");
  39 + } else if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_ALL)) {
  40 + query.apply("t.refund_price = t.total_price");
  41 + }
  42 + if (Boolean.TRUE.equals(reqVO.getRefundEnable())) {
  43 + query.apply("t.refund_price < t.total_price");
  44 + }
33 45 if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
34 46 query.leftJoin(ErpPurchaseReturnItemDO.class, ErpPurchaseReturnItemDO::getReturnId, ErpPurchaseReturnDO::getId)
35 47 .eq(reqVO.getWarehouseId() != null, ErpPurchaseReturnItemDO::getWarehouseId, reqVO.getWarehouseId())
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInServiceImpl.java
... ... @@ -140,10 +140,7 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService {
140 140 purchaseIn.setDiscountPercent(BigDecimal.ZERO);
141 141 }
142 142 purchaseIn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(purchaseIn.getTotalPrice(), purchaseIn.getDiscountPercent()));
143   - purchaseIn.setTotalPrice(purchaseIn.getTotalPrice().subtract(purchaseIn.getDiscountPrice()));
144   - // 计算应收金额
145   - BigDecimal allPrice = purchaseIn.getTotalPrice().add(purchaseIn.getOtherPrice());
146   - purchaseIn.setDebtPrice(allPrice.subtract(purchaseIn.getRefundPrice()));
  143 + purchaseIn.setTotalPrice(purchaseIn.getTotalPrice().subtract(purchaseIn.getDiscountPrice().add(purchaseIn.getOtherPrice())));
147 144 }
148 145  
149 146 private void updatePurchaseOrderInCount(Long orderId) {
... ...
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnServiceImpl.java
... ... @@ -136,10 +136,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
136 136 purchaseReturn.setDiscountPercent(BigDecimal.ZERO);
137 137 }
138 138 purchaseReturn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(purchaseReturn.getTotalPrice(), purchaseReturn.getDiscountPercent()));
139   - purchaseReturn.setTotalPrice(purchaseReturn.getTotalPrice().subtract(purchaseReturn.getDiscountPrice()));
140   - // 计算应退金额
141   - BigDecimal allPrice = purchaseReturn.getTotalPrice().add(purchaseReturn.getOtherPrice());
142   - purchaseReturn.setDebtPrice(allPrice.subtract(purchaseReturn.getRefundPrice()));
  139 + purchaseReturn.setTotalPrice(purchaseReturn.getTotalPrice().subtract(purchaseReturn.getDiscountPrice().add(purchaseReturn.getOtherPrice())));
143 140 }
144 141  
145 142 private void updatePurchaseOrderReturnCount(Long orderId) {
... ...