瀏覽代碼

Merge branch 'feature/crm12.2_seller_collect' of hongze/hongze_yb into master

xyxie 2 年之前
父節點
當前提交
3d24e15dfd
共有 3 個文件被更改,包括 33 次插入4 次删除
  1. 1 1
      controller/collection/collection.go
  2. 7 2
      models/tables/yb_user_collection/entity.go
  3. 25 1
      services/collection/collection.go

+ 1 - 1
controller/collection/collection.go

@@ -67,7 +67,7 @@ func Collect(c *gin.Context) {
 		return
 	}
 
-	collectionId, e := collection.AddCollection(int(userInfo.UserID), req.CollectionType, req.PrimaryId, req.ExtendId, req.SourceAgent)
+	collectionId, e := collection.AddCollection(userInfo, req.CollectionType, req.PrimaryId, req.ExtendId, req.SourceAgent)
 	if e != nil {
 		response.FailMsg("操作失败", "加入收藏失败, Err: "+e.Error(), c)
 		return

+ 7 - 2
models/tables/yb_user_collection/entity.go

@@ -7,8 +7,13 @@ import (
 // YbUserCollection 研报-用户收藏表
 type YbUserCollection struct {
 	CollectionID   int       `gorm:"primaryKey;column:collection_id;type:int(10) unsigned;not null" json:"-"`
-	CollectionType int       `gorm:"column:collection_type;type:tinyint(4) unsigned;not null;default:0" json:"collectionType"`         // 收藏类型:1-研报; 2-视频社区; 3-微路演视频
-	UserID         int       `gorm:"index:idx_user_id;column:user_id;type:int(10) unsigned;not null;default:0" json:"userId"`          // 用户ID
+	CollectionType int       `gorm:"column:collection_type;type:tinyint(4) unsigned;not null;default:0" json:"collectionType"` // 收藏类型:1-研报; 2-视频社区; 3-微路演视频
+	UserID         int       `gorm:"index:idx_user_id;column:user_id;type:int(10) unsigned;not null;default:0" json:"userId"`
+	RealName       string    `gorm:"column:real_name;type:varchar(100);not null;default:''" json:"realName"` // 真实姓名
+	CompanyID      int       `gorm:"column:company_id;type:int(10) unsigned;not null;default:0" json:"companyId"`
+	CompanyName    string    `gorm:"column:company_name;type:varchar(100);not null;default:''" json:"companyName"` // 客户名称
+	CompanyStatus  string    `gorm:"column:company_status;type:varchar(30);not null;default:''" json:"companyStatus"`
+	SellerID       int       `gorm:"column:seller_id;type:int(11)" json:"sellerId"`
 	PrimaryID      int       `gorm:"index:idx_primary_id;column:primary_id;type:int(10) unsigned;not null;default:0" json:"primaryId"` // 不同类型的主ID
 	ExtendID       int       `gorm:"index:idx_extend_id;column:extend_id;type:int(10) unsigned;not null;default:0" json:"extendId"`    // 扩展ID-如晨周报章节ID
 	State          int       `gorm:"column:state;type:tinyint(4) unsigned;not null;default:0" json:"state"`                            // 状态:1-已收藏;0-取消收藏;

+ 25 - 1
services/collection/collection.go

@@ -4,11 +4,13 @@ import (
 	"errors"
 	"fmt"
 	"hongze/hongze_yb/models/response"
+	"hongze/hongze_yb/models/tables/company_product"
 	"hongze/hongze_yb/models/tables/rddp/report"
 	"hongze/hongze_yb/models/tables/rddp/report_chapter"
 	"hongze/hongze_yb/models/tables/yb_community_video"
 	"hongze/hongze_yb/models/tables/yb_road_video"
 	"hongze/hongze_yb/models/tables/yb_user_collection"
+	"hongze/hongze_yb/services/user"
 	"hongze/hongze_yb/utils"
 	"strings"
 	"sync"
@@ -23,7 +25,8 @@ const (
 )
 
 // AddCollection 加入收藏
-func AddCollection(userId, collectionType, primaryId, extendId, sourceAgent int) (collectionId int, err error) {
+func AddCollection(userInfo user.UserInfo,  collectionType, primaryId, extendId, sourceAgent int) (collectionId int, err error) {
+	userId := int(userInfo.UserID)
 	if userId <= 0 || collectionType <= 0 || primaryId <= 0 {
 		return
 	}
@@ -110,11 +113,32 @@ func AddCollection(userId, collectionType, primaryId, extendId, sourceAgent int)
 		err = errors.New(fmt.Sprintf("收藏类型有误, 当前收藏类型%d", collectionType))
 		return
 	}
+	companyName := "潜在客户"
+	companyStatus := "潜在"
+	sellerId := 0
+	if userInfo.CompanyID > 0 {
+		//查询ficc产品信息和ficc销售信息
+		companyInfo, e := company_product.GetByCompany2ProductId(userInfo.CompanyID, 1)
+		if e != nil && e != utils.ErrNoRow {
+			err = errors.New("获取客户信息失败, Err: " + e.Error())
+			return
+		}
+		if companyInfo != nil && companyInfo.CompanyID > 0 {
+			companyStatus = companyInfo.Status
+			companyName = companyInfo.CompanyName
+			sellerId = companyInfo.SellerID
+		}
+	}
 
 	// 新增收藏
 	item := &yb_user_collection.YbUserCollection{
 		CollectionType: collectionType,
 		UserID:         userId,
+		RealName:       userInfo.RealName,
+		CompanyID:      int(userInfo.CompanyID),
+		CompanyName:    companyName,
+		CompanyStatus:  companyStatus,
+		SellerID:       sellerId,
 		PrimaryID:      primaryId,
 		ExtendID:       extendId,
 		State:          1,