|
@@ -46,6 +46,8 @@ type CustomService struct {
|
|
Remarks string //备注
|
|
Remarks string //备注
|
|
CreateName string //创建人
|
|
CreateName string //创建人
|
|
Source string
|
|
Source string
|
|
|
|
+ OwnerId int64 //潜客收录id(人脉)
|
|
|
|
+ BusinessId int64 //商机收录id(人脉)
|
|
}
|
|
}
|
|
|
|
|
|
// Add 创建客户
|
|
// Add 创建客户
|
|
@@ -79,22 +81,22 @@ func (this *CustomService) Add(ctx context.Context) (int64, string) {
|
|
baseUserIdArr = append(baseUserIdArr, resp.UserId)
|
|
baseUserIdArr = append(baseUserIdArr, resp.UserId)
|
|
}
|
|
}
|
|
//客户
|
|
//客户
|
|
- 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, this.Source)
|
|
|
|
|
|
+ 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, this.Source, this.OwnerId, this.BusinessId)
|
|
//任务
|
|
//任务
|
|
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, this.EntId, this.EntUserId, this.EntDeptId)
|
|
|
|
|
|
+ customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.OwnerId, this.BusinessId, this.PositionId, this.CreateName, transferArr, this.EntId, this.EntUserId, this.EntDeptId)
|
|
if customId < 0 {
|
|
if customId < 0 {
|
|
return -1, groupId
|
|
return -1, groupId
|
|
}
|
|
}
|
|
} else if this.Types == 1 {
|
|
} 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, this.Source)
|
|
|
|
|
|
+ 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, this.Source, this.OwnerId, this.BusinessId)
|
|
//任务s
|
|
//任务s
|
|
argsTask = append(argsTask, this.EntId, this.CustomAllName+"的跟进任务", 3, this.PositionId, 2, nowtime, 1, 0, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime), nil, nil)
|
|
argsTask = append(argsTask, this.EntId, this.CustomAllName+"的跟进任务", 3, this.PositionId, 2, nowtime, 1, 0, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime), nil, nil)
|
|
//任务团队
|
|
//任务团队
|
|
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{}, this.EntId, this.EntUserId, this.EntDeptId)
|
|
|
|
|
|
+ customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.OwnerId, this.BusinessId, this.PositionId, this.CreateName, []int64{}, this.EntId, this.EntUserId, this.EntDeptId)
|
|
if customId < 0 {
|
|
if customId < 0 {
|
|
return -1, groupId
|
|
return -1, groupId
|
|
}
|
|
}
|
|
@@ -114,10 +116,10 @@ func (this *CustomService) Add(ctx context.Context) (int64, string) {
|
|
transferArr := []int64{}
|
|
transferArr := []int64{}
|
|
transferArr = append(transferArr, this.PositionId)
|
|
transferArr = append(transferArr, this.PositionId)
|
|
//客户
|
|
//客户
|
|
- 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, this.Source)
|
|
|
|
|
|
+ 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, this.Source, this.OwnerId, this.BusinessId)
|
|
//任务
|
|
//任务
|
|
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, this.EntId, this.EntUserId, this.EntDeptId)
|
|
|
|
|
|
+ customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.OwnerId, this.BusinessId, this.PositionId, this.CreateName, transferArr, this.EntId, this.EntUserId, this.EntDeptId)
|
|
if customId < 0 {
|
|
if customId < 0 {
|
|
return -1, groupId
|
|
return -1, groupId
|
|
}
|
|
}
|
|
@@ -151,7 +153,7 @@ func (this *CustomService) Add(ctx context.Context) (int64, string) {
|
|
}
|
|
}
|
|
|
|
|
|
func SaleCustomAdd(tx *sql.Tx, args []interface{}) int64 {
|
|
func SaleCustomAdd(tx *sql.Tx, args []interface{}) int64 {
|
|
- fields := []string{"position_id", "ent_id", "ent_user_id", "employ_info_id", "employ_custom_id", "type", "full_name", "sort_name", "summary", "level", "industry", "subdivision_industry", "province", "city", "county", "address", "phone", "remark", "create_person", "create_time", "source"}
|
|
|
|
|
|
+ fields := []string{"position_id", "ent_id", "ent_user_id", "employ_info_id", "employ_custom_id", "type", "full_name", "sort_name", "summary", "level", "industry", "subdivision_industry", "province", "city", "county", "address", "phone", "remark", "create_person", "create_time", "source", "connection_owner_id", "connection_business_id"}
|
|
_, id := cm.CrmMysql.InsertBatchByTx(tx, entity.CUSTOM, fields, args)
|
|
_, id := cm.CrmMysql.InsertBatchByTx(tx, entity.CUSTOM, fields, args)
|
|
return id
|
|
return id
|
|
}
|
|
}
|
|
@@ -227,7 +229,7 @@ func EmployUpdate(tx *sql.Tx, employ_info_id, employ_custom_id, positionId int64
|
|
return employ_info_id, employ_custom_id
|
|
return employ_info_id, employ_custom_id
|
|
}
|
|
}
|
|
|
|
|
|
-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) {
|
|
|
|
|
|
+func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id, ownerId, connectionBusinessId, positionId int64, createPerson string, transferArr []int64, entId, entUserId, entDeptId int64) (int64, int64) {
|
|
customId := int64(-1)
|
|
customId := int64(-1)
|
|
taskId := int64(-1)
|
|
taskId := int64(-1)
|
|
//存库
|
|
//存库
|
|
@@ -247,6 +249,10 @@ func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interf
|
|
taskId = TaskAdd(tx, argsTask, argsTaskTeam, transferArr, positionId)
|
|
taskId = TaskAdd(tx, argsTask, argsTaskTeam, transferArr, positionId)
|
|
//插入台账
|
|
//插入台账
|
|
ok2 := SaveLedger(ctx, positionId, customId, taskId, "创建客户", fmt.Sprintf("%s创建了客户", createPerson), createPerson)
|
|
ok2 := SaveLedger(ctx, positionId, customId, taskId, "创建客户", fmt.Sprintf("%s创建了客户", createPerson), createPerson)
|
|
|
|
+ //人脉信息添加
|
|
|
|
+ if ownerId != 0 || connectionBusinessId != 0 {
|
|
|
|
+ SaveConnection(tx, positionId, connectionBusinessId, ownerId, entId, entDeptId, entUserId)
|
|
|
|
+ }
|
|
if customId > 0 && taskId > 0 && ok2 {
|
|
if customId > 0 && taskId > 0 && ok2 {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
@@ -323,3 +329,45 @@ func GetOtherKey(key string) []string {
|
|
}
|
|
}
|
|
return parameters[key]
|
|
return parameters[key]
|
|
}
|
|
}
|
|
|
|
+func SaveConnection(tx *sql.Tx, positionId, businessId, ownerId, entId, entDeptId, entUserId int64) bool {
|
|
|
|
+ if businessId != 0 || ownerId != 0 {
|
|
|
|
+ table := entity.CONNECTION_BUSINESS_INFO
|
|
|
|
+ key := "business_id"
|
|
|
|
+ key1 := "is_create_chancis_create_chance"
|
|
|
|
+ if businessId == 0 {
|
|
|
|
+ businessId = ownerId
|
|
|
|
+ table = entity.CONNECTION_OWNER_INFO
|
|
|
|
+ key = "owner_id"
|
|
|
|
+ key1 = "is_create_custom"
|
|
|
|
+ }
|
|
|
|
+ if cm.CrmMysql.Count(table, map[string]interface{}{
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ key: businessId,
|
|
|
|
+ }) > 0 {
|
|
|
|
+ cm.CrmMysql.UpdateByTx(tx, table, map[string]interface{}{
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ key: businessId,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "is_handle": 1,
|
|
|
|
+ key1: 1,
|
|
|
|
+ "update_time": time.Now().Format(date.Date_Full_Layout),
|
|
|
|
+ "updater": positionId,
|
|
|
|
+ })
|
|
|
|
+ return true
|
|
|
|
+ } else {
|
|
|
|
+ id := cm.CrmMysql.InsertByTx(tx, entity.CONNECTION_BUSINESS_INFO, map[string]interface{}{
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "ent_id": entId,
|
|
|
|
+ "ent_dept_id": entDeptId,
|
|
|
|
+ "ent_user_id": entUserId,
|
|
|
|
+ key: businessId,
|
|
|
|
+ "is_handle": 1,
|
|
|
|
+ key1: 1,
|
|
|
|
+ "create_time": positionId,
|
|
|
|
+ "creator": positionId,
|
|
|
|
+ })
|
|
|
|
+ return id > 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+}
|