|
@@ -25,6 +25,7 @@ type CustomService struct {
|
|
EntId int64
|
|
EntId int64
|
|
AppId string
|
|
AppId string
|
|
AccountId int64
|
|
AccountId int64
|
|
|
|
+ EntDeptId int64
|
|
CustomType int64 //客户类型
|
|
CustomType int64 //客户类型
|
|
Summary string //概要信息
|
|
Summary string //概要信息
|
|
CustomAllName string //客户全称
|
|
CustomAllName string //客户全称
|
|
@@ -77,12 +78,12 @@ func (this *CustomService) Add(ctx context.Context) (int64, string) {
|
|
baseUserIdArr = append(baseUserIdArr, resp.UserId)
|
|
baseUserIdArr = append(baseUserIdArr, resp.UserId)
|
|
}
|
|
}
|
|
|
|
|
|
- //客户
|
|
|
|
|
|
+ //客户3
|
|
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)
|
|
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.EntId, this.CustomAllName+"的跟进任务", 3, this.PositionId, 1, nowtime, 1, 0, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime), nil, nil)
|
|
argsTask = append(argsTask, this.EntId, this.CustomAllName+"的跟进任务", 3, this.PositionId, 1, nowtime, 1, 0, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime), nil, nil)
|
|
|
|
|
|
- customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName, transferArr)
|
|
|
|
|
|
+ customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName, transferArr, this.EntId, this.EntUserId, this.EntDeptId)
|
|
if customId < 0 {
|
|
if customId < 0 {
|
|
return -1, groupId
|
|
return -1, groupId
|
|
}
|
|
}
|
|
@@ -94,7 +95,7 @@ func (this *CustomService) Add(ctx context.Context) (int64, string) {
|
|
//任务团队
|
|
//任务团队
|
|
argsTaskTeam = append(argsTaskTeam, this.PositionId, this.EntUserId, this.CreateName, 1, nowtime)
|
|
argsTaskTeam = append(argsTaskTeam, this.PositionId, this.EntUserId, this.CreateName, 1, nowtime)
|
|
//存库
|
|
//存库
|
|
- customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName, []int64{})
|
|
|
|
|
|
+ customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName, []int64{}, this.EntId, this.EntUserId, this.EntDeptId)
|
|
if customId < 0 {
|
|
if customId < 0 {
|
|
return -1, groupId
|
|
return -1, groupId
|
|
}
|
|
}
|
|
@@ -148,7 +149,8 @@ func SaleCustomAdd(tx *sql.Tx, args []interface{}) int64 {
|
|
}
|
|
}
|
|
|
|
|
|
//EmployUpdate 是否创建线索/机会/客户修改
|
|
//EmployUpdate 是否创建线索/机会/客户修改
|
|
-func EmployUpdate(tx *sql.Tx, employ_info_id, employ_custom_id, positionId int64, key string) bool {
|
|
|
|
|
|
+func EmployUpdate(tx *sql.Tx, employ_info_id, employ_custom_id, positionId int64, key string, entId, entUserId, entDeptId int64) bool {
|
|
|
|
+ ok := true
|
|
tablename := ""
|
|
tablename := ""
|
|
id := int64(0)
|
|
id := int64(0)
|
|
if employ_custom_id > 0 {
|
|
if employ_custom_id > 0 {
|
|
@@ -159,12 +161,44 @@ func EmployUpdate(tx *sql.Tx, employ_info_id, employ_custom_id, positionId int64
|
|
id = employ_info_id
|
|
id = employ_info_id
|
|
}
|
|
}
|
|
if tablename == "" || id == 0 {
|
|
if tablename == "" || id == 0 {
|
|
- return true
|
|
|
|
|
|
+ return ok
|
|
|
|
+ }
|
|
|
|
+ //判断该条信息是不是当前资讯分配员的
|
|
|
|
+ d := cm.CrmMysql.SelectBySqlByTx(tx, fmt.Sprintf(`select * from %v where id = ?`, tablename), id)
|
|
|
|
+ if d != nil && len(*d) > 0 {
|
|
|
|
+ data := (*d)[0]
|
|
|
|
+ position_id := gconv.Int64(data["position_id"])
|
|
|
|
+ if position_id == positionId {
|
|
|
|
+ return cm.CrmMysql.UpdateByTx(tx, tablename, map[string]interface{}{"id": id, "position_id": positionId}, map[string]interface{}{key: 1})
|
|
|
|
+ } else {
|
|
|
|
+ data["position_id"] = positionId
|
|
|
|
+ data["ent_id"] = entId
|
|
|
|
+ data["ent_dept_id"] = entDeptId
|
|
|
|
+ data["ent_user_id"] = entUserId
|
|
|
|
+ //当前咨询不是分配员的 创建该条
|
|
|
|
+ if employ_custom_id > 0 {
|
|
|
|
+ //
|
|
|
|
+ data["is_handle"] = 1
|
|
|
|
+ data["is_ignore"] = 0
|
|
|
|
+ data["is_create_custom"] = 1
|
|
|
|
+
|
|
|
|
+ } else if employ_info_id > 0 {
|
|
|
|
+ data["is_handle"] = 1
|
|
|
|
+ data["is_ignore"] = 0
|
|
|
|
+ data["is_dis"] = 0
|
|
|
|
+ data[key] = 1
|
|
|
|
+ for _, v := range GetOtherKey(key) {
|
|
|
|
+ data[v] = 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ delete(data, "id")
|
|
|
|
+ return cm.CrmMysql.InsertByTx(tx, tablename, data) > 0
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return cm.CrmMysql.UpdateByTx(tx, tablename, map[string]interface{}{"id": id, "position_id": positionId}, map[string]interface{}{key: 1})
|
|
|
|
|
|
+ return ok
|
|
}
|
|
}
|
|
|
|
|
|
-func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id, positionId int64, createPerson string, transferArr []int64) (int64, int64) {
|
|
|
|
|
|
+func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id, positionId int64, createPerson string, transferArr []int64, entId, entUserId, entDeptId int64) (int64, int64) {
|
|
customId := int64(-1)
|
|
customId := int64(-1)
|
|
taskId := int64(-1)
|
|
taskId := int64(-1)
|
|
//存库
|
|
//存库
|
|
@@ -175,7 +209,7 @@ func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interf
|
|
argsTask = append(argsTask, customId)
|
|
argsTask = append(argsTask, customId)
|
|
//任务车存储
|
|
//任务车存储
|
|
taskId = TaskAdd(tx, argsTask, argsTaskTeam, transferArr, positionId)
|
|
taskId = TaskAdd(tx, argsTask, argsTaskTeam, transferArr, positionId)
|
|
- ok := EmployUpdate(tx, employ_info_id, employ_custom_id, positionId, "is_create_custom")
|
|
|
|
|
|
+ ok := EmployUpdate(tx, employ_info_id, employ_custom_id, positionId, "is_create_custom", entId, entUserId, entDeptId)
|
|
//插入台账
|
|
//插入台账
|
|
ok2 := SaveLedger(ctx, positionId, customId, taskId, "创建客户", fmt.Sprintf("%s创建了客户", createPerson), createPerson)
|
|
ok2 := SaveLedger(ctx, positionId, customId, taskId, "创建客户", fmt.Sprintf("%s创建了客户", createPerson), createPerson)
|
|
if customId > 0 && taskId > 0 && ok && ok2 {
|
|
if customId > 0 && taskId > 0 && ok && ok2 {
|
|
@@ -209,3 +243,12 @@ func SaveLedger(ctx context.Context, positionId, businessId, taskId int64, types
|
|
}
|
|
}
|
|
return resp.State
|
|
return resp.State
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func GetOtherKey(key string) []string {
|
|
|
|
+ parameters := map[string][]string{
|
|
|
|
+ "is_create_clue": []string{"is_create_chance", "is_create_custom"},
|
|
|
|
+ "is_create_chance": []string{"is_create_clue", "is_create_custom"},
|
|
|
|
+ "is_create_custom": []string{"is_create_chance", "is_create_clue"},
|
|
|
|
+ }
|
|
|
|
+ return parameters[key]
|
|
|
|
+}
|