ERP:销售订单的 receiptPrice 调整,为接入财务的收款单做准备

plp
YunaiV 2 years ago
parent 9e3858aea7
commit 33f654b73b

@ -17,6 +17,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true) @ToString(callSuper = true)
public class ErpSaleOutPageReqVO extends PageParam { public class ErpSaleOutPageReqVO extends PageParam {
public static final Integer RECEIPT_STATUS_NONE = 0;
public static final Integer RECEIPT_STATUS_PART = 1;
public static final Integer RECEIPT_STATUS_ALL = 2;
@Schema(description = "销售单编号", example = "XS001") @Schema(description = "销售单编号", example = "XS001")
private String no; private String no;
@ -45,8 +49,11 @@ public class ErpSaleOutPageReqVO extends PageParam {
@Schema(description = "结算账号编号", example = "1") @Schema(description = "结算账号编号", example = "1")
private Long accountId; private Long accountId;
@Schema(description = "是否欠款", example = "true") @Schema(description = "收款状态", example = "1")
private Boolean debtStatus; private Integer receiptStatus;
@Schema(description = "是否可收款", example = "true")
private Boolean receiptEnable; // 对应 receiptStatus = [0, 1]
@Schema(description = "销售单号", example = "1") @Schema(description = "销售单号", example = "1")
private String orderNo; private String orderNo;

@ -55,6 +55,8 @@ public class ErpSaleOutRespVO {
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("最终合计价格") @ExcelProperty("最终合计价格")
private BigDecimal totalPrice; private BigDecimal totalPrice;
@Schema(description = "已收款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal receiptPrice;
@Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal totalProductPrice; private BigDecimal totalProductPrice;
@ -68,15 +70,9 @@ public class ErpSaleOutRespVO {
@Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal discountPrice; private BigDecimal discountPrice;
@Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") @Schema(description = "其它金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal otherPrice; private BigDecimal otherPrice;
@Schema(description = "本次收款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal payPrice;
@Schema(description = "本次欠款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
private BigDecimal debtPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn") @Schema(description = "附件地址", example = "https://www.iocoder.cn")
@ExcelProperty("附件地址") @ExcelProperty("附件地址")
private String fileUrl; private String fileUrl;

@ -35,10 +35,6 @@ public class ErpSaleOutSaveReqVO {
@Schema(description = "其它金额,单位:元", example = "7127") @Schema(description = "其它金额,单位:元", example = "7127")
private BigDecimal otherPrice; private BigDecimal otherPrice;
@Schema(description = "本次收款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
@NotNull(message = "本次收款不能为空")
private BigDecimal payPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn") @Schema(description = "附件地址", example = "https://www.iocoder.cn")
private String fileUrl; private String fileUrl;

@ -17,6 +17,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true) @ToString(callSuper = true)
public class ErpSaleReturnPageReqVO extends PageParam { public class ErpSaleReturnPageReqVO extends PageParam {
public static final Integer REFUND_STATUS_NONE = 0;
public static final Integer REFUND_STATUS_PART = 1;
public static final Integer REFUND_STATUS_ALL = 2;
@Schema(description = "销售单编号", example = "XS001") @Schema(description = "销售单编号", example = "XS001")
private String no; private String no;
@ -48,4 +52,10 @@ public class ErpSaleReturnPageReqVO extends PageParam {
@Schema(description = "销售单号", example = "1") @Schema(description = "销售单号", example = "1")
private String orderNo; private String orderNo;
@Schema(description = "退款状态", example = "1")
private Integer refundStatus;
@Schema(description = "是否可退款", example = "true")
private Boolean refundEnable; // 对应 refundStatus = [0, 1]
} }

@ -55,6 +55,8 @@ public class ErpSaleReturnRespVO {
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("最终合计价格") @ExcelProperty("最终合计价格")
private BigDecimal totalPrice; private BigDecimal totalPrice;
@Schema(description = "已退款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal refundPrice;
@Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal totalProductPrice; private BigDecimal totalProductPrice;
@ -68,15 +70,9 @@ public class ErpSaleReturnRespVO {
@Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal discountPrice; private BigDecimal discountPrice;
@Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") @Schema(description = "其它金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal otherPrice; private BigDecimal otherPrice;
@Schema(description = "本次退款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal refundPrice;
@Schema(description = "本次欠款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
private BigDecimal debtPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn") @Schema(description = "附件地址", example = "https://www.iocoder.cn")
@ExcelProperty("附件地址") @ExcelProperty("附件地址")
private String fileUrl; private String fileUrl;

@ -35,10 +35,6 @@ public class ErpSaleReturnSaveReqVO {
@Schema(description = "其它金额,单位:元", example = "7127") @Schema(description = "其它金额,单位:元", example = "7127")
private BigDecimal otherPrice; private BigDecimal otherPrice;
@Schema(description = "本次退款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
@NotNull(message = "本次退款不能为空")
private BigDecimal refundPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn") @Schema(description = "附件地址", example = "https://www.iocoder.cn")
private String fileUrl; private String fileUrl;

@ -0,0 +1,4 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.finance;
public class ErpFinanceReceiptDO {
}

@ -83,7 +83,7 @@ public class ErpPurchaseInDO extends BaseDO {
/** /**
* *
* *
* TODO erp_finance_payment * {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO}
*/ */
private BigDecimal paymentPrice; private BigDecimal paymentPrice;

@ -83,7 +83,7 @@ public class ErpPurchaseReturnDO extends BaseDO {
/** /**
* 退 * 退
* *
* TODO erp_finance_payment 退 * {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO}
*/ */
private BigDecimal refundPrice; private BigDecimal refundPrice;

@ -83,9 +83,15 @@ public class ErpSaleOutDO extends BaseDO {
/** /**
* *
* *
* totalPrice = totalProductPrice + totalTaxPrice - discountPrice * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice
*/ */
private BigDecimal totalPrice; private BigDecimal totalPrice;
/**
*
*
* {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO}
*/
private BigDecimal receiptPrice;
/** /**
* *
@ -110,18 +116,6 @@ public class ErpSaleOutDO extends BaseDO {
*/ */
private BigDecimal otherPrice; private BigDecimal otherPrice;
// TODO 芋艿receiptPrice
/**
*
*
* payPrice = totalPrice + otherPrice - debtPrice
*/
private BigDecimal payPrice;
/**
*
*/
private BigDecimal debtPrice;
/** /**
* *
*/ */

@ -83,9 +83,15 @@ public class ErpSaleReturnDO extends BaseDO {
/** /**
* *
* *
* totalPrice = totalProductPrice + totalTaxPrice - discountPrice * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice
*/ */
private BigDecimal totalPrice; private BigDecimal totalPrice;
/**
* 退
*
* {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} 退
*/
private BigDecimal refundPrice;
/** /**
* *
@ -110,17 +116,6 @@ public class ErpSaleReturnDO extends BaseDO {
*/ */
private BigDecimal otherPrice; private BigDecimal otherPrice;
/**
*
*
* refundPrice = totalPrice + otherPrice - debtPrice
*/
private BigDecimal refundPrice;
/**
*
*/
private BigDecimal debtPrice;
/** /**
* *
*/ */

@ -10,8 +10,8 @@ import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO;
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.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* ERP Mapper * ERP Mapper
@ -32,10 +32,16 @@ public interface ErpSaleOutMapper extends BaseMapperX<ErpSaleOutDO> {
.eqIfPresent(ErpSaleOutDO::getAccountId, reqVO.getAccountId()) .eqIfPresent(ErpSaleOutDO::getAccountId, reqVO.getAccountId())
.likeIfPresent(ErpSaleOutDO::getOrderNo, reqVO.getOrderNo()) .likeIfPresent(ErpSaleOutDO::getOrderNo, reqVO.getOrderNo())
.orderByDesc(ErpSaleOutDO::getId); .orderByDesc(ErpSaleOutDO::getId);
if (Boolean.TRUE.equals(reqVO.getDebtStatus())) { // 收款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误
query.gt(ErpSaleOutDO::getDebtPrice, BigDecimal.ZERO); if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_NONE)) {
} else if (Boolean.FALSE.equals(reqVO.getDebtStatus())) { query.eq(ErpSaleOutDO::getReceiptPrice, 0);
query.eq(ErpSaleOutDO::getDebtPrice, BigDecimal.ZERO); } else if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_PART)) {
query.gt(ErpSaleOutDO::getReceiptPrice, 0).apply("t.receipt_price < t.total_price");
} else if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_ALL)) {
query.apply("t.receipt_price = t.total_price");
}
if (Boolean.TRUE.equals(reqVO.getReceiptEnable())) {
query.apply("t.receipt_price < t.total_price");
} }
if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId) query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId)

@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* ERP 退 Mapper * ERP 退 Mapper
@ -31,6 +32,17 @@ public interface ErpSaleReturnMapper extends BaseMapperX<ErpSaleReturnDO> {
.eqIfPresent(ErpSaleReturnDO::getAccountId, reqVO.getAccountId()) .eqIfPresent(ErpSaleReturnDO::getAccountId, reqVO.getAccountId())
.likeIfPresent(ErpSaleReturnDO::getOrderNo, reqVO.getOrderNo()) .likeIfPresent(ErpSaleReturnDO::getOrderNo, reqVO.getOrderNo())
.orderByDesc(ErpSaleReturnDO::getId); .orderByDesc(ErpSaleReturnDO::getId);
// 退款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误
if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_NONE)) {
query.eq(ErpSaleReturnDO::getRefundPrice, 0);
} else if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_PART)) {
query.gt(ErpSaleReturnDO::getRefundPrice, 0).apply("t.refund_price < t.total_price");
} else if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_ALL)) {
query.apply("t.refund_price = t.total_price");
}
if (Boolean.TRUE.equals(reqVO.getRefundEnable())) {
query.apply("t.refund_price < t.total_price");
}
if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
query.leftJoin(ErpSaleReturnItemDO.class, ErpSaleReturnItemDO::getReturnId, ErpSaleReturnDO::getId) query.leftJoin(ErpSaleReturnItemDO.class, ErpSaleReturnItemDO::getReturnId, ErpSaleReturnDO::getId)
.eq(reqVO.getWarehouseId() != null, ErpSaleReturnItemDO::getWarehouseId, reqVO.getWarehouseId()) .eq(reqVO.getWarehouseId() != null, ErpSaleReturnItemDO::getWarehouseId, reqVO.getWarehouseId())

@ -148,10 +148,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
saleOut.setDiscountPercent(BigDecimal.ZERO); saleOut.setDiscountPercent(BigDecimal.ZERO);
} }
saleOut.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleOut.getTotalPrice(), saleOut.getDiscountPercent())); saleOut.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleOut.getTotalPrice(), saleOut.getDiscountPercent()));
saleOut.setTotalPrice(saleOut.getTotalPrice().subtract(saleOut.getDiscountPrice())); saleOut.setTotalPrice(saleOut.getTotalPrice().subtract(saleOut.getDiscountPrice().add(saleOut.getOtherPrice())));
// 计算应收金额
BigDecimal allPrice = saleOut.getTotalPrice().add(saleOut.getOtherPrice());
saleOut.setDebtPrice(allPrice.subtract(saleOut.getPayPrice()));
} }
private void updateSaleOrderOutCount(Long orderId) { private void updateSaleOrderOutCount(Long orderId) {

@ -148,10 +148,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
saleReturn.setDiscountPercent(BigDecimal.ZERO); saleReturn.setDiscountPercent(BigDecimal.ZERO);
} }
saleReturn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleReturn.getTotalPrice(), saleReturn.getDiscountPercent())); saleReturn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleReturn.getTotalPrice(), saleReturn.getDiscountPercent()));
saleReturn.setTotalPrice(saleReturn.getTotalPrice().subtract(saleReturn.getDiscountPrice())); saleReturn.setTotalPrice(saleReturn.getTotalPrice().subtract(saleReturn.getDiscountPrice().add(saleReturn.getOtherPrice())));
// 计算应退金额
BigDecimal allPrice = saleReturn.getTotalPrice().add(saleReturn.getOtherPrice());
saleReturn.setDebtPrice(allPrice.subtract(saleReturn.getRefundPrice()));
} }
private void updateSaleOrderReturnCount(Long orderId) { private void updateSaleOrderReturnCount(Long orderId) {

Loading…
Cancel
Save