!844 CRM: 完善跟进 TODO

Merge pull request !844 from puhui999/develop
This commit is contained in:
芋道源码 2024-01-20 11:00:23 +00:00 committed by Gitee
commit 5b26d8fa00
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
26 changed files with 143 additions and 415 deletions

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.crm.convert.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
@ -8,6 +9,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -45,4 +47,11 @@ public interface CrmBusinessConvert {
return voPageResult;
}
@Mapping(target = "id", source = "reqBO.bizId")
CrmBusinessDO convert(CrmUpdateFollowUpReqBO reqBO);
default List<CrmBusinessDO> convertList(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList) {
return CollectionUtils.convertList(updateFollowUpReqBOList, INSTANCE::convert);
}
}

View File

@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
@ -66,4 +67,11 @@ public interface CrmContactConvert {
findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname()));
}
@Mapping(target = "id", source = "reqBO.bizId")
CrmContactDO convert(CrmUpdateFollowUpReqBO reqBO);
default List<CrmContactDO> convertList(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList) {
return CollectionUtils.convertList(updateFollowUpReqBOList, INSTANCE::convert);
}
}

View File

@ -7,7 +7,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.business.bo.CrmBusinessUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -41,7 +41,7 @@ public interface CrmBusinessService {
*
* @param updateFollowUpReqBOList 跟进信息
*/
void updateContactFollowUpBatch(List<CrmBusinessUpdateFollowUpReqBO> updateFollowUpReqBOList);
void updateBusinessFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList);
/**
* 删除商机

View File

@ -21,8 +21,8 @@ import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.service.business.bo.CrmBusinessUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import com.mzt.logapi.context.LogRecordContext;
@ -172,8 +172,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
}
@Override
public void updateContactFollowUpBatch(List<CrmBusinessUpdateFollowUpReqBO> updateFollowUpReqBOList) {
businessMapper.updateBatch(BeanUtils.toBean(updateFollowUpReqBOList, CrmBusinessDO.class));
public void updateBusinessFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList) {
businessMapper.updateBatch(CrmBusinessConvert.INSTANCE.convertList(updateFollowUpReqBOList));
}
@Override

View File

@ -1,38 +0,0 @@
package cn.iocoder.yudao.module.crm.service.business.bo;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
// TODO @puhui999是不是搞个通用的 ReqBO 就好了
/**
* 商机跟进信息 Update Req BO
*
* @author HUIHUI
*/
@Data
public class CrmBusinessUpdateFollowUpReqBO {
@Schema(description = "商机编号", example = "3167")
@NotNull(message = "商机编号不能为空")
private Long id;
@Schema(description = "最后跟进时间")
@DiffLogField(name = "最后跟进时间")
@NotNull(message = "最后跟进时间不能为空")
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@DiffLogField(name = "下次联系时间")
@NotNull(message = "下次联系时间不能为空")
private LocalDateTime contactNextTime;
@Schema(description = "最后更进内容")
@DiffLogField(name = "最后更进内容")
@NotNull(message = "最后更进内容不能为空")
private String contactLastContent;
}

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
import cn.iocoder.yudao.module.crm.service.clue.bo.CrmClueUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -39,7 +39,7 @@ public interface CrmClueService {
*
* @param clueUpdateFollowUpReqBO 信息
*/
void updateClueFollowUp(CrmClueUpdateFollowUpReqBO clueUpdateFollowUpReqBO);
void updateClueFollowUp(CrmUpdateFollowUpReqBO clueUpdateFollowUpReqBO);
/**
* 删除线索

View File

@ -19,8 +19,8 @@ import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.service.clue.bo.CrmClueUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@ -113,8 +113,8 @@ public class CrmClueServiceImpl implements CrmClueService {
}
@Override
public void updateClueFollowUp(CrmClueUpdateFollowUpReqBO clueUpdateFollowUpReqBO) {
clueMapper.updateById(BeanUtils.toBean(clueUpdateFollowUpReqBO, CrmClueDO.class));
public void updateClueFollowUp(CrmUpdateFollowUpReqBO clueUpdateFollowUpReqBO) {
clueMapper.updateById(BeanUtils.toBean(clueUpdateFollowUpReqBO, CrmClueDO.class).setId(clueUpdateFollowUpReqBO.getBizId()));
}
@Override

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReq
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.contact.bo.CrmContactUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -63,7 +63,7 @@ public interface CrmContactService {
*
* @param updateFollowUpReqBOList 跟进信息
*/
void updateContactFollowUpBatch(List<CrmContactUpdateFollowUpReqBO> updateFollowUpReqBOList);
void updateContactFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList);
/**
* 获得联系人

View File

@ -15,9 +15,9 @@ import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
import cn.iocoder.yudao.module.crm.service.contact.bo.CrmContactUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@ -195,8 +195,8 @@ public class CrmContactServiceImpl implements CrmContactService {
}
@Override
public void updateContactFollowUpBatch(List<CrmContactUpdateFollowUpReqBO> updateFollowUpReqBOList) {
contactMapper.updateBatch(BeanUtils.toBean(updateFollowUpReqBOList, CrmContactDO.class));
public void updateContactFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList) {
contactMapper.updateBatch(CrmContactConvert.INSTANCE.convertList(updateFollowUpReqBOList));
}
//======================= 查询相关 =======================

View File

@ -1,38 +0,0 @@
package cn.iocoder.yudao.module.crm.service.contact.bo;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
// TODO @puhui999是不是搞个通用的 ReqBO 就好了
/**
* 联系人跟进信息 Update Req BO
*
* @author HUIHUI
*/
@Data
public class CrmContactUpdateFollowUpReqBO {
@Schema(description = "联系人编号", example = "3167")
@NotNull(message = "联系人编号不能为空")
private Long id;
@Schema(description = "最后跟进时间")
@DiffLogField(name = "最后跟进时间")
@NotNull(message = "最后跟进时间不能为空")
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@DiffLogField(name = "下次联系时间")
@NotNull(message = "下次联系时间不能为空")
private LocalDateTime contactNextTime;
@Schema(description = "最后更进内容")
@DiffLogField(name = "最后更进内容")
@NotNull(message = "最后更进内容不能为空")
private String contactLastContent;
}

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveR
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.contract.bo.CrmContractUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -55,7 +55,7 @@ public interface CrmContractService {
*
* @param contractUpdateFollowUpReqBO 信息
*/
void updateContractFollowUp(CrmContractUpdateFollowUpReqBO contractUpdateFollowUpReqBO);
void updateContractFollowUp(CrmUpdateFollowUpReqBO contractUpdateFollowUpReqBO);
/**
* 获得合同

View File

@ -13,7 +13,7 @@ import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.service.contract.bo.CrmContractUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import com.mzt.logapi.context.LogRecordContext;
@ -137,8 +137,8 @@ public class CrmContractServiceImpl implements CrmContractService {
}
@Override
public void updateContractFollowUp(CrmContractUpdateFollowUpReqBO contractUpdateFollowUpReqBO) {
contractMapper.updateById(BeanUtils.toBean(contractUpdateFollowUpReqBO, CrmContractDO.class));
public void updateContractFollowUp(CrmUpdateFollowUpReqBO contractUpdateFollowUpReqBO) {
contractMapper.updateById(BeanUtils.toBean(contractUpdateFollowUpReqBO, CrmContractDO.class).setId(contractUpdateFollowUpReqBO.getBizId()));
}
//======================= 查询相关 =======================

View File

@ -1,38 +0,0 @@
package cn.iocoder.yudao.module.crm.service.contract.bo;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
// TODO @puhui999是不是搞个通用的 ReqBO 就好了
/**
* 合同跟进信息 Update Req BO
*
* @author HUIHUI
*/
@Data
public class CrmContractUpdateFollowUpReqBO {
@Schema(description = "合同编号", example = "3167")
@NotNull(message = "合同编号不能为空")
private Long id;
@Schema(description = "最后跟进时间")
@DiffLogField(name = "最后跟进时间")
@NotNull(message = "最后跟进时间不能为空")
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@DiffLogField(name = "下次联系时间")
@NotNull(message = "下次联系时间不能为空")
private LocalDateTime contactNextTime;
@Schema(description = "最后更进内容")
@DiffLogField(name = "最后更进内容")
@NotNull(message = "最后更进内容不能为空")
private String contactLastContent;
}

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageR
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -96,7 +96,7 @@ public interface CrmCustomerService {
*
* @param customerUpdateFollowUpReqBO 请求
*/
void updateCustomerFollowUp(CrmCustomerUpdateFollowUpReqBO customerUpdateFollowUpReqBO);
void updateCustomerFollowUp(CrmUpdateFollowUpReqBO customerUpdateFollowUpReqBO);
// ==================== 公海相关操作 ====================

View File

@ -21,7 +21,7 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.util.CrmPermissionU
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@ -205,8 +205,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
}
@Override
public void updateCustomerFollowUp(CrmCustomerUpdateFollowUpReqBO customerUpdateFollowUpReqBO) {
customerMapper.updateById(BeanUtils.toBean(customerUpdateFollowUpReqBO, CrmCustomerDO.class));
public void updateCustomerFollowUp(CrmUpdateFollowUpReqBO customerUpdateFollowUpReqBO) {
customerMapper.updateById(BeanUtils.toBean(customerUpdateFollowUpReqBO, CrmCustomerDO.class).setId(customerUpdateFollowUpReqBO.getBizId()));
}
// ==================== 公海相关操作 ====================

View File

@ -1,33 +0,0 @@
package cn.iocoder.yudao.module.crm.service.customer.bo;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
// TODO @puhui999是不是搞个通用的 ReqBO 就好了
/**
* 跟进信息 Update Req BO
*
* @author HUIHUI
*/
@Data
public class CrmCustomerUpdateFollowUpReqBO {
@Schema(description = "主键", example = "3167")
private Long id;
@Schema(description = "最后跟进时间")
@DiffLogField(name = "最后跟进时间")
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@DiffLogField(name = "下次联系时间")
private LocalDateTime contactNextTime;
@Schema(description = "最后更进内容")
@DiffLogField(name = "最后更进内容")
private String contactLastContent;
}

View File

@ -9,19 +9,22 @@ import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecor
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
import cn.iocoder.yudao.module.crm.dal.mysql.followup.CrmFollowUpRecordMapper;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
import cn.iocoder.yudao.module.crm.service.business.bo.CrmBusinessUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.clue.CrmClueService;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
import cn.iocoder.yudao.module.crm.service.contact.bo.CrmContactUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.followup.handle.CrmFollowUpHandler;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -45,11 +48,15 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
@Resource
private CrmPermissionService permissionService;
@Resource
private List<CrmFollowUpHandler> followUpHandlers;
@Resource
private CrmBusinessService businessService;
@Resource
private CrmClueService clueService;
@Resource
private CrmContactService contactService;
@Resource
private CrmContractService contractService;
@Resource
private CrmCustomerService customerService;
@Override
@CrmPermission(bizTypeValue = "#createReqVO.bizType", bizId = "#createReqVO.bizId", level = CrmPermissionLevelEnum.WRITE)
@ -60,29 +67,88 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
LocalDateTime now = LocalDateTime.now();
// 2. 更新 bizId 对应的记录
followUpHandlers.forEach(handler -> handler.execute(followUpRecord, now));
updateBizTypeFollowUp(followUpRecord, now);
// 3.1 更新 contactIds 对应的记录
if (CollUtil.isNotEmpty(createReqVO.getContactIds())) {
// TODO @puhui999可以用链式设置哈
contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), contactId -> {
CrmContactUpdateFollowUpReqBO crmContactUpdateFollowUpReqBO = new CrmContactUpdateFollowUpReqBO();
crmContactUpdateFollowUpReqBO.setId(contactId).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent());
return crmContactUpdateFollowUpReqBO;
}));
contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), contactId ->
new CrmUpdateFollowUpReqBO().setBizId(contactId).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent())));
}
// 3.2 需要更新 businessIdscontactIds 对应的记录
if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) {
businessService.updateContactFollowUpBatch(convertList(createReqVO.getBusinessIds(), businessId -> {
CrmBusinessUpdateFollowUpReqBO crmBusinessUpdateFollowUpReqBO = new CrmBusinessUpdateFollowUpReqBO();
crmBusinessUpdateFollowUpReqBO.setId(businessId).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent());
return crmBusinessUpdateFollowUpReqBO;
}));
businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), businessId ->
new CrmUpdateFollowUpReqBO().setBizId(businessId).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent())));
}
return followUpRecord.getId();
}
/**
* 执行更新
*
* @param followUpRecord 跟进记录
* @param now 跟进时间
*/
private void updateBizTypeFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
updateBusinessFollowUp(followUpRecord, now);
updateClueFollowUp(followUpRecord, now);
updateContactFollowUp(followUpRecord, now);
updateContractFollowUp(followUpRecord, now);
updateCustomerFollowUp(followUpRecord, now);
}
private void updateBusinessFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_BUSINESS.getType(), followUpRecord.getBizType())) {
return;
}
// 更新商机跟进信息
businessService.updateBusinessFollowUpBatch(Collections.singletonList(new CrmUpdateFollowUpReqBO()
.setBizId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime()).setContactLastTime(now)
.setContactLastContent(followUpRecord.getContent())));
}
private void updateClueFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_LEADS.getType(), followUpRecord.getBizType())) {
return;
}
// 更新线索跟进信息
clueService.updateClueFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now)
.setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()));
}
private void updateContactFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTACT.getType(), followUpRecord.getBizType())) {
return;
}
// 更新联系人跟进信息
contactService.updateContactFollowUpBatch(Collections.singletonList(new CrmUpdateFollowUpReqBO()
.setBizId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime()).setContactLastTime(now)
.setContactLastContent(followUpRecord.getContent())));
}
private void updateContractFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTRACT.getType(), followUpRecord.getBizType())) {
return;
}
// 更新合同跟进信息
contractService.updateContractFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now)
.setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()));
}
private void updateCustomerFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CUSTOMER.getType(), followUpRecord.getBizType())) {
return;
}
// 更新客户跟进信息
customerService.updateCustomerFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now)
.setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()));
}
@Override
public void deleteFollowUpRecord(Long id, Long userId) {
// 校验存在

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.service.clue.bo;
package cn.iocoder.yudao.module.crm.service.followup.bo;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
@ -7,18 +7,18 @@ import lombok.Data;
import java.time.LocalDateTime;
// TODO @puhui999是不是搞个通用的 ReqBO 就好了
/**
* 线索跟进信息 Update Req BO
* 跟进信息 Update Req BO
*
* @author HUIHUI
*/
@Data
public class CrmClueUpdateFollowUpReqBO {
public class CrmUpdateFollowUpReqBO {
@Schema(description = "线索编号", example = "3167")
@NotNull(message = "线索编号不能为空")
private Long id;
@Schema(description = "数据编号", example = "3167")
@NotNull(message = "数据编号不能为空")
private Long bizId;
@Schema(description = "最后跟进时间")
@DiffLogField(name = "最后跟进时间")
@ -27,7 +27,6 @@ public class CrmClueUpdateFollowUpReqBO {
@Schema(description = "下次联系时间")
@DiffLogField(name = "下次联系时间")
@NotNull(message = "下次联系时间不能为空")
private LocalDateTime contactNextTime;
@Schema(description = "最后更进内容")

View File

@ -1,38 +0,0 @@
package cn.iocoder.yudao.module.crm.service.followup.handle;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
import cn.iocoder.yudao.module.crm.service.business.bo.CrmBusinessUpdateFollowUpReqBO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Collections;
/**
* CRM 商机的 {@link CrmFollowUpHandler} 实现类
*
* @author HUIHUI
*/
@Component
public class CrmBusinessFollowUpHandler implements CrmFollowUpHandler {
@Resource
private CrmBusinessService businessService;
@Override
public void execute(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_BUSINESS.getType(), followUpRecord.getBizType())) {
return;
}
// 更新商机跟进信息
CrmBusinessUpdateFollowUpReqBO businessUpdateFollowUpReqBO = new CrmBusinessUpdateFollowUpReqBO();
businessUpdateFollowUpReqBO.setId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent());
businessService.updateContactFollowUpBatch(Collections.singletonList(businessUpdateFollowUpReqBO));
}
}

View File

@ -1,37 +0,0 @@
package cn.iocoder.yudao.module.crm.service.followup.handle;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.service.clue.CrmClueService;
import cn.iocoder.yudao.module.crm.service.clue.bo.CrmClueUpdateFollowUpReqBO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* CRM 线索的 {@link CrmFollowUpHandler} 实现类
*
* @author HUIHUI
*/
@Component
public class CrmClueFollowUpHandler implements CrmFollowUpHandler {
@Resource
private CrmClueService clueService;
@Override
public void execute(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_LEADS.getType(), followUpRecord.getBizType())) {
return;
}
// 更新线索跟进信息
CrmClueUpdateFollowUpReqBO clueUpdateFollowUpReqBO = new CrmClueUpdateFollowUpReqBO();
clueUpdateFollowUpReqBO.setId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent());
clueService.updateClueFollowUp(clueUpdateFollowUpReqBO);
}
}

