Commit 9d2e98af8e493f38ae67cca70086f63b479d7e2c

Authored by 芋道源码
Committed by GitHub
2 parents 7cab3a72 85a63467

Merge pull request #1219 from dadiyang/fix/crm-receivable-plan-max-period-wrapper

[FIX] CRM:回款计划创建查最大期次改单表查询,修 Unknown column 't.contract_id'(A6)
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.receivable; @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.receivable;
3 import cn.hutool.core.date.LocalDateTimeUtil; 3 import cn.hutool.core.date.LocalDateTimeUtil;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  6 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; 7 import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
7 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; 8 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO;
8 import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; 9 import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
@@ -24,7 +25,9 @@ import java.util.Objects; @@ -24,7 +25,9 @@ import java.util.Objects;
24 public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO> { 25 public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO> {
25 26
26 default CrmReceivablePlanDO selectMaxPeriodByContractId(Long contractId) { 27 default CrmReceivablePlanDO selectMaxPeriodByContractId(Long contractId) {
27 - return selectOne(new MPJLambdaWrapperX<CrmReceivablePlanDO>() 28 + // 单表查询不能用 MPJLambdaWrapperX:它会给列拼接表别名前缀(t.contract_id),
  29 + // 但 selectOne 生成的 FROM 不带别名,导致 Unknown column 't.contract_id'。
  30 + return selectOne(new LambdaQueryWrapperX<CrmReceivablePlanDO>()
28 .eq(CrmReceivablePlanDO::getContractId, contractId) 31 .eq(CrmReceivablePlanDO::getContractId, contractId)
29 .orderByDesc(CrmReceivablePlanDO::getPeriod) 32 .orderByDesc(CrmReceivablePlanDO::getPeriod)
30 .last("LIMIT 1")); 33 .last("LIMIT 1"));