mirror of
https://github.com/1Panel-dev/CordysCRM.git
synced 2026-05-16 13:00:44 +08:00
feat: add follow record log
This commit is contained in:
@@ -45,7 +45,7 @@ public class CustomerFollowRecordController {
|
||||
@RequiresPermissions(PermissionConstants.CUSTOMER_MANAGEMENT_UPDATE)
|
||||
@Operation(summary = "更新客户跟进记录")
|
||||
public FollowUpRecord update(@Validated @RequestBody FollowUpRecordUpdateRequest request) {
|
||||
return followUpRecordService.update(request, SessionUtils.getUserId());
|
||||
return followUpRecordService.update(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,6 @@ public class CustomerFollowRecordController {
|
||||
@Operation(summary = "客户跟进记录列表")
|
||||
public Pager<List<FollowUpRecordListResponse>> list(@Validated @RequestBody FollowUpRecordPageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
|
||||
return PageUtils.setPageInfo(page, followUpRecordService.list(request, OrganizationContext.getOrganizationId(),"CUSTOMER","CUSTOMER"));
|
||||
return PageUtils.setPageInfo(page, followUpRecordService.list(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId(), "CUSTOMER", "CUSTOMER"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ import java.util.List;
|
||||
|
||||
public interface ExtFollowUpRecordMapper {
|
||||
|
||||
List<FollowUpRecordListResponse> selectList(@Param("request") FollowUpRecordPageRequest request, @Param("orgId") String orgId, @Param("resourceType") String resourceType, @Param("type") String type);
|
||||
List<FollowUpRecordListResponse> selectList(@Param("request") FollowUpRecordPageRequest request, @Param("userId") String userId, @Param("orgId") String orgId, @Param("resourceType") String resourceType, @Param("type") String type);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
</if>
|
||||
<if test="resourceType == 'LEAD'">
|
||||
AND lead_id = #{request.sourceId}
|
||||
AND create_user = #{userId}
|
||||
</if>
|
||||
<if test="resourceType == 'OPPORTUNITY'">
|
||||
AND opportunity_id = #{request.sourceId}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package io.cordys.crm.follow.service;
|
||||
|
||||
import io.cordys.aspectj.constants.LogModule;
|
||||
import io.cordys.aspectj.constants.LogType;
|
||||
import io.cordys.aspectj.dto.LogDTO;
|
||||
import io.cordys.common.domain.BaseModuleFieldValue;
|
||||
import io.cordys.common.dto.OptionDTO;
|
||||
import io.cordys.common.exception.GenericException;
|
||||
import io.cordys.common.service.BaseService;
|
||||
import io.cordys.common.uid.IDGenerator;
|
||||
import io.cordys.common.util.BeanUtils;
|
||||
import io.cordys.common.util.Translator;
|
||||
import io.cordys.crm.customer.mapper.ExtCustomerContactMapper;
|
||||
import io.cordys.crm.follow.domain.FollowUpRecord;
|
||||
import io.cordys.crm.follow.dto.request.FollowUpRecordAddRequest;
|
||||
@@ -13,6 +17,7 @@ import io.cordys.crm.follow.dto.request.FollowUpRecordPageRequest;
|
||||
import io.cordys.crm.follow.dto.request.FollowUpRecordUpdateRequest;
|
||||
import io.cordys.crm.follow.dto.response.FollowUpRecordListResponse;
|
||||
import io.cordys.crm.follow.mapper.ExtFollowUpRecordMapper;
|
||||
import io.cordys.crm.system.service.LogService;
|
||||
import io.cordys.mybatis.BaseMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -38,6 +43,8 @@ public class FollowUpRecordService {
|
||||
private BaseService baseService;
|
||||
@Resource
|
||||
private ExtCustomerContactMapper extCustomerContactMapper;
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
/**
|
||||
* 添加跟进记录
|
||||
@@ -69,13 +76,17 @@ public class FollowUpRecordService {
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public FollowUpRecord update(FollowUpRecordUpdateRequest request, String userId) {
|
||||
public FollowUpRecord update(FollowUpRecordUpdateRequest request, String userId, String orgId) {
|
||||
FollowUpRecord followUpRecord = followUpRecordMapper.selectByPrimaryKey(request.getId());
|
||||
Optional.ofNullable(followUpRecord).ifPresentOrElse(record -> {
|
||||
LogDTO logDTO = new LogDTO(orgId, followUpRecord.getId(), userId, LogType.UPDATE, LogModule.FOLLOW_UP_RECORD, Translator.get("update_follow_up_record"));
|
||||
logDTO.setOriginalValue(record);
|
||||
//更新跟进记录
|
||||
updateRecord(record, request, userId);
|
||||
//更新模块字段
|
||||
updateModuleField(request.getId(), request.getModuleFields());
|
||||
logDTO.setModifiedValue(record);
|
||||
logService.add(logDTO);
|
||||
}, () -> {
|
||||
throw new GenericException("record_not_found");
|
||||
});
|
||||
@@ -113,13 +124,14 @@ public class FollowUpRecordService {
|
||||
* 跟进记录列表查询
|
||||
*
|
||||
* @param request
|
||||
* @param userId
|
||||
* @param orgId
|
||||
* @param resourceType
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public List<FollowUpRecordListResponse> list(FollowUpRecordPageRequest request, String orgId, String resourceType, String type) {
|
||||
List<FollowUpRecordListResponse> list = extFollowUpRecordMapper.selectList(request, orgId, resourceType, type);
|
||||
public List<FollowUpRecordListResponse> list(FollowUpRecordPageRequest request, String userId, String orgId, String resourceType, String type) {
|
||||
List<FollowUpRecordListResponse> list = extFollowUpRecordMapper.selectList(request, userId, orgId, resourceType, type);
|
||||
return buildListData(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class LeadFollowRecordController {
|
||||
@RequiresPermissions(PermissionConstants.LEAD_MANAGEMENT_UPDATE)
|
||||
@Operation(summary = "更新线索跟进记录")
|
||||
public FollowUpRecord update(@Validated @RequestBody FollowUpRecordUpdateRequest request) {
|
||||
return followUpRecordService.update(request, SessionUtils.getUserId());
|
||||
return followUpRecordService.update(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,6 @@ public class LeadFollowRecordController {
|
||||
@Operation(summary = "线索跟进记录列表")
|
||||
public Pager<List<FollowUpRecordListResponse>> list(@Validated @RequestBody FollowUpRecordPageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
|
||||
return PageUtils.setPageInfo(page, followUpRecordService.list(request, OrganizationContext.getOrganizationId(),"LEAD","LEAD"));
|
||||
return PageUtils.setPageInfo(page, followUpRecordService.list(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId(),"LEAD","LEAD"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.cordys.crm.opportunity.controller;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.cordys.aspectj.constants.LogModule;
|
||||
import io.cordys.common.constants.PermissionConstants;
|
||||
import io.cordys.common.pager.PageUtils;
|
||||
import io.cordys.common.pager.Pager;
|
||||
@@ -44,7 +45,7 @@ public class OpportunityFollowRecordController {
|
||||
@RequiresPermissions(PermissionConstants.OPPORTUNITY_MANAGEMENT_UPDATE)
|
||||
@Operation(summary = "更新商机跟进记录")
|
||||
public FollowUpRecord update(@Validated @RequestBody FollowUpRecordUpdateRequest request) {
|
||||
return followUpRecordService.update(request, SessionUtils.getUserId());
|
||||
return followUpRecordService.update(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId());
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
@@ -52,6 +53,6 @@ public class OpportunityFollowRecordController {
|
||||
@Operation(summary = "商机跟进记录列表")
|
||||
public Pager<List<FollowUpRecordListResponse>> list(@Validated @RequestBody FollowUpRecordPageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
|
||||
return PageUtils.setPageInfo(page, followUpRecordService.list(request, OrganizationContext.getOrganizationId(),"OPPORTUNITY","CUSTOMER"));
|
||||
return PageUtils.setPageInfo(page, followUpRecordService.list(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId(), "OPPORTUNITY", "CUSTOMER"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,4 +266,5 @@ opportunity.access_fail=Access fail, not pool owner!
|
||||
field_validate_error=The field ${field} parameter value is invalid, please check the required items and field type!
|
||||
record_not_found=Record not found
|
||||
user_has_been_disabled=The user has been disabled
|
||||
user_not_exist=The user does not exist
|
||||
user_not_exist=The user does not exist
|
||||
update_follow_up_record=Update follow record
|
||||
@@ -272,3 +272,4 @@ field_validate_error=${field}字段参数值不合法, 请检查必填项和字
|
||||
record_not_found=跟进记录不存在
|
||||
user_has_been_disabled=用户已被禁用
|
||||
user_not_exist=用户不存在
|
||||
update_follow_up_record=更新跟进记录
|
||||
@@ -77,6 +77,8 @@ public class CustomerFollowRecordControllerTests extends BaseTest {
|
||||
void testList() throws Exception {
|
||||
FollowUpRecordPageRequest request = new FollowUpRecordPageRequest();
|
||||
request.setSourceId("123");
|
||||
request.setCurrent(1);
|
||||
request.setPageSize(10);
|
||||
this.requestPost(DEFAULT_PAGE, request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ public class LeadFollowRecordControllerTests extends BaseTest {
|
||||
void testList() throws Exception {
|
||||
FollowUpRecordPageRequest request = new FollowUpRecordPageRequest();
|
||||
request.setSourceId("123456");
|
||||
request.setCurrent(1);
|
||||
request.setPageSize(10);
|
||||
this.requestPost(DEFAULT_PAGE, request);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ public class OpportunityFollowRecordControllerTests extends BaseTest {
|
||||
void testList() throws Exception {
|
||||
FollowUpRecordPageRequest request = new FollowUpRecordPageRequest();
|
||||
request.setSourceId("12345");
|
||||
request.setCurrent(1);
|
||||
request.setPageSize(10);
|
||||
this.requestPost(DEFAULT_PAGE, request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,5 +45,14 @@ public class LogModule {
|
||||
*/
|
||||
public static final String MODULE_SETTING = "MODULE_SETTING";
|
||||
|
||||
|
||||
//TODO start 暂定跟进记录模块常量
|
||||
/**
|
||||
* 客户模块
|
||||
*/
|
||||
public static final String FOLLOW_UP_RECORD = "FOLLOW_UP_RECORD";
|
||||
|
||||
//todo end
|
||||
|
||||
// 可以根据需要扩展其他模块常量
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user