Commit 90b5dfc4 by 284718418@qq.com

客户公海:离职自动释放到公海

parent bc414567
......@@ -51,7 +51,7 @@ import lombok.NoArgsConstructor;
@ApiModel("客户数据表")
public class CrmClientData extends Model<CrmClientData> {
private static final long serialVersionUID = -5368056704790782780L;
private static final long serialVersionUID = -5368056704790782781L;
@Id
@GeneratedValue
......
package cn.timer.api.controller.crm.task;
import cn.hutool.core.date.DateUtil;
import cn.timer.api.bean.crm.CrmClientAssociate;
import cn.timer.api.bean.crm.CrmClientData;
import cn.timer.api.bean.crm.CrmClientPlan;
import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.insure.InsureUser;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.dao.insure.InsureUserMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper;
import cn.timer.api.dao.crm.CrmClientDataMapper;
import cn.timer.api.utils.aliyun.AliyunSMS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
......@@ -19,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
......@@ -35,6 +34,9 @@ public class CrmClientPlanTask {
@Autowired
private AliyunSMS aliyunSMS;
@Resource
private CrmClientDataMapper crmClientDataMapper;
@Scheduled(cron = "0 0/30 * * * ? ")
@Transactional(rollbackFor = Exception.class)
public void updateInsureStatusTask(){
......@@ -58,4 +60,31 @@ public class CrmClientPlanTask {
throw new CustomException("客户跟进计划定时任务异常");
}
}
/**
* 每天4点半执行一次
* 离职员工,全部客户释放公海
*/
@Scheduled(cron = "0 30 4 * * ?")
@Transactional(rollbackFor = Exception.class)
public void lzygCrmClientData() {
try {
// 离职用户全部客户
List<Integer> ids = crmClientDataMapper.selectLzygCrmClientData();
if(CollectionUtils.isEmpty(ids)){
return;
}
for (Integer id : ids) {
// 0-进入客户公海
CrmClientData.builder().id(id).belongUser(0).belongUserName(null).build().updateById();
// 删除协作人列表
CrmClientAssociate.builder().build().delete(
new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getCid, id));
}
System.out.println("离职员工,全部客户释放公海:"+ids.size()+"个");
}catch (Exception e){
e.printStackTrace();
throw new CustomException("离职员工,全部客户释放公海定时任务异常");
}
}
}
......@@ -38,4 +38,6 @@ public interface CrmClientDataMapper extends BaseMapper<CrmClientData> {
@RequestParam(name = "belongGroup", required = false) Integer belongGroup,
@RequestParam(name = "startCreateTime", required = false) String startCreateTime,
@RequestParam(name = "endCreateTime", required = false) String endCreateTime);
List<Integer> selectLzygCrmClientData();
}
......@@ -2,7 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.timer.api.dao.crm.CrmClientDataMapper">
<select id="crmCartogram"
resultType="cn.timer.api.dto.crm.CrmCartogramDto">
SELECT
......@@ -50,4 +49,11 @@
</where>
GROUP BY ccd.belong_user
</select>
<select id="selectLzygCrmClientData" resultType="java.lang.Integer">
SELECT c.id FROM crm_client_data as c
LEFT JOIN yggl_main_lzb as y ON y.emp_num = c.belong_user AND y.id <![CDATA[>]]> 0 AND c.id <![CDATA[>]]> 0
WHERE y.job_status = 3 AND c.client_status <![CDATA[<]]> 5
</select>
</mapper>
\ No newline at end of file
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