登录用户拿不到问题处理;

This commit is contained in:
王奎兴
2026-09-07 15:45:03 +08:00
parent 590e840a7b
commit 1367a1d225
4 changed files with 202 additions and 25 deletions
@@ -184,6 +184,10 @@ public class BillManageApplicationService {
return billManageDomainService.save(billingStatementDTO);
}
public Boolean saveBillJob(BillingStatementDTO billingStatementDTO) {
return billManageDomainService.saveJob(billingStatementDTO);
}
/**
* 批量删除账单管理
*/
@@ -398,7 +398,15 @@ public class BillingStatementApplicationService {
if (!StringUtils.isNotEmpty(billingStatementDTO.getBillingStatementIds())) {
throw new ServiceException("所选审核对象不能为空");
}
billingStatementDomainService.reviewBilling(billingStatementDTO);
billingStatementDomainService.reviewBillingJob(billingStatementDTO);
}
@Transactional
public void reviewBillingJob(BillingStatementDTO billingStatementDTO) {
if (!StringUtils.isNotEmpty(billingStatementDTO.getBillingStatementIds())) {
throw new ServiceException("所选审核对象不能为空");
}
billingStatementDomainService.reviewBillingJob(billingStatementDTO);
}
@@ -444,6 +452,32 @@ public class BillingStatementApplicationService {
}
@Transactional
public Boolean generateBillsJob(BillingStatementDTO billingStatementDTO) {
//获取当前登录用户信息
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
// throw new DigitalLogisticsException(UserError.TIMEOUT);
}
/*
首先对账单主体、来源系统、账单类型、组织进行唯一校验
对要生成账单的流水加锁
然后判断流水状态是否满足生成账单需求
最后生成账单
*/
billingStatementDomainService.checkUniqueEntity(billingStatementDTO.getBillingStatementIds());
//校验完成后,生成账单
Boolean flag1 = billManageApplicationService.saveBillJob(billingStatementDTO);
//修改流水状态
billingStatementDTO.setBillingState(3);
Boolean flag2 = billingStatementDomainService.updateBillingStateJob(billingStatementDTO);
if (flag1 && flag2) {
return true;
} else {
throw new ServiceException("生成账单失败");
}
}
/**
* 批量流水作废
*/
@@ -795,7 +829,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -823,7 +857,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
} else {
@@ -852,7 +886,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -880,7 +914,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
}
@@ -924,7 +958,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -952,7 +986,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
}
@@ -1004,7 +1038,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1031,7 +1065,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
} else {
@@ -1060,7 +1094,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1088,7 +1122,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
}
@@ -1132,7 +1166,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1160,7 +1194,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
}
@@ -1206,7 +1240,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1234,7 +1268,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
} else {
@@ -1263,7 +1297,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1291,7 +1325,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
}
@@ -1335,7 +1369,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1363,7 +1397,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
}
@@ -1415,7 +1449,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1442,7 +1476,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
} else {
@@ -1471,7 +1505,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1499,7 +1533,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
}
@@ -1543,7 +1577,7 @@ public class BillingStatementApplicationService {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
billingStatementDTO.setAuditOperation(1);
reviewBilling(billingStatementDTO);
reviewBillingJob(billingStatementDTO);
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
BigDecimal amount = billingStatementDTO.getBillingAmount();
@@ -1571,7 +1605,7 @@ public class BillingStatementApplicationService {
billingStatementDTO1.setTaxFreeFee(allFreeFee);
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
generateBills(billingStatementDTO1);
generateBillsJob(billingStatementDTO1);
}
}
}
@@ -296,6 +296,64 @@ public class BillManageDomainService {
return saveBill(distinctList,billingStatementDTO.getBillingRemark(),billingStatementDTO.getBillCreateTime(),billingStatementDTO);
}
public Boolean saveJob(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
// throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//根据前端传的流水id,查询计费流水信息列表
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
BillingStatementDO billingStatementDO = new BillingStatementDO();
billingStatementDO.setBillingStatementIdSet(billingSet);
List<BillingStatementPO> billingStatementPOS = billingStatementDomainService.queryList(billingStatementDO);
//获取最新一条的业务员信息
String salesmanId = null;
String salesmanName = null;
if (billingStatementPOS != null && !billingStatementPOS.isEmpty()) {
billingStatementPOS.sort((a, b) -> {
if (a.getCreateTime() == null && b.getCreateTime() == null) return 0;
if (a.getCreateTime() == null) return 1;
if (b.getCreateTime() == null) return -1;
return b.getCreateTime().compareTo(a.getCreateTime());
});
salesmanId = billingStatementPOS.get(0).getSalesmanId();
salesmanName = billingStatementPOS.get(0).getSalesmanName();
}
List<BillingStatementADDVO> billingStatementList = billingStatementDTO.getBillingStatementList();
for (BillingStatementPO billingStatementPO : billingStatementPOS) {
String billingStatementId = billingStatementPO.getBillingStatementId() == null ? "" : String.valueOf(billingStatementPO.getBillingStatementId());
BillingStatementADDVO billingStatementADDVO = billingStatementList.stream().filter(billingStatementADDVO1 -> billingStatementADDVO1.getBillingStatementId().contains(billingStatementId)).findFirst().orElse(null);
billingStatementPO.setTaxAmount(billingStatementADDVO.getTaxAmount()); // 设置税额
billingStatementPO.setTaxRate(billingStatementADDVO.getTaxRate()); // 设置税率
billingStatementPO.setTaxFreeFee(billingStatementADDVO.getTaxFreeFee()); // 设置税免金额
billingStatementPO.setSettlementCurrency(billingStatementADDVO.getSettlementCurrency());//设置结算币种
billingStatementPO.setFeeType(billingStatementADDVO.getFeeType());
billingStatementPO.setInvoiceItem(billingStatementADDVO.getInvoiceItem());
billingStatementPO.setInvoiceItemName(billingStatementADDVO.getInvoiceItemName());
billingStatementPO.setBillingAmount(billingStatementADDVO.getBillingAmount());
billingStatementPO.setBillingStatementIdStr(billingStatementADDVO.getBillingStatementId());
if (salesmanName != null && !salesmanName.isEmpty() && salesmanId != null && !salesmanId.isEmpty()) {
billingStatementPO.setSalesmanId(salesmanId);
billingStatementPO.setSalesmanName(salesmanName);
}
}
List<BillingStatementPO> distinctList = billingStatementPOS.stream()
.filter(Objects::nonNull)
.collect(Collectors.toMap(
BillingStatementPO::getBillingStatementIdStr, // key:去重字段
po -> po, // value:对象本身
(existing, replacement) -> existing // 重复时保留第一个
))
.values()
.stream().collect(Collectors.toList());
if(billingStatementPOS==null || billingStatementPOS.size()==0){
throw new ServiceException("所选流水信息未找到");
}
return saveBill(distinctList,billingStatementDTO.getBillingRemark(),billingStatementDTO.getBillCreateTime(),billingStatementDTO);
}
public List<BillManage> queryListLambda(LambdaQueryWrapper<BillManage> queryWrapper) {
return billManageService.list(queryWrapper);
@@ -171,6 +171,48 @@ public class BillingStatementDomainService {
return billingStatementService.updateBatchById(billingStatements);
}
public Boolean reviewBillingJob(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
// throw new DigitalLogisticsException(UserError.TIMEOUT);
}
List<BillingStatement> billingStatements = new ArrayList<>();
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
for (String billingId : billingSet) {
Long billingStatementId = Long.valueOf(billingId);
BillingStatementPO billingStatementPO = billingStatementService.getInfo(billingStatementId);
if(null == billingStatementPO){
throw new ServiceException("流水不存在");
}
if(billingStatementPO.getBillingState()!=1){
throw new ServiceException("该计费流水状态不为待审核,不能进行审核");
}
if(billingStatementPO.getRedFlushState()==2){
throw new ServiceException("计费流水"+ billingStatementPO.getBillingFlow() +"已红冲,不能进行审核");
}
BillingStatement billingStatement = new BillingStatement();
billingStatement.setBillingStatementId(billingStatementId);
billingStatement.setReviewRemarks(billingStatementDTO.getReviewRemarks());
if(billingStatementDTO.getAuditOperation()==1){
//审核通过
billingStatement.setBillingState(2);
}else {
//审核不通过
billingStatement.setBillingState(4);
//计费流水审核不通过时,修改业务单据中的状态到已生效
BusinessDocumentDO businessDocumentDO = new BusinessDocumentDO();
businessDocumentDO.setBusinessDocumentId(billingStatementPO.getBusinessDocumentId());
businessDocumentDO.setBusinessState(2);
businessDocumentService.update(businessDocumentDO);
}
billingStatement.setUpdateTime(new Date());
// billingStatement.setUpdateBy(loginUser.getUserPo().getUserId());
// billingStatement.setUpdateByName(loginUser.getUserPo().getUserName());
billingStatements.add(billingStatement);
}
return billingStatementService.updateBatchById(billingStatements);
}
/**
* 批量红冲
@@ -299,6 +341,45 @@ public class BillingStatementDomainService {
return update;
}
public Boolean updateBillingStateJob(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
// throw new DigitalLogisticsException(UserError.TIMEOUT);
}
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
LambdaUpdateWrapper<BillingStatement> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BillingStatement::getBillingStatementId,billingSet);
updateWrapper.set(BillingStatement::getBillingState,billingStatementDTO.getBillingState());
// updateWrapper.set(BillingStatement::getUpdateBy,loginUser.getUserPo().getUserId());
updateWrapper.set(BillingStatement::getUpdateTime,new Date());
// updateWrapper.set(BillingStatement::getUpdateByName,loginUser.getUserPo().getUserName());
updateWrapper.set(BillingStatement::getBillManageId,billingStatementDTO.getBillManageId());
boolean update = billingStatementService.update(updateWrapper);
List<BillingStatementADDVO> billingStatementList = billingStatementDTO.getBillingStatementList();
for (BillingStatementADDVO billingStatementADDVO : billingStatementList) {
String billingStatementIds = billingStatementADDVO.getBillingStatementId();
Set<String> billings = Stream.of(billingStatementIds.split(",")).collect(Collectors.toSet());
if (billings != null && billings.size() > 0) {
for (String billing : billings) {
Long billingStatementId = Long.valueOf(billing);
Double taxRate = billingStatementADDVO.getTaxRate();
BillingStatement billingStatement = billingStatementService.getById(billingStatementId);
if (billingStatement != null) {
BigDecimal billingAmount = billingStatement.getBillingAmount();
BigDecimal taxAmount = billingAmount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal taxFreeFee = billingAmount.subtract(taxAmount);
billingStatement.setTaxAmount(taxAmount);
billingStatement.setTaxFreeFee(taxFreeFee);
billingStatement.setTaxRate(taxRate);
billingStatementService.updateById(billingStatement);
}
}
}
}
return update;
}
public Boolean nullifyByIds(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();