Commit a288f338 authored by zhangfeng's avatar zhangfeng

feat(wealth): 批量创建收款单

parent 9982361d
......@@ -7,4 +7,8 @@ public interface BankApi {
* 根据银行账号获取账号信息
*/
BankAccountDTO getBankAccountByAccountNo(String baAccountNum);
/**
* 根据银行账号id获取账号信息
*/
BankAccountDTO getBankAccountByAccountId(Long id);
}
......@@ -23,4 +23,10 @@ public class BankApiImpl implements BankApi {
}
return null;
}
@Override
public BankAccountDTO getBankAccountByAccountId(Long id) {
BankAccountDO bankAccountDO = bankAccountMapper.selectById(id);
return BankAccountConvert.INSTANCE.convertDTO(bankAccountDO);
}
}
......@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptInvoice.ReceiptInvoiceDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptInvoiceLog.ReceiptInvoiceLogDO;
import cn.iocoder.yudao.module.wealth.vo.receipt.ReceiptBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptInvoice.*;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
......@@ -62,4 +63,6 @@ public interface ReceiptInvoiceConvert {
ReceiptInvoiceDO convertInvoiceCreateReqVO(ReceiptInvoiceCreateReqVO receiptInvoiceCreateReqVO);
InvoiceInReceiptRespVO convertRespVO(ReceiptInvoiceDO receiptInvoiceDO);
ReceiptInvoiceCreateReqVO convertCreateReqVO(ReceiptBatchCreateReqVO receiptBatchCreateReqVO);
}
......@@ -52,4 +52,6 @@ public interface ReceivableConvert {
PageResult<ReceivableBackVO> convertPage(PageResult<ReceivableDO> page);
List<ReceivableInItemVO> convertToItemVOList(List<ReceivableDO> receivableDOS);
List<ReceivableUpdateReqVO> convertToUpdateVO(List<ReceivableBackVO> receivable);
}
......@@ -79,7 +79,7 @@ public class ReceiptItemDO extends BaseDO {
*/
private String attr;
/**
* 状态0待核销,1已核销
* 状态0待核销,1已核销,2核销审核中,3反核销审核中,4核销审批拒绝
*/
private Integer status;
......
......@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
@Mapper
......@@ -16,9 +15,9 @@ public interface BankReceiptDetailsMapper {
IPage<BankIncomeItemResp> getBankIncomeItemPage(IPage<BankIncomeItemResp> page, @Param("req") BankIncomeItemReq req);
BigDecimal calculateAccountBalance(String accountNo);
List<CurrencyAmount> calculateAccountBalance(String accountNo);
List<ReceiptItemActualAmount> calculateCurrentAmount(@Param("req") BankIncomeItemReq req);
List<CurrencyAmount> calculateCurrentAmount(@Param("req") BankIncomeItemReq req);
List<ReceiptItemActualAmount> calculateTotalAmount();
List<CurrencyAmount> calculateTotalAmount();
}
......@@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemActualAmount;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemQueryVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemReviewPageReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemReviewPageVO;
......@@ -94,9 +94,9 @@ public interface ReceiptItemMapper extends AbstractMapper<ReceiptItemDO> {
IPage<ReceiptItemReviewPageVO> getReceiptItemReviewPage(IPage<ReceiptItemReviewPageVO> mpPage, @Param("query") ReceiptItemReviewPageReqVO pageReqVO);
List<ReceiptItemActualAmount> getReceiptItemActualAmount(@Param("query") ReceiptItemReviewPageReqVO pageReqVO);
List<CurrencyAmount> getReceiptItemActualAmount(@Param("query") ReceiptItemReviewPageReqVO pageReqVO);
List<ReceiptItemActualAmount> countTotalActualAmount();
List<CurrencyAmount> countTotalActualAmount();
List<ReceiptItemActualAmount> countTotalWriteOffAmount();
List<CurrencyAmount> countTotalWriteOffAmount();
}
......@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableDO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount;
import cn.iocoder.yudao.module.wealth.vo.receivable.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.*;
......@@ -420,4 +421,6 @@ public interface ReceivableMapper extends AbstractMapper<ReceivableDO> {
List<BatchGenReceiptPageVO> batchGenReceiptPage(@Param("start") int start,@Param("size") int size, @Param("query") BatchGenReceiptPageQueryVO query);
int countBatchGenReceiptPage(@Param("query") BatchGenReceiptPageQueryVO query);
List<CurrencyAmount> calculateReceivableAmountByOrderId(Long orderId);
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import java.util.Arrays;
public enum ReceiptStatusEnum implements IntArrayValuable {
DRAFT(0, "草稿", "DRAFT"),
RECEIPT_WAITING(1, "待收款", "RECEIPT_WAITING"),
WRITE_OFF_WAITING(2, "待核销", "write_off_waiting"),
WRITE_OFF_WAITING(2, "待提交", "write_off_waiting"),
WRITE_OFF_PART_ING(3, "已部分核销", "write_off_part_ing"),
WRITE_OFF_ALL_SUCCESS(4, "已核销", "WRITE_OFF_ALL_SUCCESS"),
WRITE_OFF_ALL_OPENING(5, "已核销,待开票", "WRITE_OFF_ALL_OPENING"),
......
......@@ -6,11 +6,13 @@ import cn.iocoder.yudao.module.wealth.service.receiptItem.ReceiptItemService;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
* 银行收款明细审核通过监听
*/
@AllArgsConstructor
@Component
public class ReceiptItemWriteOffListener {
private final ReceiptItemService receiptItemService;
......
......@@ -261,7 +261,7 @@ public class FinanceReceiptApproveService {
// updateReceiptItem.setStatus(ReceiptItemStatusEnum.DRAFT.getValue());
//}
//receiptItemMapper.updateById(updateReceiptItem);
applicationContext.publishEvent(new ReceiptItemWriteOffEvent(receiptApprovalDO.getId(), result));
applicationContext.publishEvent(new ReceiptItemWriteOffEvent(receiptApprovalDO.getReceiptItemId(), result));
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF_NO.getKey(), bmpKey)) {
//收款单明细核销反审核
if (null == receiptApprovalDO.getReceiptItemId()) {
......
......@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.wealth.enums.ReceiptLinkEnum;
import cn.iocoder.yudao.module.wealth.vo.receipt.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
......@@ -161,7 +162,7 @@ public interface ReceiptService extends IService<ReceiptDO> {
* @param createReqVOList
* @return
*/
List<ReceiptBatchGenRespVO> batchGenReceipt(List<ReceiptCreateReqVO> createReqVOList);
List<ReceiptBatchGenRespVO> batchGenReceipt(List<ReceiptBatchCreateReqVO> createReqVOList);
/**
* 生成收款单相关数据
......@@ -193,4 +194,6 @@ public interface ReceiptService extends IService<ReceiptDO> {
* @return
*/
ReceiptBackVO getReceiptDetail(Long id);
void batchApprovedReceipt(ArrayList<Long> receiptIds);
}
......@@ -14,8 +14,11 @@ import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.bpm.api.BpmCreateServiceFactory;
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
import cn.iocoder.yudao.module.bpm.enums.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.enums.WorkFlowEmus;
import cn.iocoder.yudao.module.ecw.api.bank.BankApi;
import cn.iocoder.yudao.module.ecw.api.bank.dto.BankAccountDTO;
import cn.iocoder.yudao.module.ecw.api.currency.CurrencyApi;
import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
......@@ -47,12 +50,15 @@ import cn.iocoder.yudao.module.wealth.vo.receipt.*;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptInvoice.InvoiceInReceiptRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptInvoice.ReceiptInvoiceCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableBackVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableUpdateReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -106,6 +112,10 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
private ReceiptLogMapper receiptLogMapper;
@Resource
private AdminUserApi adminUserApi;
@Resource
private BankApi bankApi;
@Resource
private BpmProcessInstanceApi bpmProcessInstanceApi;
private static final String RECEIPT_NEW_NUMBER = "receipt:new:number";
......@@ -215,7 +225,11 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
}
@Override
public List<ReceiptBatchGenRespVO> batchGenReceipt(List<ReceiptCreateReqVO> createReqVOList) {
public List<ReceiptBatchGenRespVO> batchGenReceipt(List<ReceiptBatchCreateReqVO> batchCreateReqVOList) {
if (CollectionUtil.isEmpty(batchCreateReqVOList)) {
return Collections.emptyList();
}
List<ReceiptCreateReqVO> createReqVOList = assembleCreateReqVOList(batchCreateReqVOList);
ArrayList<ReceiptBatchGenRespVO> respVOS = new ArrayList<>();
createReqVOList.forEach(createReqVO -> {
try {
......@@ -228,16 +242,83 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
return respVOS;
}
ReceiptService currentProxy = (ReceiptService) AopContext.currentProxy();
ArrayList<Long> receiptIds = new ArrayList<>();
for (ReceiptCreateReqVO receiptCreateReqVO : createReqVOList) {
try {
currentProxy.generateReceiptRelevantData(receiptCreateReqVO);
Long receiptId = currentProxy.generateReceiptRelevantData(receiptCreateReqVO);
receiptIds.add(receiptId);
} catch (Exception e) {
respVOS.add(new ReceiptBatchGenRespVO(null, receiptCreateReqVO.getCustomerName(), e.getMessage()));
}
}
// 批量收款单审核通过
if (!respVOS.isEmpty()) {
currentProxy.batchApprovedReceipt(receiptIds);
}
return respVOS;
}
/**
* 组装批量生成收款单的参数
*
* @param batchCreateReqVOList
* @return
*/
private List<ReceiptCreateReqVO> assembleCreateReqVOList(List<ReceiptBatchCreateReqVO> batchCreateReqVOList) {
ArrayList<ReceiptCreateReqVO> createReqVOs = new ArrayList<>();
for (ReceiptBatchCreateReqVO receiptBatchCreateReqVO : batchCreateReqVOList) {
ReceiptCreateReqVO receiptCreateReqVO = new ReceiptCreateReqVO();
receiptCreateReqVO.setGeneratePath(1);
receiptCreateReqVO.setAddType("0");
// TODO 收款单信息待完善
// 设置开票信息
if (receiptBatchCreateReqVO.getOpenInvoice() == 1) {
receiptCreateReqVO.setReceiptInvoice(ReceiptInvoiceConvert.INSTANCE.convertCreateReqVO(receiptBatchCreateReqVO));
}
List<ReceivableBackVO> receivable = receivableService.getReceivableByOrderId(receiptBatchCreateReqVO.getOrderId());
Map<Long, ReceiptAccountCreateReqVO> receiptAccountCreateReqVOS = new HashMap<>();
receivable.forEach(receivableBackVO -> {
// 设置应收信息
BigDecimal taxPoint = receiptBatchCreateReqVO.getTaxPoint();
if (taxPoint == null || taxPoint.compareTo(BigDecimal.ZERO) == 0) {
receivableBackVO.setTaxPoint(BigDecimal.ZERO);
} else {
receivableBackVO.setTaxPoint(taxPoint);
receivableBackVO.setTaxAmount(receivableBackVO.getTaxPoint().multiply(receivableBackVO.getTotalAmount()).add(receivableBackVO.getTotalAmount()));
receivableBackVO.setActualAmount(receivableBackVO.getTaxAmount().subtract(receivableBackVO.getDiscountTotal()));
}
// 设置账单信息
if (receiptAccountCreateReqVOS.containsKey(receivableBackVO.getCurrencyId())) {
ReceiptAccountCreateReqVO receiptAccountCreateReqVO = receiptAccountCreateReqVOS.get(receivableBackVO.getCurrencyId());
receiptAccountCreateReqVO.setReceivableAmount(receiptAccountCreateReqVO.getReceivableAmount().add(receivableBackVO.getActualAmount()));
receiptAccountCreateReqVO.setWriteOffAmount(receiptAccountCreateReqVO.getWriteOffAmount().add(receivableBackVO.getBaseAmount()));
receiptAccountCreateReqVO.setCollectionAmount(receiptAccountCreateReqVO.getCollectionAmount().add(receivableBackVO.getBaseAmount()));
} else {
ReceiptAccountCreateReqVO receiptAccountCreateReqVO = new ReceiptAccountCreateReqVO();
receiptAccountCreateReqVO.setCurrencyId(receivableBackVO.getCurrencyId());
receiptAccountCreateReqVO.setReceivableAmount(receivableBackVO.getActualAmount());
receiptAccountCreateReqVO.setWriteOffRate(receivableBackVO.getExchangeRate());
receiptAccountCreateReqVO.setWriteOffAmount(receivableBackVO.getBaseAmount());
receiptAccountCreateReqVO.setCollectionAmount(receivableBackVO.getBaseAmount());
receiptAccountCreateReqVO.setCollectionCurrencyId(receivableBackVO.getBaseCurrencyId());
receiptAccountCreateReqVO.setCollectionRate(receivableBackVO.getExchangeRate());
if (receiptBatchCreateReqVO.getPlatformAccountId() != null) {
receiptAccountCreateReqVO.setPlatformAccountId(receiptBatchCreateReqVO.getPlatformAccountId().intValue());
BankAccountDTO account = bankApi.getBankAccountByAccountId(receiptBatchCreateReqVO.getPlatformAccountId());
receiptAccountCreateReqVO.setPlatformAccountNo(account.getBaAccountNum());
receiptAccountCreateReqVO.setPlatformAccountName(account.getBaAccountName());
receiptAccountCreateReqVO.setPlatformAccountBlankName(account.getBaBankName());
}
receiptAccountCreateReqVOS.put(receivableBackVO.getCurrencyId(), receiptAccountCreateReqVO);
}
});
receiptCreateReqVO.setReceivableVOList(ReceivableConvert.INSTANCE.convertToUpdateVO(receivable));
receiptCreateReqVO.setReceiptAccountList((List<ReceiptAccountCreateReqVO>) receiptAccountCreateReqVOS.values());
createReqVOs.add(receiptCreateReqVO);
}
return createReqVOs;
}
/**
* 生成收款单相关数据
*
......@@ -1038,6 +1119,13 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
return backVO;
}
@Override
@Async
public void batchApprovedReceipt(ArrayList<Long> receiptIds) {
List<ReceiptDO> receiptDOS = receiptMapper.selectList(Wrappers.lambdaQuery(ReceiptDO.class).in(ReceiptDO::getId, receiptIds));
receiptDOS.forEach(receiptDO -> bpmProcessInstanceApi.approveTask(receiptDO.getBmpId(), "批量生成收款单自动审批"));
}
/**
* 更新收款单明细状态
*/
......
......@@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import cn.iocoder.yudao.module.ecw.api.currency.dto.ExchangeRateRespDTO;
import cn.iocoder.yudao.module.ecw.api.internalMessage.ClientInternalMessageApi;
import cn.iocoder.yudao.module.ecw.api.internalMessage.dto.InternalMessageCreateDto;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.wealth.convert.receiptInvoice.ReceiptInvoiceConvert;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptInvoice.ReceiptInvoiceDO;
......@@ -72,6 +73,8 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
private CurrencyApi currencyApi;
@Resource
private ClientInternalMessageApi clientInternalMessageApi;
@Resource
private AdminUserApi adminUserApi;
@Override
@Transactional(rollbackFor = Exception.class)
......@@ -94,6 +97,7 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptInvoiceMapper.insert(receiptInvoiceDO);
// 更新收款单状态
receiptDO.setInvoiceId(receiptInvoiceDO.getId());
receiptDO.setOpenInvoice(1);
receiptDO.setInvoicingStatus(InvoicingStatusEnum.WAIT.getValue());
receiptDO.setInvoiceDataStatus(SUBMIT.getValue());
receiptMapper.updateById(receiptDO);
......@@ -135,6 +139,7 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
ReceiptInvoiceDO updateObj = ReceiptInvoiceConvert.INSTANCE.convert(updateReqVO);
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
updateObj.setInvoicerId(loginUser.getId());
updateObj.setInvoiceInfoSaveTime(new Date());
receiptInvoiceMapper.updateById(updateObj);
ReceiptDO receiptDO = new ReceiptDO();
receiptDO.setId(receiptInvoiceDO.getReceiptId());
......@@ -165,9 +170,11 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
// 查询日志
List<ReceiptInvoiceLogDO> invoiceLogDOS = receiptInvoiceLogMapper.selectList("invoice_id", id);
receiptInvoiceDetail.setInvoiceLog(ReceiptInvoiceConvert.INSTANCE.logDOtoLogVOList(invoiceLogDOS));
List<ReceiptRelationOrderInfoVO> orderInfoList = receiptMapper.getOrderInfoByReceiptId(receiptInvoiceDetail.getReceiptId());
receiptInvoiceDetail.setOrderInfoList(orderInfoList);
receiptInvoiceDetail.setCreator(adminUserApi.getUser(Long.parseLong(receiptInvoiceDetail.getCreator())).getNickname());
receiptInvoiceDetail.setUpdater(adminUserApi.getUser(Long.parseLong(receiptInvoiceDetail.getUpdater())).getNickname());
return receiptInvoiceDetail;
}
......
......@@ -77,8 +77,10 @@ public class BankReceiptDetailsImpl implements BankReceiptDetailsService {
}
// 计算账号余额
List<BankIncomeItemResp> records = mpPage.getRecords();
HashMap<String, BigDecimal> accountBalanceMap = new HashMap<>();
HashMap<String, List<CurrencyAmount>> accountBalanceMap = new HashMap<>();
for (BankIncomeItemResp record : records) {
// 目前只有收
record.setIsIncome(0);
if (accountBalanceMap.containsKey(record.getAccountNo())) {
record.setAccountBalance(accountBalanceMap.get(record.getAccountNo()));
} else {
......
......@@ -21,9 +21,7 @@ import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import cn.iocoder.yudao.module.ecw.api.currency.dto.ExchangeRateRespDTO;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.wealth.convert.receipt.ReceiptConvert;
import cn.iocoder.yudao.module.wealth.convert.receiptItem.ReceiptItemConvert;
import cn.iocoder.yudao.module.wealth.convert.receivable.ReceivableConvert;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptBankWriteoffRangeDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptAccount.ReceiptAccountDO;
......@@ -69,7 +67,6 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
......@@ -253,9 +250,6 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
if (null == receiptItemDO) {
throw exception(RECEIPT_ITEM_NOT_FOUND);
}
if (receiptItemDO.getStatus() != 0) {
throw exception(RECEIPTITEM_VERIFICATION);
}
receiptItemDO.setBmpStatus(bpmResult);
// 核销通过
if (Objects.equals(bpmResult, BpmProcessInstanceResultEnum.APPROVE.getResult())) {
......@@ -288,7 +282,6 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
}
}
receivableService.updateBatchById(receivableDOS);
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
}
// 审核拒绝
else if (Objects.equals(bpmResult, BpmProcessInstanceResultEnum.REJECT.getResult())) {
......@@ -299,6 +292,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
receiptItemDO.setStatus(ReceiptItemStatusEnum.DRAFT.getValue());
}
receiptItemMapper.updateById(receiptItemDO);
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
}
@Override
......@@ -511,8 +505,8 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
update.setStatus(ReceiptItemStatusEnum.WRITE_OFF_APPROVE_ING.getValue());
update.setBmpId(bpmId);
this.updateById(update);
receiptService.recordLog(update.getReceiptId(), ReceiptLinkEnum.SUBMIT_BANK_RECEIPT, financeReceiptItemVo.getRemark(), update.getBmpId());
receiptService.updateReceiptItemStatus(update.getReceiptId());
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.SUBMIT_BANK_RECEIPT, financeReceiptItemVo.getRemark(), update.getBmpId());
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
return approvalDO;
}
......@@ -539,9 +533,9 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
BigDecimal totalAmount = receiptAccounts.stream().map(ReceiptAccountDO::getWriteOffAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
// 计算核销比例
BigDecimal writeOffDown = new BigDecimal(receiptBankWriteoffRangeDOS.get(0).getWriteOffDown()).divide(new BigDecimal("100"));
BigDecimal writeOffUp = new BigDecimal(receiptBankWriteoffRangeDOS.get(0).getWriteOffUp()).divide(new BigDecimal("100"));
BigDecimal writeOffRate = receiptItemDO.getWriteOffAmount().divide(totalAmount, 8, RoundingMode.HALF_UP).setScale(6, RoundingMode.HALF_UP);
BigDecimal writeOffDown = new BigDecimal(receiptBankWriteoffRangeDOS.get(0).getWriteOffDown());
BigDecimal writeOffUp = new BigDecimal(receiptBankWriteoffRangeDOS.get(0).getWriteOffUp());
BigDecimal writeOffRate = receiptItemDO.getWriteOffAmount().multiply(new BigDecimal(10000)).divide(totalAmount, 8, RoundingMode.HALF_UP).setScale(6, RoundingMode.HALF_UP);
if (writeOffRate.compareTo(writeOffDown) < 0 || writeOffRate.compareTo(writeOffUp) > 0) {
return;
}
......@@ -757,9 +751,9 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
record.setFeeStatistics(getReceivableFeeStatistics(receivableDOS));
}
ReceiptItemReviewPageResult<ReceiptItemReviewPageVO> pageResult = ReceiptItemReviewPageResult.of(mpPage);
List<ReceiptItemActualAmount> actualAmount = receiptItemMapper.getReceiptItemActualAmount(pageReqVO);
List<ReceiptItemActualAmount> totalActualAmount = receiptItemMapper.countTotalActualAmount();
List<ReceiptItemActualAmount> totalWriteOffAmount = receiptItemMapper.countTotalWriteOffAmount();
List<CurrencyAmount> actualAmount = receiptItemMapper.getReceiptItemActualAmount(pageReqVO);
List<CurrencyAmount> totalActualAmount = receiptItemMapper.countTotalActualAmount();
List<CurrencyAmount> totalWriteOffAmount = receiptItemMapper.countTotalWriteOffAmount();
pageResult.setActualAmount(actualAmount);
pageResult.setTotalActualAmount(totalActualAmount);
pageResult.setTotalWriteOffAmount(totalWriteOffAmount);
......
......@@ -33,6 +33,7 @@ import cn.iocoder.yudao.module.wealth.dal.mysql.receivable.ReceivableMapper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receivable.ReceivableWriteOffRecordMapper;
import cn.iocoder.yudao.module.wealth.service.receipt.ReceiptService;
import cn.iocoder.yudao.module.wealth.service.receivableDiscount.ReceivableDiscountService;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount;
import cn.iocoder.yudao.module.wealth.vo.receivable.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -574,6 +575,8 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
List<BatchGenReceiptPageVO> batchGenReceiptPageVOS = receivableMapper.batchGenReceiptPage(start, size, query);
int total = receivableMapper.countBatchGenReceiptPage(query);
batchGenReceiptPageVOS.forEach(vo -> {
List<CurrencyAmount> receivableAmount = receivableMapper.calculateReceivableAmountByOrderId(vo.getOrderId());
vo.setReceivableAmount(receivableAmount);
CustomerDTO customer;
if (vo.getDrawee().equals(1)) {
customer = customerApi.getCustomerInfo(vo.getConsignorId());
......@@ -631,6 +634,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
receivableInItemVO.setWriteOffAmountUsd(totalWriteOffAmount);
receivableInItemVO.setNotWriteOffAmountUsd(receivableInItemVO.getBaseAmount().subtract(totalWriteOffAmount));
}
receivableInItemVOS.sort(Comparator.comparing(ReceivableInItemVO::getNotWriteOffAmountUsd).reversed());
return receivableInItemVOS;
}
......@@ -656,6 +660,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
}
receivableInItemVO.setNotWriteOffAmountUsd(receivableInItemVO.getBaseAmount().subtract(receivableInItemVO.getWriteOffAmountUsd()));
}
receivableInItemVOS.sort(Comparator.comparing(ReceivableInItemVO::getNotWriteOffAmountUsd).reversed());
return receivableInItemVOS;
}
......
......@@ -2,14 +2,18 @@ package cn.iocoder.yudao.module.wealth.vo.receipt;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
@Data
@Builder
@ApiModel("收款单明细审核")
@AllArgsConstructor
@NoArgsConstructor
public class FinanceReceiptItemVo {
@ApiModelProperty(value = "收款单ID")
@NotNull(message = "收款单ID不能为空")
......
......@@ -48,7 +48,7 @@ public class ReceiptBaseVO {
private String remark;
@ApiModelProperty(value = "核销币种")
@NotNull(message = "核销币种不能为空")
//@NotNull(message = "核销币种不能为空")
private Long currencyId;
@ApiModelProperty(value = "核销比例传值要乘以100")
......@@ -149,4 +149,7 @@ public class ReceiptBaseVO {
@ApiModelProperty(value = "财务备注")
private String financeRemark;
@ApiModelProperty(value = "生成路径")
private Integer generatePath;
}
package cn.iocoder.yudao.module.wealth.vo.receipt;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.math.BigDecimal;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("管理后台 - 收款单创建 Request VO")
public class ReceiptBatchCreateReqVO extends ReceiptBaseVO {
@ApiModelProperty(value = "订单id")
private Long orderId;
@ApiModelProperty(value = "税点(明细)")
private BigDecimal taxPoint;
@ApiModelProperty(value = "平台收款账户id")
private Long platformAccountId;
@ApiModelProperty(value = "发票抬头")
private String invoice;
@ApiModelProperty(value = "纳税人识别号")
private String taxpayer;
@ApiModelProperty(value = "开户行")
private String accountBank;
@ApiModelProperty(value = "账号")
private String accountName;
@ApiModelProperty(value = "开票品名")
private String projectName;
@ApiModelProperty(value = "税率(发票)")
private BigDecimal taxRate;
@ApiModelProperty(value = "开票电话")
private String invoicePhone;
@ApiModelProperty(value = "开票电话/地址")
private String addressPhone;
@ApiModelProperty(value = "备注")
private String invoiceRemark;
}
......@@ -29,7 +29,7 @@ public class ReceiptInvoicePageBackVO {
private String receiptNo;
@ApiModelProperty(value = "申请日期")
private String invoiceInfoSaveTime;
private String createTime;
@ExcelProperty("开票状态")
@ApiModelProperty(value = "开票状态")
......
......@@ -17,7 +17,7 @@ public class BankIncomeItemReq extends PageParam {
@ApiModelProperty(value = "收款账号银行名称")
private List<Integer> platformAccountIds;
@ApiModelProperty(value = "收/支,暂时没支")
@ApiModelProperty(value = "0收/1支,暂时没支")
private Integer isIncome;
@ApiModelProperty(value = "金额符号")
private Integer relationSymbol;
......@@ -25,10 +25,10 @@ public class BankIncomeItemReq extends PageParam {
private java.math.BigDecimal amount;
@ApiModelProperty(value = "交易日期开始")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date amountDateStart;
private Date beginAmountDate;
@ApiModelProperty(value = "交易日期结束")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date amountDateEnd;
private Date endAmountDate;
@ApiModelProperty(value = "关联单号")
private String relationNo;
@ApiModelProperty(value = "交易日期排序方式")
......
......@@ -21,6 +21,9 @@ public class BankIncomeItemResp {
@ApiModelProperty(value = "收款单id")
private String receiptId;
@ApiModelProperty(value = "0收/1支,暂时没支")
private Integer isIncome;
@ApiModelProperty(value = "收款账号")
private String accountNo;
......@@ -33,6 +36,9 @@ public class BankIncomeItemResp {
@ApiModelProperty(value = "货币id")
private Long currencyId;
@ApiModelProperty(value = "实收金额")
private java.math.BigDecimal amount;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "实收日期")
private Date amountDate;
......@@ -40,8 +46,11 @@ public class BankIncomeItemResp {
@ApiModelProperty(value = "收款单编号")
private String receiptNo;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "账号余额")
private java.math.BigDecimal accountBalance;
private List<CurrencyAmount> accountBalance;
@ApiModelProperty(value = "相关订单信息列表")
private List<ReceiptRelationOrderInfoVO> orderInfoList;
......
......@@ -30,10 +30,10 @@ public final class BankIncomePageResult<T> implements Serializable {
private Long pages = 0L;
@ApiModelProperty(value = "当前搜索条件汇总")
List<ReceiptItemActualAmount> currentAmount;
List<CurrencyAmount> currentAmount;
@ApiModelProperty(value = "总合计")
List<ReceiptItemActualAmount> totalAmount;
List<CurrencyAmount> totalAmount;
public BankIncomePageResult() {}
......
......@@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ReceiptItemActualAmount {
public class CurrencyAmount {
@ApiModelProperty(value = "币种id")
private String currencyId;
@ApiModelProperty(value = "金额")
......
......@@ -30,13 +30,13 @@ public final class ReceiptItemReviewPageResult<T> implements Serializable {
private Long pages = 0L;
@ApiModelProperty(value = "当前查询实收")
private List<ReceiptItemActualAmount> actualAmount;
private List<CurrencyAmount> actualAmount;
@ApiModelProperty(value = "总实收")
List<ReceiptItemActualAmount> totalActualAmount;
List<CurrencyAmount> totalActualAmount;
@ApiModelProperty(value = "结算总合计")
List<ReceiptItemActualAmount> totalWriteOffAmount;
List<CurrencyAmount> totalWriteOffAmount;
public ReceiptItemReviewPageResult() {}
......
......@@ -9,6 +9,8 @@ import java.util.List;
@Data
@ApiModel("管理后台 - 批量生成收款单列表查询 Request VO")
public class BatchGenReceiptPageQueryVO {
@ApiModelProperty(value = "订单id")
private List<Long> orderIds;
@ApiModelProperty(value = "订单号")
private String orderNo;
......
package cn.iocoder.yudao.module.wealth.vo.receivable;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("管理后台 - 批量生成收款单列表 VO")
public class BatchGenReceiptPageVO {
......@@ -51,4 +54,7 @@ public class BatchGenReceiptPageVO {
@ApiModelProperty(value = "自编号状态")
private Integer selfNoStatus;
@ApiModelProperty(value = "应收汇总")
private List<CurrencyAmount> receivableAmount;
}
......@@ -311,7 +311,7 @@ public class ReceiptController {
@PostMapping("/batch-gen-receipt")
@ApiOperation("批量生成收款单")
public CommonResult<List<ReceiptBatchGenRespVO>> batchGenReceipt(@RequestBody List<ReceiptCreateReqVO> createReqVOList) {
public CommonResult<List<ReceiptBatchGenRespVO>> batchGenReceipt(@RequestBody List<ReceiptBatchCreateReqVO> createReqVOList) {
return success(receiptService.batchGenReceipt(createReqVOList));
}
......
......@@ -117,7 +117,7 @@
</select>
<sql id="incomePageCondition">
<if test="req.relationNo != null and req.relationNo != ''">
AND (er.receipt_no LIKE concat('%',#{req.receiptNo},'%') OR eo.order_no LIKE
AND (er.receipt_no LIKE concat('%',#{req.relationNo},'%') OR eo.order_no LIKE
concat('%',#{req.relationNo},'%') OR eo.tidan_no = #{req.relationNo})
</if>
<if test="req.platformAccountIds != null and req.platformAccountIds.size > 0">
......@@ -127,29 +127,32 @@
</foreach>
</if>
<if test="req.amount != null and req.relationSymbol != null">
<!--1:大于 2:等于 3:小于-->
<if test="req.rewardCountOperate == 1">
<!--1:大于 2:等于 3:小于等于-->
<if test="req.relationSymbol == 0">
AND eri.amount &gt; #{req.amount}
</if>
<if test="req.rewardCountOperate == 2">
<if test="req.relationSymbol == 1">
AND eri.amount = #{req.amount}
</if>
<if test="req.rewardCountOperate == 3">
AND eri.amount &lt; #{req.amount}
<if test="req.relationSymbol == 2">
AND eri.amount &lt;= #{req.amount}
</if>
</if>
<if test="req.amountDateStart != null and req.amountDateEnd != null">
AND eri.amount_date BETWEEN #{req.amountDateStart} AND #{req.amountDateEnd}
<if test="req.beginAmountDate != null and req.endAmountDate != null">
AND eri.amount_date BETWEEN #{req.beginAmountDate} AND #{req.endAmountDate}
</if>
</sql>
<select id="calculateAccountBalance" resultType="java.math.BigDecimal">
SELECT SUM(amount)
<select id="calculateAccountBalance" resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount">
SELECT
currency_id,
SUM(amount) AS amount
FROM ecw_receipt_item
WHERE
account_no = #{accountNo} AND status = 1
GROUP BY currency_id
</select>
<select id="calculateCurrentAmount"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemActualAmount">
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount">
SELECT
SUM(t.amount) AS amount,
t.currency_id AS currencyId
......@@ -168,7 +171,7 @@
GROUP BY t.currency_id
</select>
<select id="calculateTotalAmount"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemActualAmount">
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount">
SELECT
SUM(amount) AS amount,
currency_id AS currencyId
......
......@@ -69,7 +69,7 @@
</if>
</sql>
<select id="getReceiptItemActualAmount"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemActualAmount">
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount">
SELECT t.currency_id,
SUM(t.amount) AS amount
FROM ( SELECT
......@@ -89,7 +89,7 @@
GROUP BY t.currency_id
</select>
<select id="countTotalActualAmount"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemActualAmount">
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount">
SELECT
eri.currency_id,
SUM(eri.amount) AS amount
......@@ -98,7 +98,7 @@
GROUP BY eri.currency_id
</select>
<select id="countTotalWriteOffAmount"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemActualAmount">
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount">
SELECT
eri.write_off_currency_id AS currency_id,
SUM(eri.write_off_amount) AS amount
......
......@@ -37,6 +37,7 @@
</if>
WHERE er.deleted = 0
<include refid="pageCondition"/>
ORDER BY er.create_time DESC
<if test="query.numberNo != null and query.numberNo != ''">
GROUP BY er.receipt_no
</if>
......
......@@ -306,7 +306,27 @@
WHERE r.deleted = 0 AND r.receipt_id IS NULL
<include refid="batchGenReceiptPageCondition"/>
</select>
<select id="calculateReceivableAmountByOrderId"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount">
SELECT
r.currency_id,
SUM(r.total_amount) AS amount
FROM ecw_receivable r
WHERE r.deleted = 0 AND r.order_id = #{orderId} AND r.receipt_id IS NULL
GROUP BY r.currency_id
</select>
<sql id="batchGenReceiptPageCondition">
<if test="query.orderIds != null">
<if test="query.orderIds.size() == 1">
AND e.order_id = #{query.orderIds[0]}
</if>
<if test="query.orderIds.size() > 1">
AND e.order_id IN
<foreach collection="query.orderIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</if>
<if test="query.orderNo != null and query.orderNo != ''">
AND r.order_no = #{query.orderNo}
</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment