Commit f8ee4809 authored by zhangfeng's avatar zhangfeng

feat(wealth): 收款明细状态,收款单日志

parent 44c6d1a6
......@@ -225,7 +225,7 @@ public class ReceiptDO extends BaseDO {
/**
* 明细状态
*/
private Integer detailStatus;
private Integer receiptItemStatus;
/**
* 开票状态
......
package cn.iocoder.yudao.module.wealth.dal.dataobject.receiptLog;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
......@@ -45,7 +45,7 @@ public class ReceiptLogDO {
/**
* 审批流程
*/
private Integer bpmStatus;
private String bpmStatus;
/**
* 创建时间
*/
......
......@@ -9,7 +9,7 @@ import java.util.Arrays;
@AllArgsConstructor
@Getter
public enum ReceiptDetailStatusEnum implements IntArrayValuable {
public enum ReceiptItemStatusInReceiptEnum implements IntArrayValuable {
/**
* 未录入
*/
......@@ -35,7 +35,7 @@ public enum ReceiptDetailStatusEnum implements IntArrayValuable {
*/
ALL_APPROVED(5, "全部审批", "All Approved");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ReceiptDetailStatusEnum::getValue).toArray();
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ReceiptItemStatusInReceiptEnum::getValue).toArray();
/**
* 状态
......@@ -52,8 +52,8 @@ public enum ReceiptDetailStatusEnum implements IntArrayValuable {
private final String nameEn;
public static ReceiptDetailStatusEnum valueOf(Integer value) {
return ArrayUtil.firstMatch(orderStatus -> orderStatus.getValue().equals(value), ReceiptDetailStatusEnum.values());
public static ReceiptItemStatusInReceiptEnum valueOf(Integer value) {
return ArrayUtil.firstMatch(orderStatus -> orderStatus.getValue().equals(value), ReceiptItemStatusInReceiptEnum.values());
}
@Override
......
package cn.iocoder.yudao.module.wealth.service;
import cn.hutool.core.util.StrUtil;
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.enums.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.enums.WorkFlowEmus;
......@@ -15,12 +13,12 @@ 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.ReceiptStatusEnum;
import cn.iocoder.yudao.module.wealth.service.receipt.ReceiptService;
import cn.iocoder.yudao.module.wealth.service.receiptApproval.ReceiptApprovalService;
import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -39,21 +37,18 @@ import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.RECEIPT_NO
@Slf4j
public class FinanceReceiptApproveService {
@Autowired
@Resource
private ReceiptMapper receiptMapper;
@Resource
private ReceiptService receiptService;
@Resource
private ReceiptItemMapper receiptItemMapper;
@Autowired
BpmCreateServiceFactory bpmCreateServiceFactory;
@Autowired
ReceiptApprovalService receiptApprovalService;
@Resource
ReceivableService receivableService;
private BpmCreateServiceFactory bpmCreateServiceFactory;
@Resource
private ReceiptApprovalService receiptApprovalService;
@Resource
private ReceivableService receivableService;
@Transactional
public void financeApproveCallBack(String bmpKey, String businessKey, Integer result) {
......@@ -253,8 +248,7 @@ public class FinanceReceiptApproveService {
lambdaUpdateWrapper.set(ReceivableDO::getState, 1);
receivableService.update(lambdaUpdateWrapper);
}
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
} else if (result == BpmProcessInstanceResultEnum.REJECT.getResult()) {
updateReceiptItem.setStatus(ReceiptItemStatusEnum.DRAFT.getValue());
} else if (result == BpmProcessInstanceResultEnum.CANCEL.getResult()) {
......@@ -288,6 +282,7 @@ public class FinanceReceiptApproveService {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_PART_ING.getValue());
}
receiptMapper.updateById(updateReceipt);
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
} else if (result == BpmProcessInstanceResultEnum.REJECT.getResult()) {
updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF.getValue());
receiptItemMapper.updateById(updateReceiptItem);
......
......@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
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;
......@@ -186,4 +187,20 @@ public interface ReceiptService extends IService<ReceiptDO> {
* @return
*/
List<ReceiptAccountBatchRespVO> receiptAccountImport(List<ReceiptAccountBatchCreateReqVO> list);
/**
* 更新收款明细状态
* @param receiptId
*/
void updateReceiptItemStatus(Long receiptId);
/**
* 记录日志
*
* @param receiptId 收款单ID
* @param linkEnum 环节
* @param remark 备注
* @param bpmId 审批流程
*/
void recordLog(Long receiptId, ReceiptLinkEnum linkEnum, String remark, String bpmId);
}
......@@ -38,7 +38,10 @@ import cn.iocoder.yudao.module.wealth.dal.mysql.receiptAccount.ReceiptAccountMap
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptInvoice.ReceiptInvoiceMapper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem.ReceiptItemMapper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptLog.ReceiptLogMapper;
import cn.iocoder.yudao.module.wealth.enums.*;
import cn.iocoder.yudao.module.wealth.enums.InvoicingStatusEnum;
import cn.iocoder.yudao.module.wealth.enums.ReceiptItemStatusInReceiptEnum;
import cn.iocoder.yudao.module.wealth.enums.ReceiptLinkEnum;
import cn.iocoder.yudao.module.wealth.enums.ReceiptStatusEnum;
import cn.iocoder.yudao.module.wealth.service.receiptAccount.ReceiptAccountService;
import cn.iocoder.yudao.module.wealth.service.receiptApproval.ReceiptApprovalService;
import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
......@@ -129,7 +132,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
ReceiptDO receipt = ReceiptConvert.INSTANCE.convert(createReqVO);
generateReceiptNo(receipt);
receipt.setDetailStatus(ReceiptDetailStatusEnum.NO_INPUT.getValue());
receipt.setReceiptItemStatus(ReceiptItemStatusInReceiptEnum.NO_INPUT.getValue());
// 应收明细关联收款单
List<ReceivableDO> receivableDOList = receivableUpdateReqVOList.stream().filter(re -> null != re.getId()).map(re -> {
ReceivableDO receivableDO = ReceivableConvert.INSTANCE.convert(re);
......@@ -187,6 +190,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
receipt.setBmpId(bpmId);
receiptMapper.insert(receipt);
}
recordLog(receipt.getId(), ReceiptLinkEnum.CREATE_RECEIPT, receipt.getRemark(), receipt.getBmpId());
return receipt.getId();
}
......@@ -194,7 +198,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
public List<ReceiptBatchGenRespVO> batchGenReceipt(List<ReceiptCreateReqVO> createReqVOList) {
// TODO 区分批量和单个创建,添加新字段
ArrayList<ReceiptBatchGenRespVO> respVOS = new ArrayList<>();
ReceiptService currentProxy = (ReceiptService)AopContext.currentProxy();
ReceiptService currentProxy = (ReceiptService) AopContext.currentProxy();
for (ReceiptCreateReqVO receiptCreateReqVO : createReqVOList) {
try {
currentProxy.createReceipt(receiptCreateReqVO);
......@@ -390,7 +394,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
return receivableDO;
}).collect(Collectors.toList());
receiptAccountService.saveBatch(receiptAccountDOList);
recordLog(updateObj.getId(), ReceiptLinkEnum.EDIT_RECEIPT, updateObj.getRemark(), updateObj.getBmpId());
}
// TODO 拆分到开票管理
......@@ -500,7 +504,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
Map<Integer, CurrencyRespDTO> currencyMap = currencyApi.getAllCurrency();
for (ReceiptBackVO r : mpPage.getRecords()) {
String sR = getReceiptMxStatus(listItem, r.getId());
String sR = getReceiptMxStatus(listItem, r.getId()).getNameZh();
r.setMxStatus(sR);
//应收
......@@ -631,18 +635,18 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
收款单明细表
SELECT * from ecw_receipt_item where receipt_id=6554
*/
private String getReceiptMxStatus(List<ReceiptItemDO> listItem, long ReceiptId) {
private ReceiptItemStatusInReceiptEnum getReceiptMxStatus(List<ReceiptItemDO> listItem, long ReceiptId) {
//未录入 收款单下无收款明细 OK
//未提交 :收款单下有收款明细且全未提交 OK
//部分提交 收款单下有收款明细且部分提交(无需判断收款明细是否审批) OK
//未审核 收款明细全部提交且全部未审批 OK
//部分审核 收款明细全部提交且部分已审批 OK
//全部审核 收款明细全部已审批 OK
String sMxStatus = "";
ReceiptItemStatusInReceiptEnum sMxStatus = null;
//计算明细总数
Long iCount = listItem.stream().filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
if (iCount == 0) {
sMxStatus = "未录入";
sMxStatus = ReceiptItemStatusInReceiptEnum.NO_INPUT;
return sMxStatus;
} else {
//存在记录就判断状态
......@@ -659,31 +663,31 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
if (Item0 == iCount) {
//0待核销
//收款单下有收款明细且全未提交
sMxStatus = "未提交";
sMxStatus = ReceiptItemStatusInReceiptEnum.UN_SUBMITTED;
return sMxStatus;
}
if (Item0 > 0 && Item0 < iCount) {
//部分提交 收款单下有收款明细且部分提交(无需判断收款明细是否审批)
sMxStatus = "部分提交";
sMxStatus = ReceiptItemStatusInReceiptEnum.PART_SUBMITTED;
return sMxStatus;
}
//进部分提交,部分审核逻辑
//未审核 收款明细全部提交且全部未审批
if (Item2 == iCount) {
sMxStatus = "未审核";
sMxStatus = ReceiptItemStatusInReceiptEnum.UN_APPROVED;
return sMxStatus;
}
if (Item1 == iCount) {
//1已核销
sMxStatus = "全部审核";
sMxStatus = ReceiptItemStatusInReceiptEnum.ALL_APPROVED;
return sMxStatus;
}
if ((Item2 + Item3) == iCount || (Item1 + Item3) == iCount || (Item2 + Item1) == iCount) {
sMxStatus = "部分审核";
sMxStatus = ReceiptItemStatusInReceiptEnum.PART_APPROVED;
return sMxStatus;
}
}
......@@ -755,6 +759,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());
}
@Override
......@@ -832,6 +837,7 @@ 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
......@@ -856,6 +862,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
update.setState(ReceiptStatusEnum.WRITE_OFF_ALL_NEGATION.getValue());
update.setBmpId(bpmId);
receiptMapper.updateById(update);
recordLog(update.getId(), ReceiptLinkEnum.REJECT_WRITE_OFF_RECEIPT, financeReceiptVo.getRemark(), update.getBmpId());
}
@Override
......@@ -1012,22 +1019,30 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
}
/**
* 设置收款明细状态
* 更新收款明细状态
*/
private void setReceiptDetailStatus(ReceiptDO receiptDO, ReceiptDetailStatusEnum oldStatus, ReceiptDetailStatusEnum newStatus) {
receiptDO.setDetailStatus(newStatus.getValue());
@Override
public void updateReceiptItemStatus(Long receiptId) {
List<ReceiptItemDO> receiptItemDOS = receiptItemMapper.selectList(ReceiptItemDO::getReceiptId, receiptId);
ReceiptItemStatusInReceiptEnum receiptMxStatus = getReceiptMxStatus(receiptItemDOS, receiptId);
ReceiptDO receiptDO = new ReceiptDO();
receiptDO.setId(receiptId);
receiptDO.setReceiptItemStatus(receiptMxStatus.getValue());
receiptMapper.updateById(receiptDO);
}
/**
* 记录日志
*/
private void recordLog(Long receiptId, ReceiptLinkEnum linkEnum, String remark, Integer bpmStatus) {
@Override
public void recordLog(Long receiptId, ReceiptLinkEnum linkEnum, String remark, String bpmId) {
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)
......
......@@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableDO;
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.service.receipt.ReceiptService;
import cn.iocoder.yudao.module.wealth.service.receiptApproval.ReceiptApprovalService;
......@@ -98,7 +99,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
}
// TODO 更新收款明细核销金额在创建环节还是审批环节
// receivableService.writeOffByReceiptItem(createReqVO.getReceivableWriteOffList());
receiptService.updateReceiptItemStatus(receiptItem.getReceiptId());
// 返回
return receiptItem.getId();
}
......@@ -148,7 +149,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
//end 添加的逻辑点
}
}
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
}
private void validateReceiptItemExists(Long id) {
......@@ -433,7 +434,8 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
update.setStatus(ReceiptItemStatusEnum.WRITE_OFF_APPROVE_ING.getValue());
update.setBmpId(bpmId);
this.updateById(update);
receiptService.recordLog(update.getReceiptId(), ReceiptLinkEnum.SUBMIT_BANK_RECEIPT, financeReceiptItemVo.getRemark(), update.getBmpId());
receiptService.updateReceiptItemStatus(update.getReceiptId());
// TODO 判断是否符合自动审批条件
}
......@@ -493,6 +495,7 @@ 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
......@@ -500,6 +503,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
Long userId = SecurityFrameworkUtils.getLoginUserId();
ReceiptItemDO receiptItemDO = validateReceiptItemBmpCancel(financeReceiptItemVo.getReceiptItemId());
bpmCreateServiceFactory.cancelBmpById(userId, receiptItemDO.getBmpId(), financeReceiptItemVo.getRemark());
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
}
@Override
......
......@@ -219,7 +219,7 @@ public class ReceiptBackVO {
private String hxBiLi;
@ApiModelProperty(value = "明细状态(数据库)")
private Integer detailStatus;
private Integer receiptItemStatus;
@ApiModelProperty(value = "开票状态")
private Integer invoicingStatus;
......
......@@ -142,7 +142,7 @@ public class ReceiptQueryVO {
private String numberNo;
@ApiModelProperty(value = "明细状态")
private Integer detailStatus;
private Integer receiptItemStatus;
@ApiModelProperty(value = "开票状态")
private Integer invoicingStatus;
......
......@@ -13,8 +13,8 @@
LEFT JOIN ecw_receivable rb ON rb.receipt_id=er.id AND rb.deleted=0
LEFT JOIN ecw_order o ON o.order_no=rb.order_no AND o.deleted=0
WHERE er.deleted = 0
<if test="query.detailStatus != null">
AND er.`detail_status` = #{query.detailStatus}
<if test="query.receiptItemStatus != null">
AND er.`detail_status` = #{query.receiptItemStatus}
</if>
<if test="query.invoicingStatus != null">
AND er.`invoicing_status` = #{query.invoicingStatus}
......
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