Commit af94536a0606e62f3288687b4f4fdee1fce74feb

Authored by YunaiV
1 parent a9c7b584

fix:【CRM 客户管理】修改数据时,避免操作日志出现“删除负责人”的情况

yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
... ... @@ -142,6 +142,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
142 142 updateBusinessProduct(updateObj.getId(), businessProducts);
143 143  
144 144 // 3. 记录操作日志上下文
  145 + updateReqVO.setOwnerUserId(oldBusiness.getOwnerUserId()); // 避免操作日志出现“删除负责人”的情况
145 146 LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldBusiness, CrmBusinessSaveReqVO.class));
146 147 LogRecordContext.putVariable("businessName", oldBusiness.getName());
147 148 }
... ...
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
... ... @@ -92,19 +92,20 @@ public class CrmClueServiceImpl implements CrmClueService {
92 92 @Transactional(rollbackFor = Exception.class)
93 93 @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
94 94 success = CRM_CLUE_UPDATE_SUCCESS)
95   - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#updateReq.id", level = CrmPermissionLevelEnum.OWNER)
96   - public void updateClue(CrmClueSaveReqVO updateReq) {
97   - Assert.notNull(updateReq.getId(), "线索编号不能为空");
  95 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.OWNER)
  96 + public void updateClue(CrmClueSaveReqVO updateReqVO) {
  97 + Assert.notNull(updateReqVO.getId(), "线索编号不能为空");
98 98 // 1.1 校验线索是否存在
99   - CrmClueDO oldClue = validateClueExists(updateReq.getId());
  99 + CrmClueDO oldClue = validateClueExists(updateReqVO.getId());
100 100 // 1.2 校验关联数据
101   - validateRelationDataExists(updateReq);
  101 + validateRelationDataExists(updateReqVO);
102 102  
103 103 // 2. 更新线索
104   - CrmClueDO updateObj = BeanUtils.toBean(updateReq, CrmClueDO.class);
  104 + CrmClueDO updateObj = BeanUtils.toBean(updateReqVO, CrmClueDO.class);
105 105 clueMapper.updateById(updateObj);
106 106  
107 107 // 3. 记录操作日志上下文
  108 + updateReqVO.setOwnerUserId(oldClue.getOwnerUserId()); // 避免操作日志出现“删除负责人”的情况
108 109 LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldClue, CrmCustomerSaveReqVO.class));
109 110 LogRecordContext.putVariable("clueName", oldClue.getName());
110 111 }
... ...
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
... ... @@ -114,6 +114,7 @@ public class CrmContactServiceImpl implements CrmContactService {
114 114 contactMapper.updateById(updateObj);
115 115  
116 116 // 3. 记录操作日志
  117 + updateReqVO.setOwnerUserId(oldContact.getOwnerUserId()); // 避免操作日志出现“删除负责人”的情况
117 118 LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldContact, CrmContactSaveReqVO.class));
118 119 LogRecordContext.putVariable("contactName", oldContact.getName());
119 120 }
... ...
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
... ... @@ -140,9 +140,9 @@ public class CrmContractServiceImpl implements CrmContractService {
140 140 Assert.notNull(updateReqVO.getId(), "合同编号不能为空");
141 141 updateReqVO.setOwnerUserId(null); // 不允许更新的字段
142 142 // 1.1 校验存在
143   - CrmContractDO contract = validateContractExists(updateReqVO.getId());
  143 + CrmContractDO oldContract = validateContractExists(updateReqVO.getId());
144 144 // 1.2 只有草稿、审批中,可以编辑;
145   - if (!ObjectUtils.equalsAny(contract.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(),
  145 + if (!ObjectUtils.equalsAny(oldContract.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(),
146 146 CrmAuditStatusEnum.PROCESS.getStatus())) {
147 147 throw exception(CONTRACT_UPDATE_FAIL_NOT_DRAFT);
148 148 }
... ... @@ -159,8 +159,9 @@ public class CrmContractServiceImpl implements CrmContractService {
159 159 updateContractProduct(updateReqVO.getId(), contractProducts);
160 160  
161 161 // 3. 记录操作日志上下文
162   - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(contract, CrmContractSaveReqVO.class));
163   - LogRecordContext.putVariable("contractName", contract.getName());
  162 + updateReqVO.setOwnerUserId(oldContract.getOwnerUserId()); // 避免操作日志出现“删除负责人”的情况
  163 + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldContract, CrmContractSaveReqVO.class));
  164 + LogRecordContext.putVariable("contractName", oldContract.getName());
164 165 }
165 166  
166 167 private void updateContractProduct(Long id, List<CrmContractProductDO> newList) {
... ...
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
... ... @@ -137,6 +137,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
137 137 customerMapper.updateById(updateObj);
138 138  
139 139 // 3. 记录操作日志上下文
  140 + updateReqVO.setOwnerUserId(oldCustomer.getOwnerUserId()); // 避免操作日志出现“删除负责人”的情况
140 141 LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomer, CrmCustomerSaveReqVO.class));
141 142 LogRecordContext.putVariable("customerName", oldCustomer.getName());
142 143 }
... ...
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java
... ... @@ -104,6 +104,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
104 104 receivablePlanMapper.updateById(updateObj);
105 105  
106 106 // 3. 记录操作日志上下文
  107 + updateReqVO.setOwnerUserId(oldReceivablePlan.getOwnerUserId()); // 避免操作日志出现“删除负责人”的情况
