Commit 4a25ff9a authored by zhangfeng's avatar zhangfeng

feat(wealth): 优化

parent 88a4351d
......@@ -55,6 +55,10 @@ INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('开票管理', '', 2, 2, 1624, 'invoiceManagement', 'order', 'ecw/financial/invoiceManagement', 0, '1', '2024-12-24 18:13:46', '1', '2024-12-24 18:13:46', b'0', b'1', 'invoiceManagement', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('收款数据审批列表', '', 2, 2, 1624, 'collectionApprovalList', 'clipboard', 'ecw/financial/collectionApprovalList', 0, '1', '2025-01-03 08:58:08', '1', '2025-01-03 08:58:08', b'0', b'1', 'collectionApprovalList', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('审批', 'ecw:collectionApprovalList:update', 3, 1, 2388, '', '', '', 0, '1', '2025-01-03 16:59:36', '1', '2025-01-03 16:59:36', b'0', b'1', 'approve', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('批量生成收款单', '', 2, 12, 1624, 'batchGenerateReceipt/:id', 'button', 'ecw/financial/batchGenerateReceipt', 0, '2696', '2025-01-08 09:57:18', '2696', '2025-01-09 10:53:46', b'0', b'0', 'batchGenerateReceipt', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('批量生成收款单列表', '', 2, 7, 1624, 'batchGenerateReceiptList', 'component', 'ecw/financial/batchGenerateReceiptList', 0, '2696', '2025-01-08 09:58:54', '2696', '2025-01-08 09:58:54', b'0', b'1', 'batchGenerateReceiptList', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('银行收支明细', '', 2, 1, 1624, 'bankBalanceDetails', 'dashboard', 'ecw/financial/bankBalanceDetails', 0, '2696', '2025-01-09 13:44:20', '2696', '2025-01-09 13:50:15', b'0', b'1', 'bank Balance Details', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('单个订单费用明细', '', 2, 4, 1624, 'orderItemCostDetails/:id/:drawee', 'theme', 'ecw/financial/orderItemCostDetails', 0, '2696', '2025-01-09 15:30:19', '2696', '2025-01-13 10:17:48', b'0', b'0', 'orderItemCostDetails', b'0', NULL, NULL);
UPDATE `system_menu` SET `name` = '银行账户', `permission` = '', `menu_type` = 2, `sort` = 9, `parent_id` = 1624, `path` = 'bank-account', `icon` = 'lock', `component` = 'ecw/bankAccount/index', `status` = 0, `creator` = '', `create_time` = '2022-05-09 11:40:51', `updater` = '1', `update_time` = '2024-12-20 13:36:45', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Bank account management', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1269;
......
......@@ -42,7 +42,7 @@ public class InternalMessageCreateDto {
@ApiModelProperty(value = "内容法文")
private String contentFr;
@ApiModelProperty(value = "1订单消息,2出货消息,3提醒消息")
@ApiModelProperty(value = "1订单消息,2出货消息,3提醒消息,4开票资料消息,5开票消息")
private Integer type;
}
package cn.iocoder.boot.module.order.api;
import cn.iocoder.boot.module.order.api.dto.OrderCustomerInfoDTO;
import cn.iocoder.boot.module.order.api.dto.OrderItemRespDTO;
import cn.iocoder.boot.module.order.api.dto.OrderOperateLogDTO;
import cn.iocoder.boot.module.order.api.dto.OrderRespDTO;
......@@ -46,4 +47,9 @@ public interface OrderApi {
* 根据订单号获取目的国
*/
Long getDestCountryByOrderId(Long orderId);
/**
* 创建收款单获取客户id
*/
OrderCustomerInfoDTO createReceiptGetOrderCustomerInfo(Long orderId);
}
package cn.iocoder.boot.module.order.api.dto;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class OrderCustomerInfoDTO {
private Long customerId;
private String customerName;
}
......@@ -11,13 +11,14 @@ import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignee.OrderConsigne
import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignor.OrderConsignorDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO;
import cn.iocoder.yudao.module.order.dal.mysql.order.OrderMapper;
import cn.iocoder.yudao.module.order.dto.OrderBackInfoDto;
import cn.iocoder.yudao.module.order.service.order.*;
import cn.iocoder.yudao.module.order.service.order.impl.OrderItemServiceImpl;
import cn.iocoder.yudao.module.order.service.orderOperateLog.OrderOperateLogService;
import cn.iocoder.yudao.module.order.vo.orderOperateLog.OrderOperateLogCreateReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.base.Joiner;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
......@@ -32,6 +33,7 @@ import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.ORDER_IS_APPROVAL_IN_PROCESS_WITH_ORDERNOS;
@Slf4j
@Service
@Validated
public class OrderApiImpl implements OrderApi {
......@@ -51,6 +53,8 @@ public class OrderApiImpl implements OrderApi {
private OrderConsignorService orderConsignorService;
@Resource
private OrderOperateLogService orderOperateLogService;
@Resource
private OrderQueryService orderQueryService;
@Override
public OrderRespDTO getOrder(Long id, String orderNo) {
......@@ -199,4 +203,30 @@ public class OrderApiImpl implements OrderApi {
OrderObjectiveDO orderObjectiveDO = objectiveService.getByOrderId(orderId);
return orderObjectiveDO == null ? null : orderObjectiveDO.getObjectiveCountryId();
}
@Override
public OrderCustomerInfoDTO createReceiptGetOrderCustomerInfo(Long orderId) {
OrderBackInfoDto info = orderQueryService.info(orderId);
if (info == null) {
return null;
}
Long customerId = null;
if (info.getCustomerId() != null) {
customerId = info.getCustomerId();
}
if (info.getDrawee() == 1) {
customerId = info.getConsignorVO().getCustomerId();
}
if (info.getDrawee() == 2) {
customerId = info.getConsigneeVO().getCustomerId();
}
CustomerDO customer = customerService.getCustomer(customerId);
if (customer != null) {
return OrderCustomerInfoDTO.builder()
.customerId(customer.getId())
.customerName(customer.getName())
.build();
}
return null;
}
}
......@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
/**
......@@ -91,4 +92,6 @@ public interface ReceiptMapper extends AbstractMapper<ReceiptDO> {
List<ReceiptRelationOrderInfoVO> getOrderInfoByReceiptId(Long id);
void updateReceiptNewFieldBatch(List<ReceiptDO> receiptDOS);
Date getReceiptItemPayat(Long id);
}
......@@ -168,6 +168,7 @@ public interface ReceivableMapper extends AbstractMapper<ReceivableDO> {
"<when test = 'query.containerNumber != null'>",
"AND o.`container_number` = #{query.containerNumber}",
"</when>",
"group by r.id",
"</script>"
})
IPage<ReceivableBackVO> receivablePage(@Param("mpPage") IPage<ReceivableBackVO> mpPage, @Param("query") ReceivableQueryVO query);
......@@ -423,4 +424,8 @@ public interface ReceivableMapper extends AbstractMapper<ReceivableDO> {
int countBatchGenReceiptPage(@Param("query") BatchGenReceiptPageQueryVO query);
List<CurrencyAmount> calculateReceivableAmountByOrderId(Long orderId);
IPage<BatchGenReceiptReceivablePageVO> batchGenReceiptReceivablePage(IPage<BatchGenReceiptReceivablePageVO> mpPage, @Param("query") BatchGenReceiptReceivablePageQueryVO query);
List<CurrencyAmount> batchGenReceiptReceivablAmount(@Param("query") BatchGenReceiptReceivablePageQueryVO query);
}
\ No newline at end of file
......@@ -16,13 +16,15 @@ import org.springframework.stereotype.Component;
public class ReceiptItemWriteOffListener {
private final ReceiptItemService receiptItemService;
/**
* 银行收款明细审核通过更新应收核销金额
*
* @param event 编号记录
*/
@EventListener(ReceiptItemWriteOffEvent.class)
@Async
public void onReceiptItemWriteOff(ReceiptItemWriteOffEvent event) {
receiptItemService.verification(event.getId(), event.getBpmResult());
receiptItemService.verification(event.getId(), event.getBpmResult(), event.getComment());
}
}
......@@ -18,4 +18,8 @@ public class ReceiptItemWriteOffEvent {
* 审核结果
*/
private Integer bpmResult;
/**
* 备注
*/
private String comment;
}
......@@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableWriteO
import cn.iocoder.yudao.module.wealth.dal.mysql.receipt.ReceiptMapper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem.ReceiptItemMapper;
import cn.iocoder.yudao.module.wealth.enums.ReceiptItemStatusEnum;
import cn.iocoder.yudao.module.wealth.enums.ReceiptLinkEnum;
import cn.iocoder.yudao.module.wealth.enums.ReceiptStatusEnum;
import cn.iocoder.yudao.module.wealth.listener.event.ReceiptItemWriteOffEvent;
import cn.iocoder.yudao.module.wealth.service.receipt.ReceiptService;
......@@ -97,7 +98,7 @@ public class FinanceReceiptApproveService {
}
updateReceipt.setComment(comment);
receiptMapper.updateById(updateReceipt);
receiptService.recordLog(receiptDO.getId(), ReceiptLinkEnum.APPROVE_RECEIPT, comment, WorkFlowEmus.FINANCE_RECEIPT_APPROVE.getValue());
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_APPROVE_NO.getKey(), bmpKey)) {
//收款单反审核
if (null == receiptApprovalDO.getReceiptId()) {
......@@ -121,6 +122,7 @@ public class FinanceReceiptApproveService {
}
updateReceipt.setComment(comment);
receiptMapper.updateById(updateReceipt);
receiptService.recordLog(receiptDO.getId(), ReceiptLinkEnum.REJECT_RECEIPT, comment, WorkFlowEmus.FINANCE_RECEIPT_APPROVE_NO.getValue());
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_WRITE_OFF.getKey(), bmpKey)) {
//收款单核销审核
if (null == receiptApprovalDO.getReceiptId()) {
......@@ -163,6 +165,7 @@ public class FinanceReceiptApproveService {
updateReceipt.setPayedAt(new Date());
updateReceipt.setComment(comment);
receiptMapper.updateById(updateReceipt);
receiptService.recordLog(receiptDO.getId(), ReceiptLinkEnum.WRITE_OFF_RECEIPT, comment, WorkFlowEmus.FINANCE_RECEIPT_WRITE_OFF.getValue());
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_WRITE_OFF_NO.getKey(), bmpKey)) {
//收款单核销反审核
if (null == receiptApprovalDO.getReceiptId()) {
......@@ -208,6 +211,7 @@ public class FinanceReceiptApproveService {
}
updateReceipt.setComment(comment);
receiptMapper.updateById(updateReceipt);
receiptService.recordLog(receiptDO.getId(), ReceiptLinkEnum.REJECT_WRITE_OFF_RECEIPT, comment, WorkFlowEmus.FINANCE_RECEIPT_WRITE_OFF_NO.getValue());
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF.getKey(), bmpKey)) {
//收款单明细核销审核
//if (null == receiptApprovalDO.getReceiptItemId()) {
......@@ -244,7 +248,7 @@ public class FinanceReceiptApproveService {
// updateReceiptItem.setStatus(ReceiptItemStatusEnum.DRAFT.getValue());
//}
//receiptItemMapper.updateById(updateReceiptItem);
applicationContext.publishEvent(new ReceiptItemWriteOffEvent(receiptApprovalDO.getReceiptItemId(), result));
applicationContext.publishEvent(new ReceiptItemWriteOffEvent(receiptApprovalDO.getReceiptItemId(), result, comment));
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF_NO.getKey(), bmpKey)) {
//收款单明细核销反审核
if (null == receiptApprovalDO.getReceiptItemId()) {
......@@ -293,7 +297,7 @@ public class FinanceReceiptApproveService {
updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF.getValue());
receiptItemMapper.updateById(updateReceiptItem);
}
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.REJECT_BANK_RECEIPT, comment, WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF_NO.getValue());
}
ReceiptApprovalDO updateReceiptApproval = new ReceiptApprovalDO();
updateReceiptApproval.setId(receiptApprovalDO.getId());
......
......@@ -145,12 +145,14 @@ public interface ReceiptService extends IService<ReceiptDO> {
/**
* 获得收款单银行明细核销范围
*
* @return
*/
ReceiptBankWriteoffRangeVO getBankWriteoffRange();
/**
* 设置收款单银行明细核销范围
*
* @param range
* @return
*/
......@@ -170,10 +172,11 @@ public interface ReceiptService extends IService<ReceiptDO> {
* @param createReqVO
* @return
*/
Long generateReceiptRelevantData(ReceiptCreateReqVO createReqVO);
Long generateReceiptRelevantData(ReceiptCreateReqVO createReqVO, boolean isBatch);
/**
* 更新收款明细状态
*
* @param receiptId
*/
void updateReceiptItemStatus(Long receiptId);
......@@ -190,10 +193,11 @@ public interface ReceiptService extends IService<ReceiptDO> {
/**
* 获得收款单详情
*
* @param id
* @return
*/
ReceiptBackVO getReceiptDetail(Long id);
void batchApprovedReceipt(ArrayList<Long> receiptIds);
String getReceiptApprover(Long receiptId);
}
......@@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.boot.module.order.api.OrderApi;
import cn.iocoder.boot.module.order.api.dto.OrderCustomerInfoDTO;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderNumberLogEvent;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.code.CodeUtils;
......@@ -14,7 +16,6 @@ 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;
......@@ -23,6 +24,7 @@ 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;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.wealth.convert.receipt.ReceiptConvert;
import cn.iocoder.yudao.module.wealth.convert.receiptAccount.ReceiptAccountConvert;
import cn.iocoder.yudao.module.wealth.convert.receiptInvoice.ReceiptInvoiceConvert;
......@@ -58,7 +60,7 @@ 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.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -71,6 +73,7 @@ import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.wealth.enums.ReceiptItemStatusEnum.*;
......@@ -115,7 +118,8 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
@Resource
private BankApi bankApi;
@Resource
private BpmProcessInstanceApi bpmProcessInstanceApi;
@Lazy
private OrderApi orderApi;
private static final String RECEIPT_NEW_NUMBER = "receipt:new:number";
......@@ -126,7 +130,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
ReceiptService currentProxy = (ReceiptService) AopContext.currentProxy();
return currentProxy.generateReceiptRelevantData(createReqVO);
return currentProxy.generateReceiptRelevantData(createReqVO, false);
}
/**
......@@ -136,7 +140,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
* @param copyUserList
* @param receipt
*/
private void initApproval(String reason, String[] copyUserList, ReceiptDO receipt) {
private void initApproval(String reason, String[] copyUserList, ReceiptDO receipt, boolean isBatch) {
ReceiptApprovalDO approvalDO = new ReceiptApprovalDO();
approvalDO.setReceiptId(receipt.getId());
approvalDO.setReceiptNo(receipt.getReceiptNo());
......@@ -144,14 +148,21 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
approvalDO.setStatus(BpmProcessInstanceResultEnum.PROCESS.getResult());
approvalDO.setReason(reason);
receiptApprovalService.save(approvalDO);
if (!isBatch) {
Long userId = SecurityFrameworkUtils.getLoginUserId();
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);
} else {
approvalDO.setStatus(BpmProcessInstanceResultEnum.APPROVE.getResult());
receiptApprovalService.updateById(approvalDO);
receipt.setBmpStatus(BpmProcessInstanceResultEnum.APPROVE.getResult());
receipt.setState(ReceiptStatusEnum.RECEIPT_WAITING.getValue());
}
recordLog(receipt.getId(), ReceiptLinkEnum.SUBMIT_RECEIPT, receipt.getRemark(), WorkFlowEmus.FINANCE_RECEIPT_APPROVE.getValue());
}
/**
......@@ -245,18 +256,17 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
ArrayList<Long> receiptIds = new ArrayList<>();
for (ReceiptCreateReqVO receiptCreateReqVO : createReqVOList) {
try {
Long receiptId = currentProxy.generateReceiptRelevantData(receiptCreateReqVO);
Long receiptId = currentProxy.generateReceiptRelevantData(receiptCreateReqVO, true);
receiptIds.add(receiptId);
} catch (Exception e) {
respVOS.add(new ReceiptBatchGenRespVO(null, receiptCreateReqVO.getCustomerName(), e.getMessage()));
}
}
// 批量收款单审核通过
if (!respVOS.isEmpty()) {
currentProxy.batchApprovedReceipt(receiptIds);
}
return respVOS;
}
return null;
}
/**
* 组装批量生成收款单的参数
......@@ -265,17 +275,33 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
* @return
*/
private List<ReceiptCreateReqVO> assembleCreateReqVOList(List<ReceiptBatchCreateReqVO> batchCreateReqVOList) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (null == loginUser) {
throw exception(USER_NOT_EXISTS);
}
ArrayList<ReceiptCreateReqVO> createReqVOs = new ArrayList<>();
for (ReceiptBatchCreateReqVO receiptBatchCreateReqVO : batchCreateReqVOList) {
OrderCustomerInfoDTO customerInfo = orderApi.createReceiptGetOrderCustomerInfo(receiptBatchCreateReqVO.getOrderId());
ReceiptCreateReqVO receiptCreateReqVO = new ReceiptCreateReqVO();
receiptCreateReqVO.setRateValidateDate(receiptBatchCreateReqVO.getRateValidateDate());
receiptCreateReqVO.setCustomerId(customerInfo.getCustomerId());
receiptCreateReqVO.setCustomerName(customerInfo.getCustomerName());
receiptCreateReqVO.setSalesmanId(loginUser.getId());
receiptCreateReqVO.setSalesmanName(loginUser.getUsername());
receiptCreateReqVO.setDepartmentId(loginUser.getDeptId());
receiptCreateReqVO.setRemark(receiptBatchCreateReqVO.getRemark());
receiptCreateReqVO.setGeneratePath(1);
receiptCreateReqVO.setAddType("0");
// TODO 收款单信息待完善
// 设置开票信息
receiptCreateReqVO.setOpenInvoice(receiptBatchCreateReqVO.getOpenInvoice());
if (receiptBatchCreateReqVO.getOpenInvoice() == 1) {
receiptCreateReqVO.setReceiptInvoice(ReceiptInvoiceConvert.INSTANCE.convertCreateReqVO(receiptBatchCreateReqVO));
}
List<ReceivableBackVO> receivable = receivableService.getReceivableByOrderId(receiptBatchCreateReqVO.getOrderId());
if (CollectionUtil.isEmpty(receivable)) {
throw exception(RECEIVABLE_NOT_EXISTS);
}
receiptCreateReqVO.setCurrencyId(receivable.get(0).getBaseCurrencyId());
Map<Long, ReceiptAccountCreateReqVO> receiptAccountCreateReqVOS = new HashMap<>();
receivable.forEach(receivableBackVO -> {
// 设置应收信息
......@@ -284,7 +310,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
receivableBackVO.setTaxPoint(BigDecimal.ZERO);
} else {
receivableBackVO.setTaxPoint(taxPoint);
receivableBackVO.setTaxAmount(receivableBackVO.getTaxPoint().multiply(receivableBackVO.getTotalAmount()).add(receivableBackVO.getTotalAmount()));
receivableBackVO.setTaxAmount(receivableBackVO.getTaxPoint().divide(BigDecimal.valueOf(100)).multiply(receivableBackVO.getTotalAmount()).add(receivableBackVO.getTotalAmount()));
receivableBackVO.setActualAmount(receivableBackVO.getTaxAmount().subtract(receivableBackVO.getDiscountTotal()));
}
// 设置账单信息
......@@ -313,7 +339,8 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
}
});
receiptCreateReqVO.setReceivableVOList(ReceivableConvert.INSTANCE.convertToUpdateVO(receivable));
receiptCreateReqVO.setReceiptAccountList((List<ReceiptAccountCreateReqVO>) receiptAccountCreateReqVOS.values());
List<ReceiptAccountCreateReqVO> collect = new ArrayList<>(receiptAccountCreateReqVOS.values());
receiptCreateReqVO.setReceiptAccountList(collect);
createReqVOs.add(receiptCreateReqVO);
}
return createReqVOs;
......@@ -327,11 +354,12 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
*/
@Transactional(rollbackFor = Exception.class)
@Override
public Long generateReceiptRelevantData(ReceiptCreateReqVO createReqVO) {
public Long generateReceiptRelevantData(ReceiptCreateReqVO createReqVO, boolean isBatch) {
ReceiptDO receipt = ReceiptConvert.INSTANCE.convert(createReqVO);
generateReceiptNo(receipt);
receipt.setReceiptItemStatus(ReceiptItemStatusInReceiptEnum.NO_INPUT.getValue());
receiptMapper.insert(receipt);
recordLog(receipt.getId(), ReceiptLinkEnum.CREATE_RECEIPT, receipt.getRemark(), null);
receivableAssocReceipt(createReqVO.getReceivableVOList(), receipt);
genReceiptAccount(createReqVO.getReceiptAccountList(), receipt);
// 需要开票时生成开票信息
......@@ -348,10 +376,9 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
}
// 不是草稿创建收款单并发起审核流程
else if (StringUtils.equals(createReqVO.getAddType(), "0")) {
initApproval(createReqVO.getReason(), createReqVO.getCopyUserList(), receipt);
initApproval(createReqVO.getReason(), createReqVO.getCopyUserList(), receipt, isBatch);
receiptMapper.updateById(receipt);
}
recordLog(receipt.getId(), ReceiptLinkEnum.CREATE_RECEIPT, receipt.getRemark(), receipt.getBmpId());
return receipt.getId();
}
......@@ -475,15 +502,14 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
updateObj.setInvoiceDataStatus(InvoiceDataStatusEnum.NO_AUDIT.getValue());
updateObj.setInvoicingStatus(InvoicingStatusEnum.NO_INVOICE.getValue());
}
recordLog(updateObj.getId(), ReceiptLinkEnum.EDIT_RECEIPT, updateObj.getRemark(), null);
if (StringUtils.equals(updateReqVO.getUpdateType(), "0")) {
updateReqVO.setState(ReceiptStatusEnum.DRAFT.getValue());
receiptMapper.updateById(updateObj);
} else if (StringUtils.equals(updateReqVO.getUpdateType(), "1")) {
//更新收款单并发起审核流程
initApproval(updateReqVO.getReason(), updateReqVO.getCopyUserList(), updateObj);
receiptMapper.updateById(updateObj);
initApproval(updateReqVO.getReason(), updateReqVO.getCopyUserList(), updateObj, false);
}
recordLog(updateObj.getId(), ReceiptLinkEnum.EDIT_RECEIPT, updateObj.getRemark(), updateObj.getBmpId());
receiptMapper.updateById(updateObj);
}
private ReceiptDO validateUpdateVO(ReceiptUpdateReqVO updateReqVO) {
......@@ -543,6 +569,9 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
// 根据收款单id获取关联订单信息
List<ReceiptRelationOrderInfoVO> orderInfoList = receiptMapper.getOrderInfoByReceiptId(receiptBackVO.getId());
receiptBackVO.setOrderInfoList(orderInfoList);
if (receiptBackVO.getPayedAt() == null) {
receiptBackVO.setPayedAt(receiptMapper.getReceiptItemPayat(receiptBackVO.getId()));
}
});
List<Long> idList = receiptBackPage.stream().map(ReceiptBackVO::getId).collect(Collectors.toList());
//一定要判空,不然会报错
......@@ -815,7 +844,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
update.setState(ReceiptStatusEnum.APPROVE_NEGATION.getValue());
update.setBmpId(bpmId);
receiptMapper.updateById(update);
recordLog(update.getId(), ReceiptLinkEnum.REJECT_WRITE_OFF_RECEIPT, financeReceiptVo.getRemark(), update.getBmpId());
//recordLog(update.getId(), ReceiptLinkEnum.REJECT_RECEIPT, financeReceiptVo.getRemark(), WorkFlowEmus.FINANCE_RECEIPT_APPROVE_NO.getValue());
}
@Override
......@@ -887,7 +916,6 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
update.setBmpId(bpmId);
update.setFinanceRemark(financeRemark);
receiptMapper.updateById(update);
recordLog(update.getId(), ReceiptLinkEnum.WRITE_OFF_RECEIPT, financeReceiptVo.getRemark(), update.getBmpId());
}
@Override
......@@ -1063,17 +1091,12 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
}
@Override
public void recordLog(Long receiptId, ReceiptLinkEnum linkEnum, String remark, String bpmId) {
public void recordLog(Long receiptId, ReceiptLinkEnum linkEnum, String remark, String bpmStatus) {
LoginUser user = SecurityFrameworkUtils.getLoginUser();
String username = "";
if (user != null && user.getUsername() != null) {
username = user.getUsername();
}
String bpmStatus = null;
if (StringUtils.isNotBlank(bpmId)) {
ReceiptApprovalDO receiptApprovalDO = receiptApprovalService.selectOne(ReceiptApprovalDO::getBmpId, bpmId);
bpmStatus = WorkFlowEmus.getValue(receiptApprovalDO.getBmpKey());
}
ReceiptLogDO receiptLogDO = ReceiptLogDO.builder()
.receiptId(receiptId)
.operator(username)
......@@ -1116,10 +1139,17 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
}
@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(), "批量生成收款单自动审批"));
public String getReceiptApprover(Long receiptId) {
List<ReceiptApprovalDO> approvalDOS = receiptApprovalService.selectList(Wrappers.lambdaQuery(ReceiptApprovalDO.class)
.eq(ReceiptApprovalDO::getReceiptId, receiptId)
.eq(ReceiptApprovalDO::getStatus, BpmProcessInstanceResultEnum.APPROVE.getResult())
.eq(ReceiptApprovalDO::getBmpKey, WorkFlowEmus.FINANCE_RECEIPT_APPROVE.getKey()));
if (CollectionUtil.isEmpty(approvalDOS)) {
return null;
}
ReceiptApprovalDO receiptApprovalDO = approvalDOS.stream().max(Comparator.comparing(ReceiptApprovalDO::getCreateTime)).orElse(null);
AdminUserRespDTO user = adminUserApi.getUser(Long.parseLong(receiptApprovalDO.getUpdater()));
return user.getNickname();
}
/**
......
......@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.wealth.service.receiptInvoice;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.framework.i18n.core.LangEnum;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
......@@ -11,7 +13,7 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
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.ExchangeRateRespDTO;
import cn.iocoder.yudao.module.ecw.api.internalMessage.ClientInternalMessageApi;
import cn.iocoder.yudao.module.ecw.api.internalMessage.InternalMessageApi;
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;
......@@ -23,6 +25,7 @@ import cn.iocoder.yudao.module.wealth.dal.mysql.receiptInvoice.ReceiptInvoiceMap
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptInvoiceLog.ReceiptInvoiceLogMapper;
import cn.iocoder.yudao.module.wealth.enums.InvoicingLinkEnum;
import cn.iocoder.yudao.module.wealth.enums.InvoicingStatusEnum;
import cn.iocoder.yudao.module.wealth.service.receipt.ReceiptService;
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.ReceiptRelationOrderInfoVO;
......@@ -32,6 +35,7 @@ import cn.iocoder.yudao.module.wealth.vo.receivable.WealthMoneyAmountVO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -47,6 +51,7 @@ import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.RECEIPT_NO
import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.RECEIPT_VERIFICATION;
import static cn.iocoder.yudao.module.wealth.enums.InvoiceDataStatusEnum.REJECT;
import static cn.iocoder.yudao.module.wealth.enums.InvoiceDataStatusEnum.SUBMIT;
import static cn.iocoder.yudao.module.wealth.enums.InvoicingLinkEnum.REJECT_INVOICE_DATA;
import static cn.iocoder.yudao.module.wealth.enums.InvoicingStatusEnum.CANCELLED;
import static cn.iocoder.yudao.module.wealth.enums.InvoicingStatusEnum.NO_INVOICE;
import static cn.iocoder.yudao.module.wealth.enums.ReceiptStatusEnum.*;
......@@ -73,9 +78,11 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
@Resource
private CurrencyApi currencyApi;
@Resource
private ClientInternalMessageApi clientInternalMessageApi;
private InternalMessageApi internalMessageApi;
@Resource
private AdminUserApi adminUserApi;
@Resource
private ReceiptService receiptService;
@Override
@Transactional(rollbackFor = Exception.class)
......@@ -183,6 +190,10 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptInvoiceDetail.setCreator(adminUserApi.getUser(Long.parseLong(receiptInvoiceDetail.getCreator())).getNickname());
receiptInvoiceDetail.setUpdater(adminUserApi.getUser(Long.parseLong(receiptInvoiceDetail.getUpdater())).getNickname());
// 设置收款人,核销人
receiptInvoiceDetail.setPayee(receiptInvoiceDetail.getCreator());
String approver = receiptService.getReceiptApprover(receiptInvoiceDetail.getReceiptId());
receiptInvoiceDetail.setWriteOffUser(approver);
return receiptInvoiceDetail;
}
......@@ -191,11 +202,15 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
ReceiptDO receiptDO = receiptMapper.selectById(receiptId);
ReceiptInvoiceDetailVO receiptInvoiceDetail = ReceiptInvoiceConvert.INSTANCE.convert(receiptDO);
receiptInvoiceDetail.setReceiptId(receiptDO.getId());
receiptInvoiceDetail.setUpdater(adminUserApi.getUser(Long.parseLong(receiptInvoiceDetail.getUpdater())).getNickname());
List<ReceivableBackVO> receivableList = receivableService.getReceivableListByReceiptId(receiptInvoiceDetail.getReceiptId());
receiptInvoiceDetail.setReceivableList(receivableList);
// 根据应收明细统计收款单信息
receiptInvoiceDetail.setBaseCurrencyId(receivableList.get(0).getBaseCurrencyId());
statisticsReceiptInfo(receiptInvoiceDetail, receivableList);
receiptInvoiceDetail.setPayee(receiptInvoiceDetail.getCreator());
String approver = receiptService.getReceiptApprover(receiptInvoiceDetail.getReceiptId());
receiptInvoiceDetail.setWriteOffUser(approver);
return receiptInvoiceDetail;
}
......@@ -225,7 +240,8 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptInvoiceDetail.setReceivableTotalAmountUsd(receiptInvoiceDetail.getReceivableTotalAmountUsd().add(wealthMoneyAmountVO.getReceivableTotalAmount().multiply(rate.getCurrencyRate())));
receiptInvoiceDetail.setWriteOffAmountUsd(receiptInvoiceDetail.getWriteOffAmountUsd().add(wealthMoneyAmountVO.getWriteOffAmount().multiply(rate.getCurrencyRate())));
}
receiptInvoiceDetail.setWriteOffProportion(receiptInvoiceDetail.getWriteOffAmountUsd().divide(receiptInvoiceDetail.getReceivableTotalAmountUsd(), 4, RoundingMode.HALF_UP).toString());
BigDecimal writeOffProportion = receiptInvoiceDetail.getWriteOffAmountUsd().divide(receiptInvoiceDetail.getReceivableTotalAmountUsd(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
receiptInvoiceDetail.setWriteOffProportion(writeOffProportion + "%");
if (receiptInvoiceDetail.getCurrencyId() != null) {
receiptInvoiceDetail.setCurrencySymbol(currencyMap.get(receiptInvoiceDetail.getCurrencyId().intValue()).getFuhao());
}
......@@ -245,8 +261,11 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
IPage<ReceiptInvoicePageBackVO> mpPage = MyBatisUtils.buildPage(page);
receiptInvoiceMapper.getReceiptInvoicePage(mpPage, query);
mpPage.getRecords().forEach(receiptInvoicePageBackVO -> {
if (receiptInvoicePageBackVO.getWriteOffProportion() == null) {
receiptInvoicePageBackVO.setWriteOffProportion(BigDecimal.ZERO);
String writeOffProportion = receiptInvoicePageBackVO.getWriteOffProportion();
if (StringUtils.isBlank(writeOffProportion)) {
receiptInvoicePageBackVO.setWriteOffProportion("0.00%");
} else {
receiptInvoicePageBackVO.setWriteOffProportion(new BigDecimal(writeOffProportion).setScale(2, RoundingMode.HALF_UP) + "%");
}
List<ReceiptRelationOrderInfoVO> orderInfoByReceiptId = receiptMapper.getOrderInfoByReceiptId(receiptInvoicePageBackVO.getReceiptId());
receiptInvoicePageBackVO.setOrderInfoList(orderInfoByReceiptId);
......@@ -270,8 +289,8 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptDO.setId(receiptInvoiceDO.getReceiptId());
receiptDO.setInvoiceDataStatus(REJECT.getValue());
receiptMapper.updateById(receiptDO);
recordLog(receiptInvoiceDO.getId(), InvoicingLinkEnum.REJECT_INVOICE_DATA, reqVO.getRemark(), null);
sendMessage(reqVO.getNotifyUserIdList(), InvoicingLinkEnum.REJECT_INVOICE_DATA, reqVO.getRemark());
recordLog(receiptInvoiceDO.getId(), REJECT_INVOICE_DATA, reqVO.getRemark(), null);
sendMessage(reqVO.getNotifyUserIdList(), REJECT_INVOICE_DATA, receiptInvoiceDO.getReceiptNo(), receiptInvoiceDO.getInvoiceHeader());
return true;
}
......@@ -293,7 +312,7 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptInvoiceDO.setCancelTime(new Date());
receiptInvoiceMapper.updateById(receiptInvoiceDO);
recordLog(receiptInvoiceDO.getId(), InvoicingLinkEnum.CANCEL_INVOICE, reqVO.getRemark(), null);
sendMessage(reqVO.getNotifyUserIdList(), InvoicingLinkEnum.CANCEL_INVOICE, reqVO.getRemark());
sendMessage(reqVO.getNotifyUserIdList(), InvoicingLinkEnum.CANCEL_INVOICE, receiptInvoiceDO.getReceiptNo(), receiptInvoiceDO.getInvoiceHeader());
return true;
}
......@@ -353,16 +372,45 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
/**
* 发送站内信
*/
private void sendMessage(List<Integer> userIdList, InvoicingLinkEnum linkEnum, String content) {
private void sendMessage(List<Long> userIdList, InvoicingLinkEnum linkEnum, String receiptNo, String invoiceHeader) {
if (userIdList == null || userIdList.isEmpty()) {
return;
}
InternalMessageCreateDto dto = InternalMessageCreateDto.builder().toIdList(userIdList.stream().map(Integer::longValue).collect(Collectors.toList()))
String title = "";
String titleEn = "";
String titleFr = "";
String content = "";
String contentEn = "";
String contentFr = "";
switch (linkEnum) {
case REJECT_INVOICE_DATA:
title = String.format(I18nMessage.getMessage("app.message.reject.invoice.title", LangEnum.ZH.getLang()), receiptNo, invoiceHeader);
titleEn = String.format(I18nMessage.getMessage("app.message.reject.invoice.title", LangEnum.EN.getLang()), receiptNo, invoiceHeader);
titleFr = String.format(I18nMessage.getMessage("app.message.reject.invoice.title", LangEnum.FR.getLang()), receiptNo, invoiceHeader);
content = String.format(I18nMessage.getMessage("app.message.reject.invoice.content", LangEnum.ZH.getLang()), receiptNo, invoiceHeader);
contentEn = String.format(I18nMessage.getMessage("app.message.reject.invoice.content", LangEnum.EN.getLang()), receiptNo, invoiceHeader);
contentFr = String.format(I18nMessage.getMessage("app.message.reject.invoice.content", LangEnum.FR.getLang()), receiptNo, invoiceHeader);
break;
case CANCEL_INVOICE:
title = String.format(I18nMessage.getMessage("app.message.cancel.invoice.title", LangEnum.ZH.getLang()), receiptNo, invoiceHeader);
titleEn = String.format(I18nMessage.getMessage("app.message.cancel.invoice.title", LangEnum.EN.getLang()), receiptNo, invoiceHeader);
titleFr = String.format(I18nMessage.getMessage("app.message.cancel.invoice.title", LangEnum.FR.getLang()), receiptNo, invoiceHeader);
content = String.format(I18nMessage.getMessage("app.message.cancel.invoice.content", LangEnum.ZH.getLang()), receiptNo, invoiceHeader);
contentEn = String.format(I18nMessage.getMessage("app.message.cancel.invoice.content", LangEnum.EN.getLang()), receiptNo, invoiceHeader);
contentFr = String.format(I18nMessage.getMessage("app.message.cancel.invoice.content", LangEnum.FR.getLang()), receiptNo, invoiceHeader);
break;
}
// 发送站内信
InternalMessageCreateDto dto = InternalMessageCreateDto.builder().toIdList(userIdList)
.fromId("")
.sendTime(new Date())
.title(linkEnum.getNameZh())
.title(title)
.titleEn(titleEn)
.titleFr(titleFr)
.content(content)
.type(3).build();
clientInternalMessageApi.createInternalMessage(dto);
.contentEn(contentEn)
.contentFr(contentFr)
.type(linkEnum == REJECT_INVOICE_DATA ? 4 : 5).build();
internalMessageApi.createInternalMessage(dto);
}
}
......@@ -67,7 +67,7 @@ public interface ReceiptItemService extends IService<ReceiptItemDO> {
*
* @param id
*/
void verification(Long id,Integer bpmResult);
void verification(Long id,Integer bpmResult, String comment);
/**
* 批量核销
......
......@@ -134,6 +134,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
if (receiptDO.getState() == 1) {
ReceiptDO update = new ReceiptDO();
update.setId(receiptDO.getId());
update.setPayedAt(new Date());
update.setState(2);
receiptService.updateById(update);
}
......@@ -241,7 +242,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
@Override
@Transactional(rollbackFor = Exception.class)
public void verification(Long id, Integer bpmResult) {
public void verification(Long id, Integer bpmResult,String comment) {
//收款单明细核销审核
if (null == id) {
throw exception(RECEIPT_ITEM_NOT_FOUND);
......@@ -293,6 +294,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
}
receiptItemMapper.updateById(receiptItemDO);
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.APPROVE_BANK_RECEIPT, comment, WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF.getValue());
}
@Override
......@@ -505,7 +507,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
update.setStatus(ReceiptItemStatusEnum.WRITE_OFF_APPROVE_ING.getValue());
update.setBmpId(bpmId);
this.updateById(update);
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.SUBMIT_BANK_RECEIPT, financeReceiptItemVo.getRemark(), update.getBmpId());
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.SUBMIT_BANK_RECEIPT, financeReceiptItemVo.getRemark(), WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF.getValue());
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
return approvalDO;
}
......@@ -539,14 +541,16 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
if (writeOffRate.compareTo(writeOffDown) < 0 || writeOffRate.compareTo(writeOffUp) > 0) {
return;
}
String remark = "核销比例为: " + writeOffRate + "%, " + "符合核销比例" + writeOffDown + "%-" + writeOffUp + "%";
ReceiptApprovalDO approvalDO = createFinanceReceiptItemWriteOff(FinanceReceiptItemVo.builder()
.receiptId(receiptItemDO.getReceiptId())
.receiptNo(receiptNo)
.receiptItemId(receiptItemDO.getId())
.remark("核销比例为: " + writeOffRate + "%, " + "符合核销比例" + writeOffDown + "%-" + writeOffUp + "%")
.remark(remark)
.build());
bpmProcessInstanceApi.approveTask(approvalDO.getBmpId(), "自动审批");
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.APPROVE_BANK_RECEIPT, "核销比例为: " + writeOffRate + "%, " + "符合核销比例" + writeOffDown + "%-" + writeOffUp + "%", approvalDO.getBmpId());
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.SUBMIT_BANK_RECEIPT, remark, WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF.getValue());
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.APPROVE_BANK_RECEIPT, remark, WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF.getValue());
}
@Override
......@@ -602,7 +606,6 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
update.setStatus(ReceiptItemStatusEnum.WRITE_OFF_NO_APPROVE_ING.getValue());
update.setBmpId(bpmId);
this.updateById(update);
receiptService.recordLog(update.getReceiptId(), ReceiptLinkEnum.REJECT_BANK_RECEIPT, financeReceiptItemVo.getRemark(), update.getBmpId());
}
@Override
......
......@@ -280,4 +280,6 @@ public interface ReceivableService extends IService<ReceivableDO> {
void deleteWriteOffRecord(ReceiptItemDO receiptItemDO);
List<ReceivableInItemVO> getReceivableByReceiptItem(Long receiptItemId);
ReceivablePageResult<BatchGenReceiptReceivablePageVO> batchGenReceiptReceivablePage(BatchGenReceiptReceivablePageQueryVO query, PageVO page);
}
......@@ -332,7 +332,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
if (receivableBackVO.getWriteOffAmount().compareTo(BigDecimal.ZERO) <= 0 || receivableBackVO.getActualAmount().compareTo(BigDecimal.ZERO) <= 0) {
receivableBackVO.setWriteOffProportion("0.00%");
} else {
receivableBackVO.setWriteOffProportion(receivableBackVO.getWriteOffAmount().divide(receivableBackVO.getActualAmount(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString());
receivableBackVO.setWriteOffProportion(receivableBackVO.getWriteOffAmount().divide(receivableBackVO.getActualAmount(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) + "%");
}
});
return receivableBackVOList;
......@@ -664,6 +664,16 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
return receivableInItemVOS;
}
@Override
public ReceivablePageResult<BatchGenReceiptReceivablePageVO> batchGenReceiptReceivablePage(BatchGenReceiptReceivablePageQueryVO query, PageVO page) {
IPage<BatchGenReceiptReceivablePageVO> mpPage = MyBatisUtils.buildPage(page);
receivableMapper.batchGenReceiptReceivablePage(mpPage, query);
ReceivablePageResult<BatchGenReceiptReceivablePageVO> pageResult = ReceivablePageResult.of(mpPage);
List<CurrencyAmount> totalActualAmount = receivableMapper.batchGenReceiptReceivablAmount(query);
pageResult.setTotalActualAmount(totalActualAmount);
return pageResult;
}
@Override
public void deleteWriteOffRecord(ReceiptItemDO receiptItemDO) {
receivableWriteOffRecordMapper.deleteWriteOffRecord(receiptItemDO.getId());
......
......@@ -177,4 +177,7 @@ public class ReceiptBackVO {
private String creator;
@ApiModelProperty(value = "更新人")
private String updater;
@ApiModelProperty(value = "实收日期")
private Date payedAt;
}
......@@ -135,10 +135,8 @@ public class ReceiptInvoiceDetailVO {
private List<ReceiptInvoiceLogBackVO> invoiceLog;
@ApiModelProperty(value = "收款人")
// TODO 待确认
private String payee;
@ApiModelProperty(value = "核销人")
// TODO 待确认
private String writeOffUser;
@ApiModelProperty(value = "创建时间")
......
......@@ -18,7 +18,7 @@ public class ReceiptInvoiceOperateReqVO {
private Long id;
@ApiModelProperty(value = "通知人")
private List<Integer> notifyUserIdList;
private List<Long> notifyUserIdList;
@ApiModelProperty(value = "备注")
private String remark;
......
......@@ -71,7 +71,7 @@ public class ReceiptInvoicePageBackVO {
private Integer receiptState;
@ApiModelProperty(value = "核销比例")
private java.math.BigDecimal writeOffProportion;
private String writeOffProportion;
@ApiModelProperty(value = "相关订单信息列表")
private List<ReceiptRelationOrderInfoVO> orderInfoList;
......
package cn.iocoder.yudao.module.wealth.vo.receivable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
@ApiModel("管理后台 - 批量生成收款单费用明细列表 Request VO")
public class BatchGenReceiptReceivablePageQueryVO {
@ApiModelProperty(value = "订单id")
@NotNull(message = "订单id不能为空")
private Long orderId;
@ApiModelProperty(value = "付款方(1 发货人 2 收货人)")
@NotNull(message = "付款方不能为空")
private Integer paymentUser;
@ApiModelProperty(value = "收款类型(字典 payment_type)")
private List<Integer> collectionType;
@ApiModelProperty(value = "收入类型(字典 receivable_fee_type)")
private List<Integer> feeType;
@ApiModelProperty(value = "费用来源:1 订单计算 2 费用申请 3 特需费用")
private List<Integer> feeSource;
}
package cn.iocoder.yudao.module.wealth.vo.receivable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
@ApiModel("管理后台 - 批量生成收款单费用明细列表 VO")
public class BatchGenReceiptReceivablePageVO {
@ApiModelProperty(value = "订单id")
private Long orderId;
@ApiModelProperty(value = "订单项商品ID")
private Long orderItemId;
@ApiModelProperty(value = "中文标题")
private String titleZh;
@ApiModelProperty(value = "英文标题")
private String titleEn;
@ApiModelProperty(value = "数量")
private Integer quantity;
@ApiModelProperty(value = "箱数")
private Integer num;
@ApiModelProperty(value = "体积/重量")
private BigDecimal weight;
@ApiModelProperty(value = "体积")
private BigDecimal volume;
@ApiModelProperty(value = "收款类型(字典 payment_type)")
private Integer collectionType;
@ApiModelProperty(value = "收入类型(字典 receivable_fee_type)")
private Integer feeType;
@ApiModelProperty(value = "费用来源:1 订单计算 2 费用申请 3 特需费用")
private Integer feeSource;
@ApiModelProperty(value = "付款人类型(1 发货人 2 收货人)")
private Integer paymentUser;
@ApiModelProperty(value = "单价")
private BigDecimal unitPrice;
@ApiModelProperty(value = "总金额")
private BigDecimal totalAmount;
@ApiModelProperty(value = "货币id")
private Long currencyId;
}
package cn.iocoder.yudao.module.wealth.vo.receivable;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel("分页结果")
public final class ReceivablePageResult<T> implements Serializable {
@ApiModelProperty(value = "数据", required = true)
private List<T> list;
@ApiModelProperty(value = "总量", required = true, example = "0")
private Long total = 0L;
@ApiModelProperty(value = "每页记录数", required = true, example = "10")
private Long rows = 10L;
@ApiModelProperty(value = "当前页数", required = true, example = "1")
private Long page = 1L;
@ApiModelProperty(value = "总页数", required = true, example = "0")
private Long pages = 0L;
@ApiModelProperty(value = "合计金额")
private List<CurrencyAmount> totalActualAmount;
public ReceivablePageResult() {}
public ReceivablePageResult(List<T> list, long total) {
this.list = list;
this.total = total;
}
public ReceivablePageResult(List<T> list, long total, long rows, long page, long pages) {
this.list = list;
this.rows = rows;
this.page = page;
this.pages = pages;
this.total = total;
}
public ReceivablePageResult(long total) {
this.list = new ArrayList<>();
this.total = total;
}
public static <T> ReceivablePageResult<T> empty() {
return new ReceivablePageResult<>();
}
public static <T> ReceivablePageResult<T> empty(long total) {
return new ReceivablePageResult<>(total);
}
/****
* 分页转换
* @param pager
* @return
*/
public static <T> ReceivablePageResult<T> of(IPage<T> pager){
return new ReceivablePageResult<>(pager.getRecords(), pager.getTotal(), pager.getSize(), pager.getCurrent(), pager.getPages());
}
/****
* 分页转换
* @param pager
* @return
*/
public static <T> ReceivablePageResult<T> of(PageInfo<T> pager){
return new ReceivablePageResult<>(pager.getList(), pager.getTotal(), pager.getPageSize(), pager.getPageNum(), pager.getPages());
}
}
......@@ -111,6 +111,11 @@ public class ReceivableController {
return success(receivableService.batchGenReceiptPage(query, page));
}
@PostMapping("/batch-gen-receipt/receivable/page")
@ApiOperation("财务-批量生成收款单费用明细列表")
public CommonResult<ReceivablePageResult<BatchGenReceiptReceivablePageVO>> batchGenReceiptReceivablePage(@Valid @RequestBody BatchGenReceiptReceivablePageQueryVO query, PageVO page) {
return success(receivableService.batchGenReceiptReceivablePage(query, page));
}
@GetMapping("/getListForReceiptItem")
@ApiOperation("财务-创建收款明细获取应收明细")
public CommonResult<List<ReceivableInItemVO>> getListForCreateReceiptItem(Long receiptId) {
......
......@@ -68,6 +68,13 @@
GROUP BY er.receipt_no
</if>
</select>
<select id="getReceiptItemPayat" resultType="java.util.Date">
SELECT eri.amount_date
FROM ecw_receipt_item eri
WHERE eri.receipt_id = #{id} AND eri.deleted = 0
ORDER BY eri.amount_date
LIMIT 1
</select>
<sql id="pageCondition">
<if test="query.receiptItemStatus != null">
<if test="query.receiptItemStatus.size() == 1">
......
......@@ -48,9 +48,11 @@
er.invoicing_status,
er.invoice_data_status,
er.customer_id,
er.customer_name
er.customer_name,
su.nickname AS cancelUserName
FROM ecw_receipt_invoice eri
LEFT JOIN ecw_receipt er ON eri.receipt_id = er.id
LEFT JOIN system_user su ON eri.cancel_user_id = su.id
WHERE eri.id = #{id}
</select>
<select id="getCurrentMaxInvoiceCode" resultType="java.lang.String">
......
......@@ -315,6 +315,58 @@
WHERE r.deleted = 0 AND r.order_id = #{orderId} AND r.receipt_id IS NULL
GROUP BY r.currency_id
</select>
<select id="batchGenReceiptReceivablePage"
resultType="cn.iocoder.yudao.module.wealth.vo.receivable.BatchGenReceiptReceivablePageVO">
SELECT r.*
FROM ecw_receivable r
WHERE r.order_id = #{query.orderId} AND r.receipt_id IS NULL AND r.payment_user = #{query.paymentUser} AND r.deleted = 0
<include refid="feeCondition"></include>
</select>
<select id="batchGenReceiptReceivablAmount"
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.order_id = #{query.orderId} AND r.receipt_id IS NULL AND r.payment_user = #{query.paymentUser} AND r.deleted = 0
<include refid="feeCondition"></include>
GROUP BY r.currency_id
</select>
<sql id="feeCondition">
<if test="query.feeSource != null">
<if test="query.feeSource.size() == 1">
AND r.fee_source = #{query.feeSource[0]}
</if>
<if test="query.feeSource.size() > 1">
AND r.fee_source IN
<foreach collection="query.feeSource" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</if>
<if test="query.feeType != null">
<if test="query.feeType.size() == 1">
AND r.fee_type = #{query.feeType[0]}
</if>
<if test="query.feeType.size() > 1">
AND r.fee_type IN
<foreach collection="query.feeType" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</if>
<if test="query.collectionType != null">
<if test="query.collectionType.size() == 1">
AND r.collection_type = #{query.collectionType[0]}
</if>
<if test="query.collectionType.size() > 1">
AND r.collection_type IN
<foreach collection="query.collectionType" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</if>
</sql>
<sql id="batchGenReceiptPageCondition">
<if test="query.orderIds != null">
<if test="query.orderIds.size() == 1">
......
......@@ -35,6 +35,10 @@ app.message.air.warehousein.title=
app.message.air.warehousein.content=
app.message.air.exception.warehousein.title=
app.message.air.exception.warehousein.content=
app.message.reject.invoice.title=
app.message.reject.invoice.content=
app.message.cancel.invoice.content=
app.message.cancel.invoice.title=
customer.enter.to.open.sea.cancel.delay.approval=
order.label.repeat=
customer.referrer.commission.already.exists=
......
......@@ -275,6 +275,10 @@ app.message.update.control.password.title=Cargo control password changed success
app.message.update.password.content=Your password has been changed, please be careful to save!
app.message.customer.complain.title=Customer Management "Customer Complaints"
app.message.customer.complain.content=The content of your complaint has been processed, please pay attention to review!
app.message.reject.invoice.title=%s-%s customer invoice information has been rejected
app.message.reject.invoice.content=Dear, Your submitted %s-%s customer invoice information has been rejected, please check
app.message.cancel.invoice.content=Dear, Your submitted %s-%s customer invoice has been cancelled, please check
app.message.cancel.invoice.title=%s-%s customer invoice has been cancelled
warehouse.approval.passed.cannot.cancel=warehouse approval passed can not cancel
warehouse.approval.batch.cannot.cancel=warehouse approval batch cannot cancel
order.approval.info.not.find=order approval info not find
......
......@@ -275,6 +275,10 @@ app.message.update.control.password.title=Le mot de passe de contr\u00F4le des m
app.message.update.password.content=Votre mot de passe a \u00E9t\u00E9 modifi\u00E9. Merci de le sauvegarder !
app.message.customer.complain.title=Gestion des clients - "R\u00E9clamation"
app.message.customer.complain.content=Votre plainte a \u00E9t\u00E9 trait\u00E9e, veuillez v\u00E9rifier les d\u00E9tails !
app.message.reject.invoice.title=%s-%s Les informations de facturation du client ont \u00E9t\u00E9 rejet\u00E9es
app.message.reject.invoice.content=Cher, Votre soumission %s-%s des informations de facturation du client a \u00E9t\u00E9 rejet\u00E9e, veuillez v\u00E9rifier
app.message.cancel.invoice.content=Cher, Votre soumission %s-%s facture client a \u00E9t\u00E9 annul\u00E9e, veuillez v\u00E9rifier
app.message.cancel.invoice.title=%s-%s facture client annul\u00E9e
warehouse.approval.passed.cannot.cancel=Les demandes d'approbation d\u00E9j\u00E0 approuv\u00E9es ne peuvent pas \u00EAtre annul\u00E9es
warehouse.approval.batch.cannot.cancel=Examen en cours pour le transfert de stock en masse, veuillez patienter
order.approval.info.not.find=Informations d'approbation de la commande introuvables
......
......@@ -271,6 +271,10 @@ app.message.update.password.content=\u60A8\u7684\u5BC6\u7801\u5DF2\u4FEE\u6539\u
app.message.update.control.password.content=\u60A8\u7684\u63A7\u8D27\u5BC6\u7801\u5DF2\u4FEE\u6539\uFF0C\u8BF7\u6CE8\u610F\u4FDD\u5B58\uFF01
app.message.customer.complain.title=\u5BA2\u6237\u7BA1\u7406\u201C\u5BA2\u8BC9\u201D
app.message.customer.complain.content=\u60A8\u6295\u8BC9\u7684\u5185\u5BB9\u5DF2\u7ECF\u5904\u7406\uFF0C\u8BF7\u6CE8\u610F\u67E5\u770B\uFF01
app.message.reject.invoice.title=%s-%s\u5BA2\u6237\u5F00\u7968\u8D44\u6599\u88AB\u9A73\u56DE
app.message.reject.invoice.content=\u60A8\u597D,\u60A8\u63D0\u4EA4\u7684%s-%s.\u5BA2\u6237\u5F00\u7968\u8D44\u6599\u9A73\u56DE,\u8BF7\u6CE8\u610F\u67E5\u770B
app.message.cancel.invoice.content=\u60A8\u597D,\u60A8\u63D0\u4EA4\u7684%s-%s\u5BA2\u6237\u5F00\u7968\u5DF2\u53D6\u6D88,\u8BF7\u6CE8\u610F\u67E5\u770B
app.message.cancel.invoice.title=%s-%s\u5BA2\u6237\u5F00\u7968\u5DF2\u53D6\u6D88
warehouse.approval.passed.cannot.cancel=\u5DF2\u901A\u8FC7\u7684\u5BA1\u6838\u5355\u4E0D\u53EF\u53D6\u6D88
warehouse.approval.batch.cannot.cancel=\u6279\u91CF\u8C03\u4ED3\u5BA1\u6838\u4E2D\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\u5BA1\u6838\u7ED3\u679C
order.approval.info.not.find=\u8BA2\u5355\u5BA1\u6838\u4FE1\u606F\u4E0D\u5B58\u5728
......
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