|
@@ -9,12 +9,10 @@ import (
|
|
|
|
|
|
qu "app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
|
cm "bp.jydev.jianyu360.cn/CRM/application/api/common"
|
|
|
"bp.jydev.jianyu360.cn/CRM/application/entity"
|
|
|
baseC "bp.jydev.jianyu360.cn/CRM/baseCenter/rpc/pb"
|
|
|
- "github.com/gogf/gf/v2/util/gconv"
|
|
|
)
|
|
|
|
|
|
//客户相关
|
|
@@ -23,25 +21,25 @@ type CustomService struct {
|
|
|
PositionId int64
|
|
|
EntUserId int64
|
|
|
EntId int64
|
|
|
- CustomType int64 //客户类型
|
|
|
- Summary string //概要信息
|
|
|
- CustomAllName string //客户全称
|
|
|
- CustomAbbreviation string //客户简称
|
|
|
- CustomLevel int64 //客户级别
|
|
|
- CustomIndustry int64 //客户行业
|
|
|
- CustomDetailIndustry int64 //客户细分行业
|
|
|
- Province string //省份
|
|
|
- City string //城市
|
|
|
- District string //地区
|
|
|
- Address string //详细地址
|
|
|
- CompanyPhone string //公司电话
|
|
|
- NextfollowUpTime int64 //下次跟进时间戳
|
|
|
- Types int64 //处理方式 1自办;2转办
|
|
|
- User []string //转办用户
|
|
|
- EmployCustomId int64 //客户收录id
|
|
|
- EmployInfoId int64 //资讯收录id
|
|
|
- Remarks string //备注
|
|
|
- CreateName string //创建人
|
|
|
+ CustomType int64 //客户类型
|
|
|
+ Summary string //概要信息
|
|
|
+ CustomAllName string //客户全称
|
|
|
+ CustomAbbreviation string //客户简称
|
|
|
+ CustomLevel int64 //客户级别
|
|
|
+ CustomIndustry int64 //客户行业
|
|
|
+ CustomDetailIndustry int64 //客户细分行业
|
|
|
+ Province string //省份
|
|
|
+ City string //城市
|
|
|
+ District string //地区
|
|
|
+ Address string //详细地址
|
|
|
+ CompanyPhone string //公司电话
|
|
|
+ NextfollowUpTime int64 //下次跟进时间戳
|
|
|
+ Types int64 //处理方式 1自办;2转办
|
|
|
+ User []int64 //转办用户
|
|
|
+ EmployCustomId int64 //客户收录id
|
|
|
+ EmployInfoId int64 //资讯收录id
|
|
|
+ Remarks string //备注
|
|
|
+ CreateName string //创建人
|
|
|
}
|
|
|
|
|
|
//Add 创建客户
|
|
@@ -50,12 +48,13 @@ func (this *CustomService) Add(ctx context.Context) int64 {
|
|
|
nextFollowTime := time.Unix(this.NextfollowUpTime, 0).Format(date.Date_Full_Layout)
|
|
|
args := []interface{}{}
|
|
|
argsTask := []interface{}{}
|
|
|
+ argsTaskTeam := []interface{}{}
|
|
|
//判断处理方式
|
|
|
//转办
|
|
|
if this.Types == 2 {
|
|
|
+ transferArr := []int64{}
|
|
|
for _, v := range this.User {
|
|
|
- entuserid := encrypt.SE.Decode4Hex(v)
|
|
|
- i_entuserid := gconv.Int64(entuserid)
|
|
|
+ i_entuserid := v
|
|
|
resp, err := cm.UserCenterRpc.IdentityByEntUserId(ctx, &pb.IdentityReq{
|
|
|
Id: i_entuserid,
|
|
|
})
|
|
@@ -66,23 +65,26 @@ func (this *CustomService) Add(ctx context.Context) int64 {
|
|
|
log.Println("entuser用户", i_entuserid, "没有找到职位信息")
|
|
|
return 0
|
|
|
}
|
|
|
- positionid := resp.PositionId
|
|
|
- //线索
|
|
|
- //args = append(args, positionid, this.EntId, i_entuserid, this.EmployInfoId, this.EmployCustomId, this.Types, this.CustomAllName, this.CustomAbbreviation, this.Summary, this.CustomLevel, this.CustomIndustry, this.CustomDetailIndustry, this.Province, this.City, this.District, this.Address, this.CompanyPhone, this.Remarks, nowtime)
|
|
|
- //任务
|
|
|
- //argsTask = append(argsTask, positionid, this.EntId, this.EntUserId, this.ClueName+"的跟进任务", this.CluesSource, this.EmployInfoId, positionid, 1, this.PositionId, nowtime, 1)
|
|
|
+ transferArr = append(transferArr, resp.PositionId)
|
|
|
+ }
|
|
|
|
|
|
- if !SaveCustom(ctx, args, argsTask, this.EmployInfoId, this.EmployCustomId, positionid, this.CreateName) {
|
|
|
- return 0
|
|
|
- }
|
|
|
+ //客户
|
|
|
+ args = append(args, this.PositionId, this.EntId, this.EntUserId, this.EmployInfoId, this.EmployCustomId, this.CustomType, this.CustomAllName, this.CustomAbbreviation, this.Summary, qu.If(this.CustomLevel == 0, nil, this.CustomLevel), this.CustomIndustry, this.CustomDetailIndustry, qu.If(this.Province == "", nil, this.Province), qu.If(this.City == "", nil, this.City), qu.If(this.District == "", nil, this.District), qu.If(this.Address == "", nil, this.Address), qu.If(this.CompanyPhone == "", nil, this.CompanyPhone), qu.If(this.Remarks == "", nil, this.Remarks), this.CreateName, nowtime)
|
|
|
+ //任务
|
|
|
+ argsTask = append(argsTask, this.PositionId, this.EntId, this.EntUserId, this.CustomAllName+"的跟进任务", 3, this.PositionId, 1, nowtime, 1, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime))
|
|
|
+
|
|
|
+ if !SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName, transferArr) {
|
|
|
+ return 0
|
|
|
}
|
|
|
} else if this.Types == 1 {
|
|
|
//客户
|
|
|
args = append(args, this.PositionId, this.EntId, this.EntUserId, this.EmployInfoId, this.EmployCustomId, this.CustomType, this.CustomAllName, this.CustomAbbreviation, this.Summary, qu.If(this.CustomLevel == 0, nil, this.CustomLevel), this.CustomIndustry, this.CustomDetailIndustry, qu.If(this.Province == "", nil, this.Province), qu.If(this.City == "", nil, this.City), qu.If(this.District == "", nil, this.District), qu.If(this.Address == "", nil, this.Address), qu.If(this.CompanyPhone == "", nil, this.CompanyPhone), qu.If(this.Remarks == "", nil, this.Remarks), this.CreateName, nowtime)
|
|
|
//任务
|
|
|
argsTask = append(argsTask, this.PositionId, this.EntId, this.EntUserId, this.CustomAllName+"的跟进任务", 3, this.PositionId, 1, nowtime, 1, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime))
|
|
|
+ //任务团队
|
|
|
+ argsTaskTeam = append(argsTaskTeam, this.PositionId, this.EntUserId, this.CreateName, 1, nowtime)
|
|
|
//存库
|
|
|
- if !SaveCustom(ctx, args, argsTask, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName) {
|
|
|
+ if !SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName, []int64{}) {
|
|
|
return 0
|
|
|
}
|
|
|
}
|
|
@@ -114,7 +116,7 @@ func CustomUpdate(tx *sql.Tx, employ_info_id, employ_custom_id, positionId int64
|
|
|
return cm.CrmMysql.UpdateByTx(tx, tablename, map[string]interface{}{"id": id, "position_id": positionId}, map[string]interface{}{"is_create_custom": 1})
|
|
|
}
|
|
|
|
|
|
-func SaveCustom(ctx context.Context, argsCustom, argsTask []interface{}, employ_info_id, employ_custom_id, positionId int64, createPerson string) bool {
|
|
|
+func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id, positionId int64, createPerson string, transferArr []int64) bool {
|
|
|
//存库
|
|
|
return cm.CrmMysql.ExecTx("创建客户", func(tx *sql.Tx) bool {
|
|
|
//插入客户
|
|
@@ -122,7 +124,7 @@ func SaveCustom(ctx context.Context, argsCustom, argsTask []interface{}, employ_
|
|
|
//传过来的argTask没有来源id,需要append
|
|
|
argsTask = append(argsTask, customId)
|
|
|
//任务车存储
|
|
|
- taskId := TaskAdd(tx, argsTask)
|
|
|
+ taskId := TaskAdd(tx, argsTask, argsTaskTeam, transferArr, positionId)
|
|
|
ok := CustomUpdate(tx, employ_info_id, employ_custom_id, positionId)
|
|
|
//插入台账
|
|
|
ok2 := SaveLedger(ctx, positionId, customId, taskId, "创建客户", fmt.Sprintf("%s创建了客户", createPerson), createPerson)
|