107 108 LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldReceivablePlan, CrmReceivablePlanSaveReqVO.class));
108 109 LogRecordContext.putVariable("receivablePlan", oldReceivablePlan);
109 110 }
... ...
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
... ... @@ -162,14 +162,14 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
162 162 Assert.notNull(updateReqVO.getId(), "回款编号不能为空");
163 163 updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段
164 164 // 1.1 校验存在
165   - CrmReceivableDO receivable = validateReceivableExists(updateReqVO.getId());
166   - updateReqVO.setOwnerUserId(receivable.getOwnerUserId()).setCustomerId(receivable.getCustomerId())
167   - .setContractId(receivable.getContractId()).setPlanId(receivable.getPlanId()); // 设置已存在的值
  165 + CrmReceivableDO oldReceivable = validateReceivableExists(updateReqVO.getId());
  166 + updateReqVO.setOwnerUserId(oldReceivable.getOwnerUserId()).setCustomerId(oldReceivable.getCustomerId())
  167 + .setContractId(oldReceivable.getContractId()).setPlanId(oldReceivable.getPlanId()); // 设置已存在的值
168 168 // 1.2 校验可回款金额超过上限
169 169 validateReceivablePriceExceedsLimit(updateReqVO);
170 170  
171 171 // 1.3 只有草稿、审批中,可以编辑;
172   - if (!ObjectUtils.equalsAny(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(),
  172 + if (!ObjectUtils.equalsAny(oldReceivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(),
173 173 CrmAuditStatusEnum.PROCESS.getStatus())) {
174 174 throw exception(RECEIVABLE_UPDATE_FAIL_EDITING_PROHIBITED);
175 175 }
... ... @@ -179,9 +179,10 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
179 179 receivableMapper.updateById(updateObj);
180 180  
181 181 // 3. 记录操作日志上下文
182   - LogRecordContext.putVariable("receivable", receivable);
183   - LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId()));
184   - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class));
  182 + updateReqVO.setOwnerUserId(oldReceivable.getOwnerUserId()); // 避免操作日志出现“删除负责人”的情况
  183 + LogRecordContext.putVariable("oldReceivable", oldReceivable);
  184 + LogRecordContext.putVariable("period", getReceivablePeriod(oldReceivable.getPlanId()));
  185 + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldReceivable, CrmReceivableSaveReqVO.class));
185 186 }
186 187  
187 188 private Integer getReceivablePeriod(Long planId) {
... ...