Переглянути джерело

UpdateProjectTaskRedBookLinkData

Xingyu Xian 1 тиждень тому
батько
коміт
c0972f6812

+ 30 - 0
db/link.go

@@ -2,7 +2,9 @@ package db
 
 import (
 	"context"
+	"errors"
 	"fmt"
+	"gorm.io/gorm"
 	"reflect"
 	"strconv"
 	"strings"
@@ -571,3 +573,31 @@ func GetSpecialTaskLinkList(ctx context.Context, projectID string, pageSize, pag
 	}
 	return newTaskLinks, totalTask, nil
 }
+
+// GetProjectTaskLinkInfo 返回链接
+func GetProjectTaskLinkInfo(ctx context.Context, taskId string, IsOk int) (string, error) {
+	db := GetReadDB(ctx)
+
+	var linkURL string
+
+	query := db.Debug().Model(&gorm_model.YounggeeLinkInfo{})
+
+	if taskId != "" {
+		query = query.Where("task_id = ?", taskId)
+	}
+
+	if IsOk >= 0 { // 假设 IsOk 只能是 0 或 1,如果不是可以调整
+		query = query.Where("is_ok = ?", IsOk)
+	}
+
+	err := query.Pluck("link_url", &linkURL).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return "", nil
+		}
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskLinkInfo] error querying link_url: %+v", err)
+		return "", err
+	}
+
+	return linkURL, nil
+}

+ 29 - 0
db/project.go

@@ -670,3 +670,32 @@ func GetProjecdata(ctx context.Context, projectid string) (http_model.Projectdat
 	res := http_model.ProjectdataResponse{}
 	return res, nil
 }
+
+func GetProjectIdList(ctx context.Context, projectStatus int, projectPlatform int) ([]string, int64, error) {
+	db := GetReadDB(ctx)
+
+	var total int64
+	if err := db.Model(gorm_model.ProjectInfo{}).
+		Where("project_status = ? and project_platform = ?", projectStatus, projectPlatform).
+		Count(&total).
+		Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectIdList] error counting projects, err:%+v", err)
+		return nil, 0, err
+	}
+
+	// Query only project_id with the given status
+	var projectIds []string
+	err := db.Debug().
+		Model(gorm_model.ProjectInfo{}).
+		Where("project_status = ? and project_platform = ?", projectStatus, projectPlatform).
+		Order("updated_at desc").
+		Pluck("project_id", &projectIds).
+		Error
+
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectIdList] error querying project IDs, err:%+v", err)
+		return nil, 0, err
+	}
+
+	return projectIds, total, nil
+}

+ 32 - 0
db/project_task.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"fmt"
 	"github.com/issue9/conv"
+	"github.com/sirupsen/logrus"
 	"gorm.io/gorm"
 	"strconv"
 	"strings"
@@ -1336,3 +1337,34 @@ func GetDataList(ctx context.Context, request http_model.TaskDatalistRequest) (*
 		Total:        conv.MustString(total, ""),
 	}, nil
 }
+
+// GetProjectTaskIdList 子任务ID列表
+func GetProjectTaskIdList(ctx context.Context, projectId string) ([]string, int64, error) {
+	db := GetReadDB(ctx)
+
+	// Get count first
+	var total int64
+	if err := db.Model(gorm_model.YounggeeSecTaskInfo{}).
+		Where("data_status = ? and project_id = ?", 5, projectId).
+		Count(&total).
+		Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskIdList] error counting task, err:%+v", err)
+		return nil, 0, err
+	}
+
+	// Query only project_id with the given status
+	var taskIds []string
+	err := db.Debug().
+		Model(gorm_model.YounggeeSecTaskInfo{}).
+		Where("data_status = ? and project_id = ?", 5, projectId).
+		Order("updated_at desc").
+		Pluck("task_id", &taskIds).
+		Error
+
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskIdList] error querying taskIDs, err:%+v", err)
+		return nil, 0, err
+	}
+
+	return taskIds, total, nil
+}

+ 37 - 0
db/project_task_link_statistic.go

