Ver código fonte

服务商数据卡

Ethan 1 semana atrás
pai
commit
90ae12aaa9

+ 32 - 0
app/controller/cooperation_controller.go

@@ -109,6 +109,38 @@ func (o CooperationController) GetSupplierCount(c *gin.Context) {
 	returnSuccess(c, 20000, result)
 }
 
+// 服务商管理-服务商数据卡
+func (o CooperationController) GetSupplierData(c *gin.Context) {
+	param := &vo.SupplierDataParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "Parameter Error: "+err.Error())
+		return
+	}
+	result := service.CooperationService{}.GetSupplierData(param)
+
+	returnSuccess(c, 20000, result)
+}
+
+// 服务商管理-服务商数据卡列表
+func (o CooperationController) GetSupplierPerform(c *gin.Context) {
+	param := &vo.SupplierDataParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "Parameter Error: "+err.Error())
+		return
+	}
+	result, err := service.CooperationService{}.GetSupplierPerform(param)
+	if err != nil {
+		logrus.Errorf("[GetSupplierPerform] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}
+
 // 门店详情
 func (o CooperationController) GetStoreDetail(c *gin.Context) {
 	param := &vo.StoreSearchParam{}

+ 17 - 0
app/dao/local_task_link_statistic_dao.go

@@ -0,0 +1,17 @@
+package dao
+
+import (
+	"youngee_b_api/app/entity"
+)
+
+type LocalTaskLinkStatisticDao struct{}
+
+// 获取指定服务商下的作品数据
+func (d LocalTaskLinkStatisticDao) GetSupplierData(supplierId int64) ([]entity.LocalTaskLinkStatistic, error) {
+	localTaskLinkStatistics := []entity.LocalTaskLinkStatistic{}
+	err1 := Db.Model(&entity.LocalTaskLinkStatistic{}).Where("supplier_id = ?", supplierId).Find(&localTaskLinkStatistics).Error
+	if err1 != nil {
+		return localTaskLinkStatistics, err1
+	}
+	return localTaskLinkStatistics, nil
+}

+ 17 - 0
app/dao/project_task_link_statistic_dao.go

@@ -0,0 +1,17 @@
+package dao
+
+import (
+	"youngee_b_api/app/entity"
+)
+
+type ProjectTaskLinkStatisticDao struct{}
+
+// 获取指定服务商下的作品数据
+func (d ProjectTaskLinkStatisticDao) GetSupplierData(supplierId int64) ([]entity.ProjectTaskLinkStatistic, error) {
+	projectTaskLinkStatistics := []entity.ProjectTaskLinkStatistic{}
+	err1 := Db.Model(&entity.ProjectTaskLinkStatistic{}).Where("supplier_id = ?", supplierId).Find(&projectTaskLinkStatistics).Error
+	if err1 != nil {
+		return projectTaskLinkStatistics, err1
+	}
+	return projectTaskLinkStatistics, nil
+}

+ 25 - 0
app/entity/local_task_link_statistic.go

@@ -0,0 +1,25 @@
+package entity
+
+// Code generated by sql2gorm. DO NOT EDIT.
+
+import (
+	"time"
+)
+
+type LocalTaskLinkStatistic struct {
+	StatisticID     int64      `gorm:"column:statistic_id;primary_key;AUTO_INCREMENT"` // 主键ID
+	LocalID         string     `gorm:"column:local_id"`                                // 本地生活任务ID
+	TaskID          string     `gorm:"column:task_id"`                                 // 子任务ID
+	PlatformID      int64      `gorm:"column:platform_id"`                             // 平台ID,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	VoteCount       int64      `gorm:"column:vote_count"`                              // 点赞量
+	CommitCount     int64      `gorm:"column:commit_count"`                            // 评论数
+	CollectionCount int64      `gorm:"column:collection_count"`                        // 收藏数
+	ViewCount       int64      `gorm:"column:view_count"`                              // 浏览量
+	CreateTime      *time.Time `gorm:"column:create_time"`                             // 创建时间
+	OpenID          string     `gorm:"column:open_id"`                                 // 第三方平台唯一标识符
+	SupplierID      int64      `gorm:"column:supplier_id;NOT NULL"`
+}
+
+func (m *LocalTaskLinkStatistic) TableName() string {
+	return "local_task_link_statistic"
+}

+ 25 - 0
app/entity/project_task_link_statistic.go

@@ -0,0 +1,25 @@
+package entity
+
+// Code generated by sql2gorm. DO NOT EDIT.
+
+import (
+	"time"
+)
+
+type ProjectTaskLinkStatistic struct {
+	StatisticID     int64      `gorm:"column:statistic_id;primary_key;AUTO_INCREMENT"` // 主键ID
+	ProjectID       string     `gorm:"column:project_id"`                              // 种草任务ID
+	TaskID          string     `gorm:"column:task_id"`                                 // 子任务ID
+	PlatformID      int64      `gorm:"column:platform_id"`                             // 平台ID,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	VoteCount       int64      `gorm:"column:vote_count"`                              // 点赞量
+	CommitCount     int64      `gorm:"column:commit_count"`                            // 评论数
+	CollectionCount int64      `gorm:"column:collection_count"`                        // 收藏数
+	ViewCount       int64      `gorm:"column:view_count"`                              // 浏览量
+	CreateTime      *time.Time `gorm:"column:create_time"`                             // 创建时间
+	OpenID          string     `gorm:"column:open_id"`                                 // 第三方平台唯一标识符
+	SupplierID      int64      `gorm:"column:supplier_id;NOT NULL"`
+}
+
+func (m *ProjectTaskLinkStatistic) TableName() string {
+	return "project_task_link_statistic"
+}

+ 4 - 3
app/entity/supplier.go

@@ -1,9 +1,10 @@
 package entity
 
 type Supplier struct {
-	SupplierID      int64  `gorm:"column:supplier_id"`      // 服务商ID
-	SupplierName    string `gorm:"column:supplier_name"`    // 服务商名称
-	PhoneNumber     string `gorm:"column:phone_number"`     // 手机号
+	SupplierID      int64  `gorm:"column:supplier_id"`   // 服务商ID
+	SupplierName    string `gorm:"column:supplier_name"` // 服务商名称
+	PhoneNumber     string `gorm:"column:phone_number"`  // 手机号
+	ContactPhone    string `gorm:"column:contact_phone"`
 	WechatNumber    string `gorm:"column:wechat_number"`    // 微信号
 	WechatQrcode    string `gorm:"column:wechat_qrcode"`    // 微信二维码
 	BusinessLicense string `gorm:"column:business_license"` // 营业执照url

+ 87 - 0
app/service/cooperation_service.go

@@ -209,6 +209,93 @@ func (t CooperationService) GetSupplierCount(param *vo.SupplierConfirmingParam)
 	return res
 }
 
+// 服务商管理-服务商数据卡
+func (t CooperationService) GetSupplierData(param *vo.SupplierDataParam) vo.ReSupplierCoopData {
+	var reSupplierCoopData vo.ReSupplierCoopData
+
+	supplier, err1 := dao.SupplierDao{}.GetSupplierInfoById(param.SupplierId)
+	if err1 != nil {
+		return vo.ReSupplierCoopData{}
+	}
+	supplierPreview := &vo.SupplierPreview{
+		SupplierId:   supplier.SupplierID,
+		AvatarUrl:    supplier.Avatar,
+		SupplierName: supplier.SupplierName,
+		CompanyName:  supplier.CompanyName,
+		WXAccount:    supplier.WechatNumber,
+		CodeUrl:      supplier.WechatQrcode,
+		Phone:        supplier.ContactPhone,
+		Platform:     []int{1, 2, 3, 4, 5},
+	}
+	reSupplierCoopData.SupplierPreview = supplierPreview
+
+	var count int64
+	_ = dao.Db.Model(&entity.EnterpriseSupplierCooperate{}).Where("supplier_id = ? AND cooperate_status = 2", param.SupplierId).Count(&count).Error
+	enterpriseSupplierCooperate, err2 := dao.EnterpriseSupplierCooperateDao{}.GetDataByEnterpriseAndSupplier(param.EnterpriseId, param.SupplierId)
+	if err2 != nil {
+		return reSupplierCoopData
+	}
+	coreData := &vo.CoreData{
+		CooperateNum:    enterpriseSupplierCooperate.CooperateNum,
+		ReportTalentNum: enterpriseSupplierCooperate.UploadTalentNum,
+		TalentCoopNum:   enterpriseSupplierCooperate.CooperateTalentNum,
+		PutStoreNum:     count,
+	}
+	var commentCount, viewCount int64
+	projectTaskLinkStatistics, err3 := dao.ProjectTaskLinkStatisticDao{}.GetSupplierData(param.SupplierId)
+	if err3 != nil {
+		return reSupplierCoopData
+	}
+	localTaskLinkStatistics, err4 := dao.LocalTaskLinkStatisticDao{}.GetSupplierData(param.SupplierId)
+	if err4 != nil {
+		return reSupplierCoopData
+	}
+	for _, projectTaskLinkStatistic := range projectTaskLinkStatistics {
+		commentCount += projectTaskLinkStatistic.CommitCount
+		viewCount += projectTaskLinkStatistic.ViewCount
+	}
+	for _, localTaskLinkStatistic := range localTaskLinkStatistics {
+		commentCount += localTaskLinkStatistic.CommitCount
+		viewCount += localTaskLinkStatistic.ViewCount
+	}
+	coreData.ViewNum = viewCount
+	coreData.InteractNum = commentCount
+	reSupplierCoopData.CoreData = coreData
+
+	return reSupplierCoopData
+}
+
+// 服务商管理-服务商数据卡列表
+func (t CooperationService) GetSupplierPerform(param *vo.SupplierDataParam) (vo.ResultVO, error) {
+	if param.Page <= 0 {
+		param.Page = 1
+	}
+	if param.PageSize <= 0 {
+		param.PageSize = 10
+	}
+	var supplierDataParams []*vo.SupplierPerformance
+	var total int64
+	result := vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    total,
+		Data:     supplierDataParams,
+	}
+	// 获取supplierId下的所有任务,再根据任务获取数据
+
+	supplierDataParams = append(supplierDataParams, &vo.SupplierPerformance{
+		ProductName: "xxxxxx",
+	})
+
+	result = vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    total,
+		Data:     supplierDataParams,
+	}
+	return result, nil
+}
+
 // 服务商合作-服务商列表
 func (s CooperationService) GetSupplierInTargetTaskList(param *vo.SupplierSearchInTargetTaskParam) (vo.ResultVO, error) {
 	if param.Page <= 0 {

+ 40 - 0
app/vo/re_supplier_coop_data.go

@@ -0,0 +1,40 @@
+package vo
+
+type ReSupplierCoopData struct {
+	SupplierPreview *SupplierPreview `json:"supplierPreview"`
+	CoreData        *CoreData        `json:"coreData"`
+}
+
+type SupplierPreview struct {
+	SupplierId   int64  `json:"supplierId"`
+	AvatarUrl    string `json:"avatar"`
+	SupplierName string `json:"supplierName"`
+	CompanyName  string `json:"companyName"`
+	WXAccount    string `json:"wxAccount"`
+	CodeUrl      string `json:"codeUrl"`
+	Phone        string `json:"phone"`
+	Platform     []int  `json:"platform"`
+}
+
+type CoreData struct {
+	CooperateNum    int64 `json:"cooperateNum"`
+	ReportTalentNum int64 `json:"reportTalentNum"`
+	TalentCoopNum   int64 `json:"talentCoopNum"`
+	PutStoreNum     int64 `json:"putStoreNum"`
+	ViewNum         int64 `json:"viewNum"`
+	InteractNum     int64 `json:"interactNum"`
+	SalesNum        int64 `json:"salesNum"`
+	ProductNum      int64 `json:"productNum"`
+}
+
+type SupplierPerformance struct {
+	MainImage   string  `json:"mainImage"`
+	ProductName string  `json:"productName"`
+	StoreName   string  `json:"storeName"`
+	Price       float64 `json:"price"`
+
+	ViewCount    int64 `json:"viewCount"`
+	VoteCount    int64 `json:"voteCount"`
+	CollectCount int64 `json:"collectCount"`
+	CommentCount int64 `json:"commentCount"`
+}

+ 12 - 0
app/vo/supplier_search_param.go

@@ -26,6 +26,18 @@ type SupplierConfirmingParam struct {
 	Others       string `json:"others"` // 服务商昵称/服务商ID/操作人
 }
 
+type SupplierDataParam struct {
+	EnterpriseId string `json:"enterprise_id"`
+	SubAccountId int64  `json:"sub_account_id"`
+	SupplierId   int64  `json:"supplier_id"`
+	Page         int    `json:"page"`
+	PageSize     int    `json:"page_size"`
+	Others       string `json:"others"` // 任务标题
+
+	TaskType int `json:"task_type"` // 2种草,3本地生活
+	RelType  int `json:"rel_type"`  // 1不限,2只与本账号相关
+}
+
 type SupplierSearchInTargetTaskParam struct {
 	EnterpriseId string `json:"enterprise_id"`
 	SubAccountId int64  `json:"sub_account_id"`

+ 2 - 0
route/init.go

@@ -396,6 +396,8 @@ func InitRoute(r *gin.Engine) {
 		cooperation.POST("/inPool", controller.CooperationController{}.GetEnterprisePoolList)         // 在库服务商列表
 		cooperation.POST("/confirming", controller.CooperationController{}.GetSupplierConfirmingList) // 邀请待确认服务商列表
 		cooperation.POST("/count", controller.CooperationController{}.GetSupplierCount)               // 服务商管理-角标
+		cooperation.POST("/data", controller.CooperationController{}.GetSupplierData)                 // 服务商管理-服务商数据卡
+		cooperation.POST("/perform", controller.CooperationController{}.GetSupplierPerform)           // 服务商管理-服务商数据卡列表
 	}
 	// 推广合作-商品管理相关接口
 	product := r.Group("/youngee/b/cooperation/product")