|
|
|
|
@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.dromara.oa.base.domain.BasePaymentStage;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpContractInfo;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpContractPaymentMethod;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpFinAccountInstallment;
|
|
|
|
|
import org.dromara.oa.erp.mapper.ErpFinAccountInstallmentMapper;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@ -19,11 +20,15 @@ import org.dromara.oa.erp.domain.vo.ErpFinAccountInstallmentDetailVo;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpFinAccountInstallmentDetail;
|
|
|
|
|
import org.dromara.oa.erp.mapper.ErpFinAccountInstallmentDetailMapper;
|
|
|
|
|
import org.dromara.oa.erp.service.IErpFinAccountInstallmentDetailService;
|
|
|
|
|
import org.dromara.oa.erp.service.IErpProjectPlanService;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分款明细信息Service业务层处理
|
|
|
|
|
@ -39,6 +44,32 @@ public class ErpFinAccountInstallmentDetailServiceImpl implements IErpFinAccount
|
|
|
|
|
|
|
|
|
|
private final ErpFinAccountInstallmentMapper finAccountInstallmentMapper;
|
|
|
|
|
|
|
|
|
|
private final IErpProjectPlanService erpProjectPlanService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除等场景:不覆盖阶段上的回款日期
|
|
|
|
|
*/
|
|
|
|
|
private void syncContractCollectionStage(Long contractId, Long projectId, Long paymentStageId) {
|
|
|
|
|
erpProjectPlanService.syncCollectionStageFromInstallmentDetail(contractId, projectId, paymentStageId, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增/修改:汇总后由项目计划服务组装 ErpProjectPlanStageBo 并调用
|
|
|
|
|
* {@link IErpProjectPlanService#confirmCollectionStage};回款日期取回款主表 payment_date(仅回写本明细项目对应阶段)。
|
|
|
|
|
*/
|
|
|
|
|
private void syncContractCollectionStage(Long contractId, Long projectId, Long paymentStageId,
|
|
|
|
|
Long accountInstallmentId) {
|
|
|
|
|
Date receivableDate = null;
|
|
|
|
|
if (accountInstallmentId != null) {
|
|
|
|
|
ErpFinAccountInstallment inst = finAccountInstallmentMapper.selectById(accountInstallmentId);
|
|
|
|
|
if (inst != null) {
|
|
|
|
|
receivableDate = inst.getPaymentDate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
erpProjectPlanService.syncCollectionStageFromInstallmentDetail(
|
|
|
|
|
contractId, projectId, paymentStageId, receivableDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询分款明细信息
|
|
|
|
|
*
|
|
|
|
|
@ -79,14 +110,14 @@ public class ErpFinAccountInstallmentDetailServiceImpl implements IErpFinAccount
|
|
|
|
|
private MPJLambdaWrapper<ErpFinAccountInstallmentDetail> buildQueryWrapper(ErpFinAccountInstallmentDetailBo bo) {
|
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
|
MPJLambdaWrapper<ErpFinAccountInstallmentDetail> lqw = JoinWrappers.lambda(ErpFinAccountInstallmentDetail.class)
|
|
|
|
|
.selectAll(ErpFinAccountInstallmentDetail.class)
|
|
|
|
|
.eq(bo.getAccountInstallmentId() != null, ErpFinAccountInstallmentDetail::getAccountInstallmentId, bo.getAccountInstallmentId())
|
|
|
|
|
.eq(bo.getProjectId() != null, ErpFinAccountInstallmentDetail::getProjectId, bo.getProjectId())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getProjectCode()), ErpFinAccountInstallmentDetail::getProjectCode, bo.getProjectCode())
|
|
|
|
|
.like(StringUtils.isNotBlank(bo.getProjectName()), ErpFinAccountInstallmentDetail::getProjectName, bo.getProjectName())
|
|
|
|
|
.eq(bo.getContractId() != null, ErpFinAccountInstallmentDetail::getContractId, bo.getContractId())
|
|
|
|
|
.eq(bo.getPaymentStageId() != null, ErpFinAccountInstallmentDetail::getPaymentStageId, bo.getPaymentStageId())
|
|
|
|
|
.eq(bo.getDetailAmount() != null, ErpFinAccountInstallmentDetail::getDetailAmount, bo.getDetailAmount());
|
|
|
|
|
.selectAll(ErpFinAccountInstallmentDetail.class)
|
|
|
|
|
.eq(bo.getAccountInstallmentId() != null, ErpFinAccountInstallmentDetail::getAccountInstallmentId, bo.getAccountInstallmentId())
|
|
|
|
|
.eq(bo.getProjectId() != null, ErpFinAccountInstallmentDetail::getProjectId, bo.getProjectId())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getProjectCode()), ErpFinAccountInstallmentDetail::getProjectCode, bo.getProjectCode())
|
|
|
|
|
.like(StringUtils.isNotBlank(bo.getProjectName()), ErpFinAccountInstallmentDetail::getProjectName, bo.getProjectName())
|
|
|
|
|
.eq(bo.getContractId() != null, ErpFinAccountInstallmentDetail::getContractId, bo.getContractId())
|
|
|
|
|
.eq(bo.getPaymentStageId() != null, ErpFinAccountInstallmentDetail::getPaymentStageId, bo.getPaymentStageId())
|
|
|
|
|
.eq(bo.getDetailAmount() != null, ErpFinAccountInstallmentDetail::getDetailAmount, bo.getDetailAmount());
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -106,19 +137,26 @@ public class ErpFinAccountInstallmentDetailServiceImpl implements IErpFinAccount
|
|
|
|
|
private MPJLambdaWrapper<ErpFinAccountInstallmentDetail> buildJoinQueryWrapper(ErpFinAccountInstallmentDetailBo bo) {
|
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
|
MPJLambdaWrapper<ErpFinAccountInstallmentDetail> lqw = JoinWrappers.lambda(ErpFinAccountInstallmentDetail.class)
|
|
|
|
|
.selectAll(ErpFinAccountInstallmentDetail.class)
|
|
|
|
|
.select(ErpContractInfo::getContractCode)
|
|
|
|
|
.select(ErpContractInfo::getContractName)
|
|
|
|
|
.select(BasePaymentStage::getStageName)
|
|
|
|
|
.leftJoin(ErpContractInfo.class, ErpContractInfo::getContractId, ErpFinAccountInstallmentDetail::getContractId)
|
|
|
|
|
.leftJoin(BasePaymentStage.class, BasePaymentStage::getPaymentStageId, ErpFinAccountInstallmentDetail::getPaymentStageId)
|
|
|
|
|
.eq(bo.getAccountInstallmentId() != null, ErpFinAccountInstallmentDetail::getAccountInstallmentId, bo.getAccountInstallmentId())
|
|
|
|
|
.eq(bo.getProjectId() != null, ErpFinAccountInstallmentDetail::getProjectId, bo.getProjectId())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getProjectCode()), ErpFinAccountInstallmentDetail::getProjectCode, bo.getProjectCode())
|
|
|
|
|
.like(StringUtils.isNotBlank(bo.getProjectName()), ErpFinAccountInstallmentDetail::getProjectName, bo.getProjectName())
|
|
|
|
|
.eq(bo.getContractId() != null, ErpFinAccountInstallmentDetail::getContractId, bo.getContractId())
|
|
|
|
|
.eq(bo.getPaymentStageId() != null, ErpFinAccountInstallmentDetail::getPaymentStageId, bo.getPaymentStageId())
|
|
|
|
|
.eq(bo.getDetailAmount() != null, ErpFinAccountInstallmentDetail::getDetailAmount, bo.getDetailAmount());
|
|
|
|
|
.selectAll(ErpFinAccountInstallmentDetail.class)
|
|
|
|
|
.select(ErpContractInfo::getContractCode)
|
|
|
|
|
.select(ErpContractInfo::getContractName)
|
|
|
|
|
.selectAs(ErpContractInfo::getTotalPrice, ErpFinAccountInstallmentDetailVo::getContractTotalPrice)
|
|
|
|
|
.select(BasePaymentStage::getStageName)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getPaymentPercentage, ErpFinAccountInstallmentDetailVo::getContractPaymentPercentage)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getPaymentAmount, ErpFinAccountInstallmentDetailVo::getContractPaymentAmount)
|
|
|
|
|
.leftJoin(ErpContractInfo.class, ErpContractInfo::getContractId, ErpFinAccountInstallmentDetail::getContractId)
|
|
|
|
|
.leftJoin(BasePaymentStage.class, BasePaymentStage::getPaymentStageId, ErpFinAccountInstallmentDetail::getPaymentStageId)
|
|
|
|
|
.leftJoin(ErpContractPaymentMethod.class, on -> on
|
|
|
|
|
.eq(ErpContractPaymentMethod::getContractId, ErpFinAccountInstallmentDetail::getContractId)
|
|
|
|
|
.eq(ErpContractPaymentMethod::getPaymentStageId, ErpFinAccountInstallmentDetail::getPaymentStageId)
|
|
|
|
|
.eq(ErpContractPaymentMethod::getDelFlag, "0"))
|
|
|
|
|
.eq(bo.getAccountInstallmentId() != null, ErpFinAccountInstallmentDetail::getAccountInstallmentId, bo.getAccountInstallmentId())
|
|
|
|
|
.eq(bo.getProjectId() != null, ErpFinAccountInstallmentDetail::getProjectId, bo.getProjectId())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getProjectCode()), ErpFinAccountInstallmentDetail::getProjectCode, bo.getProjectCode())
|
|
|
|
|
.like(StringUtils.isNotBlank(bo.getProjectName()), ErpFinAccountInstallmentDetail::getProjectName, bo.getProjectName())
|
|
|
|
|
.eq(bo.getContractId() != null, ErpFinAccountInstallmentDetail::getContractId, bo.getContractId())
|
|
|
|
|
.eq(bo.getPaymentStageId() != null, ErpFinAccountInstallmentDetail::getPaymentStageId, bo.getPaymentStageId())
|
|
|
|
|
.eq(bo.getDetailAmount() != null, ErpFinAccountInstallmentDetail::getDetailAmount, bo.getDetailAmount());
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -140,7 +178,10 @@ public class ErpFinAccountInstallmentDetailServiceImpl implements IErpFinAccount
|
|
|
|
|
ErpFinAccountInstallment erpFinAccountInstallment = finAccountInstallmentMapper.selectById(bo.getAccountInstallmentId());
|
|
|
|
|
erpFinAccountInstallment.setInstallmentStatus(bo.getInstallmentStatus());
|
|
|
|
|
finAccountInstallmentMapper.updateById(erpFinAccountInstallment);
|
|
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
syncContractCollectionStage(bo.getContractId(), bo.getProjectId(), bo.getPaymentStageId(),
|
|
|
|
|
bo.getAccountInstallmentId());
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -153,12 +194,22 @@ public class ErpFinAccountInstallmentDetailServiceImpl implements IErpFinAccount
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean updateByBo(ErpFinAccountInstallmentDetailBo bo) {
|
|
|
|
|
ErpFinAccountInstallmentDetail old = baseMapper.selectById(bo.getInstallmentDetailId());
|
|
|
|
|
ErpFinAccountInstallmentDetail update = MapstructUtils.convert(bo, ErpFinAccountInstallmentDetail.class);
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
ErpFinAccountInstallment erpFinAccountInstallment = finAccountInstallmentMapper.selectById(bo.getAccountInstallmentId());
|
|
|
|
|
erpFinAccountInstallment.setInstallmentStatus(bo.getInstallmentStatus());
|
|
|
|
|
finAccountInstallmentMapper.updateById(erpFinAccountInstallment);
|
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
|
boolean ok = baseMapper.updateById(update) > 0;
|
|
|
|
|
if (ok) {
|
|
|
|
|
if (old != null) {
|
|
|
|
|
syncContractCollectionStage(old.getContractId(), old.getProjectId(), old.getPaymentStageId(),
|
|
|
|
|
bo.getAccountInstallmentId());
|
|
|
|
|
}
|
|
|
|
|
syncContractCollectionStage(bo.getContractId(), bo.getProjectId(), bo.getPaymentStageId(),
|
|
|
|
|
bo.getAccountInstallmentId());
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -180,23 +231,47 @@ public class ErpFinAccountInstallmentDetailServiceImpl implements IErpFinAccount
|
|
|
|
|
if (isValid) {
|
|
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
|
|
if (ids == null || ids.isEmpty()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
List<ErpFinAccountInstallmentDetail> rows = baseMapper.selectList(
|
|
|
|
|
Wrappers.lambdaQuery(ErpFinAccountInstallmentDetail.class)
|
|
|
|
|
.in(ErpFinAccountInstallmentDetail::getInstallmentDetailId, ids));
|
|
|
|
|
boolean ok = baseMapper.deleteByIds(ids) > 0;
|
|
|
|
|
if (ok && !rows.isEmpty()) {
|
|
|
|
|
Set<String> seen = new HashSet<>();
|
|
|
|
|
for (ErpFinAccountInstallmentDetail r : rows) {
|
|
|
|
|
if (r.getContractId() == null || r.getProjectId() == null || r.getPaymentStageId() == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String key = r.getContractId() + "_" + r.getProjectId() + "_" + r.getPaymentStageId();
|
|
|
|
|
if (seen.add(key)) {
|
|
|
|
|
syncContractCollectionStage(r.getContractId(), r.getProjectId(), r.getPaymentStageId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除分款信息
|
|
|
|
|
*
|
|
|
|
|
* @param bo
|
|
|
|
|
* @return 是否删除成功
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean deleteAccountInstallmentDetail(ErpFinAccountInstallmentDetailBo bo) {
|
|
|
|
|
ErpFinAccountInstallmentDetail row = bo.getInstallmentDetailId() == null ? null : baseMapper.selectById(bo.getInstallmentDetailId());
|
|
|
|
|
|
|
|
|
|
ErpFinAccountInstallment erpFinAccountInstallment = new ErpFinAccountInstallment();
|
|
|
|
|
erpFinAccountInstallment.setAccountInstallmentId(bo.getAccountInstallmentId());
|
|
|
|
|
erpFinAccountInstallment.setInstallmentStatus(bo.getInstallmentStatus());
|
|
|
|
|
finAccountInstallmentMapper.updateById(erpFinAccountInstallment);
|
|
|
|
|
|
|
|
|
|
return baseMapper.deleteById(bo.getInstallmentDetailId()) > 0;
|
|
|
|
|
|
|
|
|
|
boolean ok = baseMapper.deleteById(bo.getInstallmentDetailId()) > 0;
|
|
|
|
|
if (ok && row != null) {
|
|
|
|
|
syncContractCollectionStage(row.getContractId(), row.getProjectId(), row.getPaymentStageId());
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|