@@ -0,0 +1,37 @@
+package db
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"youngee_b_api/model/gorm_model"
+)
+
+// CreateProjectTaskLinkStatistic 创建一条统计记录
+func CreateProjectTaskLinkStatistic(ctx context.Context, stat *gorm_model.ProjectTaskLinkStatistic) error {
+	// 基本校验
+	if stat == nil {
+		return errors.New("nil statistic data")
+	}
+
+	// 获取写数据库连接
+	db := GetWriteDB(ctx)
+	if db == nil {
+		return errors.New("database connection not available")
+	}
+
+	// 设置默认时间
+	if stat.CreateTime.IsZero() {
+		var currentTime time.Time
+		stat.CreateTime = &currentTime
+	}
+
+	// 执行创建
+	if err := db.WithContext(ctx).Create(stat).Error; err != nil {
+		// 可以在这里添加特定错误处理
+		return fmt.Errorf("failed to create statistic: %w", err)
+	}
+
+	return nil
+}

+ 38 - 0
db/reward_strategy.go

@@ -0,0 +1,38 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/model/gorm_model"
+)
+
+func CreateRewardStrategy(ctx context.Context, RewardStrategys []gorm_model.RewardStrategy) error {
+	db := GetReadDB(ctx)
+	fmt.Println("RewardStrategys: ", RewardStrategys)
+	err := db.Create(&RewardStrategys).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func DeleteRewardStrategyBySelectionId(ctx context.Context, SelectionId string) error {
+	db := GetReadDB(ctx)
+	err := db.Where("selection_id = ?", SelectionId).Delete(&gorm_model.RewardStrategy{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func GetRewardStrategyBySelectionId(ctx context.Context, SelectionId string) ([]*gorm_model.RewardStrategy, error) {
+	db := GetReadDB(ctx)
+	var RewardStrategys []*gorm_model.RewardStrategy
+	err := db.Model(gorm_model.RewardStrategy{}).Where("selection_id = ?", SelectionId).Find(&RewardStrategys).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetRewardStrategyBySelectionId] error query, err:%+v", err)
+		return nil, err
+	}
+	return RewardStrategys, nil
+}

+ 1 - 0
db/talent_platform_link_statistic.go

@@ -0,0 +1 @@
+package db

+ 29 - 35
handler/register.go

@@ -1,15 +1,8 @@
 package handler
 
 import (
-	"youngee_b_api/consts"
-	"youngee_b_api/model/http_model"
-	"youngee_b_api/service"
-	"youngee_b_api/util"
-
-	"github.com/sirupsen/logrus"
-	log "github.com/sirupsen/logrus"
-
 	"github.com/gin-gonic/gin"
+	"youngee_b_api/model/http_model"
 )
 
 func WrapRegisterHandler(ctx *gin.Context) {
@@ -41,33 +34,34 @@ func (h *RegisterHandler) getResponse() interface{} {
 	return h.resp
 }
 func (h *RegisterHandler) run() {
-	data := http_model.RegisterRequest{}
-	data = *h.req
-	message, err := service.Register.AuthRegister(h.ctx, data.Phone, data.Code)
-	if err != nil {
-		logrus.Errorf("[RegisterHandler] call AuthRegister err:%+v\n", err)
-		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
-		log.Info("Register fail,req:%+v", h.req)
-		h.resp.Status = 40000
-		h.resp.Message = err.Error()
-		return
-	} else if message == "" {
-		// 3. 先后在user表和enterprise表中增加账号信息
-		res, err := service.Enterprise.CreateEnterpriseUser(h.ctx, data)
-		if err != nil {
-			logrus.Errorf("[RegisterHandler] call CreateEnterpriseUser err:%+v\n", err)
-			util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
-			log.Info("Register fail,req:%+v", h.req)
-			return
-		}
-		h.resp.Message = "注册成功"
-		// 4. 返回ok
-		h.resp.Status = 20000
-		h.resp.Data = res
-	} else {
-		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, message)
-		return
-	}
+	//
+	//data := http_model.RegisterRequest{}
+	//data = *h.req
+	//message, err := service.Register.AuthRegister(h.ctx, data.Phone, data.Code)
+	//if err != nil {
+	//	logrus.Errorf("[RegisterHandler] call AuthRegister err:%+v\n", err)
+	//	util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+	//	log.Info("Register fail,req:%+v", h.req)
+	//	h.resp.Status = 40000
+	//	h.resp.Message = err.Error()
+	//	return
+	//} else if message == "" {
+	//	// 3. 先后在user表和enterprise表中增加账号信息
+	//	res, err := service.Enterprise.CreateEnterpriseUser(h.ctx, data)
+	//	if err != nil {
+	//		logrus.Errorf("[RegisterHandler] call CreateEnterpriseUser err:%+v\n", err)
+	//		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+	//		log.Info("Register fail,req:%+v", h.req)
+	//		return
+	//	}
+	//	h.resp.Message = "注册成功"
+	//	// 4. 返回ok
+	//	h.resp.Status = 20000
+	//	h.resp.Data = res
+	//} else {
+	//	util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, message)
+	//	return
+	//}
 }
 
 func (h *RegisterHandler) checkParam() error {

+ 16 - 13
model/gorm_model/product.go

@@ -1,4 +1,3 @@
-// Code generated by sql2gorm. DO NOT EDIT.
 package gorm_model
 
 import (
@@ -6,20 +5,24 @@ import (
 )
 
 type YounggeeProduct struct {
-	ProductID     int64       `gorm:"column:product_id;primary_key;AUTO_INCREMENT"` // 商品id
-	ProductName   string    `gorm:"column:product_name"`                          // 商品名称
-	ProductType   int64       `gorm:"column:product_type"`                          // 商品类型
-	ShopAddress   string    `gorm:"column:shop_address"`                          // 店铺地址,商品类型为线下品牌时需填写
-	ProductPrice  float64     `gorm:"column:product_price"`                         // 商品价值
-	ProductDetail string    `gorm:"column:product_detail"`
-	ProductUrl    string    `gorm:"column:product_url"`   // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
-	EnterpriseID  string      `gorm:"column:enterprise_id"` // 所属企业id
-	CreatedAt     time.Time `gorm:"column:created_at"`    // 创建时间
-	UpdatedAt     time.Time `gorm:"column:updated_at"`    // 更新时间
-	BrandName     string    `gorm:"column:brand_name"`
+	ProductID           int64     `gorm:"column:product_id;primary_key;AUTO_INCREMENT"` // 商品id
+	ProductName         string    `gorm:"column:product_name"`                          // 商品名称
+	ProductType         int64     `gorm:"column:product_type"`                          // 商品类型
+	ShopAddress         string    `gorm:"column:shop_address"`                          // 店铺地址,商品类型为线下品牌时需填写
+	ProductPrice        float64   `gorm:"column:product_price"`                         // 商品价值
+	ProductDetail       string    `gorm:"column:product_detail"`                        // 商品详情
+	ProductUrl          string    `gorm:"column:product_url"`                           // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
+	EnterpriseID        string    `gorm:"column:enterprise_id"`                         // 所属企业id
+	CreatedAt           time.Time `gorm:"column:created_at"`                            // 创建时间
+	UpdatedAt           time.Time `gorm:"column:updated_at"`                            // 更新时间
+	BrandName           string    `gorm:"column:brand_name"`                            // 品牌名称
+	PublicCommission    float64   `gorm:"column:public_commission"`                     // 公开佣金
+	ExclusiveCommission float64   `gorm:"column:exclusive_commission"`                  // 专属佣金
+	CommissionPrice     float64   `gorm:"column:commission_price"`                      // 佣金金额
+	KuaishouProductId   int64     `gorm:"column:kuaishou_product_id"`                   // 快手商品ID
+	SalesCount          string    `gorm:"column:sales_count"`                           // 商品30天销量
 }
 
 func (m *YounggeeProduct) TableName() string {
 	return "younggee_product"
 }
-

+ 21 - 0
model/gorm_model/project_task_link_statistic.go

@@ -0,0 +1,21 @@
+package gorm_model
+
+import (
+	"time"
+)
+
+type ProjectTaskLinkStatistic struct {
+	StatisticId     int        `gorm:"column:statistic_id;primary_key;AUTO_INCREMENT"` // 主键ID
+	ProjectId       string     `gorm:"column:project_id"`                              // 种草任务ID
+	TaskID          string     `gorm:"column:task_id"`                                 // 子任务ID
+	PlatformId      int        `gorm:"column:platform_id"`                             // 平台ID,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	VoteCount       int        `gorm:"column:vote_count"`                              // 点赞量
+	CommitCount     int        `gorm:"column:commit_count"`                            // 评论数
+	CollectionCount int        `gorm:"column:collection_count"`                        // 收藏数
+	ViewCount       int        `gorm:"column:view_count"`                              // 浏览量
+	CreateTime      *time.Time `gorm:"column:create_time"`                             // 创建时间
+}
+
+func (m *ProjectTaskLinkStatistic) TableName() string {
+	return "project_task_link_statistic"
+}

+ 14 - 0
model/gorm_model/reward_strategy.go

@@ -0,0 +1,14 @@
+package gorm_model
+
+type RewardStrategy struct {
+	RewardStrategyId int64   `gorm:"column:reward_strategy_id;primary_key;AUTO_INCREMENT"` // 悬赏策略id
+	SelectionId      string  `gorm:"column:selection_id"`                                  // 带货任务id
+	Reward           float64 `gorm:"column:reward"`                                        // 悬赏池总金额
+	SaleActual       int64   `gorm:"column:sale_actual"`                                   // 实际带货销量
+	PerReward        float64 `gorm:"column:per_reward"`                                    // 每人可获得悬赏金
+	StrategyStatus   int64   `gorm:"column:strategy_status"`                               // 悬赏策略状态
+}
+
+func (m *RewardStrategy) TableName() string {
+	return "reward_strategy"
+}

+ 12 - 1
model/http_model/qecode.go

@@ -32,7 +32,18 @@ type WxQrCodeResponse struct {
 	Buffer      []byte `json:"buffer"`
 }
 type GetWxQRCodeData struct {
-	QrCodeBytes []byte `json:"qr_code_bytes"`
+	QrCodeBytes         []byte  `json:"qr_code_bytes"`        // 二维码
+	SelectedName        string  `json:"selected_name"`        // 带货任务名称
+	TaskMode            int     `json:"task_mode"`            // 任务形式,1、2分别表示悬赏任务、纯佣带货
+	SampleMode          int     `json:"sample_mode"`          // 领样形式,1、2、3分别表示免费领样、垫付领样、不提供样品
+	SaleActual          int     `json:"sale_actual"`          // 带货销量条件
+	PerReward           float64 `json:"per_reward"`           // 每人可获得悬赏金
+	ProductPrice        float64 `json:"product_price"`        // 商品价值
+	CommissionPrice     float64 `json:"commission_price"`     // 每单赚-佣金金额
+	ExclusiveCommission float64 `json:"exclusive_commission"` // 每单赚-佣金比例
+	MainPhotoUrl        string  `json:"main_photo_url"`       // 商品主图url
+	ProjectType         int     `json:"project_type"`         // 种草任务类型,1代表公开,2代表定向
+	ProjectName         string  `json:"project_name"`         // 种草任务名称
 }
 
 func NewGetWxQRCodeRequest() *GetWxQRCodeRequest {

+ 4 - 4
route/init.go

@@ -28,7 +28,7 @@ func InitRoute(r *gin.Engine) {
 		})
 	}
 
-	subAccount := r.Group("/youngee/subAccount")
+	subAccount := r.Group("/youngee/b/subAccount")
 	{
 		subAccount.Use(middleware.LoginAuthMiddleware)
 		subAccount.POST("/create", handler.WrapAddNewSubAccountHandler)  // 商家子账号注册
@@ -37,7 +37,7 @@ func InitRoute(r *gin.Engine) {
 		subAccount.POST("/update", handler.WrapFindAllSubAccountHandler) // 修改商家子账号
 	}
 
-	job := r.Group("/youngee/job")
+	job := r.Group("/youngee/b/job")
 	{
 		job.Use(middleware.LoginAuthMiddleware)
 		job.POST("/get", handler.WrapFindAllJobHandler)   // 查找商家全部所属岗位
@@ -46,7 +46,7 @@ func InitRoute(r *gin.Engine) {
 		job.POST("/delete", handler.WrapdeleteJobHandler) // 商家删除岗位
 	}
 
-	accountInfo := r.Group("/youngee")
+	accountInfo := r.Group("/youngee/b")
 	{
 		accountInfo.Use(middleware.LoginAuthMiddleware)
 		accountInfo.POST("/getUserInfo", handler.WrapGetUserInfoHandler)              // 商家用户信息
@@ -436,6 +436,6 @@ func InitRoute(r *gin.Engine) {
 	{
 		common.POST("/platform", controller.CommonController{}.CooperationPlatform)     // 获取合作平台icon
 		common.POST("/product/category", controller.CommonController{}.ProductCategory) // 获取商品类目
-		common.POST("/talent/province", handler.WrapGetProviceHandler)                  //获取达人省份
+		common.POST("/talent/province", handler.WrapGetProviceHandler)                  // 获取达人省份
 	}
 }

+ 56 - 0
service/autoTask.go

@@ -1,11 +1,13 @@
 package service
 
 import (
+	"context"
 	"fmt"
 	"github.com/robfig/cron/v3"
 	log "github.com/sirupsen/logrus"
 	"time"
 	"youngee_b_api/db"
+	"youngee_b_api/model/gorm_model"
 )
 
 func AutoTask() error {
@@ -102,3 +104,57 @@ func GetAutoCaseCloseDefaultTask() {
 		log.Println("GetAutoCaseCloseDefaultTask error : ", err)
 	}
 }
+
+// UpdateProjectTaskRedBookLinkData 定时拉取小红书平台,种草子任务链接数据
+func UpdateProjectTaskRedBookLinkData() {
+	// GetRedBookLinkDetail()
+	// 1. 符合条件的project
+	ctx := context.Background()
+	projectIdList, projectIdListTotal, projectIdListErr := db.GetProjectIdList(ctx, 8, 1)
+	if projectIdListErr != nil {
+		log.Println("GetProjectIdList error : ", projectIdListErr)
+		return
+	}
+
+	// 2. 符合条件的task
+	if projectIdList != nil && projectIdListTotal != 0 {
+		for _, projectId := range projectIdList {
+			taskIdList, taskIdTotal, taskIdErr := db.GetProjectTaskIdList(ctx, projectId)
+			if taskIdErr != nil {
+				log.Println("GetProjectTaskIdList error : ", taskIdErr)
+				return
+			}
+			if taskIdList != nil && taskIdTotal != 0 {
+				for _, taskId := range taskIdList {
+					linkInfo, linkErr := db.GetProjectTaskLinkInfo(ctx, taskId, 1)
+					if linkErr != nil {
+						log.Println("GetProjectTaskLinkInfo error : ", linkErr)
+						return
+					}
+					if linkInfo != "" {
+						like, comment, collect, share, moreApiErr := GetRedBookLinkDetail(ctx, linkInfo)
+						if moreApiErr != nil {
+							log.Println("GetRedBookLinkDetail error : ", moreApiErr)
+							return
+						}
+						ctrateData := gorm_model.ProjectTaskLinkStatistic{
+							ProjectId:       projectId,
+							TaskID:          taskId,
+							PlatformId:      1,
+							VoteCount:       like,
+							CommitCount:     comment,
+							CollectionCount: collect,
+							ViewCount:       share,
+						}
+						createErr := db.CreateProjectTaskLinkStatistic(ctx, &ctrateData)
+						if createErr != nil {
+							log.Println("CreateProjectTaskLinkStatistic error : ", createErr)
+							return
+						}
+					}
+				}
+
+			}
+		}
+	}
+}

+ 54 - 4
service/qrcode.go

@@ -85,11 +85,61 @@ func (q *qrcode) GetWxQrCode(ctx context.Context, req *http_model.GetWxQRCodeReq
 
 	var reqPath string
 	var reqData string
+	var respData *http_model.GetWxQRCodeData
+	respData = &http_model.GetWxQRCodeData{}
 
+	// 推广带货任务
 	if req.SelectionId != "" {
 		reqPath = "pageCommerce/taskDetail"
 		reqData = req.SelectionId
+
+		// selectionInfo, selectionInfoErr := db.GetSelectionById(ctx, req.SelectionId)
+		// if selectionInfoErr != nil {
+		// 	fmt.Printf("err: %+v\n", selectionInfoErr)
+		// 	return nil, selectionInfoErr
+		// }
+		// if selectionInfo != nil {
+		// 	respData.SelectedName = selectionInfo.SelectionName
+		// 	respData.TaskMode = selectionInfo.TaskMode
+		// 	respData.SampleMode = selectionInfo.SampleMode
+		//
+		// 	selectionRewardStrategy, selectionRewardStrategyErr := db.GetRewardStrategyBySelectionId(ctx, req.SelectionId)
+		// 	if selectionRewardStrategyErr != nil {
+		// 		fmt.Printf("err: %+v\n", selectionRewardStrategyErr)
+		// 		return nil, selectionRewardStrategyErr
+		// 	}
+		// 	if selectionRewardStrategy != nil {
+		// 		respData.PerReward = selectionRewardStrategy[0].PerReward
+		// 		respData.SaleActual = int(selectionRewardStrategy[0].SaleActual)
+		// 	}
+		//
+		// 	selectionProductInfo, selectionProductInfoErr := db.GetProductInfoBySelectionId(ctx, req.SelectionId)
+		// 	if selectionProductInfoErr != nil {
+		// 		fmt.Printf("err: %+v\n", selectionProductInfoErr)
+		// 		return nil, selectionProductInfoErr
+		// 	}
+		// 	if selectionProductInfo != nil {
+		// 		respData.ProductPrice = selectionProductInfo.ProductPrice
+		// 		respData.CommissionPrice = selectionProductInfo.CommissionPrice
+		// 		respData.ExclusiveCommission = selectionProductInfo.ExclusiveCommission
+		// 	}
+		// 	selectionProductPhoto, selectionProductPhotoErr := db.GetProductPhotoByProductID(ctx, int64(selectionInfo.ProductID))
+		// 	if selectionProductPhotoErr != nil {
+		// 		fmt.Printf("err: %+v\n", selectionProductPhotoErr)
+		// 		return nil, selectionProductPhotoErr
+		// 	}
+		// 	if selectionProductPhoto != nil {
+		// 		for _, photo := range selectionProductPhoto {
+		// 			if photo.Symbol == 1 {
+		// 				respData.MainPhotoUrl = photo.PhotoUrl
+		// 				break
+		// 			}
+		// 		}
+		// 	}
+		// }
 	}
+
+	// 推广种草任务
 	if req.SProjectId != 0 || req.ProjectId != "" {
 		reqPath = "pageRecommend/recommendDetail"
 		if req.SProjectId != 0 {
@@ -98,6 +148,8 @@ func (q *qrcode) GetWxQrCode(ctx context.Context, req *http_model.GetWxQRCodeReq
 			reqData = req.ProjectId + "-" + "0"
 		}
 	}
+
+	// 推广本地生活任务
 	if req.SLocalId != 0 || req.LocalId != "" {
 		reqPath = "pageLife/lifeDetail"
 		if req.SLocalId != 0 {
@@ -150,9 +202,7 @@ func (q *qrcode) GetWxQrCode(ctx context.Context, req *http_model.GetWxQRCodeReq
 			return nil, err
 		}
 	}
-	data := http_model.GetWxQRCodeData{
-		QrCodeBytes: qrcodeBytes,
-	}
+	respData.QrCodeBytes = qrcodeBytes
 	//fmt.Printf("data: %+v\n", data)
-	return &data, nil
+	return respData, nil
 }

+ 120 - 0
service/talent_platform_link_statistic.go

@@ -0,0 +1,120 @@
+package service
+
+import (
+	"context"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"io/ioutil"
+	"net/http"
+	"strconv"
+	"strings"
+)
+
+type XiaohongshuNoteResponse struct {
+	Code int `json:"code"`
+	Data struct {
+		ResponseBody struct {
+			Data struct {
+				Items []struct {
+					NoteCard struct {
+						InteractInfo struct {
+							LikedCount     string `json:"liked_count"`     // 点赞数
+							CommentCount   string `json:"comment_count"`   // 评论数
+							CollectedCount string `json:"collected_count"` // 收藏数
+							ShareCount     string `json:"share_count"`     // 分享数
+						} `json:"interact_info"`
+					} `json:"note_card"`
+				} `json:"items"`
+			} `json:"data"`
+		} `json:"response_body"`
+	} `json:"data"`
+}
+
+func parseNoteStats(jsonData []byte) (likes, comments, collects, shares string, err error) {
+	var resp XiaohongshuNoteResponse
+	if err := json.Unmarshal(jsonData, &resp); err != nil {
+		return "", "", "", "", fmt.Errorf("JSON解析失败: %v", err)
+	}
+
+	// 检查数据是否存在
+	if len(resp.Data.ResponseBody.Data.Items) == 0 {
+		return "", "", "", "", errors.New("未找到笔记数据")
+	}
+
+	stats := resp.Data.ResponseBody.Data.Items[0].NoteCard.InteractInfo
+	return stats.LikedCount, stats.CommentCount, stats.CollectedCount, stats.ShareCount, nil
+}
+
+func GetRedBookLinkDetail(ctx context.Context, shareText string) (int, int, int, int, error) {
+
+	url := "http://120.46.92.62:6888/api/xhs/note_detail"
+	method := "POST"
+
+	// 构造请求体结构
+	requestBody := struct {
+		ShareText string `json:"share_text"`
+		Proxy     string `json:"proxy"`
+	}{
+		ShareText: shareText,
+		Proxy:     "",
+	}
+
+	jsonData, err := json.Marshal(requestBody)
+	if err != nil {
+		fmt.Println("JSON编码失败:", err)
+		return 0, 0, 0, 0, err
+	}
+
+	payload := strings.NewReader(string(jsonData))
+
+	client := &http.Client{}
+	req, err := http.NewRequest(method, url, payload)
+
+	if err != nil {
+		// fmt.Println(err)
+		return 0, 0, 0, 0, err
+	}
+	req.Header.Add("Cookie", "abRequestId=87d8ec6f-314f-5914-af1d-21296bf34c5f; a1=197a0b8a06djmry91j6taqhe0kcutwojdcu15nypd50000386246; webId=ae01b40eef7780a778b6624a3b295f4f; gid=yjW08S8Y2yffyjW08DY08SIvKfV6FvjyVK907UfAxd8TSy2879ElV2888qYKJ4K82qfKy82D; webBuild=4.68.0; acw_tc=0a4a2d6e17510033969926232e7b39d55058a43fb37e1ddc19745e6642f746; websectiga=7750c37de43b7be9de8ed9ff8ea0e576519e8cd2157322eb972ecb429a7735d4; sec_poison_id=b4fae566-5d78-4269-85c6-28fc28ec20d3; xsecappid=xhs-pc-web; web_session=040069b22467fb3084e74f796b3a4b11424ee0; loadts=1751003476156; unread={%22ub%22:%22685b56850000000020019eef%22%2C%22ue%22:%22685df405000000002201fd00%22%2C%22uc%22:14}")
+	req.Header.Add("Content-Type", "application/json")
+
+	res, err := client.Do(req)
+	if err != nil {
+		// fmt.Println(err)
+		return 0, 0, 0, 0, err
+	}
+	defer res.Body.Close()
+
+	body, err := ioutil.ReadAll(res.Body)
+	if err != nil {
+		// fmt.Println(err)
+		return 0, 0, 0, 0, err
+	}
+	fmt.Println(string(body))
+
+	// 提取互动数据
+	likes, comments, collects, shares, err := parseNoteStats(body)
+	if err != nil {
+		//fmt.Println("解析互动数据失败:", err)
+		return 0, 0, 0, 0, err
+	}
+
+	// fmt.Println("点赞数:", likes)
+	// fmt.Println("评论数:", comments)
+	// fmt.Println("收藏数:", collects)
+	// fmt.Println("分享数(可作为浏览量参考):", shares)
+
+	like, likeErr := strconv.Atoi(likes)
+	if likeErr != nil {
+	}
+	comment, commentErr := strconv.Atoi(comments)
+	if commentErr != nil {
+	}
+	collect, collectErr := strconv.Atoi(collects)
+	if collectErr != nil {
+	}
+	share, shareErr := strconv.Atoi(shares)
+	if shareErr != nil {
+	}
+	return like, comment, collect, share, nil
+}