View File

@ -1,38 +0,0 @@
package cn.iocoder.yudao.module.crm.service.followup.handle;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
import cn.iocoder.yudao.module.crm.service.contact.bo.CrmContactUpdateFollowUpReqBO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Collections;
/**
* CRM 联系人的 {@link CrmFollowUpHandler} 实现类
*
* @author HUIHUI
*/
@Component
public class CrmContactFollowUpHandler implements CrmFollowUpHandler {
@Resource
private CrmContactService contactService;
@Override
public void execute(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTACT.getType(), followUpRecord.getBizType())) {
return;
}
// 更新联系人跟进信息
CrmContactUpdateFollowUpReqBO contactUpdateFollowUpReqBO = new CrmContactUpdateFollowUpReqBO();
contactUpdateFollowUpReqBO.setId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent());
contactService.updateContactFollowUpBatch(Collections.singletonList(contactUpdateFollowUpReqBO));
}
}

View File

@ -1,37 +0,0 @@
package cn.iocoder.yudao.module.crm.service.followup.handle;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.contract.bo.CrmContractUpdateFollowUpReqBO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* CRM 合同的 {@link CrmFollowUpHandler} 实现类
*
* @author HUIHUI
*/
@Component
public class CrmContractFollowUpHandler implements CrmFollowUpHandler {
@Resource
private CrmContractService contractService;
@Override
public void execute(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTRACT.getType(), followUpRecord.getBizType())) {
return;
}
// 更新合同跟进信息
CrmContractUpdateFollowUpReqBO contractUpdateFollowUpReqBO = new CrmContractUpdateFollowUpReqBO();
contractUpdateFollowUpReqBO.setId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent());
contractService.updateContractFollowUp(contractUpdateFollowUpReqBO);
}
}

