yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java
@@ -14,6 +14,7 @@
import org.apache.ibatis.annotations.Mapper;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -84,4 +85,34 @@
        return convertMap(result, obj -> (Long) obj.get("invoice_id"), obj -> (BigDecimal) obj.get("total_payment_price"));
    }
    /**
     * 提交审批:置为审批中,并清空上一轮审核结果
     *
     * 用 UpdateWrapper 而非 updateById:MyBatis-Plus 默认更新策略忽略 null,
     * 直接 updateById 无法把审核不通过后残留的审核人/审核时间/审核意见清空。
     */
    default int submitAndResetAuditInfo(Long id, Integer status) {
        return update(null, new LambdaUpdateWrapper<ErpFinancePaymentDO>()
                .eq(ErpFinancePaymentDO::getId, id)
                .set(ErpFinancePaymentDO::getStatus, status)
                .set(ErpFinancePaymentDO::getReviewerId, null)
                .set(ErpFinancePaymentDO::getReviewerName, null)
                .set(ErpFinancePaymentDO::getReviewTime, null)
                .set(ErpFinancePaymentDO::getReviewRemark, null));
    }
    /**
     * 审核(通过 / 不通过):写入审核结果、审核人与审核意见
     */
    default int auditFinancePayment(Long id, Integer status, Long reviewerId,
                                    String reviewerName, String reviewRemark) {
        return update(null, new LambdaUpdateWrapper<ErpFinancePaymentDO>()
                .eq(ErpFinancePaymentDO::getId, id)
                .set(ErpFinancePaymentDO::getStatus, status)
                .set(ErpFinancePaymentDO::getReviewerId, reviewerId)
                .set(ErpFinancePaymentDO::getReviewerName, reviewerName)
                .set(ErpFinancePaymentDO::getReviewTime, LocalDateTime.now())
                .set(ErpFinancePaymentDO::getReviewRemark, reviewRemark));
    }
}