|
@@ -37,10 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
|
@@ -81,7 +78,6 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|
|
@Resource
|
|
|
private BpmProcessInstanceApi bpmProcessInstanceApi;
|
|
|
|
|
|
- // TODO @puhui999:操作日志没记录上
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_CREATE_SUB_TYPE, bizNo = "{{#receivable.id}}",
|
|
@@ -115,6 +111,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|
|
|
|
|
// 5. 记录操作日志上下文
|
|
|
LogRecordContext.putVariable("receivable", receivable);
|
|
|
+ LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId()));
|
|
|
return receivable.getId();
|
|
|
}
|
|
|
|
|
@@ -156,7 +153,6 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // TODO @puhui999:操作日志没记录上
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
|
@@ -165,10 +161,13 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|
|
public void updateReceivable(CrmReceivableSaveReqVO updateReqVO) {
|
|
|
Assert.notNull(updateReqVO.getId(), "回款编号不能为空");
|
|
|
updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段
|
|
|
- // 1.1 校验可回款金额超过上限
|
|
|
- validateReceivablePriceExceedsLimit(updateReqVO);
|
|
|
- // 1.2 校验存在
|
|
|
+ // 1.1 校验存在
|
|
|
CrmReceivableDO receivable = validateReceivableExists(updateReqVO.getId());
|
|
|
+ updateReqVO.setOwnerUserId(receivable.getOwnerUserId()).setCustomerId(receivable.getCustomerId())
|
|
|
+ .setContractId(receivable.getContractId()).setPlanId(receivable.getPlanId()); // 设置已存在的值
|
|
|
+ // 1.2 校验可回款金额超过上限
|
|
|
+ validateReceivablePriceExceedsLimit(updateReqVO);
|
|
|
+
|
|
|
// 1.3 只有草稿、审批中,可以编辑;
|
|
|
if (!ObjectUtils.equalsAny(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(),
|
|
|
CrmAuditStatusEnum.PROCESS.getStatus())) {
|
|
@@ -180,8 +179,17 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|
|
receivableMapper.updateById(updateObj);
|
|
|
|
|
|
// 3. 记录操作日志上下文
|
|
|
- LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class));
|
|
|
LogRecordContext.putVariable("receivable", receivable);
|
|
|
+ LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId()));
|
|
|
+ LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getReceivablePeriod(Long planId) {
|
|
|
+ if (Objects.isNull(planId)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(planId);
|
|
|
+ return receivablePlan.getPeriod();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -212,8 +220,10 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|
|
if (receivable.getPlanId() != null && receivablePlanService.getReceivablePlan(receivable.getPlanId()) != null) {
|
|
|
throw exception(RECEIVABLE_DELETE_FAIL);
|
|
|
}
|
|
|
- // TODO @puhui999:审批通过时,不允许删除;
|
|
|
-
|
|
|
+ // 1.3 审批通过时,不允许删除
|
|
|
+ if (ObjUtil.equal(receivable.getAuditStatus(), CrmAuditStatusEnum.APPROVE.getStatus())) {
|
|
|
+ throw exception(RECEIVABLE_DELETE_FAIL_IS_APPROVE);
|
|
|
+ }
|
|
|
// 2. 删除
|
|
|
receivableMapper.deleteById(id);
|
|
|
// 3. 删除数据权限
|
|
@@ -221,6 +231,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|
|
|
|
|
// 4. 记录操作日志上下文
|
|
|
LogRecordContext.putVariable("receivable", receivable);
|
|
|
+ LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -289,4 +300,9 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|
|
return receivableMapper.selectReceivablePriceMapByContractId(contractIds);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<CrmReceivableDO> getReceivableByContractId(Long contractId) {
|
|
|
+ return receivableMapper.selectList(CrmReceivableDO::getContractId, contractId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|