View File

@ -1,37 +0,0 @@
package cn.iocoder.yudao.module.crm.service.followup.handle;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerUpdateFollowUpReqBO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* CRM 客户的 {@link CrmFollowUpHandler} 实现类
*
* @author HUIHUI
*/
@Component
public class CrmCustomerFollowUpHandler implements CrmFollowUpHandler {
@Resource
private CrmCustomerService customerService;
@Override
public void execute(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CUSTOMER.getType(), followUpRecord.getBizType())) {
return;
}
// 更新客户跟进信息
CrmCustomerUpdateFollowUpReqBO customerUpdateFollowUpReqBO = new CrmCustomerUpdateFollowUpReqBO();
customerUpdateFollowUpReqBO.setId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent());
customerService.updateCustomerFollowUp(customerUpdateFollowUpReqBO);
}
}

View File

@ -1,23 +0,0 @@
package cn.iocoder.yudao.module.crm.service.followup.handle;
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import java.time.LocalDateTime;
/**
* CRM 跟进信息处理器 handler 接口
*
* @author HUIHUI
*/
public interface CrmFollowUpHandler {
// TODO @puhui999需要考虑下次联系时间为空
/**
* 执行更新
*
* @param followUpRecord 跟进记录
* @param now 跟进时间
*/
void execute(CrmFollowUpRecordDO followUpRecord, LocalDateTime now);
}

View File

@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.product.convert.comment;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO;
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
@ -59,4 +61,6 @@ public interface ProductCommentConvert {
return divide.intValue();
}
PageResult<ProductCommentRespVO> convertPage(PageResult<ProductCommentDO> productCommentDOPageResult);
}

View File

@ -9,20 +9,19 @@ import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommen
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO;
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO;
import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper;
import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Lazy;
import jakarta.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
@ -148,10 +147,10 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest {
assertEquals(2, result3.getTotal());
// 测试分页 tab count
AppCommentStatisticsRespVO tabsCount = productCommentService.getCommentStatistics(spuId, Boolean.TRUE);
assertEquals(4, tabsCount.getGoodCount());
assertEquals(2, tabsCount.getMediocreCount());
assertEquals(0, tabsCount.getNegativeCount());
//AppCommentStatisticsRespVO tabsCount = productCommentService.getCommentStatistics(spuId, Boolean.TRUE);
//assertEquals(4, tabsCount.getGoodCount());
//assertEquals(2, tabsCount.getMediocreCount());
//assertEquals(0, tabsCount.getNegativeCount());
}