| | |
| | | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| | | import cn.iocoder.yudao.module.crm.service.followup.bo.CrmFollowUpCreateReqBO; |
| | | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Resource |
| | | @Lazy |
| | | private CrmCustomerService customerService; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @Override |
| | | @CrmPermission(bizTypeValue = "#createReqVO.bizType", bizId = "#createReqVO.bizId", level = CrmPermissionLevelEnum.WRITE) |
| | |
| | | // 1. 创建更进记录 |
| | | CrmFollowUpRecordDO record = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); |
| | | crmFollowUpRecordMapper.insert(record); |
| | | storageAttachmentApi.bindAttachments("file", "crm_follow_up_record", |
| | | record.getId(), createReqVO.getBlobIds()); |
| | | |
| | | // 2. 更新 bizId 对应的记录 |
| | | if (ObjUtil.equal(CrmBizTypeEnum.CRM_CUSTOMER.getType(), record.getBizType())) { // 更新客户跟进信息 |
| | |
| | | throw exception(FOLLOW_UP_RECORD_DELETE_DENIED); |
| | | } |
| | | |
| | | // 删除附件 |
| | | storageAttachmentApi.deleteAttachmentsByRecord("crm_follow_up_record", id); |
| | | // 删除 |
| | | crmFollowUpRecordMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteFollowUpRecordByBiz(Integer bizType, Long bizId) { |
| | | List<CrmFollowUpRecordDO> records = crmFollowUpRecordMapper.selectListByBiz(bizType, List.of(bizId)); |
| | | for (CrmFollowUpRecordDO record : records) { |
| | | storageAttachmentApi.deleteAttachmentsByRecord("crm_follow_up_record", record.getId()); |
| | | } |
| | | crmFollowUpRecordMapper.deleteByBiz(bizType, bizId); |
| | | } |
| | | |