Commit 7c732a99 authored by zhangfeng's avatar zhangfeng

feat(wealth): 批量生成收款单;优化创建,更新收款单

parent f8ee4809
......@@ -236,4 +236,9 @@ public class ReceiptDO extends BaseDO {
* 开票资料状态
*/
private Integer invoiceDataStatus;
/**
* 生成路径
*/
private Integer generatePath;
}
package cn.iocoder.yudao.module.wealth.enums;
import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.util.json.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
@AllArgsConstructor
@Getter
public enum GeneratePathEnum implements IntArrayValuable {
/**
* 单个生成
*/
SINGLE(0, "单个生成", "SINGLE"),
/**
* 批量生成
*/
BATCH(1, "批量生成", "BATCH");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(GeneratePathEnum::getValue).toArray();
/**
* 状态
*/
private final Integer value;
/**
* 状态中文
*/
private final String nameZh;
/**
* 状态英语
*/
private final String nameEn;
public static GeneratePathEnum valueOf(Integer value) {
return ArrayUtil.firstMatch(orderStatus -> orderStatus.getValue().equals(value), GeneratePathEnum.values());
}
@Override
public int[] array() {
return ARRAYS;
}
}
......@@ -6,8 +6,6 @@ import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO;
import cn.iocoder.yudao.module.wealth.enums.ReceiptLinkEnum;
import cn.iocoder.yudao.module.wealth.vo.receipt.*;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountBatchRespVO;
import javax.validation.Valid;
import java.util.Collection;
......@@ -35,21 +33,6 @@ public interface ReceiptService extends IService<ReceiptDO> {
*/
void updateReceipt(@Valid ReceiptUpdateReqVO updateReqVO);
///**
// * 获取开票信息
// *
// * @param receiptId 付款单ID
// */
//ReceiptBackVO getInvoicingInfo(Long receiptId);
//
///**
// * 更新发票信息
// *
// * @param invoicingUpdateVO 更新信息
// */
//void updateInvoicingInfo(@Valid InvoicingUpdateVO invoicingUpdateVO);
/**
* 删除收款单
*
......@@ -173,7 +156,7 @@ public interface ReceiptService extends IService<ReceiptDO> {
Boolean setBankWriteoffRange(ReceiptBankWriteoffRangeVO range);
/**
* 批量生成收款单
* 批量创建收款单
*
* @param createReqVOList
* @return
......@@ -181,12 +164,12 @@ public interface ReceiptService extends IService<ReceiptDO> {
List<ReceiptBatchGenRespVO> batchGenReceipt(List<ReceiptCreateReqVO> createReqVOList);
/**
* 批量导入收款信息
* 生成收款单相关数据
*
* @param list
* @param createReqVO
* @return
*/
List<ReceiptAccountBatchRespVO> receiptAccountImport(List<ReceiptAccountBatchCreateReqVO> list);
Long generateReceiptRelevantData(ReceiptCreateReqVO createReqVO);
/**
* 更新收款明细状态
......
......@@ -47,8 +47,6 @@ import cn.iocoder.yudao.module.wealth.service.receiptApproval.ReceiptApprovalSer
import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import cn.iocoder.yudao.module.wealth.util.WealthGenCodeUtils;
import cn.iocoder.yudao.module.wealth.vo.receipt.*;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountBatchRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptInvoice.ReceiptInvoiceCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableUpdateReqVO;
......@@ -114,94 +112,123 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
@Override
@Transactional(rollbackFor = Exception.class)
public Long createReceipt(ReceiptCreateReqVO createReqVO) {
// TODO 一个收款单是否可以关联多个订单的应收明细,校验明细的规则是什么?
if (createReqVO.getOrderId() == 0) {
throw exception(ORDER_ID_NULL);
}
List<ReceivableUpdateReqVO> receivableUpdateReqVOList = createReqVO.getReceivableVOList();
if (CollectionUtil.isEmpty(receivableUpdateReqVOList)) {
throw exception(RECEIVABLE_NOT_NULL);
}
// 收款账户信息(对应收款信息/账单信息)
List<ReceiptAccountCreateReqVO> receiptAccountCreateReqVOList = createReqVO.getReceiptAccountList();
if (CollectionUtil.isEmpty(receiptAccountCreateReqVOList)) {
throw exception(RECEIPT_ACCOUNT_NOT_EXISTS);
}
// 校验应收明细
validateSameCustomerReceivable(receivableUpdateReqVOList);
validateCreateVO(createReqVO);
ReceiptDO receipt = ReceiptConvert.INSTANCE.convert(createReqVO);
generateReceiptNo(receipt);
receipt.setReceiptItemStatus(ReceiptItemStatusInReceiptEnum.NO_INPUT.getValue());
// 应收明细关联收款单
List<ReceivableDO> receivableDOList = receivableUpdateReqVOList.stream().filter(re -> null != re.getId()).map(re -> {
ReceivableDO receivableDO = ReceivableConvert.INSTANCE.convert(re);
receivableDO.setReceiptNo(receipt.getReceiptNo());
receivableDO.setReceiptId(receipt.getId());
receivableDO.setState(1);
return receivableDO;
}).collect(Collectors.toList());
receivableService.updateBatchById(receivableDOList);
// 生成收款账户信息
List<ReceiptAccountDO> receiptAccountDOList = receiptAccountCreateReqVOList.stream().map(re -> {
ReceiptAccountDO receivableDO = ReceiptAccountConvert.INSTANCE.convert(re);
receivableDO.setReceiptId(receipt.getId());
receivableDO.setUpdateTime(new Date());
return receivableDO;
}).collect(Collectors.toList());
receiptAccountService.saveBatch(receiptAccountDOList);
// 需要开票时生成开票信息
if (createReqVO.getOpenInvoice().equals(1)) {
ReceiptInvoiceCreateReqVO receiptInvoiceCreateReqVO = createReqVO.getReceiptInvoice();
ReceiptInvoiceDO receiptInvoiceDO = ReceiptInvoiceConvert.INSTANCE.convert(receiptInvoiceCreateReqVO);
receiptInvoiceDO.setInvoiceNo(wealthGenCodeUtils.generateInvoiceCode());
receiptInvoiceDO.setReceiptId(receipt.getId());
receiptInvoiceDO.setReceiptNo(receipt.getReceiptNo());
receiptInvoiceDO.setOrderId(createReqVO.getOrderId());
receiptInvoiceDO.setOrderNo(createReqVO.getOrderNo());
receiptInvoiceMapper.insert(receiptInvoiceDO);
receipt.setInvoiceId(receiptInvoiceDO.getId());
receipt.setInvoicingStatus(InvoicingStatusEnum.WAIT.getValue());
}
receipt.setInvoicingStatus(InvoicingStatusEnum.NO_INVOICE.getValue());
// 是草稿
if (StringUtils.equals(createReqVO.getAddType(), "1")) {
receipt.setState(ReceiptStatusEnum.DRAFT.getValue());
receiptMapper.insert(receipt);
ReceiptService currentProxy = (ReceiptService) AopContext.currentProxy();
return currentProxy.generateReceiptRelevantData(createReqVO);
}
// 不是草稿创建收款单并发起审核流程
else if (StringUtils.equals(createReqVO.getAddType(), "0")) {
//validateReceiptBmpStatus(receipt.getId());
/**
* 发起审批流程
*
* @param reason
* @param copyUserList
* @param receipt
*/
private void initApproval(String reason, String[] copyUserList, ReceiptDO receipt) {
ReceiptApprovalDO approvalDO = new ReceiptApprovalDO();
approvalDO.setReceiptId(receipt.getId());
approvalDO.setReceiptNo(receipt.getReceiptNo());
approvalDO.setBmpKey(WorkFlowEmus.FINANCE_RECEIPT_APPROVE.getKey());
approvalDO.setStatus(BpmProcessInstanceResultEnum.PROCESS.getResult());
approvalDO.setReason(createReqVO.getReason());
approvalDO.setReason(reason);
receiptApprovalService.save(approvalDO);
Long userId = SecurityFrameworkUtils.getLoginUserId();
String bpmId = bpmCreateServiceFactory.createBmp(userId, approvalDO.getId(), WorkFlowEmus.FINANCE_RECEIPT_APPROVE.getKey(), receipt.getReceiptNo(), createReqVO.getCopyUserList());
String bpmId = bpmCreateServiceFactory.createBmp(userId, approvalDO.getId(), WorkFlowEmus.FINANCE_RECEIPT_APPROVE.getKey(), receipt.getReceiptNo(), copyUserList);
approvalDO.setBmpId(bpmId);
receiptApprovalService.updateById(approvalDO);
receipt.setBmpStatus(BpmProcessInstanceResultEnum.PROCESS.getResult());
receipt.setState(ReceiptStatusEnum.APPROVE_ING.getValue());
receipt.setBmpId(bpmId);
receiptMapper.insert(receipt);
}
recordLog(receipt.getId(), ReceiptLinkEnum.CREATE_RECEIPT, receipt.getRemark(), receipt.getBmpId());
return receipt.getId();
/**
* 创建发票
*
* @param receiptInvoiceCreateReqVO
* @param receipt
*/
private void createInvoice(ReceiptInvoiceCreateReqVO receiptInvoiceCreateReqVO, ReceiptDO receipt) {
ReceiptInvoiceDO receiptInvoiceDO = ReceiptInvoiceConvert.INSTANCE.convert(receiptInvoiceCreateReqVO);
receiptInvoiceDO.setInvoiceNo(wealthGenCodeUtils.generateInvoiceCode());
receiptInvoiceDO.setReceiptId(receipt.getId());
receiptInvoiceDO.setReceiptNo(receipt.getReceiptNo());
receiptInvoiceDO.setOrderId(receipt.getOrderId());
receiptInvoiceDO.setOrderNo(receipt.getOrderNo());
receiptInvoiceMapper.insert(receiptInvoiceDO);
receipt.setInvoiceId(receiptInvoiceDO.getId());
receipt.setInvoicingStatus(InvoicingStatusEnum.WAIT.getValue());
}
/**
* 生成收款账户信息
*
* @param receiptAccountCreateReqVOList
* @param receipt
*/
private void genReceiptAccount(List<ReceiptAccountCreateReqVO> receiptAccountCreateReqVOList, ReceiptDO receipt) {
List<ReceiptAccountDO> receiptAccountDOList = receiptAccountCreateReqVOList.stream().map(re -> {
ReceiptAccountDO receivableDO = ReceiptAccountConvert.INSTANCE.convert(re);
receivableDO.setReceiptId(receipt.getId());
receivableDO.setUpdateTime(new Date());
return receivableDO;
}).collect(Collectors.toList());
receiptAccountService.saveBatch(receiptAccountDOList);
}
/**
* 应收明细关联收款单
*
* @param receivableUpdateReqVOList
* @param receipt
*/
private void receivableAssocReceipt(List<ReceivableUpdateReqVO> receivableUpdateReqVOList, ReceiptDO receipt) {
List<ReceivableDO> receivableDOList = receivableUpdateReqVOList.stream().filter(re -> null != re.getId()).map(re -> {
ReceivableDO receivableDO = ReceivableConvert.INSTANCE.convert(re);
receivableDO.setReceiptNo(receipt.getReceiptNo());
receivableDO.setReceiptId(receipt.getId());
receivableDO.setState(1);
return receivableDO;
}).collect(Collectors.toList());
receivableService.updateBatchById(receivableDOList);
}
/**
* 校验创建收款单
*
* @param createReqVO
*/
private void validateCreateVO(ReceiptCreateReqVO createReqVO) {
if (createReqVO.getOrderId() == 0) {
throw exception(ORDER_ID_NULL);
}
// 收款账户信息(对应收款信息/账单信息)
if (CollectionUtil.isEmpty(createReqVO.getReceiptAccountList())) {
throw exception(RECEIPT_ACCOUNT_NOT_EXISTS);
}
// 校验应收明细
validateSameCustomerReceivable(createReqVO.getReceivableVOList());
}
@Override
public List<ReceiptBatchGenRespVO> batchGenReceipt(List<ReceiptCreateReqVO> createReqVOList) {
// TODO 区分批量和单个创建,添加新字段
ArrayList<ReceiptBatchGenRespVO> respVOS = new ArrayList<>();
createReqVOList.forEach(createReqVO -> {
try {
validateCreateVO(createReqVO);
} catch (Exception e) {
respVOS.add(new ReceiptBatchGenRespVO(createReqVO.getOrderNo(), createReqVO.getCustomerName(), e.getMessage()));
}
});
if (!respVOS.isEmpty()) {
return respVOS;
}
ReceiptService currentProxy = (ReceiptService) AopContext.currentProxy();
for (ReceiptCreateReqVO receiptCreateReqVO : createReqVOList) {
try {
currentProxy.createReceipt(receiptCreateReqVO);
currentProxy.generateReceiptRelevantData(receiptCreateReqVO);
} catch (Exception e) {
respVOS.add(new ReceiptBatchGenRespVO(receiptCreateReqVO.getOrderNo(), receiptCreateReqVO.getCustomerName(), e.getMessage()));
}
......@@ -209,36 +236,39 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
return respVOS;
}
/**
* 生成收款单相关数据
*
* @param createReqVO 创建信息
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
public List<ReceiptAccountBatchRespVO> receiptAccountImport(List<ReceiptAccountBatchCreateReqVO> list) {
// TODO 逻辑待完善
// 校验收款账户信息
List<ReceiptAccountBatchRespVO> respVOS = validateBatchReceiptAccount(list);
// 插入数据
// 校验收款明细自动审核
// 更新收款单
return respVOS;
}
private List<ReceiptAccountBatchRespVO> validateBatchReceiptAccount(List<ReceiptAccountBatchCreateReqVO> list) {
// 根据订单号或提单号是否能查到订单
// 根据订单号或提单号匹配状态≠已核销/草稿状态的收款单是否存在,存在多条匹配创建时间最晚的一条
// 根据上条校验,一个收款单存在一条或多条收款数据弹提示
// 收款账号是否存在,是否匹配
// 校验收款金额
// 校验实收金额币种
// 结算币种需为收款单所在目的国结算币种
// 校验当前收款单汇率是否过期,过期则更新为导入的汇率
public Long generateReceiptRelevantData(ReceiptCreateReqVO createReqVO) {
ReceiptDO receipt = ReceiptConvert.INSTANCE.convert(createReqVO);
generateReceiptNo(receipt);
receipt.setReceiptItemStatus(ReceiptItemStatusInReceiptEnum.NO_INPUT.getValue());
receivableAssocReceipt(createReqVO.getReceivableVOList(), receipt);
genReceiptAccount(createReqVO.getReceiptAccountList(), receipt);
// 需要开票时生成开票信息
if (createReqVO.getOpenInvoice().equals(1)) {
createInvoice(createReqVO.getReceiptInvoice(), receipt);
} else {
receipt.setInvoicingStatus(InvoicingStatusEnum.NO_INVOICE.getValue());
}
return null;
if (StringUtils.equals(createReqVO.getAddType(), "1")) {
receipt.setState(ReceiptStatusEnum.DRAFT.getValue());
receiptMapper.insert(receipt);
}
// 不是草稿创建收款单并发起审核流程
else if (StringUtils.equals(createReqVO.getAddType(), "0")) {
initApproval(createReqVO.getReason(), createReqVO.getCopyUserList(), receipt);
receiptMapper.insert(receipt);
}
recordLog(receipt.getId(), ReceiptLinkEnum.CREATE_RECEIPT, receipt.getRemark(), receipt.getBmpId());
return receipt.getId();
}
/**
......@@ -266,6 +296,9 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
* @param receivableUpdateReqVOList 收款明细
*/
public void validateSameCustomerReceivable(List<ReceivableUpdateReqVO> receivableUpdateReqVOList) {
if (CollectionUtil.isEmpty(receivableUpdateReqVOList)) {
throw exception(RECEIVABLE_NOT_NULL);
}
Long tempCustomerId = null;
String tempGuojia = "";
String tempNum = "";
......@@ -319,54 +352,25 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
@Override
@Transactional(rollbackFor = Exception.class)
public void updateReceipt(ReceiptUpdateReqVO updateReqVO) {
// 校验流程是不是正在审核中
validateReceiptBmpStatus(updateReqVO.getId());
validateUpdateVO(updateReqVO);
List<ReceivableUpdateReqVO> receivableUpdateReqVOList = updateReqVO.getReceivableVOList();
if (CollectionUtil.isEmpty(receivableUpdateReqVOList)) {
throw exception(RECEIVABLE_NOT_NULL);
}
List<ReceiptAccountCreateReqVO> receiptAccountCreateReqVOList = updateReqVO.getReceiptAccountList();
if (CollectionUtil.isEmpty(receiptAccountCreateReqVOList)) {
throw exception(RECEIPT_ACCOUNT_NOT_EXISTS);
}
// 校验存在
this.validateReceiptExists(updateReqVO.getId());
validateSameCustomerReceivable(updateReqVO.getReceivableVOList());
ReceiptDO updateObj = ReceiptConvert.INSTANCE.convert(updateReqVO);
// TODO 逻辑不对,待确认非草稿状态能否改成草稿
if (StringUtils.equals(updateReqVO.getUpdateType(), "0")) {
updateReqVO.setState(ReceiptStatusEnum.DRAFT.getValue());
receiptMapper.updateById(updateObj);
} else if (StringUtils.equals(updateReqVO.getUpdateType(), "1")) {
//更新收款单并发起审核流程
ReceiptApprovalDO approvalDO = new ReceiptApprovalDO();
approvalDO.setReceiptId(updateReqVO.getId());
approvalDO.setReceiptNo(updateReqVO.getReceiptNo());
approvalDO.setBmpKey(WorkFlowEmus.FINANCE_RECEIPT_APPROVE.getKey());
approvalDO.setStatus(BpmProcessInstanceResultEnum.PROCESS.getResult());
approvalDO.setReason(updateReqVO.getReason());
receiptApprovalService.save(approvalDO);
Long userId = SecurityFrameworkUtils.getLoginUserId();
String bpmId = bpmCreateServiceFactory.createBmp(userId, approvalDO.getId(), WorkFlowEmus.FINANCE_RECEIPT_APPROVE.getKey(), updateReqVO.getReceiptNo(), updateReqVO.getCopyUserList());
approvalDO.setBmpId(bpmId);
receiptApprovalService.updateById(approvalDO);
updateObj.setId(updateReqVO.getId());
updateObj.setBmpStatus(BpmProcessInstanceResultEnum.PROCESS.getResult());
updateObj.setState(ReceiptStatusEnum.APPROVE_ING.getValue());
updateObj.setBmpId(bpmId);
initApproval(updateReqVO.getReason(), updateReqVO.getCopyUserList(), updateObj);
receiptMapper.updateById(updateObj);
}
// 删除的应收明细取消关联收款单
LambdaQueryWrapper<ReceivableDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ReceivableDO::getReceiptId, updateReqVO.getId());
List<ReceivableDO> allReceivable = receivableService.list(lambdaQueryWrapper);
for (ReceivableDO receivableDO : allReceivable) {
if (!receivableUpdateReqVOList.stream().filter(w -> w.getId() == receivableDO.getId()).findAny().isPresent()) {
if (receivableUpdateReqVOList.stream().noneMatch(w -> Objects.equals(w.getId(), receivableDO.getId()))) {
LambdaUpdateWrapper<ReceivableDO> update = new LambdaUpdateWrapper<>();
update.set(ReceivableDO::getReceiptId, null);
update.set(ReceivableDO::getReceiptNo, null);
......@@ -374,81 +378,29 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
receivableService.update(update);
}
}
List<ReceivableDO> receivableDOList = receivableUpdateReqVOList.stream().filter(re -> null != re.getId()).map(re -> {
ReceivableDO receivableDO = ReceivableConvert.INSTANCE.convert(re);
receivableDO.setReceiptNo(updateObj.getReceiptNo());
receivableDO.setReceiptId(updateObj.getId());
receivableDO.setState(1);
return receivableDO;
}).collect(Collectors.toList());
receivableService.updateBatchById(receivableDOList);
receivableAssocReceipt(receivableUpdateReqVOList, updateObj);
// 删除旧的收款账户信息,保存新的收款账户信息
LambdaQueryWrapper<ReceiptAccountDO> removeLambdaWrapper = new LambdaQueryWrapper();
removeLambdaWrapper.eq(ReceiptAccountDO::getReceiptId, updateObj.getId());
receiptAccountService.remove(removeLambdaWrapper);
genReceiptAccount(receiptAccountCreateReqVOList, updateObj);
List<ReceiptAccountDO> receiptAccountDOList = receiptAccountCreateReqVOList.stream().map(re -> {
ReceiptAccountDO receivableDO = ReceiptAccountConvert.INSTANCE.convert(re);
receivableDO.setReceiptId(updateObj.getId());
return receivableDO;
}).collect(Collectors.toList());
receiptAccountService.saveBatch(receiptAccountDOList);
recordLog(updateObj.getId(), ReceiptLinkEnum.EDIT_RECEIPT, updateObj.getRemark(), updateObj.getBmpId());
}
// TODO 拆分到开票管理
//@Override
//public ReceiptBackVO getInvoicingInfo(Long receiptId) {
// ReceiptBackVO receiptBackVO = receiptMapper.getInvoicingInfo(receiptId);
// if (Objects.isNull(receiptBackVO)) {
// throw exception(RECEIPT_NOT_EXISTS);
// }
// /* if (receiptBackVO.getState() != 5) {
// throw exception(THIS_RECEIPT_NOT_STAY_INVOICE_STATE);
// }
// if (StringUtils.isBlank(receiptBackVO.getAccountBank()) || StringUtils.isBlank(receiptBackVO.getAccountName()) || StringUtils.isBlank(receiptBackVO.getInvoice()) || StringUtils.isBlank(receiptBackVO.getAddressPhone()) || StringUtils.isBlank(receiptBackVO.getTaxpayer())) {
// throw exception(BILLING_INFO_NOT_COMPLETE);
// }*/
// //receiptMapper.updateById(ReceiptConvert.INSTANCE.convert(receiptBackVO));
// // 根据客户ID获取用户信息
/// * List<ReceivableDO> receivableDOList = receivableService.list(new LambdaQueryWrapper<ReceivableDO>()
// .eq(ReceivableDO::getReceiptId, receiptId)
// .eq(ReceivableDO::getDeleted, 0)
// .orderByDesc(ReceivableDO::getId));
// receiptBackVO.setReceivableList(ReceivableConvert.INSTANCE.convertList(receivableDOList));*/
// return receiptBackVO;
//}
// TODO 拆分到开票管理
//@Override
//public void updateInvoicingInfo(@Valid InvoicingUpdateVO invoicingUpdateVO) {
// ReceiptDO receiptDO = receiptMapper.selectById(invoicingUpdateVO.getId());
// if (Objects.isNull(receiptDO)) {
// throw exception(RECEIPT_NOT_EXISTS);
// }
// if (receiptDO.getState() != 5) {
// throw exception(THIS_RECEIPT_NOT_STAY_INVOICE_STATE);
// }
// receiptDO.setInvoicingAt(new Date());
// receiptDO.setInvoiceNumber(invoicingUpdateVO.getInvoiceNumber());
// receiptDO.setInvoicingType(invoicingUpdateVO.getInvoicingType());
// receiptDO.setInvoicingRemark(invoicingUpdateVO.getInvoicingRemark());
// receiptDO.setInvoicingTypeId(invoicingUpdateVO.getInvoicingTypeId());
// receiptDO.setTaxRate(invoicingUpdateVO.getTaxRate());
// receiptDO.setProjectName(invoicingUpdateVO.getProjectName());
//
// receiptDO.setInvoice(invoicingUpdateVO.getInvoice());
// receiptDO.setTaxpayer(invoicingUpdateVO.getTaxpayer());
// receiptDO.setAccountBank(invoicingUpdateVO.getAccountBank());
// receiptDO.setAccountName(invoicingUpdateVO.getAccountName());
//
// receiptDO.setAddressPhone(invoicingUpdateVO.getAddressPhone());
//
// receiptDO.setState(ReceiptStatusEnum.OPEN_BILL.getValue());
// receiptMapper.updateById(receiptDO);
//}
private void validateUpdateVO(ReceiptUpdateReqVO updateReqVO) {
// 校验流程是不是正在审核中
validateReceiptBmpStatus(updateReqVO.getId());
if (CollectionUtil.isEmpty(updateReqVO.getReceivableVOList())) {
throw exception(RECEIVABLE_NOT_NULL);
}
if (CollectionUtil.isEmpty(updateReqVO.getReceiptAccountList())) {
throw exception(RECEIPT_ACCOUNT_NOT_EXISTS);
}
validateSameCustomerReceivable(updateReqVO.getReceivableVOList());
}
@Override
@Transactional
public void deleteReceipt(Long id) {
......@@ -628,12 +580,12 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
return sR;
}
/*
计算收款单明细状态
收款单主表
SELECT * from ecw_receipt where receipt_no='SKD00006547'
收款单明细表
SELECT * from ecw_receipt_item where receipt_id=6554
/**
* 计算收款单明细状态
* 收款单主表
* SELECT * from ecw_receipt where receipt_no='SKD00006547'
* 收款单明细表
* SELECT * from ecw_receipt_item where receipt_id=6554
*/
private ReceiptItemStatusInReceiptEnum getReceiptMxStatus(List<ReceiptItemDO> listItem, long ReceiptId) {
//未录入 收款单下无收款明细 OK
......
......@@ -4,9 +4,10 @@ import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemUpdateReqVO;
import org.apache.ibatis.annotations.Param;
import javax.validation.Valid;
import java.math.BigDecimal;
......@@ -121,4 +122,5 @@ public interface ReceiptItemService extends IService<ReceiptItemDO> {
BigDecimal getWriteOffAmountByReceiptId( Long receiptId);
List<ReceiptItemBatchRespVO> receiptItemImport(List<ReceiptItemBatchCreateReqVO> list);
}
......@@ -23,6 +23,8 @@ import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import cn.iocoder.yudao.module.wealth.util.WealthGenCodeUtils;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemUpdateReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -545,4 +547,36 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
public BigDecimal getWriteOffAmountByReceiptId(Long receiptId) {
return receiptItemMapper.getWriteOffAmountByReceiptId(receiptId);
}
@Override
public List<ReceiptItemBatchRespVO> receiptItemImport(List<ReceiptItemBatchCreateReqVO> list) {
// TODO 逻辑待完善
// 校验收款账户信息
List<ReceiptItemBatchRespVO> respVOS = validateBatchReceiptAccount(list);
// 插入数据
// 校验收款明细自动审核
// 更新收款单
return respVOS;
}
private List<ReceiptItemBatchRespVO> validateBatchReceiptAccount(List<ReceiptItemBatchCreateReqVO> list) {
// 根据订单号或提单号是否能查到订单
// 根据订单号或提单号匹配状态≠已核销/草稿状态的收款单是否存在,存在多条匹配创建时间最晚的一条
// 根据上条校验,一个收款单存在一条或多条收款数据弹提示
// 收款账号是否存在,是否匹配
// 校验收款金额
// 校验实收金额币种
// 结算币种需为收款单所在目的国结算币种
// 校验当前收款单汇率是否过期,过期则更新为导入的汇率
return null;
}
}
......@@ -7,7 +7,7 @@ import lombok.Data;
@Data
@ApiModel("管理后台 - 批量收款信息创建 Request VO")
public class ReceiptAccountBatchCreateReqVO {
public class ReceiptItemBatchCreateReqVO {
@ApiModelProperty(value = "订单号/提单号")
@ExcelProperty("订单号/提单号")
private String orderNo;
......
......@@ -6,7 +6,7 @@ import lombok.Data;
@Data
@ApiModel("管理后台 - 批量导入收款信息结果 VO")
public class ReceiptAccountBatchRespVO {
public class ReceiptItemBatchRespVO {
@ApiModelProperty(value = "订单号/提单号")
private String orderNo;
......
......@@ -10,7 +10,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.framework.idempotent.core.annotation.Idempotent;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
......@@ -30,15 +29,12 @@ import cn.iocoder.yudao.module.wealth.service.receiptApproval.ReceiptApprovalSer
import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import cn.iocoder.yudao.module.wealth.vo.receipt.*;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountBackVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountBatchRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptApproval.ReceiptApprovalBackVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableBackVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableQueryVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -48,16 +44,13 @@ import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFPicture;
import org.apache.poi.xssf.usermodel.XSSFShape;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.Collection;
......@@ -296,34 +289,6 @@ public class ReceiptController {
return success(ReceiptAccountConvert.INSTANCE.convertList(list));
}
// TODO 拆分到开票管理
//@GetMapping("/invoicing/info/{id}")
//@ApiOperation("获得收款单开票信息")
//@ApiImplicitParam(name = "id", value = "收款单ID", required = true, example = "1024", dataTypeClass = Long.class)
////@PreAuthorize("@ss.hasPermission('ecw:receipt:query')")
//public CommonResult<ReceiptBackVO> getInvoicingInfo(@PathVariable("id") Long id) {
// ReceiptBackVO receiptBackVO = receiptService.getInvoicingInfo(id);
// return success(receiptBackVO);
//}
/* @GetMapping("/getInvoicingItem")
@ApiOperation("根据收款单ID获取应收明细")
@ApiImplicitParam(name = "id", value = "收款单ID", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult<List<ReceivableBackVO>> getInvoicingItem(@RequestParam("id") Long id) {
LambdaQueryWrapper<ReceivableDO> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.eq(ReceivableDO::getReceiptId, id);
return success(ReceivableConvert.INSTANCE.convertList(receivableService.list(lambdaQueryWrapper)));
}*/
// TODO 拆分到开票管理
//@PutMapping("/invoicing/info")
//@ApiOperation("更新收款单开票信息")
////@PreAuthorize("@ss.hasPermission('ecw:receipt:update')")
//public CommonResult<Boolean> updateInvoicingInfo(@Valid @RequestBody InvoicingUpdateVO invoicingUpdateVO) {
// receiptService.updateInvoicingInfo(invoicingUpdateVO);
// return success(true);
//}
@GetMapping("/list")
@ApiOperation("获得收款单列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
......@@ -361,16 +326,6 @@ public class ReceiptController {
return success(receiptService.batchGenReceipt(createReqVOList));
}
@PostMapping(value = "receipt-account/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("批量银行收款信息导入")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "Excel 文件", required = true, dataTypeClass = MultipartFile.class)
})
public CommonResult<List<ReceiptAccountBatchRespVO>> receiptAccountImport(@RequestParam("file") MultipartFile file) throws IOException {
List<ReceiptAccountBatchCreateReqVO> list = ExcelUtils.read(file, ReceiptAccountBatchCreateReqVO.class);
return success(receiptService.receiptAccountImport(list));
}
@GetMapping("/export-excel")
@ApiOperation("导出收款单 Excel")
......
......@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.wealth.controller.admin.receiptItem;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.collectors.CollectorsUtil;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.framework.idempotent.core.annotation.Idempotent;
import cn.iocoder.yudao.module.ecw.api.currency.CurrencyApi;
import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
......@@ -18,18 +19,24 @@ import cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem.ReceiptItemMapper;
import cn.iocoder.yudao.module.wealth.service.receiptItem.ReceiptItemService;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemBackVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemUpdateReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
......@@ -270,4 +277,14 @@ public class ReceiptItemController {
return success(true);
}
@PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("批量银行收款信息导入")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "Excel 文件", required = true, dataTypeClass = MultipartFile.class)
})
public CommonResult<List<ReceiptItemBatchRespVO>> receiptAccountImport(@RequestParam("file") MultipartFile file) throws IOException {
List<ReceiptItemBatchCreateReqVO> list = ExcelUtils.read(file, ReceiptItemBatchCreateReqVO.class);
return success(receiptItemService.receiptItemImport(list));
}
}
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