zhangxinlei1996 1 éve
szülő
commit
ae5cf878dc
3 módosított fájl, 15 hozzáadás és 11 törlés
  1. 1 1
      service/custom.go
  2. 11 7
      service/sale_chance.go
  3. 3 3
      service/sale_clue.go

+ 1 - 1
service/custom.go

@@ -80,7 +80,7 @@ func (this *CustomService) Add(ctx context.Context) int64 {
 		//客户
 		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, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime))
+		argsTask = append(argsTask, this.EntId, this.CustomAllName+"的跟进任务", 3, this.PositionId, 2, nowtime, 1, qu.If(this.NextfollowUpTime == 0, nil, nextFollowTime))
 		//任务团队
 		argsTaskTeam = append(argsTaskTeam, this.PositionId, this.EntUserId, this.CreateName, 1, nowtime)
 		//存库

+ 11 - 7
service/sale_chance.go

@@ -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 {

+ 3 - 3
service/sale_clue.go

@@ -73,7 +73,7 @@ func (this *SaleClueService) Add(ctx context.Context) int64 {
 		//线索
 		args = append(args, this.PositionId, this.EntId, this.EntUserId, this.ClueName, this.CluesSource, this.Summary, this.EmployInfoId, 0, time.Now().Format(date.Date_Full_Layout), this.CreateName)
 		//任务
-		argsTask = append(argsTask, this.EntId, this.ClueName+"的跟进任务", 1, this.PositionId, 1, nowtime, 1, qu.If(this.FollowUpTime == 0, nil, nextFollowTime))
+		argsTask = append(argsTask, this.EntId, this.ClueName+"的跟进任务", 1, this.PositionId, 2, nowtime, 1, qu.If(this.FollowUpTime == 0, nil, nextFollowTime))
 		//任务团队
 		argsTaskTeam = append(argsTaskTeam, this.PositionId, this.EntUserId, this.CreateName, 1, nowtime)
 		//存库
@@ -103,9 +103,9 @@ func TaskAdd(tx *sql.Tx, args, taskTeamArgs []interface{}, transferArr []int64,
 	teamId, transferId := int64(0), int64(0)
 	if len(taskTeamArgs) > 0 {
 		//自办
-		// taskTeamFields := []string{"position_id", "ent_user_id", "name", "role", "create_time", "task_id"}
+		taskTeamFields := []string{"position_id", "ent_user_id", "name", "role", "create_time", "task_id"}
 		taskTeamArgs = append(taskTeamArgs, id)
-		// _, teamId = cm.CrmMysql.InsertBatchByTx(tx, entity.TASK_TEAM, taskTeamFields, taskTeamArgs)
+		_, teamId = cm.CrmMysql.InsertBatchByTx(tx, entity.TASK_TEAM, taskTeamFields, taskTeamArgs)
 	} else if len(transferArr) > 0 {
 		//转办
 		taskTransferFields := []string{"transfer_id", "responsible_id", "create_time", "task_id"}