|
@@ -5,6 +5,7 @@ import (
|
|
|
"database/sql"
|
|
|
"fmt"
|
|
|
"log"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
|
|
|
qu "app.yhyue.com/moapp/jybase/common"
|
|
@@ -60,30 +61,31 @@ func (this *SaleChanceService) Add(ctx context.Context) int64 {
|
|
|
})
|
|
|
if err != nil {
|
|
|
log.Println("获取用户职位id信息出错", i_entuserid, "的信息出错", err)
|
|
|
- return 0
|
|
|
+ return -1
|
|
|
} else if resp == nil {
|
|
|
log.Println("entuser用户", i_entuserid, "没有找到职位信息")
|
|
|
- return 0
|
|
|
+ return -1
|
|
|
}
|
|
|
transferArr = append(transferArr, resp.PositionId)
|
|
|
}
|
|
|
- args = append(args, this.PositionId, this.EntId, this.EntUserId, this.EmployInfoId, this.CustomId, this.BusinessType, this.ChanceName, this.Summary, this.ChanceClassify, qu.If(this.ExpectedOrderTime == 0, nil, expect_deal_time), qu.If(this.ExpectedMoney == 0, nil, this.ExpectedMoney), qu.If(this.Remarks == "", nil, this.Remarks), nowtime)
|
|
|
+
|
|
|
+ args = append(args, this.PositionId, this.EntId, this.EntUserId, this.EmployInfoId, this.CustomId, this.BusinessType, this.ChanceName, this.Summary, this.ChanceClassify, qu.If(this.ExpectedOrderTime == 0, nil, expect_deal_time), qu.If(this.ExpectedMoney == 0, nil, this.ExpectedMoney), qu.If(this.Remarks == "", nil, this.Remarks), nowtime, this.CreateName)
|
|
|
//任务
|
|
|
argsTask = append(argsTask, this.EntId, this.ChanceName+"的跟进任务", 2, this.PositionId, 1, nowtime, 1, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime))
|
|
|
|
|
|
if !SaveChange(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.CustomId, this.PositionId, this.BusinessType, this.CreateName, transferArr) {
|
|
|
- return 0
|
|
|
+ return -1
|
|
|
}
|
|
|
} else if this.Types == 1 {
|
|
|
//线索机会
|
|
|
args = append(args, this.PositionId, this.EntId, this.EntUserId, this.EmployInfoId, this.CustomId, this.BusinessType, this.ChanceName, this.Summary, this.ChanceClassify, qu.If(this.ExpectedOrderTime == 0, nil, expect_deal_time), qu.If(this.ExpectedMoney == 0, nil, this.ExpectedMoney), qu.If(this.Remarks == "", nil, this.Remarks), nowtime, this.CreateName)
|
|
|
//任务
|
|
|
- argsTask = append(argsTask, this.EntId, this.ChanceName+"的跟进任务", 2, this.PositionId, 1, nowtime, 1, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime))
|
|
|
+ argsTask = append(argsTask, this.EntId, this.ChanceName+"的跟进任务", 2, this.PositionId, 2, nowtime, 1, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime))
|
|
|
//任务团队
|
|
|
argsTaskTeam = append(argsTaskTeam, this.PositionId, this.EntUserId, this.CreateName, 1, nowtime)
|
|
|
//存库
|
|
|
if !SaveChange(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.CustomId, this.PositionId, this.BusinessType, this.CreateName, []int64{}) {
|
|
|
- return 0
|
|
|
+ return -1
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -93,6 +95,7 @@ func (this *SaleChanceService) Add(ctx context.Context) int64 {
|
|
|
// SaleChangeAdd 机会存储
|
|
|
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"}
|
|
|
+
|
|
|
_, id := cm.CrmMysql.InsertBatchByTx(tx, entity.SALE_CHANCE, fields, args)
|
|
|
return id
|
|
|
}
|
|
@@ -110,7 +113,8 @@ func SaveChange(ctx context.Context, argsChange, argsTask, argsTaskTeam []interf
|
|
|
//操作台帐
|
|
|
ok1 := SaveLedger(ctx, positionId, changeId, taskId, "创建销售机会", fmt.Sprintf("%s创建了销售机会", createName), createName)
|
|
|
//是否创建销售计划
|
|
|
- ok2 := EmployUpdate(tx, employ_info_id, employ_custom_id, positionId, "is_create_chance")
|
|
|
+ log.Println(employ_info_id, employ_custom_id, "##")
|
|
|
+ ok2 := EmployUpdate(tx, employ_info_id, 0, positionId, "is_create_chance")
|
|
|
//任务执行计划
|
|
|
planId := TaskExecutePlanAdd(tx, tplId, taskId)
|
|
|
if changeId > 0 && taskId > 0 && ok1 && ok2 && planId > 0 {
|