demand: TMS系统 - 客户账单管理 - 业务销账申请、财务中心销账审核权限控制 TMS系统 - 客户账单管理 - 现金账单核销、月结账单核销,已申请销账的无法核销
This commit is contained in:
parent
c2a9a8fd22
commit
91adaeefba
@ -12,6 +12,7 @@ package com.xdadan.erp.emis.service.impl;
|
||||
|
||||
import com.xdadan.erp.emis.domain.*;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.enumtype.WriteoffApplyStatus;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.stat.PayBackRecordDtl;
|
||||
import com.xdadan.erp.emis.mapper.*;
|
||||
@ -80,6 +81,12 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
@Autowired
|
||||
private EmisWaybillMapper emisWaybillMapper;
|
||||
|
||||
@Autowired
|
||||
private EmisWriteoffApplyMapper emisWriteoffApplyMapper;
|
||||
|
||||
@Autowired
|
||||
private EmisWriteoffApplyDetailMapper emisWriteoffApplyDetailMapper;
|
||||
|
||||
/**
|
||||
* 查询账单收退款记录
|
||||
*
|
||||
@ -473,6 +480,9 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
&& !"7".equals(emisSettlePayRecord.getPayType())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "业务账单未确认,不允许收款!");
|
||||
}
|
||||
|
||||
// 校验账单对应的运单是否在销账申请表中,且中心审核状态为未审核
|
||||
checkWriteoffApplyStatus(settleBillNo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -604,6 +614,63 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验账单对应的运单是否在销账申请表中,且中心审核状态为未审核
|
||||
*
|
||||
* @param settleBillNo 账单号
|
||||
* @throws EmisBizError 如果存在未审核的销账申请,则抛出异常
|
||||
*/
|
||||
private void checkWriteoffApplyStatus(String settleBillNo) throws EmisBizError {
|
||||
// 根据账单号查询子账单列表,获取运单号列表
|
||||
List<EmisSettleSubBill> subBillList = emisSettleSubBillMapper.selectSubBillListBySettleBillNo(settleBillNo);
|
||||
if (CollectionUtils.isEmpty(subBillList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 提取运单号列表
|
||||
List<String> billCodeList = subBillList.stream()
|
||||
.map(EmisSettleSubBill::getBillCode)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isEmpty(billCodeList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据运单号查询销账申请明细
|
||||
for (String billCode : billCodeList) {
|
||||
EmisWriteoffApplyDetail queryDetail = new EmisWriteoffApplyDetail();
|
||||
queryDetail.setBillCode(billCode);
|
||||
List<EmisWriteoffApplyDetail> detailList = emisWriteoffApplyDetailMapper.selectEmisWriteoffApplyDetailList(queryDetail);
|
||||
|
||||
if (CollectionUtils.isEmpty(detailList)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取所有申请ID,去重
|
||||
List<Long> applyIds = detailList.stream()
|
||||
.map(EmisWriteoffApplyDetail::getApplyId)
|
||||
.filter(id -> id != null)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isEmpty(applyIds)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 查询销账申请,检查中心审核状态
|
||||
for (Long applyId : applyIds) {
|
||||
EmisWriteoffApply writeoffApply = emisWriteoffApplyMapper.selectEmisWriteoffApplyById(applyId);
|
||||
if (writeoffApply != null
|
||||
&& WriteoffApplyStatus.CENTER_PENDING.statusCode.equals(writeoffApply.getBlCenterConfirmed())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
billCode + "已经登记业务销账申请,请先处理再销账");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 收款退款
|
||||
*
|
||||
|
||||
@ -106,7 +106,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
|
||||
and (
|
||||
apply_site_code=#{params.privSiteCode}
|
||||
wa.apply_site_code=#{params.privSiteCode}
|
||||
or EXISTS (
|
||||
select 1 from emis_writeoff_apply_detail wad_check
|
||||
inner join emis_waybill w_check on wad_check.bill_code = w_check.bill_code and w_check.del_flag = '0'
|
||||
where wad_check.apply_id = wa.id
|
||||
and wad_check.del_flag = '0'
|
||||
and (
|
||||
w_check.salesmen = #{params.privEmpName}
|
||||
or w_check.payee = #{params.privEmpName}
|
||||
or EXISTS (
|
||||
select 1 from emis_salesmen_rel esr
|
||||
where esr.del_flag = '0'
|
||||
and esr.bl_open = '1'
|
||||
and now() <![CDATA[ >= ]]> esr.start_date
|
||||
and now() <![CDATA[ <= ]]> esr.end_date
|
||||
and esr.salesmen = w_check.salesmen
|
||||
and esr.sales_ass = #{params.privEmpName}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user