Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
43b69972
Commit
43b69972
authored
Jun 09, 2020
by
邓实川
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
业务组接口,我的客户接口,公海接口,其他接口
parent
5e43804a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
367 additions
and
49 deletions
+367
-49
src/main/java/cn/timer/api/bean/crm/CrmBusinessGroup.java
+19
-7
src/main/java/cn/timer/api/bean/crm/CrmBusinessGroupManager.java
+60
-0
src/main/java/cn/timer/api/bean/crm/CrmBusinessGroupMember.java
+3
-0
src/main/java/cn/timer/api/bean/crm/CrmClientData.java
+1
-1
src/main/java/cn/timer/api/controller/crm/CrmController.java
+260
-41
src/main/java/cn/timer/api/dao/crm/CrmBusinessGroupManagerMapper.java
+24
-0
No files found.
src/main/java/cn/timer/api/bean/crm/CrmBusinessGroup.java
View file @
43b69972
...
...
@@ -8,6 +8,8 @@
package
cn
.
timer
.
api
.
bean
.
crm
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
...
...
@@ -60,12 +62,6 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
@ApiModelProperty
(
value
=
"业务组名称"
)
private
String
name
;
@ApiModelProperty
(
value
=
"业务组管理员empNum"
)
private
Integer
manager
;
@ApiModelProperty
(
value
=
"业务组管理员名称"
)
private
String
managerName
;
@ApiModelProperty
(
value
=
"创建时间"
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
...
...
@@ -85,8 +81,18 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
@Transient
@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"
)
private
Integer
[]
i
ds
;
private
Integer
[]
memberI
ds
;
@Transient
@TableField
(
exist
=
false
)
...
...
@@ -98,4 +104,10 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
//
// @ApiModelProperty(value = "组成员姓名")
// private String memberName;
// @ApiModelProperty(value = "业务组管理员empNum")
// private Integer manager;
//
// @ApiModelProperty(value = "业务组管理员名称")
// private String managerName;
}
src/main/java/cn/timer/api/bean/crm/CrmBusinessGroupManager.java
0 → 100644
View file @
43b69972
/**
* 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
;
}
src/main/java/cn/timer/api/bean/crm/CrmBusinessGroupMember.java
View file @
43b69972
...
...
@@ -53,4 +53,7 @@ public class CrmBusinessGroupMember extends Model<CrmBusinessGroupMember>{
@ApiModelProperty
(
value
=
"员工id"
)
private
Integer
empNum
;
@ApiModelProperty
(
value
=
"企业id"
)
private
Integer
orgCode
;
}
src/main/java/cn/timer/api/bean/crm/CrmClientData.java
View file @
43b69972
...
...
@@ -108,7 +108,7 @@ public class CrmClientData extends Model<CrmClientData> {
@ApiModelProperty
(
value
=
"备注"
)
private
String
remarks
;
@ApiModelProperty
(
value
=
"客户所属(创建人empNum)"
)
@ApiModelProperty
(
value
=
"客户所属(创建人empNum)
0-进入客户公海
"
)
private
Integer
belongUser
;
@ApiModelProperty
(
value
=
"客户所属人姓名"
)
...
...
src/main/java/cn/timer/api/controller/crm/CrmController.java
View file @
43b69972
...
...
@@ -11,7 +11,10 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
...
...
@@ -24,12 +27,15 @@ import org.springframework.web.bind.annotation.RestController;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
cn.hutool.core.collection.CollUtil
;
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.ClientTypeClass
;
import
cn.timer.api.bean.clazz.IndustryClass
;
import
cn.timer.api.bean.clazz.SysRegion
;
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.CrmClientAssociate
;
import
cn.timer.api.bean.crm.CrmClientContacts
;
...
...
@@ -69,8 +75,9 @@ public class CrmController {
}
private
YgglMainEmp
getYg
(
Integer
orgCode
,
Integer
empNum
)
{
return
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
()
.
eq
(
YgglMainEmp:
:
getEmpNum
,
empNum
).
eq
(
YgglMainEmp:
:
getOrgCode
,
orgCode
).
select
(
YgglMainEmp:
:
getName
));
return
YgglMainEmp
.
builder
().
build
()
.
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
)
{
...
...
@@ -111,7 +118,7 @@ public class CrmController {
crmBusinessGroup
.
setSort
(
1
);
else
crmBusinessGroup
.
setSort
(
crmBusinessGroupOld
.
getSort
()
+
1
);
// 排序
crmBusinessGroup
.
setManagerName
(
getEmpName
(
orgCode
,
empNum
));
// 设置管理员姓名
//
crmBusinessGroup.setManagerName(getEmpName(orgCode, empNum)); // 设置管理员姓名
crmBusinessGroup
.
setCreateUser
(
empNum
);
// 创建人
crmBusinessGroup
.
setModifyUser
(
empNum
);
// 修改人
crmBusinessGroup
.
setOrgCode
(
orgCode
);
...
...
@@ -120,10 +127,15 @@ public class CrmController {
if
(!
result
)
return
ResultUtil
.
success
(
"新增失败"
);
Integer
gid
=
crmBusinessGroup
.
getId
();
Integer
[]
ids
=
crmBusinessGroup
.
get
Ids
();
for
(
Integer
empId
:
i
ds
)
{
CrmBusinessGroupMember
.
builder
().
gid
(
gid
).
empNum
(
empId
).
build
().
insert
();
Integer
[]
memberIds
=
crmBusinessGroup
.
getMember
Ids
();
for
(
Integer
empId
:
memberI
ds
)
{
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
.
setGid
(
gid
);
crmSeaRule
.
insert
();
...
...
@@ -133,12 +145,26 @@ public class CrmController {
@GetMapping
(
"getBusinessGroup"
)
@ApiOperation
(
value
=
"获取业务组列表"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
public
Result
<
Object
>
getBusinessGroup
(
@CurrentUser
UserBean
userBean
)
{
return
ResultUtil
.
data
(
CrmBusinessGroup
.
builder
().
build
()
List
<
CrmBusinessGroup
>
list
=
CrmBusinessGroup
.
builder
().
build
()
.
selectList
(
new
QueryWrapper
<
CrmBusinessGroup
>().
lambda
()
.
eq
(
CrmBusinessGroup:
:
getOrgCode
,
getOrgCode
(
userBean
)).
select
(
CrmBusinessGroup:
:
getId
,
CrmBusinessGroup:
:
getSort
,
CrmBusinessGroup:
:
getName
,
CrmBusinessGroup:
:
getManagerName
,
CrmBusinessGroup:
:
getModifyTime
)),
"获取成功"
);
CrmBusinessGroup:
:
getSort
,
CrmBusinessGroup:
:
getName
,
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"
)
...
...
@@ -153,7 +179,7 @@ public class CrmController {
return
ResultUtil
.
data
(
ygglMainEmps
,
"获取成功"
);
}
@GetMapping
(
"getBusinessGroupRules"
)
@GetMapping
(
"getBusinessGroupRules"
)
// TODO 扫描规则进行回收操作
@ApiOperation
(
value
=
"获取业务组公海规则"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
public
Result
<
Object
>
getBusinessGroupRules
(
@RequestParam
Integer
gid
)
{
List
<
CrmSeaRule
>
crmSeaRules
=
CrmSeaRule
.
builder
().
build
()
...
...
@@ -210,20 +236,85 @@ public class CrmController {
crmClientContact
.
insert
();
}
crmClientData
.
setContactsNum
(
crmClientContacts
.
size
());
crmClientData
.
dele
teById
();
crmClientData
.
upda
teById
();
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
)
{
return
CrmClientData
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
CrmClientData
>().
lambda
()
.
eq
(
CrmClientData:
:
getOrgCode
,
orgCode
).
eq
(
CrmClientData:
:
getBelongUser
,
empNum
)
.
eq
(
groupId
!=
null
,
CrmClientData:
:
getBelongGroup
,
groupId
)
.
eq
(
status
!=
null
,
CrmClientData:
:
getClientStatus
,
status
).
orderByDesc
(
CrmClientData:
:
getCreateTime
));
private
List
<
CrmClientData
>
getMyCilent
(
Integer
empNum
,
Integer
orgCode
,
Integer
groupId
,
Integer
status
,
String
like
)
{
return
CrmClientData
.
builder
().
build
()
.
selectList
(
new
QueryWrapper
<
CrmClientData
>().
lambda
().
eq
(
CrmClientData:
:
getOrgCode
,
orgCode
)
.
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
(
new
QueryWrapper
<
CrmClientAssociate
>().
lambda
().
eq
(
CrmClientAssociate:
:
getAssociateId
,
empNum
)
.
eq
(
CrmClientAssociate:
:
getOrgCode
,
orgCode
).
select
(
CrmClientAssociate:
:
getCid
));
...
...
@@ -232,60 +323,97 @@ public class CrmController {
Integer
cid
=
crmClientAssociate
.
getCid
();
CrmClientData
crmClientData
=
CrmClientData
.
builder
().
build
()
.
selectOne
(
new
QueryWrapper
<
CrmClientData
>().
lambda
().
eq
(
CrmClientData:
:
getId
,
cid
)
.
eq
(
groupId
!=
null
,
CrmClientData:
:
getBelongGroup
,
groupId
)
.
eq
(
status
!=
null
,
CrmClientData:
:
getClientStatus
,
status
));
.
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
));
myCrmClientAssociates
.
add
(
crmClientData
);
}
return
myCrmClientAssociates
;
}
// 我的全部客户
private
List
<
CrmClientData
>
getMyTotalCilent
(
Integer
empNum
,
Integer
orgCode
,
Integer
groupId
,
Integer
status
)
{
return
CheckUtil
.
distinct
(
getMyCilent
(
empNum
,
orgCode
,
groupId
,
status
),
getMyAssociateCilent
(
empNum
,
orgCode
,
groupId
,
status
),
true
);
private
List
<
CrmClientData
>
getMyTotalCilent
(
Integer
empNum
,
Integer
orgCode
,
Integer
groupId
,
Integer
status
,
String
like
)
{
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
)
{
List
<
CrmClientData
>
crmClientDatas
=
getMyTotalCilent
(
empNum
,
orgCode
,
groupId
,
status
);
crmClientDatas
.
stream
().
filter
(
item
->
item
.
getStar
().
equals
(
1
)).
findAny
();
return
crmClientDatas
;
return
getMyTotalCilent
(
empNum
,
orgCode
,
groupId
,
status
,
null
).
stream
()
.
filter
(
item
->
item
.
getStar
().
equals
(
1
)).
collect
(
Collectors
.
toList
());
}
// 七天未跟进的客户
private
List
<
CrmClientData
>
getCilentFollowOvertime
(
Integer
empNum
,
Integer
orgCode
,
Integer
groupId
,
Integer
status
)
{
List
<
CrmClientData
>
crmClientDatas
=
getMyTotalCilent
(
empNum
,
orgCode
,
groupId
,
status
);
crmClientDatas
.
stream
().
filter
(
item
->
item
.
getCreateTime
().
after
(
DateUtil
.
offsetHour
(
new
Date
(),
-
7
)))
.
findAny
();
// TODO
return
crmClientDatas
;
return
getMyTotalCilent
(
empNum
,
orgCode
,
groupId
,
status
,
null
).
stream
()
.
filter
(
item
->
item
.
getLastFollowTime
()
!=
null
&&
item
.
getLastFollowTime
().
before
(
DateUtil
.
offsetDay
(
new
Date
(),
-
7
)))
.
collect
(
Collectors
.
toList
())
;
}
@GetMapping
(
"getMyCilentTotal"
)
@ApiOperation
(
value
=
"获取我的客户列表(全)"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
public
Result
<
List
<
CrmClientData
>>
getMyCilentTotal
(
@CurrentUser
UserBean
userBean
,
@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
orgCode
=
getOrgCode
(
userBean
);
List
<
CrmClientData
>
crmClientDatas
=
null
;
if
(
type
==
null
||
type
==
0
)
// 全部客户(去重)
crmClientDatas
=
CheckUtil
.
distinct
(
getMyCilent
(
empNum
,
orgCode
,
groupId
,
status
),
getMyAssociateCilent
(
empNum
,
orgCode
,
groupId
,
status
),
true
);
crmClientDatas
=
CheckUtil
.
distinct
(
getMyCilent
(
empNum
,
orgCode
,
groupId
,
status
,
like
),
getMyAssociateCilent
(
empNum
,
orgCode
,
groupId
,
status
,
like
),
true
);
else
if
(
type
==
1
)
// 我负责的客户
crmClientDatas
=
getMyCilent
(
empNum
,
orgCode
,
groupId
,
status
);
crmClientDatas
=
getMyCilent
(
empNum
,
orgCode
,
groupId
,
status
,
like
);
else
if
(
type
==
2
)
// 我协作的客户
crmClientDatas
=
getMyAssociateCilent
(
empNum
,
orgCode
,
groupId
,
status
);
crmClientDatas
=
getMyAssociateCilent
(
empNum
,
orgCode
,
groupId
,
status
,
like
);
else
if
(
type
==
3
)
// 我关注的客户
crmClientDatas
=
getMyStarCilent
(
empNum
,
orgCode
,
groupId
,
status
);
else
if
(
type
==
4
)
// 七天未跟进的客户
crmClientDatas
=
getCilentFollowOvertime
(
empNum
,
orgCode
,
groupId
,
status
);
else
;
return
ResultUtil
.
error
(
"查询失败"
)
;
Collections
.
sort
(
crmClientDatas
,
Comparator
.
comparing
(
CrmClientData:
:
getCreateTime
).
reversed
());
// 按时间降序排序
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"
)
@Transactional
@ApiOperation
(
value
=
"新增/编辑客户联系人"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
...
...
@@ -320,24 +448,42 @@ public class CrmController {
}
@PostMapping
(
"addClientStar"
)
@ApiOperation
(
value
=
"新增客户收藏(仅归属人)"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
addClientStar
(
@CurrentUser
UserBean
userBean
,
@RequestParam
Integer
cid
)
{
@PostMapping
(
"add
OrCancel
ClientStar"
)
@ApiOperation
(
value
=
"新增客户收藏
/取消收藏
(仅归属人)"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
add
OrCancel
ClientStar
(
@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
(
"不是当前客户归属人"
);
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
.
error
(
"收藏失败"
);
}
else
if
(
star
==
1
)
{
crmClientData
.
setStar
(
0
);
crmClientData
.
updateById
();
return
ResultUtil
.
success
(
"取消收藏成功"
);
}
else
return
ResultUtil
.
error
(
"失败"
);
}
@PostMapping
(
"addClientFollow"
)
@Transactional
@ApiOperation
(
value
=
"新增跟进记录"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
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
empNum
=
getEmpNum
(
userBean
);
...
...
@@ -358,6 +504,79 @@ public class CrmController {
return
ResultUtil
.
data
(
CrmClientFollow
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
CrmClientFollow
>().
lambda
()
.
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
}
src/main/java/cn/timer/api/dao/crm/CrmBusinessGroupManagerMapper.java
0 → 100644
View file @
43b69972
/**
* 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
>
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment