|
@@ -5,20 +5,27 @@ import (
|
|
|
"database/sql"
|
|
|
"fmt"
|
|
|
"log"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
|
|
|
qu "app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
|
cm "bp.jydev.jianyu360.cn/CRM/application/api/common"
|
|
|
"bp.jydev.jianyu360.cn/CRM/application/entity"
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
|
)
|
|
|
|
|
|
+var Se = encrypt.SimpleEncrypt{Key: "topnet"}
|
|
|
+var YYYYMMDDHHMM = "2006-01-02 15:04" //%20用于转义
|
|
|
+
|
|
|
//线索相关
|
|
|
type SaleClueService struct {
|
|
|
PositionId int64
|
|
|
EntId int64
|
|
|
EntUserId int64
|
|
|
+ BaseUserId int64
|
|
|
ClueName string
|
|
|
CluesSource string
|
|
|
Summary string
|
|
@@ -36,12 +43,12 @@ func (this *SaleClueService) Add(ctx context.Context) int64 {
|
|
|
args := []interface{}{}
|
|
|
argsTask := []interface{}{}
|
|
|
argsTaskTeam := []interface{}{}
|
|
|
- // userIds, positionIds := "", ""
|
|
|
+ baseUserIdArr := []int64{}
|
|
|
+ clueId := int64(-1)
|
|
|
//判断处理方式
|
|
|
//转办
|
|
|
if this.Types == 2 {
|
|
|
transferArr := []int64{}
|
|
|
- baseUserIdArr := []int64{}
|
|
|
for _, v := range this.User {
|
|
|
i_entuserid := v
|
|
|
resp, err := cm.UserCenterRpc.IdentityByEntUserId(ctx, &pb.IdentityReq{
|
|
@@ -58,15 +65,13 @@ func (this *SaleClueService) Add(ctx context.Context) int64 {
|
|
|
baseUserIdArr = append(baseUserIdArr, resp.UserId)
|
|
|
//查询mgo
|
|
|
}
|
|
|
- // &User{
|
|
|
- // baseUserIds
|
|
|
- // }
|
|
|
+
|
|
|
//线索
|
|
|
args = append(args, this.PositionId, this.EntId, this.EntUserId, this.ClueName, this.CluesSource, this.Summary, this.EmployInfoId, 0, nowtime, this.CreateName)
|
|
|
//任务
|
|
|
argsTask = append(argsTask, this.EntId, this.ClueName+"的跟进任务", 1, this.PositionId, 1, nowtime, 1, qu.If(this.FollowUpTime == 0, nil, nextFollowTime))
|
|
|
-
|
|
|
- if !Save(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, 0, this.PositionId, this.CreateName, transferArr) {
|
|
|
+ clueId = Save(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, 0, this.PositionId, this.CreateName, transferArr)
|
|
|
+ if clueId < 0 {
|
|
|
return -1
|
|
|
}
|
|
|
} else if this.Types == 1 {
|
|
@@ -77,12 +82,25 @@ func (this *SaleClueService) Add(ctx context.Context) int64 {
|
|
|
//任务团队
|
|
|
argsTaskTeam = append(argsTaskTeam, this.PositionId, this.EntUserId, this.CreateName, 1, nowtime)
|
|
|
//存库
|
|
|
- if !Save(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, 0, this.PositionId, this.CreateName, []int64{}) {
|
|
|
+ clueId = Save(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, 0, this.PositionId, this.CreateName, []int64{})
|
|
|
+ if clueId < 0 {
|
|
|
return -1
|
|
|
}
|
|
|
+ baseUserIdArr = append(baseUserIdArr, this.BaseUserId)
|
|
|
+ }
|
|
|
+ u := &User{BaseUserIds: baseUserIdArr}
|
|
|
+
|
|
|
+ var kb strings.Builder
|
|
|
+ var vb strings.Builder
|
|
|
+ for k, v := range u.GetUserId(this.EntId) {
|
|
|
+ kb.WriteString(k + ",")
|
|
|
+ vb.WriteString(gconv.String(v) + ",")
|
|
|
+ userId := strings.TrimRight(kb.String(), ",")
|
|
|
+ positionId := strings.TrimRight(vb.String(), ",")
|
|
|
+ StationMailPush(userId, positionId, cm.Push.SaleClue.Create.Title, fmt.Sprintf(cm.Push.SaleClue.Create.Content, this.CreateName, strings.Replace(date.NowFormat(YYYYMMDDHHMM), " ", "%20", -1)), fmt.Sprintf(cm.Push.SaleClue.Create.PcHref, clueId), cm.Push.SaleClue.Create.MobileHref)
|
|
|
}
|
|
|
- // StationMailPush
|
|
|
return 1
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//SaleClueAdd 线索存储
|
|
@@ -123,11 +141,12 @@ func TaskAdd(tx *sql.Tx, args, taskTeamArgs []interface{}, transferArr []int64,
|
|
|
}
|
|
|
|
|
|
//Save 存库
|
|
|
-func Save(ctx context.Context, argsClue, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id, positionId int64, createName string, transferArr []int64) bool {
|
|
|
+func Save(ctx context.Context, argsClue, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id, positionId int64, createName string, transferArr []int64) int64 {
|
|
|
+ clueId := int64(-1)
|
|
|
//存库
|
|
|
- return cm.CrmMysql.ExecTx("创建线索", func(tx *sql.Tx) bool {
|
|
|
+ cm.CrmMysql.ExecTx("创建线索", func(tx *sql.Tx) bool {
|
|
|
//插入线索
|
|
|
- clueId := SaleClueAdd(tx, argsClue)
|
|
|
+ clueId = SaleClueAdd(tx, argsClue)
|
|
|
//传过来的argTask没有来源id,需要append
|
|
|
argsTask = append(argsTask, clueId)
|
|
|
//任务车存储
|
|
@@ -142,4 +161,5 @@ func Save(ctx context.Context, argsClue, argsTask, argsTaskTeam []interface{}, e
|
|
|
log.Println("save clue err: ", clueId, taskId, ok1, ok2)
|
|
|
return false
|
|
|
})
|
|
|
+ return clueId
|
|
|
}
|