来自编程小趴菜的分享~~
希望对你有所帮助~~
你的小小的赞就是对我最大的鼓励~~
有不明白的地方可以私信解答~
目录
任务一:线索捞取为负数bug修复
任务二:权限管理-用户管理-高级搜索-手机号搜索不可用
任务三:公海池-创建时间搜索 -没有效果
任务四:商机管理-商机状态搜索框不可用
任务五:线索管理- 线索id和手机号应该支持模糊搜索
任务六:线索管理-添加线索-活动信息-应该只展示 正在活动时间内的活动
注意:第二天的任务还是比较简单的,主要是一些bug的修复,这些bug主要原因是写sql语句的时候,缺少进行相应的判断引起的
策略:首先打开前端项目,使用F12抓包,看请求的路径是哪里,然后找到对应的代码位置进行修改
任务一:线索捞取为负数bug修复
在serviceImpl实现的代码地方添加对应的逻辑判断
if (asignRecords >= rulePool.getMaxNunmber()) {
int num = 0;
if (rulePool.getMaxNunmber() - asignRecords <= 0) {
num = 0;
}
throw new CustomException("捞取失败!最大保有量(" + rulePool.getMaxNunmber() + "),剩余可以捞取" + (num) + "条线索");
}
完整代码:
/**
* 批量捞取
*
* @param clueIds 线索id
* @param userId 当前用户id
* @return
*/
@Override
public String gain(Long[] clueIds, Long userId) {
// 是否批量捞取
boolean isBatch = clueIds.length > 1 ? true : false;
TbRulePool rulePool = rulePoolService.selectTbRulePoolByType(TbRulePool.RuleType.CLUES.getValue());
// 统计当前分配人所有线索
int asignRecords = assignRecordMapper.countAssignCluesByUser(userId);
// rulePool.getMaxNunmber() 当前分配人的最大捞取量
if (asignRecords >= rulePool.getMaxNunmber()) {
int num = 0;
if (rulePool.getMaxNunmber() - asignRecords <= 0) {
num = 0;
}
throw new CustomException("捞取失败!最大保有量(" + rulePool.getMaxNunmber() + "),剩余可以捞取" + (num) + "条线索");
}
for (int i = 0; i < clueIds.length; i++) {
Long clueId = clueIds[i];
// 超过最大保有量
if (asignRecords + i >= rulePool.getMaxNunmber()) {
throw new CustomException("捞取失败!保有量达到上线,最多选择" + rulePool.getMaxNunmber() + "条线索");
}
// 最近捞取记录
TbAssignRecord assignRecord = assignRecordMapper.selectAssignRecordByAssignId(clueId,
TbAssignRecord.RecordType.CLUES.getValue());
if (assignRecord != null && assignRecord.getUserId().equals(userId)) {
Date repeatGetTime = JobUtils.getDate(rulePool.getRepeatGetTime().intValue(), rulePool.getRepeatType(),
assignRecord.getCreateTime());
// 捞取限制时间内,不让捞取
if (DateUtils.getNowDate().before(repeatGetTime)) {
// 批量捞取跳过
if (isBatch) {
continue;
} else {
throw new CustomException("捞取失败!需要在 " + DateUtils.dateTimeHm(repeatGetTime) + " 后捞取");
}
}
}
// 捞取后下次跟进时间,及状态重置
tbClueMapper.resetNextTimeAndStatus(clueId, TbClue.StatusType.UNFOLLOWED.getValue());
// 新建分配记录
TbAssignRecord tbAssignRecord = addNewRecord(clueId, userId);
Date endDate = HuiKeCrmDateUtils.getEndDateByRule(tbAssignRecord);
tbClueMapper.updateClueEndTimeById(clueId, endDate);
}
return "全部捞取成功";
}
任务二:权限管理-用户管理-高级搜索-手机号搜索不可用
查看代码可以发现,对应的SysUserMapper.xml文件中,没有对手机号搜索的判断,只需要加上就行
解决代码:
<!-- 数据范围过滤 -->
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber = #{phonenumber}
</if>
<!-- 数据范围过滤 -->
完整代码:
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
</if>
<!-- 数据范围过滤 -->
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber = #{phonenumber}
</if>
<!-- 数据范围过滤 -->
<if test="params.dataScope != null and params.dataScope != ''">
AND (${params.dataScope})
</if>
</select>
任务三:公海池-创建时间搜索 -没有效果
其原理基本上同任务二,主要是xml文件的判断问题
解决代码:
<!--添加对时间的判断-->
<if test="beginCreateTime != null and endCreateTime != null ">
and DATE_FORMAT(create_time,'%Y-%m-%d')
BETWEEN #{beginCreateTime} AND #{endCreateTime}</if>
完整代码:
<select id="selectTbBusinessPool" parameterType="TbBusiness" resultMap="TbBusinessResult">
<include refid="selectTbBusinessVo"/>
<where>
<if test="id != null and id != ''"> and id = #{id}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="channel != null and channel != ''"> and channel = #{channel}</if>
<if test="activityId != null "> and activity_id = #{activityId}</if>
<if test="provinces != null and provinces != ''"> and provinces = #{provinces}</if>
<if test="city != null and city != ''"> and city = #{city}</if>
<if test="sex != null and sex != ''"> and sex = #{sex}</if>
<if test="age != null "> and age = #{age}</if>
<if test="weixin != null and weixin != ''"> and weixin = #{weixin}</if>
<if test="qq != null and qq != ''"> and qq = #{qq}</if>
<if test="level != null and level != ''"> and level = #{level}</if>
<if test="subject != null and subject != ''"> and subject = #{subject}</if>
<if test="courseId != null "> and course_id = #{courseId}</if>
<if test="occupation != null and occupation != ''"> and occupation = #{occupation}</if>
<if test="education != null and education != ''"> and education = #{education}</if>
<if test="job != null and job != ''"> and job = #{job}</if>
<if test="salary != null and salary != ''"> and salary = #{salary}</if>
<if test="major != null and major != ''"> and major = #{major}</if>
<if test="expectedSalary != null and expectedSalary != ''"> and expected_salary = #{expectedSalary}</if>
<if test="reasons != null and reasons != ''"> and reasons = #{reasons}</if>
<if test="plan != null and plan != ''"> and plan = #{plan}</if>
<if test="planTime != null "> and plan_time = #{planTime}</if>
<if test="otherIntention != null and otherIntention != ''"> and other_intention = #{otherIntention}</if>
<if test="nextTime != null "> and next_time = #{nextTime}</if>
<!--添加对时间的判断-->
<if test="beginCreateTime != null and endCreateTime != null ">
and DATE_FORMAT(create_time,'%Y-%m-%d')
BETWEEN #{beginCreateTime} AND #{endCreateTime}</if>
and status IN ('3','4')
</where>
</select>
任务四:商机管理-商机状态搜索框不可用
原理同上
解决代码:
<!-- 数据范围过滤 -->
<if test="status != null and status != ''"> and b.status = #{status}</if>
完整代码:
<select id="selectTbBusinessList" parameterType="TbBusiness" resultMap="TbBusinessAssignResult">
<include refid="selectTbBusinesAssignVo"/>
<where>
<if test="id != null and id != ''"> and b.id like concat('%', #{id}, '%')</if>
<if test="name != null and name != ''"> and b.name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and b.phone like concat('%', #{phone}, '%')</if>
<if test="channel != null and channel != ''"> and b.channel = #{channel}</if>
<if test="activityId != null "> and b.activity_id = #{activityId}</if>
<if test="provinces != null and provinces != ''"> and b.provinces = #{provinces}</if>
<if test="city != null and city != ''"> and b.city = #{city}</if>
<if test="sex != null and sex != ''"> and b.sex = #{sex}</if>
<if test="age != null "> and b.age = #{age}</if>
<if test="weixin != null and weixin != ''"> and b.weixin = #{weixin}</if>
<if test="qq != null and qq != ''"> and b.qq = #{qq}</if>
<if test="level != null and level != ''"> and b.level = #{level}</if>
<if test="subject != null and subject != ''"> and b.subject = #{subject}</if>
<if test="courseId != null "> and b.course_id = #{courseId}</if>
<if test="occupation != null and occupation != ''"> and b.occupation = #{occupation}</if>
<if test="education != null and education != ''"> and b.education = #{education}</if>
<if test="job != null and job != ''"> and b.job = #{job}</if>
<if test="salary != null and salary != ''"> and b.salary = #{salary}</if>
<if test="major != null and major != ''"> and b.major = #{major}</if>
<if test="expectedSalary != null and expectedSalary != ''"> and b.expected_salary = #{expectedSalary}</if>
<if test="reasons != null and reasons != ''"> and b.reasons = #{reasons}</if>
<if test="plan != null and plan != ''"> and b.plan = #{plan}</if>
<if test="planTime != null "> and b.plan_time = #{planTime}</if>
<if test="otherIntention != null and otherIntention != ''"> and b.other_intention = #{otherIntention}</if>
<if test="nextTime != null "> and b.next_time = #{nextTime}</if>
<if test="beginCreateTime != null and endCreateTime != null "> and DATE_FORMAT(b.create_time,'%Y-%m-%d') BETWEEN #{beginCreateTime} AND #{endCreateTime}</if>
<!-- 数据范围过滤 -->
<if test="status != null and status != ''"> and b.status = #{status}</if>
AND (r.latest = '1' OR r.id IS NULL)
AND (r.type = '1' OR r.id IS NULL)
</where>
<!-- 数据范围过滤 -->
<if test="params.dataScope != null and params.dataScope != ''">
AND (${params.dataScope} OR r.id IS NULL)
</if>
ORDER BY b.`create_time` DESC
</select>
任务五:线索管理- 线索id和手机号应该支持模糊搜索
在对应的xml文件中对这两个字段加上like查询
解决代码:
<!--加上对手机号和id的like模糊查询-->
<if test="id != null and id != ''"> and clue.id like concat('%', #{id}, '%')</if>
<if test="name != null and name != ''"> and clue.name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and clue.phone like concat('%', #{phone}, '%')</if>
完整代码:
<select id="selectTbClueList" parameterType="TbClue" resultMap="TbClueAssignResult">
<include refid="selectTbClueAssignVo"/>
<where>
<!--加上对手机号和id的like模糊查询-->
<if test="id != null and id != ''"> and clue.id like concat('%', #{id}, '%')</if>
<if test="name != null and name != ''"> and clue.name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and clue.phone like concat('%', #{phone}, '%')</if>
<if test="channel != null and channel != ''"> and clue.channel = #{channel}</if>
<if test="activityId != null and activityId != ''"> and clue.activity_id = #{activityId}</if>
<if test="sex != null and sex != ''"> and clue.sex = #{sex}</if>
<if test="age != null "> and clue.age = #{age}</if>
<if test="weixin != null and weixin != ''"> and clue.weixin = #{weixin}</if>
<if test="qq != null and qq != ''"> and clue.qq = #{qq}</if>
<if test="level != null and level != ''"> and clue.level = #{level}</if>
<if test="subject != null and subject != ''"> and clue.subject = #{subject}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''"><!-- 开始创建时间 -->
and date_format(clue.create_time,'%y%m%d') >= date_format(#{params.beginCreateTime},'%y%m%d')
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''"><!-- -->
and date_format(clue.create_time,'%y%m%d') <= date_format(#{params.endCreateTime},'%y%m%d')
</if>
<if test="nextTime != null "> and clue.next_time = #{nextTime}</if>
<if test="owner != null and owner != ''"> and r.user_name like concat('%', #{owner}, '%')</if>
<!-- 线索状态没有被查询,这里去掉状态转而添加if -->
<if test="status != null and status !=''"> and clue.status = #{status}</if>
<if test="status == null or status == ''"> and clue.status in ('1','2')</if>
AND (r.latest = '1' OR r.id IS NULL)
AND (r.type = '0' OR r.id IS NULL)
</where>
<!-- 数据范围过滤 -->
<if test="params.dataScope != null and params.dataScope != ''">
AND (${params.dataScope} OR r.id IS NULL)
</if>
order by clue.create_time desc
</select>
任务六:线索管理-添加线索-活动信息-应该只展示 正在活动时间内的活动
查询时对当前时间进行判断 ,在此提供一个简单方案,在查询结果返回前端时对其进行数据处理,过滤掉失效时间的活动
解决代码:
Date nowTime = new Date();
List<TbActivity> collect = tbActivities
.stream().filter(item -> item.getEndTime()
.compareTo(nowTime) == 1).collect(Collectors.toList());
以上就是今天的任务啦,希望对你有所帮助~~