mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 05:42:06 +08:00
发票抬头新增组织唯一和纳税人识别号唯一校验
This commit is contained in:
+34
-2
@@ -12,6 +12,7 @@ import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.date.LocalDateTimeUtils;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
@@ -56,6 +57,8 @@ import static com.cf.imes.framework.common.util.json.JsonUtils.zipString;
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.INVOICE_NO_EXIST;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.INVOICE_TITLE_NOT_EXISTS_ERROR;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.INVOICE_TITLE_ORG_EXISTS_ERROR;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.INVOICE_TITLE_TAXPAYERID_EXISTS_ERROR;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.INVOICING_REJECT_REASON;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORG_INVOICE_AGREE_FILE_NULL_ERROR;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORG_INVOICE_PURCHASE_RECORD_UPDATE_NUM_NOT_MATCH_ERROR;
|
||||
@@ -96,8 +99,14 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||
@Override
|
||||
public void insetInvoiceTitle(InvoiceTitleSaveReqVO reqVO) {
|
||||
Long organId = SecurityFrameworkUtils.getUserOrganId();
|
||||
if (reqVO.getId() != null) {
|
||||
validTitleOrg(reqVO.getId(), organId);
|
||||
|
||||
Long id = reqVO.getId();
|
||||
|
||||
// 校验纳税人识别号和组织id是否唯一
|
||||
validOrgAndTaxpayerNo(id, organId, reqVO.getTaxpayerId());
|
||||
|
||||
if (id != null) {
|
||||
validTitleOrg(id, organId);
|
||||
// 更新抬头
|
||||
InvoiceTitleInfoDO titleInfoDO = BeanUtils.toBean(reqVO, InvoiceTitleInfoDO.class);
|
||||
invoiceTitleInfoMapper.updateById(titleInfoDO);
|
||||
@@ -119,6 +128,29 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验组织和纳税人识别号唯一
|
||||
*
|
||||
* @param id 发票抬头id
|
||||
* @param organId 组织id
|
||||
* @param taxpayerId 纳税人识别号
|
||||
*/
|
||||
private void validOrgAndTaxpayerNo(Long id, Long organId, String taxpayerId) {
|
||||
InvoiceTitleInfoDO exist = invoiceTitleInfoMapper.selectOne(new LambdaQueryWrapperX<InvoiceTitleInfoDO>()
|
||||
.neIfPresent(InvoiceTitleInfoDO::getId, id)
|
||||
.eq(InvoiceTitleInfoDO::getOrganId, organId));
|
||||
|
||||
if (ObjectUtil.isNotNull(exist)) {
|
||||
throw new ServiceException(INVOICE_TITLE_ORG_EXISTS_ERROR);
|
||||
}
|
||||
exist = invoiceTitleInfoMapper.selectOne(new LambdaQueryWrapperX<InvoiceTitleInfoDO>()
|
||||
.neIfPresent(InvoiceTitleInfoDO::getId, id)
|
||||
.eq(InvoiceTitleInfoDO::getTaxpayerId, taxpayerId));
|
||||
if (ObjectUtil.isNotNull(exist)) {
|
||||
throw new ServiceException(INVOICE_TITLE_TAXPAYERID_EXISTS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验抬头组织
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user