Commit a288f338 authored by zhangfeng's avatar zhangfeng

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

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