|
@@ -86,7 +86,7 @@ func (this *SaleChanceService) Add(ctx context.Context) (int64, string) {
|
|
//任务
|
|
//任务
|
|
argsTask = append(argsTask, this.EntId, this.ChanceName+"的跟进任务", 2, this.PositionId, 1, nowtime, 1, 0, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime), this.BusinessType, stageId)
|
|
argsTask = append(argsTask, this.EntId, this.ChanceName+"的跟进任务", 2, this.PositionId, 1, nowtime, 1, 0, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime), this.BusinessType, stageId)
|
|
|
|
|
|
- chanceId, taskId = SaveChange(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.CustomId, this.PositionId, this.BusinessType, this.CreateName, transferArr, this.EntId, this.EntUserId, this.EntDeptId)
|
|
|
|
|
|
+ chanceId, taskId = this.SaveChange(ctx, args, argsTask, argsTaskTeam, []int64{})
|
|
|
|
|
|
if chanceId < 0 {
|
|
if chanceId < 0 {
|
|
return -1, groupId
|
|
return -1, groupId
|
|
@@ -99,7 +99,7 @@ func (this *SaleChanceService) 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)
|
|
//存库
|
|
//存库
|
|
- chanceId, taskId = SaveChange(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.CustomId, this.PositionId, this.BusinessType, this.CreateName, []int64{}, this.EntId, this.EntUserId, this.EntDeptId)
|
|
|
|
|
|
+ chanceId, taskId = this.SaveChange(ctx, args, argsTask, argsTaskTeam, []int64{})
|
|
if chanceId < 0 {
|
|
if chanceId < 0 {
|
|
return -1, groupId
|
|
return -1, groupId
|
|
}
|
|
}
|
|
@@ -151,16 +151,18 @@ func SaleChangeAdd(tx *sql.Tx, args []interface{}) int64 {
|
|
fields := []string{"position_id", "ent_id", "ent_user_id", "employ_info_id", "custom_id", "tpl_id", "name", "summary", "classify", "expect_deal_time", "expect_deal_amount", "remark", "create_time", "create_person", "source"}
|
|
fields := []string{"position_id", "ent_id", "ent_user_id", "employ_info_id", "custom_id", "tpl_id", "name", "summary", "classify", "expect_deal_time", "expect_deal_amount", "remark", "create_time", "create_person", "source"}
|
|
|
|
|
|
_, id := cm.CrmMysql.InsertBatchByTx(tx, entity.SALE_CHANCE, fields, args)
|
|
_, id := cm.CrmMysql.InsertBatchByTx(tx, entity.SALE_CHANCE, fields, args)
|
|
|
|
+ //
|
|
|
|
+
|
|
return id
|
|
return id
|
|
}
|
|
}
|
|
|
|
|
|
// Save 存库
|
|
// Save 存库
|
|
-func SaveChange(ctx context.Context, argsChange, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id, positionId, tplId int64, createName string, transferArr []int64, entId, entUserId, entDeptId int64) (int64, int64) {
|
|
|
|
|
|
+func (this *SaleChanceService) SaveChange(ctx context.Context, argsChange, argsTask, argsTaskTeam []interface{}, transferArr []int64) (int64, int64) {
|
|
//存库
|
|
//存库
|
|
changeId, taskId := int64(-1), int64(-1)
|
|
changeId, taskId := int64(-1), int64(-1)
|
|
cm.CrmMysql.ExecTx("创建机会", func(tx *sql.Tx) bool {
|
|
cm.CrmMysql.ExecTx("创建机会", func(tx *sql.Tx) bool {
|
|
//
|
|
//
|
|
- employ_info_id_new, _ := EmployUpdate(tx, employ_info_id, 0, positionId, "is_create_chance", entId, entUserId, entDeptId)
|
|
|
|
|
|
+ employ_info_id_new, _ := EmployUpdate(tx, this.EmployInfoId, 0, this.PositionId, "is_create_chance", this.EntId, this.EntUserId, this.EntDeptId)
|
|
|
|
|
|
argsChange[3] = employ_info_id_new
|
|
argsChange[3] = employ_info_id_new
|
|
|
|
|
|
@@ -169,12 +171,25 @@ func SaveChange(ctx context.Context, argsChange, argsTask, argsTaskTeam []interf
|
|
//传过来的argTask没有来源id,需要append
|
|
//传过来的argTask没有来源id,需要append
|
|
argsTask = append(argsTask, changeId)
|
|
argsTask = append(argsTask, changeId)
|
|
//任务车存储
|
|
//任务车存储
|
|
- taskId = TaskAdd(tx, argsTask, argsTaskTeam, transferArr, positionId)
|
|
|
|
|
|
+ taskId = TaskAdd(tx, argsTask, argsTaskTeam, transferArr, this.PositionId)
|
|
//操作台帐
|
|
//操作台帐
|
|
- ok1 := SaveLedger(ctx, positionId, changeId, taskId, "创建销售机会", fmt.Sprintf("%s创建了销售机会", createName), createName)
|
|
|
|
|
|
+ ok1 := SaveLedger(ctx, this.PositionId, changeId, taskId, "创建销售机会", fmt.Sprintf("%s创建了销售机会", this.CreateName), this.CreateName)
|
|
//任务执行计划
|
|
//任务执行计划
|
|
- planId := TaskExecutePlanAdd(tx, tplId, taskId)
|
|
|
|
- if changeId > 0 && taskId > 0 && ok1 && planId > 0 {
|
|
|
|
|
|
+ planId := TaskExecutePlanAdd(tx, this.BusinessType, taskId)
|
|
|
|
+ //销售漏斗
|
|
|
|
+ argsSalesFunnel := []interface{}{
|
|
|
|
+ changeId,
|
|
|
|
+ taskId,
|
|
|
|
+ fmt.Sprintf("%s创建了销售机会", this.CreateName),
|
|
|
|
+ this.Summary,
|
|
|
|
+ this.NextfollowUpTime,
|
|
|
|
+ this.ExpectedMoney,
|
|
|
|
+ this.BusinessType,
|
|
|
|
+ this.EntId,
|
|
|
|
+ this.EmployInfoId,
|
|
|
|
+ }
|
|
|
|
+ SalesFunnel := saveSalesFunnel(tx, argsSalesFunnel, this.BusinessType)
|
|
|
|
+ if changeId > 0 && taskId > 0 && ok1 && planId > 0 && SalesFunnel > 0 {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
log.Println("save change err: ", changeId, taskId, ok1, planId)
|
|
log.Println("save change err: ", changeId, taskId, ok1, planId)
|