Commit 1de703b7 by 邓实川 Committed by chenzg

业务组接口,我的客户接口,公海接口,其他接口

parent 7795245e
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
package cn.timer.api.bean.crm; package cn.timer.api.bean.crm;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
...@@ -60,12 +62,6 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> { ...@@ -60,12 +62,6 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
@ApiModelProperty(value = "业务组名称") @ApiModelProperty(value = "业务组名称")
private String name; private String name;
@ApiModelProperty(value = "业务组管理员empNum")
private Integer manager;
@ApiModelProperty(value = "业务组管理员名称")
private String managerName;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
...@@ -85,8 +81,18 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> { ...@@ -85,8 +81,18 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
@Transient @Transient
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "组管理员信息")
private List<Map<String, Object>> managers;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "组管理员id")
private Integer[] managerIds;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "组成员id") @ApiModelProperty(value = "组成员id")
private Integer[] ids; private Integer[] memberIds;
@Transient @Transient
@TableField(exist = false) @TableField(exist = false)
...@@ -98,4 +104,10 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> { ...@@ -98,4 +104,10 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
// //
// @ApiModelProperty(value = "组成员姓名") // @ApiModelProperty(value = "组成员姓名")
// private String memberName; // private String memberName;
// @ApiModelProperty(value = "业务组管理员empNum")
// private Integer manager;
//
// @ApiModelProperty(value = "业务组管理员名称")
// private String managerName;
} }
/**
* Title: CrmBusinessManager.java
* Description:
* @author dsc
* @date 2020年6月9日
* @version 1.0
*/
package cn.timer.api.bean.crm;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Title: CrmBusinessGroupManager.java
*
* @Description:
* @author dsc
* @date 2020年6月9日
* @version 1.0
*/
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "crm_business_group_manager")
@ApiModel("业务组管理员表")
public class CrmBusinessGroupManager extends Model<CrmBusinessGroupManager> {
private static final long serialVersionUID = -957497237692110042L;
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "编号")
private Integer id;
@ApiModelProperty(value = "组id")
private Integer gid;
@ApiModelProperty(value = "员工id")
private Integer empNum;
@ApiModelProperty(value = "企业id")
private Integer orgCode;
}
...@@ -53,4 +53,7 @@ public class CrmBusinessGroupMember extends Model<CrmBusinessGroupMember>{ ...@@ -53,4 +53,7 @@ public class CrmBusinessGroupMember extends Model<CrmBusinessGroupMember>{
@ApiModelProperty(value = "员工id") @ApiModelProperty(value = "员工id")
private Integer empNum; private Integer empNum;
@ApiModelProperty(value = "企业id")
private Integer orgCode;
} }
...@@ -108,7 +108,7 @@ public class CrmClientData extends Model<CrmClientData> { ...@@ -108,7 +108,7 @@ public class CrmClientData extends Model<CrmClientData> {
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remarks; private String remarks;
@ApiModelProperty(value = "客户所属(创建人empNum)") @ApiModelProperty(value = "客户所属(创建人empNum) 0-进入客户公海")
private Integer belongUser; private Integer belongUser;
@ApiModelProperty(value = "客户所属人姓名") @ApiModelProperty(value = "客户所属人姓名")
......
...@@ -11,7 +11,10 @@ import java.util.ArrayList; ...@@ -11,7 +11,10 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
...@@ -24,12 +27,15 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -24,12 +27,15 @@ import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.timer.api.bean.clazz.ClientSourceClass; import cn.timer.api.bean.clazz.ClientSourceClass;
import cn.timer.api.bean.clazz.ClientTypeClass; import cn.timer.api.bean.clazz.ClientTypeClass;
import cn.timer.api.bean.clazz.IndustryClass; import cn.timer.api.bean.clazz.IndustryClass;
import cn.timer.api.bean.clazz.SysRegion; import cn.timer.api.bean.clazz.SysRegion;
import cn.timer.api.bean.crm.CrmBusinessGroup; import cn.timer.api.bean.crm.CrmBusinessGroup;
import cn.timer.api.bean.crm.CrmBusinessGroupManager;
import cn.timer.api.bean.crm.CrmBusinessGroupMember; import cn.timer.api.bean.crm.CrmBusinessGroupMember;
import cn.timer.api.bean.crm.CrmClientAssociate; import cn.timer.api.bean.crm.CrmClientAssociate;
import cn.timer.api.bean.crm.CrmClientContacts; import cn.timer.api.bean.crm.CrmClientContacts;
...@@ -69,8 +75,9 @@ public class CrmController { ...@@ -69,8 +75,9 @@ public class CrmController {
} }
private YgglMainEmp getYg(Integer orgCode, Integer empNum) { private YgglMainEmp getYg(Integer orgCode, Integer empNum) {
return YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda() return YgglMainEmp.builder().build()
.eq(YgglMainEmp::getEmpNum, empNum).eq(YgglMainEmp::getOrgCode, orgCode).select(YgglMainEmp::getName)); .selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum, empNum)
.eq(YgglMainEmp::getOrgCode, orgCode).select(YgglMainEmp::getName, YgglMainEmp::getHeadUrl));
} }
private String getEmpName(Integer orgCode, Integer empNum) { private String getEmpName(Integer orgCode, Integer empNum) {
...@@ -111,7 +118,7 @@ public class CrmController { ...@@ -111,7 +118,7 @@ public class CrmController {
crmBusinessGroup.setSort(1); crmBusinessGroup.setSort(1);
else else
crmBusinessGroup.setSort(crmBusinessGroupOld.getSort() + 1);// 排序 crmBusinessGroup.setSort(crmBusinessGroupOld.getSort() + 1);// 排序
crmBusinessGroup.setManagerName(getEmpName(orgCode, empNum)); // 设置管理员姓名 // crmBusinessGroup.setManagerName(getEmpName(orgCode, empNum)); // 设置管理员姓名
crmBusinessGroup.setCreateUser(empNum); // 创建人 crmBusinessGroup.setCreateUser(empNum); // 创建人
crmBusinessGroup.setModifyUser(empNum); // 修改人 crmBusinessGroup.setModifyUser(empNum); // 修改人
crmBusinessGroup.setOrgCode(orgCode); crmBusinessGroup.setOrgCode(orgCode);
...@@ -120,10 +127,15 @@ public class CrmController { ...@@ -120,10 +127,15 @@ public class CrmController {
if (!result) if (!result)
return ResultUtil.success("新增失败"); return ResultUtil.success("新增失败");
Integer gid = crmBusinessGroup.getId(); Integer gid = crmBusinessGroup.getId();
Integer[] ids = crmBusinessGroup.getIds(); Integer[] memberIds = crmBusinessGroup.getMemberIds();
for (Integer empId : ids) { for (Integer empId : memberIds) {
CrmBusinessGroupMember.builder().gid(gid).empNum(empId).build().insert(); CrmBusinessGroupMember.builder().gid(gid).empNum(empId).orgCode(orgCode).build().insert();
} }
Integer[] managerIds = crmBusinessGroup.getManagerIds();
for (Integer empId : managerIds) {
CrmBusinessGroupManager.builder().gid(gid).empNum(empId).orgCode(orgCode).build().insert();
}
CrmSeaRule crmSeaRule = crmBusinessGroup.getCrmSeaRules(); CrmSeaRule crmSeaRule = crmBusinessGroup.getCrmSeaRules();
crmSeaRule.setGid(gid); crmSeaRule.setGid(gid);
crmSeaRule.insert(); crmSeaRule.insert();
...@@ -133,12 +145,26 @@ public class CrmController { ...@@ -133,12 +145,26 @@ public class CrmController {
@GetMapping("getBusinessGroup") @GetMapping("getBusinessGroup")
@ApiOperation(value = "获取业务组列表", httpMethod = "GET", notes = "接口发布说明") @ApiOperation(value = "获取业务组列表", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getBusinessGroup(@CurrentUser UserBean userBean) { public Result<Object> getBusinessGroup(@CurrentUser UserBean userBean) {
return ResultUtil.data(CrmBusinessGroup.builder().build() List<CrmBusinessGroup> list = CrmBusinessGroup.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroup>().lambda() .selectList(new QueryWrapper<CrmBusinessGroup>().lambda()
.eq(CrmBusinessGroup::getOrgCode, getOrgCode(userBean)).select(CrmBusinessGroup::getId, .eq(CrmBusinessGroup::getOrgCode, getOrgCode(userBean)).select(CrmBusinessGroup::getId,
CrmBusinessGroup::getSort, CrmBusinessGroup::getName, CrmBusinessGroup::getManagerName, CrmBusinessGroup::getSort, CrmBusinessGroup::getName, CrmBusinessGroup::getModifyTime));
CrmBusinessGroup::getModifyTime)), for (CrmBusinessGroup crmBusinessGroup : list) {
"获取成功"); Integer gid = crmBusinessGroup.getId();
List<CrmBusinessGroupManager> crmBusinessGroupManagers = CrmBusinessGroupManager.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupManager>().lambda()
.eq(CrmBusinessGroupManager::getGid, gid).select(CrmBusinessGroupManager::getEmpNum));
List<Map<String, Object>> managers = new ArrayList<Map<String, Object>>();
for (CrmBusinessGroupManager crmBusinessGroupManager : crmBusinessGroupManagers) {
Integer empNum = crmBusinessGroupManager.getEmpNum();
String name = getEmpName(getOrgCode(userBean), empNum);
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
managers.add(map);
}
crmBusinessGroup.setManagers(managers);
}
return ResultUtil.data(list, "获取成功");
} }
@GetMapping("getBusinessGroupMembers") @GetMapping("getBusinessGroupMembers")
...@@ -153,7 +179,7 @@ public class CrmController { ...@@ -153,7 +179,7 @@ public class CrmController {
return ResultUtil.data(ygglMainEmps, "获取成功"); return ResultUtil.data(ygglMainEmps, "获取成功");
} }
@GetMapping("getBusinessGroupRules") @GetMapping("getBusinessGroupRules") // TODO 扫描规则进行回收操作
@ApiOperation(value = "获取业务组公海规则", httpMethod = "GET", notes = "接口发布说明") @ApiOperation(value = "获取业务组公海规则", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getBusinessGroupRules(@RequestParam Integer gid) { public Result<Object> getBusinessGroupRules(@RequestParam Integer gid) {
List<CrmSeaRule> crmSeaRules = CrmSeaRule.builder().build() List<CrmSeaRule> crmSeaRules = CrmSeaRule.builder().build()
...@@ -210,20 +236,85 @@ public class CrmController { ...@@ -210,20 +236,85 @@ public class CrmController {
crmClientContact.insert(); crmClientContact.insert();
} }
crmClientData.setContactsNum(crmClientContacts.size()); crmClientData.setContactsNum(crmClientContacts.size());
crmClientData.deleteById(); crmClientData.updateById();
return ResultUtil.success("新增成功"); return ResultUtil.success("新增成功");
} }
@PostMapping("editClient")
@Transactional
@ApiOperation(value = "编辑客户", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> editClient(@CurrentUser UserBean userBean, @RequestBody CrmClientData crmClientData) {
Integer cid = crmClientData.getId();
if (cid == null)
return ResultUtil.error("请传入id再试");
CrmClientData oldData = CrmClientData.builder().id(cid).build().selectById();
if (oldData == null)
return ResultUtil.error("请确认该客户数据是否存在");
if (oldData.getClientStatus() == 5)
return ResultUtil.error("请解封后继续编辑操作");
List<CrmClientContacts> crmClientContacts = crmClientData.getCrmClientContacts();
for (CrmClientContacts crmClientContact : crmClientContacts) {
crmClientContact.updateById();
}
List<CrmClientAssociate> oldAssociates = CrmClientAssociate.builder().build()
.selectList(new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getCid, cid));
List<Integer> oldIdsList = oldAssociates.stream().map(CrmClientAssociate::getAssociateId)
.collect(Collectors.toList()); // 旧协助人list
Integer[] ids = crmClientData.getIds();
List<Integer> newIdsList = CollUtil.newArrayList(ids); // 新协助人list
List<Integer> delList = CheckUtil.reduce(oldIdsList, newIdsList); // 要删的协助人
for (Integer id : delList) {
CrmClientAssociate.builder().build().delete(new QueryWrapper<CrmClientAssociate>().lambda()
.eq(CrmClientAssociate::getCid, cid).eq(CrmClientAssociate::getAssociateId, id));
}
List<Integer> addList = CheckUtil.reduce(newIdsList, oldIdsList); // 要加的协助人
for (Integer id : addList) {
CrmClientAssociate.builder().cid(cid).associateId(id).build().insert();
}
crmClientData.setModifyUser(getEmpNum(userBean));
if (crmClientData.updateById())
return ResultUtil.success("编辑成功");
return ResultUtil.error("编辑失败");
}
@GetMapping("getClientAssociate")
@ApiOperation(value = "获取协作人列表", httpMethod = "GET", notes = "接口发布说明")
public Result<List<Map<String, Object>>> getClientAssociate(@CurrentUser UserBean userBean,
@RequestParam Integer cid) {
List<CrmClientAssociate> crmClientAssociates = CrmClientAssociate.builder().build()
.selectList(new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getCid, cid));
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
for (CrmClientAssociate crmClientAssociate : crmClientAssociates) {
Integer orgCode = crmClientAssociate.getOrgCode();
Integer empNum = crmClientAssociate.getAssociateId();
YgglMainEmp ygglMainEmp = getYg(orgCode, empNum);
String name = ygglMainEmp.getName();
String headUrl = ygglMainEmp.getHeadUrl();
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
map.put("empNum", empNum);
map.put("headUrl", headUrl);
list.add(map);
}
return ResultUtil.data(list, "获取成功");
}
// 归属我的客户 // 归属我的客户
private List<CrmClientData> getMyCilent(Integer empNum, Integer orgCode, Integer groupId, Integer status) { private List<CrmClientData> getMyCilent(Integer empNum, Integer orgCode, Integer groupId, Integer status,
return CrmClientData.builder().build().selectList(new QueryWrapper<CrmClientData>().lambda() String like) {
.eq(CrmClientData::getOrgCode, orgCode).eq(CrmClientData::getBelongUser, empNum) return CrmClientData.builder().build()
.eq(groupId != null, CrmClientData::getBelongGroup, groupId) .selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(status != null, CrmClientData::getClientStatus, status).orderByDesc(CrmClientData::getCreateTime)); .eq(CrmClientData::getBelongUser, empNum)
.eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId)
.eq(status != null && status >= 0, CrmClientData::getClientStatus, status)
.like(!StrUtil.isBlank(like), CrmClientData::getClientName, like).or()
.like(!StrUtil.isBlank(like), CrmClientData::getClientCellphone, like)
.orderByDesc(CrmClientData::getCreateTime));
} }
// 我协作的客户 // 我协作的客户
private List<CrmClientData> getMyAssociateCilent(Integer empNum, Integer orgCode, Integer groupId, Integer status) { private List<CrmClientData> getMyAssociateCilent(Integer empNum, Integer orgCode, Integer groupId, Integer status,
String like) {
List<CrmClientAssociate> crmClientAssociates = CrmClientAssociate.builder().build().selectList( List<CrmClientAssociate> crmClientAssociates = CrmClientAssociate.builder().build().selectList(
new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getAssociateId, empNum) new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getAssociateId, empNum)
.eq(CrmClientAssociate::getOrgCode, orgCode).select(CrmClientAssociate::getCid)); .eq(CrmClientAssociate::getOrgCode, orgCode).select(CrmClientAssociate::getCid));
...@@ -232,60 +323,97 @@ public class CrmController { ...@@ -232,60 +323,97 @@ public class CrmController {
Integer cid = crmClientAssociate.getCid(); Integer cid = crmClientAssociate.getCid();
CrmClientData crmClientData = CrmClientData.builder().build() CrmClientData crmClientData = CrmClientData.builder().build()
.selectOne(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getId, cid) .selectOne(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getId, cid)
.eq(groupId != null, CrmClientData::getBelongGroup, groupId) .eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId)
.eq(status != null, CrmClientData::getClientStatus, status)); .eq(status != null && status >= 0, CrmClientData::getClientStatus, status)
.like(!StrUtil.isBlank(like), CrmClientData::getClientName, like).or()
.like(!StrUtil.isBlank(like), CrmClientData::getClientCellphone, like));
myCrmClientAssociates.add(crmClientData); myCrmClientAssociates.add(crmClientData);
} }
return myCrmClientAssociates; return myCrmClientAssociates;
} }
// 我的全部客户 // 我的全部客户
private List<CrmClientData> getMyTotalCilent(Integer empNum, Integer orgCode, Integer groupId, Integer status) { private List<CrmClientData> getMyTotalCilent(Integer empNum, Integer orgCode, Integer groupId, Integer status,
return CheckUtil.distinct(getMyCilent(empNum, orgCode, groupId, status), String like) {
getMyAssociateCilent(empNum, orgCode, groupId, status), true); return CheckUtil.distinct(getMyCilent(empNum, orgCode, groupId, status, like),
getMyAssociateCilent(empNum, orgCode, groupId, status, like), true);
} }
// 我关注的客户 // 我关注的客户
private List<CrmClientData> getMyStarCilent(Integer empNum, Integer orgCode, Integer groupId, Integer status) { private List<CrmClientData> getMyStarCilent(Integer empNum, Integer orgCode, Integer groupId, Integer status) {
List<CrmClientData> crmClientDatas = getMyTotalCilent(empNum, orgCode, groupId, status); return getMyTotalCilent(empNum, orgCode, groupId, status, null).stream()
crmClientDatas.stream().filter(item -> item.getStar().equals(1)).findAny(); .filter(item -> item.getStar().equals(1)).collect(Collectors.toList());
return crmClientDatas;
} }
// 七天未跟进的客户 // 七天未跟进的客户
private List<CrmClientData> getCilentFollowOvertime(Integer empNum, Integer orgCode, Integer groupId, private List<CrmClientData> getCilentFollowOvertime(Integer empNum, Integer orgCode, Integer groupId,
Integer status) { Integer status) {
List<CrmClientData> crmClientDatas = getMyTotalCilent(empNum, orgCode, groupId, status); return getMyTotalCilent(empNum, orgCode, groupId, status, null).stream()
crmClientDatas.stream().filter(item -> item.getCreateTime().after(DateUtil.offsetHour(new Date(), -7))) .filter(item -> item.getLastFollowTime() != null
.findAny(); // TODO && item.getLastFollowTime().before(DateUtil.offsetDay(new Date(), -7)))
return crmClientDatas; .collect(Collectors.toList());
} }
@GetMapping("getMyCilentTotal") @GetMapping("getMyCilentTotal")
@ApiOperation(value = "获取我的客户列表(全)", httpMethod = "GET", notes = "接口发布说明") @ApiOperation(value = "获取我的客户列表(全)", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CrmClientData>> getMyCilentTotal(@CurrentUser UserBean userBean, public Result<List<CrmClientData>> getMyCilentTotal(@CurrentUser UserBean userBean,
@RequestParam(required = false, defaultValue = "0") Integer type, @RequestParam(required = false, defaultValue = "0") Integer type,
@RequestParam(required = false) Integer groupId, @RequestParam(required = false) Integer status) { @RequestParam(required = false) Integer groupId, @RequestParam(required = false) Integer status,
@RequestParam(required = false) String like) {
Integer empNum = getEmpNum(userBean); Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean); Integer orgCode = getOrgCode(userBean);
List<CrmClientData> crmClientDatas = null; List<CrmClientData> crmClientDatas = null;
if (type == null || type == 0) // 全部客户(去重) if (type == null || type == 0) // 全部客户(去重)
crmClientDatas = CheckUtil.distinct(getMyCilent(empNum, orgCode, groupId, status), crmClientDatas = CheckUtil.distinct(getMyCilent(empNum, orgCode, groupId, status, like),
getMyAssociateCilent(empNum, orgCode, groupId, status), true); getMyAssociateCilent(empNum, orgCode, groupId, status, like), true);
else if (type == 1) // 我负责的客户 else if (type == 1) // 我负责的客户
crmClientDatas = getMyCilent(empNum, orgCode, groupId, status); crmClientDatas = getMyCilent(empNum, orgCode, groupId, status, like);
else if (type == 2) // 我协作的客户 else if (type == 2) // 我协作的客户
crmClientDatas = getMyAssociateCilent(empNum, orgCode, groupId, status); crmClientDatas = getMyAssociateCilent(empNum, orgCode, groupId, status, like);
else if (type == 3) // 我关注的客户 else if (type == 3) // 我关注的客户
crmClientDatas = getMyStarCilent(empNum, orgCode, groupId, status); crmClientDatas = getMyStarCilent(empNum, orgCode, groupId, status);
else if (type == 4) // 七天未跟进的客户 else if (type == 4) // 七天未跟进的客户
crmClientDatas = getCilentFollowOvertime(empNum, orgCode, groupId, status); crmClientDatas = getCilentFollowOvertime(empNum, orgCode, groupId, status);
else else
; return ResultUtil.error("查询失败");
Collections.sort(crmClientDatas, Comparator.comparing(CrmClientData::getCreateTime).reversed()); // 按时间降序排序 Collections.sort(crmClientDatas, Comparator.comparing(CrmClientData::getCreateTime).reversed()); // 按时间降序排序
return ResultUtil.data(crmClientDatas, "查询成功"); return ResultUtil.data(crmClientDatas, "查询成功");
} }
@GetMapping("getSeaCilentTotal")
@ApiOperation(value = "获取公海客户列表(全)", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CrmClientData>> getSeaCilentTotal(@CurrentUser UserBean userBean,
@RequestParam(required = false) Integer type, @RequestParam(required = false) Integer groupId,
@RequestParam(required = false) Integer status, @RequestParam(required = false) String like) {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
// 当前用户加入的组
List<CrmBusinessGroupMember> members = CrmBusinessGroupMember.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupMember>().lambda()
.eq(CrmBusinessGroupMember::getEmpNum, empNum).eq(CrmBusinessGroupMember::getOrgCode, orgCode));
List<Integer> gids1 = members.stream().map(CrmBusinessGroupMember::getGid).collect(Collectors.toList());
// 当前用户管理的组
List<CrmBusinessGroupManager> managers = CrmBusinessGroupManager.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupManager>().lambda()
.eq(CrmBusinessGroupManager::getEmpNum, empNum)
.eq(CrmBusinessGroupManager::getOrgCode, orgCode));
List<Integer> gids2 = managers.stream().map(CrmBusinessGroupManager::getGid).collect(Collectors.toList());
List<Integer> myGids = CheckUtil.distinct(gids1, gids2, true); // 当前用户所有业务组id
List<CrmClientData> crmClientDatas = new ArrayList<CrmClientData>();
for (Integer gid : myGids) {
crmClientDatas.add(CrmClientData.builder().build()
.selectOne(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getBelongGroup, gid)
.eq(CrmClientData::getBelongUser, 0)
.eq(type != null && type >= 0, CrmClientData::getClientType, type)
.eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId)
.eq(status != null && status >= 0, CrmClientData::getClientStatus, status)
.like(!StrUtil.isBlank(like), CrmClientData::getClientName, like).or()
.like(!StrUtil.isBlank(like), CrmClientData::getClientCellphone, like)));
} // TODO
return ResultUtil.data(crmClientDatas, "查询成功");
}
@PostMapping("addCilentLinkMan") @PostMapping("addCilentLinkMan")
@Transactional @Transactional
@ApiOperation(value = "新增/编辑客户联系人", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "新增/编辑客户联系人", httpMethod = "POST", notes = "接口发布说明")
...@@ -320,24 +448,42 @@ public class CrmController { ...@@ -320,24 +448,42 @@ public class CrmController {
} }
@PostMapping("addClientStar") @PostMapping("addOrCancelClientStar")
@ApiOperation(value = "新增客户收藏(仅归属人)", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "新增客户收藏/取消收藏(仅归属人)", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> addClientStar(@CurrentUser UserBean userBean, @RequestParam Integer cid) { public Result<Void> addOrCancelClientStar(@CurrentUser UserBean userBean, @RequestParam Integer cid) {
Integer empNum = getEmpNum(userBean); Integer empNum = getEmpNum(userBean);
CrmClientData crmClientData = CrmClientData.builder().id(cid).build().selectById(); CrmClientData crmClientData = CrmClientData.builder().id(cid).build().selectById();
if (crmClientData == null) if (crmClientData == null)
return ResultUtil.error("请确认该客户是否存在"); return ResultUtil.error("请确认该客户是否存在");
if (!crmClientData.getBelongUser().equals(empNum)) if (!crmClientData.getBelongUser().equals(empNum))
return ResultUtil.error("不是当前客户归属人"); return ResultUtil.error("不是当前客户归属人");
if (CrmClientData.builder().id(cid).star(1).build().updateById()) Integer star = crmClientData.getStar();
if (star == null || star == 0) {
crmClientData.setStar(1);
crmClientData.updateById();
return ResultUtil.success("收藏成功"); return ResultUtil.success("收藏成功");
return ResultUtil.error("收藏失败"); } else if (star == 1) {
crmClientData.setStar(0);
crmClientData.updateById();
return ResultUtil.success("取消收藏成功");
} else
return ResultUtil.error("失败");
} }
@PostMapping("addClientFollow") @PostMapping("addClientFollow")
@Transactional @Transactional
@ApiOperation(value = "新增跟进记录", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "新增跟进记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> addClientFollow(@CurrentUser UserBean userBean, @RequestBody CrmClientFollow crmClientFollow) { public Result<Void> addClientFollow(@CurrentUser UserBean userBean, @RequestBody CrmClientFollow crmClientFollow) {
Integer cid = crmClientFollow.getCid();
if (cid == null)
return ResultUtil.error("请传入id再试");
CrmClientData oldData = CrmClientData.builder().id(cid).build().selectById();
if (oldData == null)
return ResultUtil.error("请确认该客户数据是否存在");
if (oldData.getClientStatus() == 5)
return ResultUtil.error("请解封后继续编辑操作");
Integer orgCode = getOrgCode(userBean); Integer orgCode = getOrgCode(userBean);
Integer empNum = getEmpNum(userBean); Integer empNum = getEmpNum(userBean);
...@@ -358,6 +504,79 @@ public class CrmController { ...@@ -358,6 +504,79 @@ public class CrmController {
return ResultUtil.data(CrmClientFollow.builder().build().selectList(new QueryWrapper<CrmClientFollow>().lambda() return ResultUtil.data(CrmClientFollow.builder().build().selectList(new QueryWrapper<CrmClientFollow>().lambda()
.eq(CrmClientFollow::getOrgCode, orgCode).eq(CrmClientFollow::getCid, cid)), "获取成功"); .eq(CrmClientFollow::getOrgCode, orgCode).eq(CrmClientFollow::getCid, cid)), "获取成功");
} }
@PostMapping("addClientArchive")
@ApiOperation(value = "客户封档/解封", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> addClientArchive(@CurrentUser UserBean userBean, @RequestParam Integer cid) {
Integer empNum = getEmpNum(userBean);
CrmClientData crmClientData = CrmClientData.builder().id(cid).build().selectById();
if (crmClientData == null)
return ResultUtil.error("请确认该客户是否存在");
if (!crmClientData.getBelongUser().equals(empNum))
return ResultUtil.error("不是当前客户归属人");
Integer status = crmClientData.getClientStatus();
if (status != null && status != 5) {
crmClientData.setClientStatus(5);
crmClientData.updateById();
return ResultUtil.success("封档成功");
} else if (status == 5) {
crmClientData.setClientStatus(0); // 解封后默认无状态
crmClientData.updateById();
return ResultUtil.success("解封成功");
} else
return ResultUtil.error("失败");
}
@PostMapping("designateClientBelonger")
@ApiOperation(value = "指派客户归属人", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> designateClientBelonger(@CurrentUser UserBean userBean, @RequestParam Integer cid,
@RequestParam Integer belongUser) {
if (cid == null)
return ResultUtil.error("请传入id再试");
CrmClientData oldData = CrmClientData.builder().id(cid).build().selectById();
if (oldData == null)
return ResultUtil.error("请确认该客户数据是否存在");
if (!oldData.getBelongUser().equals(getEmpNum(userBean)))
return ResultUtil.error("不是当前客户归属人");
if (oldData.getClientStatus() == 5)
return ResultUtil.error("请解封后继续编辑操作");
Integer belongGroup = oldData.getBelongGroup();
CrmBusinessGroupMember crmBusinessGroupMember = CrmBusinessGroupMember.builder().build()
.selectOne(new QueryWrapper<CrmBusinessGroupMember>().lambda()
.eq(CrmBusinessGroupMember::getGid, belongGroup)
.eq(CrmBusinessGroupMember::getEmpNum, belongUser));
if (crmBusinessGroupMember == null)
return ResultUtil.error("指派失败,该用户不是本组成员");
if (CrmClientData.builder().id(cid).belongUser(belongUser)
.belongUserName(getEmpName(getOrgCode(userBean), belongUser)).build().updateById())
return ResultUtil.success("指派成功");
return ResultUtil.error("指派失败");
}
@PostMapping("freeClientToSea")
@Transactional
@ApiOperation(value = "释放客户到公海", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> freeClientToSea(@CurrentUser UserBean userBean, @RequestParam Integer cid) {
if (cid == null)
return ResultUtil.error("请传入id再试");
CrmClientData oldData = CrmClientData.builder().id(cid).build().selectById();
if (oldData == null)
return ResultUtil.error("请确认该客户数据是否存在");
if (!oldData.getBelongUser().equals(getEmpNum(userBean)))
return ResultUtil.error("不是当前客户归属人");
if (oldData.getClientStatus() == 5)
return ResultUtil.error("请解封后继续编辑操作");
oldData.setBelongUser(0); // 0-进入客户公海
oldData.setBelongUserName(null);
if (oldData.updateById() && CrmClientAssociate.builder().build()
.delete(new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getCid, cid)))
return ResultUtil.success("释放成功");
return ResultUtil.error("释放失败");
}
// TODO // TODO
} }
/**
* Title: CrmBusinessGroupManagerMapper.java
* Description:
* @author dsc
* @date 2020年6月9日
* @version 1.0
*/
package cn.timer.api.dao.crm;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.timer.api.bean.crm.CrmBusinessGroupManager;
/**
* Title: CrmBusinessGroupManagerMapper.java
*
* @Description:
* @author dsc
* @date 2020年6月9日
* @version 1.0
*/
public interface CrmBusinessGroupManagerMapper extends BaseMapper<CrmBusinessGroupManager> {
}
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