Просмотр исходного кода

feat:新增创建群聊、修改消息推送地址

zhangxinlei1996 1 год назад
Родитель
Сommit
793477e152

+ 4 - 1
api/application.api

@@ -13,6 +13,7 @@ type (
 		PositionId   int64   `header:"positionId,optional"`
 		EntUserId    int64   `header:"entUserId,optional"`
 		EntId        int64   `header:"entId,optional"`
+		AccountId    int64   `header:"accountId,optional"`
 		CluesSource  string  `json:"cluesSource"`           //线索来源
 		ClueName     string  `json:"clueName"`              //线索名称
 		Summary      string  `json:"summary"`               //概要信息
@@ -29,6 +30,7 @@ type (
 		PositionId        int64   `header:"positionId,optional"`
 		EntUserId         int64   `header:"entUserId,optional"`
 		EntId             int64   `header:"entId,optional"`
+		AccountId         int64   `header:"accountId,optional"`
 		ChanceName        string  `json:"chanceName"`                 //机会名称
 		Summary           string  `json:"summary"`                    //概要信息
 		ChanceClassify    int64   `json:"chanceClassify"`             //机会分类
@@ -93,6 +95,7 @@ type (
 		PositionId           int64   `header:"positionId,optional"`
 		EntUserId            int64   `header:"entUserId,optional"`
 		EntId                int64   `header:"entId,optional"`
+		AccountId            int64   `header:"accountId,optional"`
 		CustomType           int64   `json:"customType"`                //客户类型
 		Summary              string  `json:"summary"`                   //概要信息
 		CustomAllName        string  `json:"customAllName"`             //客户全称
@@ -122,7 +125,7 @@ type (
 		EntId      int64  `header:"entId,optional"`
 		BusinessId int64  `form:"businessId"` //业务id
 		Types      int64  `form:"type"`       //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
-		FileType   string `form:"fileType"`   //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
+		FileType   int64  `form:"fileType"`   //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
 	}
 	EmployDistributeReq {
 		AppId       string             `header:"appId,default=10000"`

+ 12 - 10
api/common/initconfig.go

@@ -12,6 +12,7 @@ import (
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/config"
 	"bp.jydev.jianyu360.cn/CRM/application/entity"
 	"bp.jydev.jianyu360.cn/CRM/baseCenter/rpc/basecenter"
+	"bp.jydev.jianyu360.cn/SocialPlatform/socialPlatform/rpc/social/social"
 	"github.com/zeromicro/go-zero/core/conf"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/zrpc"
@@ -31,15 +32,16 @@ var pushFile = flag.String("pf", "etc/push.yaml", "the push file")
 var Push config.Push
 
 var (
-	MgoBidding    mongodb.MongodbSim
-	MgoEnt        mongodb.MongodbSim
-	MainMysql     *mysql.Mysql
-	BaseMysql     *mysql.Mysql
-	CrmMysql      *mysql.Mysql
-	Mgo           mongodb.MongodbSim
-	UserCenterRpc usercenter.UserCenter
-	FileCenterRpc filecenter.FileCenter
-	BaseCenterRpc basecenter.BaseCenter
+	MgoBidding        mongodb.MongodbSim
+	MgoEnt            mongodb.MongodbSim
+	MainMysql         *mysql.Mysql
+	BaseMysql         *mysql.Mysql
+	CrmMysql          *mysql.Mysql
+	Mgo               mongodb.MongodbSim
+	UserCenterRpc     usercenter.UserCenter
+	FileCenterRpc     filecenter.FileCenter
+	BaseCenterRpc     basecenter.BaseCenter
+	SocialPlatformRpc social.Social
 )
 
 func init() {
@@ -138,6 +140,6 @@ func init() {
 	UserCenterRpc = usercenter.NewUserCenter(zrpc.MustNewClient(C.UserCenterRpc))
 	FileCenterRpc = filecenter.NewFileCenter(zrpc.MustNewClient(C.FileCenterRpc))
 	BaseCenterRpc = basecenter.NewBaseCenter(zrpc.MustNewClient(C.BaseCenterRpc))
-
+	SocialPlatformRpc = social.NewSocial(zrpc.MustNewClient(C.SocialPlatformRpc))
 	conf.MustLoad(*pushFile, &Push)
 }

+ 5 - 0
api/etc/crmapplication.yaml

@@ -24,3 +24,8 @@ BaseCenterRpc:
     - 192.168.3.206:2379
     Key: basecenter.rpc
 NextFollowUpTime: 2
+SocialPlatformRpc:
+  Etcd:
+    Hosts:
+    - 192.168.3.206:2379
+    Key: social.rpc

+ 8 - 5
api/etc/push.yaml

@@ -6,7 +6,8 @@ SaleClue:
   Create:
     Title: "创建销售线索通知"
     Content: "%s于%s创建销售线索"
-    PcHref: "/succbi/crm_system/app/crm.app/task_follow/Intermediate_part/Clue_part/clue_Information_max.spg?E_position_id=%v&E_task_id=%v&E_cust_oppo_lead=%v&E_control_editing=1"
+    MyselfPcHref: "/succbi/crm_system/app/crm.app/task_follow/task_follow_up.spg?E_position_id=%v&E_control_editing=1&E_task_id=%v&E_cust_oppo_lead=%v"
+    TransferPcHref: "/succbi/crm_system/app/crm.app/task_management.spg?E_position_id=%v&E_control_editing=1"
     MobileHref: "/jy_mobile/message/msgGuide"
   Due:
     Title: "销售线索跟进任务即将到期提醒"
@@ -17,7 +18,8 @@ SaleChance:
   Create:
     Title: "创建销售机会通知"
     Content: "%s于%s创建销售机会%s"
-    PcHref: "/succbi/crm_system/app/crm.app/task_follow/Intermediate_part/Chance_part/opportunity_Information_max.spg?E_position_id=%v&E_task_id=%v&E_cust_oppo_lead=%v&E_control_editing=1"
+    MyselfPcHref: "/succbi/crm_system/app/crm.app/task_follow/task_follow_up.spg?E_position_id=%v&E_control_editing=1&E_task_id=%v&E_cust_oppo_lead=%v"
+    TransferPcHref: "/succbi/crm_system/app/crm.app/task_management.spg?E_position_id=%v&E_control_editing=1"
     MobileHref: "/jy_mobile/message/msgGuide"
   Due:
     Title: "销售机会跟进任务即将到期提醒"
@@ -28,13 +30,14 @@ Custom:
   Create:
     Title: "创建客户通知"
     Content: "%s于%s创建客户%s"
-    PcHref: "/succbi/crm_system/app/crm.app/task_follow/Intermediate_part/Customer_part/customer_information_max.spg?E_position_id=%v&E_task_id=%v&E_cust_oppo_lead=%v&E_control_editing=1"
+    MyselfPcHref: "/succbi/crm_system/app/crm.app/task_follow/task_follow_up.spg?E_position_id=%v&E_control_editing=1&E_task_id=%v&E_cust_oppo_lead=%v"
+    TransferPcHref: "/succbi/crm_system/app/crm.app/task_management.spg?E_position_id=%v&E_control_editing=1"
     MobileHref: "/jy_mobile/message/msgGuide"
   Due:
     Title: "客户跟进任务即将到期提醒"
     Content: "%s即将到期,请及时跟进。"
     PcHref: "/succbi/crm_system/app/crm.app/task_follow/Intermediate_part/Customer_part/customer_information_max.spg?E_position_id=%v&E_task_id=%v&E_cust_oppo_lead=%v&E_control_editing=1"
     MobileHref: "/jy_mobile/message/msgGuide"
-#PushTime: "0 0 8 * * *"
-PushTime: "0 50 13 * * *"
+PushTime: "0 0 8 * * *"
+# PushTime: "0 50 13 * * *"
 DueDay: 2

+ 12 - 10
api/internal/config/config.go

@@ -12,12 +12,13 @@ type Config struct {
 		ServerCode string
 		Etcd       []string
 	}
-	UserCenterRpc    zrpc.RpcClientConf
-	FileCenterRpc    zrpc.RpcClientConf
-	OssBucketName    string
-	OssUrl           string
-	BaseCenterRpc    zrpc.RpcClientConf
-	NextFollowUpTime int
+	UserCenterRpc     zrpc.RpcClientConf
+	FileCenterRpc     zrpc.RpcClientConf
+	OssBucketName     string
+	OssUrl            string
+	BaseCenterRpc     zrpc.RpcClientConf
+	NextFollowUpTime  int
+	SocialPlatformRpc zrpc.RpcClientConf
 }
 
 type Db struct {
@@ -48,10 +49,11 @@ type Push struct {
 }
 
 type Create struct {
-	Title      string
-	Content    string
-	PcHref     string
-	MobileHref string
+	Title          string
+	Content        string
+	MyselfPcHref   string
+	TransferPcHref string
+	MobileHref     string
 }
 
 type Due struct {

+ 5 - 2
api/internal/logic/clueaddlogic.go

@@ -28,9 +28,11 @@ func (l *ClueAddLogic) ClueAdd(req *types.ClueAddReq) (resp *types.Reply, err er
 	// todo: add your logic here and delete this line
 	resp = &types.Reply{}
 	clue := &service.SaleClueService{
+		AppId:        req.AppId,
 		PositionId:   req.PositionId,
 		EntId:        req.EntId,
 		EntUserId:    req.EntUserId,
+		AccountId:    req.AccountId,
 		ClueName:     req.ClueName,
 		CluesSource:  req.CluesSource,
 		Summary:      req.Summary,
@@ -41,10 +43,11 @@ func (l *ClueAddLogic) ClueAdd(req *types.ClueAddReq) (resp *types.Reply, err er
 		CreateName:   req.CreateName,
 		BaseUserId:   req.BaseUserId,
 	}
-	status := clue.Add(l.ctx)
+	status, groupId := clue.Add(l.ctx)
 
 	resp.Data = map[string]interface{}{
-		"status": status,
+		"status":  status,
+		"groupId": groupId,
 	}
 	return
 }

+ 5 - 2
api/internal/logic/customaddlogic.go

@@ -32,6 +32,8 @@ func (l *CustomAddLogic) CustomAdd(req *types.CustomAddReq) (resp *types.Reply,
 		PositionId:           req.PositionId,
 		EntUserId:            req.EntUserId,
 		EntId:                req.EntId,
+		AppId:                req.AppId,
+		AccountId:            req.AccountId,
 		CustomType:           req.CustomType,           //客户类型
 		Summary:              req.Summary,              //概要信息
 		CustomAllName:        req.CustomAllName,        //客户全称
@@ -52,9 +54,10 @@ func (l *CustomAddLogic) CustomAdd(req *types.CustomAddReq) (resp *types.Reply,
 		Remarks:              req.Remarks,              //备注
 		CreateName:           req.CreateName,           //创建人
 	}
-	status := custom.Add(l.ctx)
+	status, groupId := custom.Add(l.ctx)
 	resp.Data = map[string]interface{}{
-		"status": status,
+		"status":  status,
+		"groupId": groupId,
 	}
 	return
 }

+ 37 - 25
api/internal/logic/fileuploadlogic.go

@@ -3,10 +3,9 @@ package logic
 import (
 	"context"
 	"fmt"
-	"io"
 	"io/ioutil"
-	"log"
 	"net/http"
+	"net/url"
 	"strings"
 
 	"app.yhyue.com/moapp/jybase/common"
@@ -16,7 +15,6 @@ import (
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
 	"bp.jydev.jianyu360.cn/CRM/application/service"
 	"github.com/zeromicro/go-zero/core/logx"
-	"golang.org/x/text/encoding/charmap"
 )
 
 type FileUploadLogic struct {
@@ -36,12 +34,25 @@ func NewFileUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http
 }
 
 func (l *FileUploadLogic) FileUpload(req *types.FileUploadReq) (resp *types.Reply, err error) {
+
+	fileTypeMap := map[int64]string{
+		1:  "文件类型",
+		2:  "产品介绍",
+		3:  "项目方案",
+		4:  "立项报告",
+		5:  "报价文件",
+		6:  "招标文件",
+		7:  "投标文件",
+		8:  "中标通知书",
+		9:  "合同",
+		10: "发票",
+		11: "其他文件",
+	}
 	resp = &types.Reply{}
 	file, header, _ := l.r.FormFile("file")
 	status := 1
 	defer file.Close()
 	bt, _ := ioutil.ReadAll(file)
-	utf8Filename, err := convertToUTF8(header.Filename)
 
 	up, err := cm.FileCenterRpc.Upload(l.ctx, &fpb.UploadReq{
 		File:          bt,
@@ -49,7 +60,19 @@ func (l *FileUploadLogic) FileUpload(req *types.FileUploadReq) (resp *types.Repl
 		OssUrl:        cm.C.OssUrl,
 		Name:          header.Filename,
 	})
-	log.Println("=====", header.Filename, "~~", utf8Filename)
+
+	formUrl := l.r.Form.Get("url")
+	u, err := url.Parse(formUrl)
+	if err != nil {
+		fmt.Println("Failed to parse URL:", err)
+		return
+	}
+	queryValues, _ := url.ParseQuery(u.RawQuery)
+	fileName := queryValues.Get("fileId")
+	index := strings.Index(fileName, "-")
+	// 截取 "-" 后边的内容
+	fileName = fileName[index+1:]
+
 	if up == nil || up.Url == "" {
 		resp.Error_code = -1
 		resp.Error_msg = "上传失败"
@@ -72,20 +95,20 @@ func (l *FileUploadLogic) FileUpload(req *types.FileUploadReq) (resp *types.Repl
 	fileSize := size + "KB"
 	var data map[string]interface{}
 
-	fileTypeTmp := strings.Split(header.Filename, ".")
+	fileTypeTmp := strings.Split(fileName, ".")
 	var ftype string
 	if len(fileTypeTmp) > 0 && len(fileTypeTmp) == 2 {
-		ftype = strings.Split(header.Filename, ".")[1]
+		ftype = strings.Split(fileName, ".")[1]
 	}
 
 	fl := &service.File{
-		Name:       header.Filename, //附件名称
-		Suffix:     ftype,           //文件后缀
-		FileType:   req.FileType,    //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
-		Size:       fileSize,        //文件大小
-		Oss:        up.Url,          //oss地址
-		BusinessId: req.BusinessId,  //业务id
-		Types:      req.Types,       //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
+		Name:       fileName,                  //附件名称
+		Suffix:     ftype,                     //文件后缀
+		FileType:   fileTypeMap[req.FileType], //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
+		Size:       fileSize,                  //文件大小
+		Oss:        up.Url,                    //oss地址
+		BusinessId: req.BusinessId,            //业务id
+		Types:      req.Types,                 //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
 	}
 	if !fl.Add() {
 		status = -1
@@ -103,14 +126,3 @@ func (l *FileUploadLogic) FileUpload(req *types.FileUploadReq) (resp *types.Repl
 	resp.Data = data
 	return
 }
-
-func convertToUTF8(iso8859Filename string) (string, error) {
-	iso8859Decoder := charmap.ISO8859_1.NewDecoder()
-	utf8Bytes, err := io.ReadAll(iso8859Decoder.Reader(strings.NewReader(iso8859Filename)))
-	if err != nil {
-		return "", err
-	}
-
-	utf8Filename := string(utf8Bytes)
-	return utf8Filename, nil
-}

+ 5 - 2
api/internal/logic/salechanceaddlogic.go

@@ -32,6 +32,8 @@ func (l *SaleChanceAddLogic) SaleChanceAdd(req *types.SaleChanceReq) (resp *type
 		PositionId:        req.PositionId,
 		EntUserId:         req.EntUserId,
 		EntId:             req.EntId,
+		AppId:             req.AppId,
+		AccountId:         req.AccountId,
 		ChanceName:        req.ChanceName,        //机会名称
 		Summary:           req.Summary,           //概要信息
 		ChanceClassify:    req.ChanceClassify,    //机会分类
@@ -47,10 +49,11 @@ func (l *SaleChanceAddLogic) SaleChanceAdd(req *types.SaleChanceReq) (resp *type
 		CustomId:          req.CustomId,          //客户id
 		CreateName:        req.CreateName,
 	}
-	status := chance.Add(l.ctx)
+	status, groupId := chance.Add(l.ctx)
 
 	resp.Data = map[string]interface{}{
-		"status": status,
+		"status":  status,
+		"groupId": groupId,
 	}
 	return
 }

+ 4 - 1
api/internal/types/types.go

@@ -13,6 +13,7 @@ type ClueAddReq struct {
 	PositionId   int64   `header:"positionId,optional"`
 	EntUserId    int64   `header:"entUserId,optional"`
 	EntId        int64   `header:"entId,optional"`
+	AccountId    int64   `header:"accountId,optional"`
 	CluesSource  string  `json:"cluesSource"`           //线索来源
 	ClueName     string  `json:"clueName"`              //线索名称
 	Summary      string  `json:"summary"`               //概要信息
@@ -29,6 +30,7 @@ type SaleChanceReq struct {
 	PositionId        int64   `header:"positionId,optional"`
 	EntUserId         int64   `header:"entUserId,optional"`
 	EntId             int64   `header:"entId,optional"`
+	AccountId         int64   `header:"accountId,optional"`
 	ChanceName        string  `json:"chanceName"`                 //机会名称
 	Summary           string  `json:"summary"`                    //概要信息
 	ChanceClassify    int64   `json:"chanceClassify"`             //机会分类
@@ -93,6 +95,7 @@ type CustomAddReq struct {
 	PositionId           int64   `header:"positionId,optional"`
 	EntUserId            int64   `header:"entUserId,optional"`
 	EntId                int64   `header:"entId,optional"`
+	AccountId            int64   `header:"accountId,optional"`
 	CustomType           int64   `json:"customType"`                //客户类型
 	Summary              string  `json:"summary"`                   //概要信息
 	CustomAllName        string  `json:"customAllName"`             //客户全称
@@ -122,7 +125,7 @@ type FileUploadReq struct {
 	EntId      int64  `header:"entId,optional"`
 	BusinessId int64  `form:"businessId"` //业务id
 	Types      int64  `form:"type"`       //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
-	FileType   string `form:"fileType"`   //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
+	FileType   int64  `form:"fileType"`   //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
 }
 
 type EmployDistributeReq struct {

+ 1 - 1
api/timetask/timetask.go

@@ -79,7 +79,7 @@ func sendMess() {
 			}
 			return true
 		}, `select a.id,a.name,b.position_id,a.source,a.source_id from task a left join task_team b on (a.id =b.task_id and b.role=1)
-			where a.status!=3 and a.next_follow_time >= ? and a.next_follow_time < ?`, st, et)
+				where a.status!=3 and a.next_follow_time >= ? and a.next_follow_time < ?`, st, et)
 
 		log.Println("end cron")
 	}, "sendMsg")

+ 1 - 0
go.mod

@@ -9,6 +9,7 @@ require (
 	bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.14-0.20230821092053-934ffe439a9d
 	bp.jydev.jianyu360.cn/CRM/baseCenter v0.0.0-20230904054652-d86e21ec57f3
+	bp.jydev.jianyu360.cn/SocialPlatform/socialPlatform v0.0.0-20230529115950-b726dfbf171f
 	github.com/RoaringBitmap/roaring v1.5.0
 	github.com/gogf/gf/v2 v2.0.6
 	github.com/zeromicro/go-zero v1.5.5

Разница между файлами не показана из-за своего большого размера
+ 518 - 0
go.sum


+ 29 - 8
service/custom.go

@@ -23,6 +23,8 @@ type CustomService struct {
 	PositionId           int64
 	EntUserId            int64
 	EntId                int64
+	AppId                string
+	AccountId            int64
 	CustomType           int64   //客户类型
 	Summary              string  //概要信息
 	CustomAllName        string  //客户全称
@@ -45,7 +47,7 @@ type CustomService struct {
 }
 
 //Add 创建客户
-func (this *CustomService) Add(ctx context.Context) int64 {
+func (this *CustomService) Add(ctx context.Context) (int64, string) {
 	nowtime := time.Now().Format(date.Date_Full_Layout)
 	nextFollowTime := time.Unix(this.NextfollowUpTime, 0).Format(date.Date_Full_Layout)
 
@@ -56,7 +58,7 @@ func (this *CustomService) Add(ctx context.Context) int64 {
 	//转办
 	baseUserIdArr := []int64{}
 	customId, taskId := int64(-1), int64(-1)
-
+	groupId := ""
 	if this.Types == 2 {
 		transferArr := []int64{}
 		for _, v := range this.User {
@@ -66,10 +68,10 @@ func (this *CustomService) Add(ctx context.Context) int64 {
 			})
 			if err != nil {
 				log.Println("获取用户职位id信息出错", i_entuserid, "的信息出错", err)
-				return -1
+				return -1, groupId
 			} else if resp == nil {
 				log.Println("entuser用户", i_entuserid, "没有找到职位信息")
-				return -1
+				return -1, groupId
 			}
 			transferArr = append(transferArr, resp.PositionId)
 			baseUserIdArr = append(baseUserIdArr, resp.UserId)
@@ -82,7 +84,7 @@ func (this *CustomService) Add(ctx context.Context) int64 {
 
 		customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName, transferArr)
 		if customId < 0 {
-			return -1
+			return -1, groupId
 		}
 	} else if this.Types == 1 {
 		//客户
@@ -94,9 +96,20 @@ func (this *CustomService) Add(ctx context.Context) int64 {
 		//存库
 		customId, taskId = SaveCustom(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.EmployCustomId, this.PositionId, this.CreateName, []int64{})
 		if customId < 0 {
-			return -1
+			return -1, groupId
 		}
 		baseUserIdArr = append(baseUserIdArr, this.BaseUserId)
+
+		//自办 创建 群聊
+		gp := &Group{
+			EntId:      this.EntId,
+			PositionId: this.PositionId,
+			UserIdArr:  []int64{},
+			AppId:      this.AppId,
+			EntUserId:  this.EntUserId,
+			AccountId:  this.AccountId,
+		}
+		groupId = gp.GroupAdd()
 	}
 	u := &User{BaseUserIds: baseUserIdArr}
 
@@ -113,10 +126,18 @@ func (this *CustomService) Add(ctx context.Context) int64 {
 			nexttime = strings.Replace(time.Unix(this.NextfollowUpTime, 0).Format(YYYYMMDDHHMM), " ", "%20", -1)
 		}
 		content := fmt.Sprintf(cm.Push.Custom.Create.Content, this.CreateName, strings.Replace(date.NowFormat(YYYYMMDDHHMM), " ", "%20", -1), nexttime)
-		StationMailPush(userId, positionId, cm.Push.Custom.Create.Title, content, fmt.Sprintf(cm.Push.Custom.Create.PcHref, positionId, taskId, customId), cm.Push.Custom.Create.MobileHref)
+
+		pcHref := ""
+		if this.Types == 1 {
+			pcHref = fmt.Sprintf(cm.Push.SaleClue.Create.MyselfPcHref, positionId, taskId, customId)
+		} else if this.Types == 2 {
+			pcHref = fmt.Sprintf(cm.Push.SaleClue.Create.TransferPcHref, positionId)
+		}
+
+		StationMailPush(userId, positionId, cm.Push.Custom.Create.Title, content, pcHref, cm.Push.Custom.Create.MobileHref)
 	}
 
-	return 1
+	return 1, groupId
 }
 
 //

+ 40 - 0
service/group.go

@@ -0,0 +1,40 @@
+package service
+
+import (
+	"log"
+
+	cm "bp.jydev.jianyu360.cn/CRM/application/api/common"
+	"bp.jydev.jianyu360.cn/SocialPlatform/socialPlatform/rpc/social/social"
+	"github.com/gogf/gf/v2/os/gctx"
+)
+
+type Group struct {
+	EntId      int64
+	PositionId int64
+	UserIdArr  []int64
+	AppId      string
+	EntUserId  int64
+	AccountId  int64
+}
+
+//GroupAdd 创建群组
+//return 群组id
+func (this *Group) GroupAdd() string {
+	resp, err := cm.SocialPlatformRpc.ChatGroupAdd(gctx.New(), &social.ChatGroupAddReq{
+		EntId:      this.EntId,
+		PositionId: this.PositionId,
+		UserIdArr:  this.UserIdArr,
+		AppId:      this.AppId,
+		EntUserId:  this.EntUserId,
+		AccountId:  this.AccountId,
+	})
+	if err != nil {
+		log.Println("新建群组出错", this.PositionId, err)
+		return ""
+	} else if resp == nil {
+		log.Println("positionId用户", this.PositionId, "新建群组失败")
+		return ""
+	}
+
+	return resp.Data
+}

+ 29 - 7
service/sale_chance.go

@@ -23,6 +23,8 @@ type SaleChanceService struct {
 	PositionId        int64
 	EntUserId         int64
 	EntId             int64
+	AppId             string
+	AccountId         int64
 	ChanceName        string  //机会名称
 	Owner             string  //机会所有者
 	Summary           string  //概要信息
@@ -41,7 +43,7 @@ type SaleChanceService struct {
 }
 
 // Add 创建机会
-func (this *SaleChanceService) Add(ctx context.Context) int64 {
+func (this *SaleChanceService) Add(ctx context.Context) (int64, string) {
 	nowtime := time.Now().Format(date.Date_Full_Layout)
 	args := []interface{}{}
 	argsTask := []interface{}{}
@@ -53,6 +55,7 @@ func (this *SaleChanceService) Add(ctx context.Context) int64 {
 
 	baseUserIdArr := []int64{}
 	chanceId, taskId := int64(-1), int64(-1)
+	groupId := ""
 	//判断处理方式
 	stageId := 0
 	if stageData := cm.CrmMysql.SelectBySql("select id from  config_tpl_stage where tpl_id =? order by `order` limit 1", this.BusinessType); stageData != nil && len(*stageData) > 0 {
@@ -68,10 +71,10 @@ func (this *SaleChanceService) Add(ctx context.Context) int64 {
 			})
 			if err != nil {
 				log.Println("获取用户职位id信息出错", i_entuserid, "的信息出错", err)
-				return -1
+				return -1, groupId
 			} else if resp == nil {
 				log.Println("entuser用户", i_entuserid, "没有找到职位信息")
-				return -1
+				return -1, groupId
 			}
 			transferArr = append(transferArr, resp.PositionId)
 			baseUserIdArr = append(baseUserIdArr, resp.UserId)
@@ -84,7 +87,7 @@ func (this *SaleChanceService) Add(ctx context.Context) int64 {
 		chanceId, taskId = SaveChange(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.CustomId, this.PositionId, this.BusinessType, this.CreateName, transferArr)
 
 		if chanceId < 0 {
-			return -1
+			return -1, groupId
 		}
 	} else if this.Types == 1 {
 		//线索机会
@@ -96,9 +99,20 @@ func (this *SaleChanceService) Add(ctx context.Context) int64 {
 		//存库
 		chanceId, taskId = SaveChange(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, this.CustomId, this.PositionId, this.BusinessType, this.CreateName, []int64{})
 		if chanceId < 0 {
-			return -1
+			return -1, groupId
 		}
 		baseUserIdArr = append(baseUserIdArr, this.BaseUserId)
+
+		//自办 创建 群聊
+		gp := &Group{
+			EntId:      this.EntId,
+			PositionId: this.PositionId,
+			UserIdArr:  []int64{},
+			AppId:      this.AppId,
+			EntUserId:  this.EntUserId,
+			AccountId:  this.AccountId,
+		}
+		groupId = gp.GroupAdd()
 	}
 
 	u := &User{BaseUserIds: baseUserIdArr}
@@ -115,11 +129,19 @@ func (this *SaleChanceService) Add(ctx context.Context) int64 {
 			nexttime = strings.Replace(time.Unix(this.NextfollowUpTime, 0).Format(YYYYMMDDHHMM), " ", "%20", -1)
 		}
 		content := fmt.Sprintf(cm.Push.SaleChance.Create.Content, this.CreateName, strings.Replace(date.NowFormat(YYYYMMDDHHMM), " ", "%20", -1), nexttime)
-		StationMailPush(userId, positionId, cm.Push.SaleChance.Create.Title, content, fmt.Sprintf(cm.Push.SaleChance.Create.PcHref, positionId, taskId, chanceId), cm.Push.SaleChance.Create.MobileHref)
+
+		pcHref := ""
+		if this.Types == 1 {
+			pcHref = fmt.Sprintf(cm.Push.SaleClue.Create.MyselfPcHref, positionId, taskId, chanceId)
+		} else if this.Types == 2 {
+			pcHref = fmt.Sprintf(cm.Push.SaleClue.Create.TransferPcHref, positionId)
+		}
+
+		StationMailPush(userId, positionId, cm.Push.SaleChance.Create.Title, content, pcHref, cm.Push.SaleChance.Create.MobileHref)
 
 	}
 
-	return 1
+	return 1, groupId
 }
 
 // SaleChangeAdd 机会存储

+ 28 - 9
service/sale_clue.go

@@ -22,10 +22,12 @@ var YYYYMMDDHHMM = "2006-01-02 15:04" //%20用于转义
 
 //线索相关
 type SaleClueService struct {
+	AppId        string
 	PositionId   int64
 	EntId        int64
 	EntUserId    int64
 	BaseUserId   int64
+	AccountId    int64
 	ClueName     string
 	CluesSource  string
 	Summary      string
@@ -37,10 +39,11 @@ type SaleClueService struct {
 }
 
 //Add 创建线索
-func (this *SaleClueService) Add(ctx context.Context) int64 {
+//return 是否成功,群组id
+func (this *SaleClueService) Add(ctx context.Context) (int64, string) {
 	nowtime := time.Now().Format(date.Date_Full_Layout)
 	nextFollowTime := time.Unix(this.FollowUpTime, 0).Format(date.Date_Full_Layout)
-
+	groupId := ""
 	args := []interface{}{}
 	argsTask := []interface{}{}
 	argsTaskTeam := []interface{}{}
@@ -57,10 +60,10 @@ func (this *SaleClueService) Add(ctx context.Context) int64 {
 			})
 			if err != nil {
 				log.Println("获取用户职位id信息出错", i_entuserid, "的信息出错", err)
-				return -1
+				return -1, groupId
 			} else if resp == nil {
 				log.Println("entuser用户", i_entuserid, "没有找到职位信息")
-				return -1
+				return -1, groupId
 			}
 			transferArr = append(transferArr, resp.PositionId)
 			baseUserIdArr = append(baseUserIdArr, resp.UserId)
@@ -73,7 +76,7 @@ func (this *SaleClueService) Add(ctx context.Context) int64 {
 		argsTask = append(argsTask, this.EntId, this.ClueName+"的跟进任务", 1, this.PositionId, 1, nowtime, 1, 0, qu.If(this.FollowUpTime == 0, nil, nextFollowTime), nil, nil)
 		clueId, taskId = Save(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, 0, this.PositionId, this.CreateName, transferArr)
 		if clueId < 0 {
-			return -1
+			return -1, groupId
 		}
 	} else if this.Types == 1 {
 		//线索
@@ -86,9 +89,20 @@ func (this *SaleClueService) Add(ctx context.Context) int64 {
 		//存库
 		clueId, taskId = Save(ctx, args, argsTask, argsTaskTeam, this.EmployInfoId, 0, this.PositionId, this.CreateName, []int64{})
 		if clueId < 0 {
-			return -1
+			return -1, groupId
 		}
 		baseUserIdArr = append(baseUserIdArr, this.BaseUserId)
+
+		//自办 创建 群聊
+		gp := &Group{
+			EntId:      this.EntId,
+			PositionId: this.PositionId,
+			UserIdArr:  []int64{},
+			AppId:      this.AppId,
+			EntUserId:  this.EntUserId,
+			AccountId:  this.AccountId,
+		}
+		groupId = gp.GroupAdd()
 	}
 	u := &User{BaseUserIds: baseUserIdArr}
 
@@ -99,10 +113,15 @@ func (this *SaleClueService) Add(ctx context.Context) int64 {
 		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, positionId, taskId, clueId), cm.Push.SaleClue.Create.MobileHref)
+		pcHref := ""
+		if this.Types == 1 {
+			pcHref = fmt.Sprintf(cm.Push.SaleClue.Create.MyselfPcHref, positionId, taskId, clueId)
+		} else if this.Types == 2 {
+			pcHref = fmt.Sprintf(cm.Push.SaleClue.Create.TransferPcHref, positionId)
+		}
+		StationMailPush(userId, positionId, cm.Push.SaleClue.Create.Title, fmt.Sprintf(cm.Push.SaleClue.Create.Content, this.CreateName, strings.Replace(date.NowFormat(YYYYMMDDHHMM), " ", "%20", -1)), pcHref, cm.Push.SaleClue.Create.MobileHref)
 	}
-	return 1
-
+	return 1, groupId
 }
 
 //SaleClueAdd 线索存储

Некоторые файлы не были показаны из-за большого количества измененных файлов