Commit 18dfcaac by 翁国栋

crm新需求--

客户新增手机微信二选一
客户新增跟进状态(潜在,意向)
客户跟进列表中如果是签约或者合作中的,增加签约时间和合同时间
加一条本月待跟进列表
parent fa4ded37
......@@ -74,3 +74,13 @@ CREATE TABLE `crm_list_color` (
`color3` varchar(50) DEFAULT NULL COMMENT '颜色',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COMMENT='跟进记录的颜色标识配置';
ALTER TABLE `timer_test_0620`.`crm_client_data`
ADD COLUMN `contract_signing_date` datetime NULL COMMENT '签约时间' AFTER `hidingcustomers`,
ADD COLUMN `contract_end_date` varchar(50) NULL COMMENT '合同到期时间' AFTER `contract_signing_date`;
ALTER TABLE `timer_test_0620`.`crm_client_follow`
ADD COLUMN `contract_end_date` datetime NULL COMMENT '合同到期时间' AFTER `client_status`,
ADD COLUMN `contract_signing_date` varchar(50) NULL COMMENT '签约时间' AFTER `contract_end_date`;
......@@ -182,13 +182,10 @@ public class CrmClientData extends Model<CrmClientData> {
@TableField(exist = false)
@ApiModelProperty(value = "客户联系人数据列表")
private List<CrmClientContacts> CrmClientContacts;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "签约时间")
private Date contractSigningDate;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "合同有效期")
private String contractEndDate ;
......
......@@ -399,7 +399,9 @@ public class CrmController {
log.info("crmClientData合同有效期",crmClientData.getContractEndDate());
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
crmClientData.setClientStatus(1);
if(crmClientData.getClientStatus()==null){
crmClientData.setClientStatus(1);
}
crmClientData.setCreateUser(empNum);
SysRegion district = zpglService.getSysRegion(crmClientData.getDistrictId());
// crmClientData.setZipCode(district.getZipCode());
......@@ -1027,8 +1029,16 @@ public class CrmController {
Integer orgCode = getOrgCode(userBean);
Integer empNum = getEmpNum(userBean);
CrmClientData.builder().id(crmClientFollow.getCid()).clientStatus(crmClientFollow.getClientStatus())
.lastFollowTime(new Date()).build().updateById(); // 更新客户最近跟进时间
oldData.setClientStatus(crmClientFollow.getClientStatus());
oldData.setLastFollowTime(new Date());
if(crmClientFollow.getContractSigningDate()!=null){
oldData.setContractSigningDate(crmClientFollow.getContractSigningDate());
}
if(crmClientFollow.getContractEndDate()!=null){
oldData.setContractEndDate(crmClientFollow.getContractEndDate());
}
oldData.updateById();// 更新客户最近跟进时间
crmClientFollow.setOrgCode(orgCode);
crmClientFollow.setCreateUser(empNum);
......@@ -1998,7 +2008,7 @@ public class CrmController {
return ResultUtil.data(crmListColorList, "成功");
}
@PostMapping(value="/getFollowUpMonth")
@GetMapping(value="/getFollowUpMonth")
@ApiOperation(value = "获取当月待跟进客户列表", httpMethod = "GET", notes = "获取当月待跟进客户列表")
public Result<Object> getFollowUpMonthList(@CurrentUser UserBean userBean,
@RequestParam(required = false) Integer type, @RequestParam(required = false) Integer groupId,
......@@ -2013,24 +2023,68 @@ public class CrmController {
@RequestParam(required = false, defaultValue = "10") int pageSize,
@RequestParam(required = false) Integer unfollowedDays,
@RequestParam(required = false) Integer followNumber,
@RequestParam(required = false) Integer industry) {
log.info("crmClientDatahe状态",type);
log.info("crmClientDatahe签约时间",groupId);
log.info("crmClientData合同有效期",status);
log.info("crmClientData合同有效期",like);
log.info("crmClientData合同有效期",customerowner);
log.info("crmClientData合同有效期",startCreateTime);
log.info("crmClientData合同有效期",endCreateTime);
log.info("crmClientData合同有效期",startFollowTime);
log.info("crmClientData合同有效期",startFollowTime);
log.info("crmClientData合同有效期",endFollowTime);
log.info("crmClientData合同有效期",ifPhone);
log.info("crmClientData合同有效期",pageNumber);
log.info("crmClientData合同有效期",pageSize);
log.info("crmClientData合同有效期",unfollowedDays);
log.info("crmClientData合同有效期",followNumber);
log.info("crmClientData合同有效期",industry);
List<CrmListColor> crmListColorList = CrmListColor.builder().build().selectList(new QueryWrapper<CrmListColor>().lambda().eq(CrmListColor::getDeleteFlag, 0));
return ResultUtil.data(crmListColorList, "成功");
@RequestParam(required = false) Integer industry,
@RequestParam(required = false) String remindDay) {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
if (endCreateTime != null && !("").equals(endCreateTime)) {
endCreateTime = endCreateTime.substring(0, 10) + " 23:59:59";
}
if (endFollowTime != null && !("").equals(endFollowTime)) {
endFollowTime = endFollowTime.substring(0, 10) + " 23:59:59";
}
QyzxEmpEntAsso qyzxEmpEntAsso = QyzxEmpEntAsso.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, orgCode)
.eq(QyzxEmpEntAsso::getEmpNum, empNum));
if (qyzxEmpEntAsso != null && qyzxEmpEntAsso.getUserType() != null
&& (qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_ADMIN.getType()
|| qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_C_ADMIN.getType())) {
IPage<CrmClientData> page = new Page<CrmClientData>(pageNumber, pageSize);
List<CrmBusinessGroupMember> grouplis = CrmBusinessGroupMember.builder().build().selectList(new QueryWrapper<CrmBusinessGroupMember>().lambda().eq(CrmBusinessGroupMember::getEmpNum, userBean.getEmpNum())
.eq(CrmBusinessGroupMember::getOrgCode, userBean.getOrgCode()));
String keywordStr = "";
IPage<CrmClientData> datas;
Integer count = new LambdaQueryChainWrapper<QyzxEmpEntAsso>(qyzxEmpEntAssoMapper)
.eq(QyzxEmpEntAsso::getEmpNum, userBean.getEmpNum())
.eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode())
.in(QyzxEmpEntAsso::getUserType, "0,1")
.count();
if(count > 0) {
datas = crmClientDataMapper.getCrmClientData4(page,empNum, orgCode, groupId, status, like,startCreateTime,endCreateTime,startFollowTime,endFollowTime,type,ifPhone,customerowner,unfollowedDays,followNumber,industry,remindDay);
}else {
if(grouplis.size()>0 && grouplis != null) {
StringBuffer sb = new StringBuffer();
for(CrmBusinessGroupMember grp : grouplis) {
sb.append(grp.getGid()).append(",");
}
keywordStr = sb.deleteCharAt(sb.length() - 1).toString();
}
datas = crmClientDataMapper.getCrmClientData5(page,empNum, orgCode, groupId, status, like,startCreateTime,endCreateTime,startFollowTime,endFollowTime,type,ifPhone,customerowner,unfollowedDays,followNumber,industry,remindDay);
}
return ResultUtil.pageData(datas.getRecords(), datas.getTotal(), "查询成功");
} else {
// 当前用户管理的组
List<Integer> gids = MyManageGroup(empNum, orgCode);
List<CrmClientData> crmClientDatas = new ArrayList<CrmClientData>();
if(gids.size()>0) {
for (Integer gid : gids) {
List<CrmClientData> datas = crmClientDataMapper.getCrmClientData6(empNum, orgCode, groupId, status, like, startCreateTime, endCreateTime, startFollowTime, endFollowTime, type, ifPhone, customerowner, unfollowedDays, followNumber, industry,gid,remindDay);
for (CrmClientData data : datas)
crmClientDatas.add(data);
}
}
List<CrmClientData> result = getPageList(crmClientDatas, pageNumber, pageSize,
Comparator.comparing(CrmClientData::getCreateTime).reversed());
return ResultUtil.pageData(result, (long) crmClientDatas.size(), "查询成功");
}
}
}
......@@ -78,4 +78,33 @@ public interface CrmClientDataMapper extends BaseMapper<CrmClientData> {
@Param("ifPhone") String ifPhone,@Param("customerowner") String customerowner,
@Param("unfollowedDays") Integer unfollowedDays, @Param("followNumber") Integer followNumber,
@Param("industry") Integer industry,@Param("gid")Integer gid);
IPage<CrmClientData> getCrmClientData4(IPage<CrmClientData> page,
@Param("empNum") Integer empNum, @Param("orgCode") Integer orgCode,
@Param("groupId") Integer groupId, @Param("status") Integer status,
@Param("like") String like, @Param("startCreateTime") String startCreateTime,
@Param("endCreateTime") String endCreateTime, @Param("startFollowTime") String startFollowTime,
@Param("endFollowTime") String endFollowTime,@Param("type") Integer type,
@Param("ifPhone") String ifPhone,@Param("customerowner") String customerowner,
@Param("unfollowedDays") Integer unfollowedDays, @Param("followNumber") Integer followNumber,
@Param("industry") Integer industry,@Param("remindDay")String remindDay);
IPage<CrmClientData> getCrmClientData5(IPage<CrmClientData> page,
@Param("empNum") Integer empNum, @Param("orgCode") Integer orgCode,
@Param("groupId") Integer groupId, @Param("status") Integer status,
@Param("like") String like, @Param("startCreateTime") String startCreateTime,
@Param("endCreateTime") String endCreateTime, @Param("startFollowTime") String startFollowTime,
@Param("endFollowTime") String endFollowTime,@Param("type") Integer type,
@Param("ifPhone") String ifPhone,@Param("customerowner") String customerowner,
@Param("unfollowedDays") Integer unfollowedDays, @Param("followNumber") Integer followNumber,
@Param("industry") Integer industry,@Param("remindDay")String remindDay);
List<CrmClientData> getCrmClientData6(@Param("empNum") Integer empNum, @Param("orgCode") Integer orgCode,
@Param("groupId") Integer groupId, @Param("status") Integer status,
@Param("like") String like, @Param("startCreateTime") String startCreateTime,
@Param("endCreateTime") String endCreateTime, @Param("startFollowTime") String startFollowTime,
@Param("endFollowTime") String endFollowTime,@Param("type") Integer type,
@Param("ifPhone") String ifPhone,@Param("customerowner") String customerowner,
@Param("unfollowedDays") Integer unfollowedDays, @Param("followNumber") Integer followNumber,
@Param("industry") Integer industry,@Param("gid")Integer gid,@Param("remindDay")String remindDay);
}
......@@ -239,4 +239,164 @@
</if>
ORDER BY ccd.create_time DESC;
</select>
</mapper>
\ No newline at end of file
<select id="getCrmClientData4" resultType="CrmClientData">
SELECT ccd.*
FROM crm_remind_rule crr
left join crm_client_data ccd on ccd.id=crr.crm_client_id
WHERE ccd.org_code = #{orgCode}
AND ccd.belong_user = #{empNum}
and crr.remind_day>=#{remindDay}
and crr.delete_flag = 0
<if test="industry != null and industry > 0">
AND ccd.industry = #{industry}
</if>
<if test="groupId != null and groupId >= 0">
AND ccd.belong_group = #{groupId}
</if>
<if test="type != null and type >= 0">
AND ccd.client_type = #{type}
</if>
<if test="customerowner != null and customerowner != ''">
AND ccd.belong_user_name LIKE CONCAT('%', #{customerowner}, '%')
</if>
<if test="status != null and status >= 0">
AND ccd.client_status = #{status}
</if>
<if test="keywordStr != null and keywordStr != ''">
AND ccd.belong_group IN (${keywordStr})
</if>
<if test="ifPhone != null and ifPhone != '' and ifPhone == '1'">
AND ccd.client_cellphone LIKE '%1'
</if>
<if test="ifPhone != null and ifPhone != '' and ifPhone == '2'">
AND (ccd.client_cellphone IS NULL OR ccd.client_cellphone = '')
</if>
<if test="startCreateTime != null and startCreateTime != '' and endCreateTime != null and endCreateTime != '' ">
AND ccd.create_time BETWEEN #{startCreateTime} AND #{endCreateTime}
</if>
<if test="startFollowTime != null and endFollowTime != null">
AND ccd.last_follow_time BETWEEN #{startFollowTime} AND #{endFollowTime}
</if>
<if test="like != null and like.trim().length() > 0">
AND (ccd.client_name LIKE CONCAT('%', #{like}, '%') OR ccd.client_cellphone LIKE CONCAT('%', #{like}, '%'))
</if>
<if test="unfollowedDays != null and unfollowedDays > 0">
AND DATEDIFF(NOW(), (SELECT MAX(last_follow_time) FROM crm_client_follow ccf WHERE ccf.cid = ccd.id)) >= #{unfollowedDays}
</if>
<if test="followNumber != null and followNumber > 0">
AND (
SELECT COUNT(*)
FROM crm_client_follow
WHERE cid = ccd.id
) >= #{followNumber}
</if>
ORDER BY ccd.create_time DESC;
</select>
<select id="getCrmClientData5" resultType="CrmClientData">
SELECT ccd.*
FROM crm_remind_rule crr
left join crm_client_data ccd on ccd.id=crr.crm_client_id
where crr.delete_flag = 0
and ccd.belong_group = #{gid}
and crr.remind_day>=#{remindDay}
<if test="industry != null and industry > 0">
AND ccd.industry = #{industry}
</if>
<if test="groupId != null and groupId >= 0">
AND ccd.belong_group = #{groupId}
</if>
<if test="type != null and type >= 0">
AND ccd.client_type = #{type}
</if>
<if test="customerowner != null and customerowner != ''">
AND ccd.belong_user_name LIKE CONCAT('%', #{customerowner}, '%')
</if>
<if test="status != null and status >= 0">
AND ccd.client_status = #{status}
</if>
<if test="ifPhone != null and ifPhone != '' and ifPhone == '1'">
AND ccd.client_cellphone LIKE '%1'
</if>
<if test="ifPhone != null and ifPhone != '' and ifPhone == '2'">
AND (ccd.client_cellphone IS NULL OR ccd.client_cellphone = '')
</if>
<if test="startCreateTime != null and startCreateTime != '' and endCreateTime != null and endCreateTime != '' ">
AND ccd.create_time BETWEEN #{startCreateTime} AND #{endCreateTime}
</if>
<if test="startFollowTime != null and endFollowTime != null">
AND ccd.last_follow_time BETWEEN #{startFollowTime} AND #{endFollowTime}
</if>
<if test="like != null and like.trim().length() > 0">
AND (ccd.client_name LIKE CONCAT('%', #{like}, '%') OR ccd.client_cellphone LIKE CONCAT('%', #{like}, '%'))
</if>
<if test="unfollowedDays != null and unfollowedDays > 0">
AND DATEDIFF(NOW(), (SELECT MAX(last_follow_time) FROM crm_client_follow ccf WHERE ccf.cid = ccd.id)) >= #{unfollowedDays}
</if>
<if test="followNumber != null and followNumber > 0">
AND (
SELECT COUNT(*)
FROM crm_client_follow
WHERE cid = ccd.id
) >= #{followNumber}
</if>
ORDER BY ccd.create_time DESC;
</select>
<select id="getCrmClientData6" resultType="CrmClientData">
SELECT ccd.*
FROM crm_remind_rule crr
left join crm_client_data ccd on ccd.id=crr.crm_client_id
where crr.delete_flag = 0
AND ccr.crm_group_member = #{empNum}
AND ccr.org_code = #{orgCode}
and crr.remind_day>=#{remindDay}
<if test="gid != null and gid > 0">
and ccd.belong_group = #{gid}
</if>
<if test="industry != null and industry > 0">
AND ccd.industry = #{industry}
</if>
<if test="groupId != null and groupId >= 0">
AND ccd.belong_group = #{groupId}
</if>
<if test="type != null and type >= 0">
AND ccd.client_type = #{type}
</if>
<if test="customerowner != null and customerowner != ''">
AND ccd.belong_user_name LIKE CONCAT('%', #{customerowner}, '%')
</if>
<if test="status != null and status >= 0">
AND ccd.client_status = #{status}
</if>
<if test="ifPhone != null and ifPhone != '' and ifPhone == '1'">
AND ccd.client_cellphone LIKE '%1'
</if>
<if test="ifPhone != null and ifPhone != '' and ifPhone == '2'">
AND (ccd.client_cellphone IS NULL OR ccd.client_cellphone = '')
</if>
<if test="startCreateTime != null and startCreateTime != '' and endCreateTime != null and endCreateTime != '' ">
AND ccd.create_time BETWEEN #{startCreateTime} AND #{endCreateTime}
</if>
<if test="startFollowTime != null and endFollowTime != null">
AND ccd.last_follow_time BETWEEN #{startFollowTime} AND #{endFollowTime}
</if>
<if test="like != null and like.trim().length() > 0">
AND (ccd.client_name LIKE CONCAT('%', #{like}, '%') OR ccd.client_cellphone LIKE CONCAT('%', #{like}, '%'))
</if>
<if test="unfollowedDays != null and unfollowedDays > 0">
AND DATEDIFF(NOW(), (SELECT MAX(last_follow_time) FROM crm_client_follow ccf WHERE ccf.cid = ccd.id)) >= #{unfollowedDays}
</if>
<if test="followNumber != null and followNumber > 0">
AND (
SELECT COUNT(*)
FROM crm_client_follow
WHERE cid = ccd.id
) >= #{followNumber}
</if>
ORDER BY ccd.create_time DESC;
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment