Commit c479d815 by 邓实川

公海扫描规则,业务组单独id,name列表

parent fad12c50
......@@ -64,6 +64,6 @@ public class CrmSeaRule extends Model<CrmSeaRule> {
@ApiModelProperty(value = "系统提前(four)天自动提醒业务员客户将被回收")
private Integer four;
@ApiModelProperty(value = "我的客户数量最多(five)人(合作中的不算)")
private Integer five;
// @ApiModelProperty(value = "我的客户数量最多(five)人(合作中的不算)")
// private Integer five;
}
......@@ -117,6 +117,17 @@ public class CrmController {
@RequestBody CrmBusinessGroup crmBusinessGroup) {
Integer orgCode = getOrgCode(userBean);
Integer empNum = getEmpNum(userBean);
CrmSeaRule crmSeaRule = crmBusinessGroup.getCrmSeaRules();
Integer one = crmSeaRule.getOne();
Integer two = crmSeaRule.getTwo();
Integer three = crmSeaRule.getThree();
Integer four = crmSeaRule.getFour();
if ((one != null && one < 1) || (two != null && two < 1) || (three != null && three < 1)
|| (four != null && four < 1))
return ResultUtil.error("请输入正确的规则天数");
if (three <= one)
return ResultUtil.error("该规则天数必须大于规则1的天数");
Integer gid = crmBusinessGroup.getId();
crmBusinessGroup.setModifyUser(empNum); // 修改人
if (gid == null) {
......@@ -141,7 +152,6 @@ public class CrmController {
for (Integer empId : managerIds) {
insertMembers(gid, empId, orgCode, 1);
}
CrmSeaRule crmSeaRule = crmBusinessGroup.getCrmSeaRules();
crmSeaRule.setGid(gid);
crmSeaRule.insert();
return ResultUtil.success("新增业务组成功");
......@@ -153,10 +163,10 @@ public class CrmController {
updateMembers(orgCode, gid, memberIds, 0);
updateMembers(orgCode, gid, managerIds, 1);
// 更新公海规则
crmBusinessGroup.getCrmSeaRules().update(new LambdaQueryWrapper<CrmSeaRule>().eq(CrmSeaRule::getGid, gid));
crmSeaRule.update(new LambdaQueryWrapper<CrmSeaRule>().eq(CrmSeaRule::getGid, gid));
return ResultUtil.success("编辑业务组成功");
}
}
private void insertMembers(Integer gid, Integer empId, Integer orgCode, Integer type) {
......@@ -229,6 +239,16 @@ public class CrmController {
return ResultUtil.data(list, "获取成功");
}
@GetMapping("getBusinessGroupId")
@ApiOperation(value = "获取业务组列表(id,name)", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getBusinessGroupId(@CurrentUser UserBean userBean) {
return ResultUtil.data(CrmBusinessGroup.builder().build()
.selectList(new LambdaQueryWrapper<CrmBusinessGroup>()
.eq(CrmBusinessGroup::getOrgCode, getOrgCode(userBean))
.select(CrmBusinessGroup::getId, CrmBusinessGroup::getName)),
"获取成功");
}
// @GetMapping("getBusinessGroupMembers")
// @ApiOperation(value = "获取业务组列表成员", httpMethod = "GET", notes = "接口发布说明")
// public Result<Object> getBusinessGroupMembers(@CurrentUser UserBean userBean, @RequestParam Integer gid) {
......@@ -284,18 +304,26 @@ public class CrmController {
crmClientData.setBelongUserName(getEmpName(orgCode, crmClientData.getBelongUser()));
crmClientData.setOrgCode(getOrgCode(userBean));
Integer belongGroup = crmClientData.getBelongGroup();
if (belongGroup == null)
return ResultUtil.error("未选择业务组");
String belongGroupName = CrmBusinessGroup.builder().id(belongGroup).build().selectById().getName();
crmClientData.setBelongGroupName(belongGroupName);
String clientSourceName = ClientSourceClass.builder().id(crmClientData.getClientSource()).build().selectById()
.getName(); // 客户来源
String clientTypeName = ClientTypeClass.builder().id(crmClientData.getClientType()).build().selectById()
.getName(); // 客户类型
String industryName = IndustryClass.builder().id(crmClientData.getIndustry()).build().selectById().getName();// 行业名
crmClientData.setClientSourceName(clientSourceName);
crmClientData.setClientTypeName(clientTypeName);
crmClientData.setIndustryName(industryName);
Integer clientSource = crmClientData.getClientSource();
Integer clientType = crmClientData.getClientType();
Integer industry = crmClientData.getIndustry();
if (clientSource != null) {
String clientSourceName = ClientSourceClass.builder().id(clientSource).build().selectById().getName(); // 客户来源
crmClientData.setClientSourceName(clientSourceName);
}
if (clientType != null) {
String clientTypeName = ClientTypeClass.builder().id(clientType).build().selectById().getName(); // 客户类型
crmClientData.setClientTypeName(clientTypeName);
}
if (industry != null) {
String industryName = IndustryClass.builder().id(industry).build().selectById().getName();// 行业名
crmClientData.setIndustryName(industryName);
}
if (!crmClientData.insert())
return ResultUtil.error("新增失败");
Integer crmDataId = crmClientData.getId();
......
/**
* Title: CrmRuleController.java
* Description:
* @author dsc
* @date 2020年6月11日
* @version 1.0
*/
package cn.timer.api.controller.crm;
import java.util.Date;
import java.util.List;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
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.CrmSeaRule;
/**
* Title: CrmRuleController.java
*
* @Description: 公海规则
* @author dsc
* @date 2020年6月11日
* @version 1.0
*/
@Component
public class CrmRuleController {
@Scheduled(cron = "0 0 0/1 * * ? ") // 每小时扫描
@Transactional
public void getRules() {
// 全部业务组规则
List<CrmSeaRule> crmSeaRules = CrmSeaRule.builder().build().selectAll();
for (CrmSeaRule crmSeaRule : crmSeaRules) {
// 单个业务组规则信息
Integer one = crmSeaRule.getOne();
Integer two = crmSeaRule.getTwo();
Integer three = crmSeaRule.getThree();
Integer four = crmSeaRule.getFour(); // app提醒
// Integer five = crmSeaRule.getFive(); // 客户添加限制(暂不做)
Integer gid = crmSeaRule.getGid();
// 单个业务组对应的全部客户
List<CrmClientData> crmClientDatas = CrmClientData.builder().build()
.selectList(new LambdaQueryWrapper<CrmClientData>().eq(CrmClientData::getBelongGroup, gid).select(
CrmClientData::getCreateTime, CrmClientData::getId, CrmClientData::getLastFollowTime,
CrmClientData::getClientStatus, CrmClientData::getBelongUserName,
CrmClientData::getClientName));
for (CrmClientData crmClientData : crmClientDatas) {
// 单个客户信息
Date createTime = crmClientData.getCreateTime();
Date lastFollowTime = crmClientData.getLastFollowTime();
Integer status = crmClientData.getClientStatus();
String belongUserName = crmClientData.getBelongUserName();
String clientName = crmClientData.getClientName();
// 客户创建时间+ x天 = 过期释放时间
DateTime overDate1 = DateUtil.offsetDay(createTime, one);
DateTime overDate2 = DateUtil.offsetDay(lastFollowTime, two);
DateTime overDate3 = DateUtil.offsetDay(createTime, three);
// 时间比较
Date now = new Date();
long compare1 = DateUtil.between(overDate1, now, DateUnit.DAY, false);
long compare2 = DateUtil.between(overDate2, now, DateUnit.DAY, false);
long compare3 = DateUtil.between(overDate3, now, DateUnit.DAY, false);
// 判断1和2和3
if ((lastFollowTime == null && compare1 >= 0) || (lastFollowTime != null && compare2 >= 0)
|| (compare3 >= 0 && status != 3 && status != 4))
release(crmClientData);
// 判断4
if (compare1 == -four || compare2 == -four || compare3 == -four)
remind(belongUserName, clientName, four);
}
}
}
/**
* @param four
* @param name
*/
// app提醒
private void remind(String belongUserName, String clienName, Integer four) {
System.err.println(
belongUserName + "的客户:" + clienName + "还有" + four + "天即将过期," + "正在向'" + belongUserName + "'的App发推送提醒");
// TODO
}
// 释放到公海
private void release(CrmClientData crmClientData) {
crmClientData.setBelongUser(0); // 0-进入客户公海
crmClientData.setBelongUserName(null);
// 删除协作人列表
CrmClientAssociate.builder().build().delete(
new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getCid, crmClientData.getId()));
crmClientData.updateById();
}
}
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