Browse Source

账单数据&达人账单

Ethan 2 hours ago
parent
commit
97cc8db849

+ 54 - 0
app/controller/bill_controller.go

@@ -107,6 +107,60 @@ func (f BillController) LocalSupplierBillList(c *gin.Context) {
 	returnSuccess(c, 20000, result)
 }
 
+// 品牌种草达人账单列表
+func (f BillController) ProjectTalentBillList(c *gin.Context) {
+	param := &vo.SearchTalentBillParam{}
+	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.BillService{}.GetBillProjectTalentList(param)
+	if err != nil {
+		logrus.Errorf("[GetBillProjectTalentList] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}
+
+// 本地生活达人账单列表
+func (f BillController) LocalTalentBillList(c *gin.Context) {
+	param := &vo.SearchTalentBillParam{}
+	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.BillService{}.GetBillLocalTalentList(param)
+	if err != nil {
+		logrus.Errorf("[GetBillLocalTalentList] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}
+
+// 账单查询-顶部数据预览
+func (f BillController) BillPreview(c *gin.Context) {
+	param := &vo.SearchTalentBillParam{}
+	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.BillService{}.GetBillPreview(param)
+	if err != nil {
+		logrus.Errorf("[GetBillPreview] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}
+
 // 品牌种草账单支付
 func (f BillController) ProjectPay(c *gin.Context) {
 	param := &vo.PayParam{}

+ 29 - 0
app/dao/local_life_task_info_dao.go

@@ -261,3 +261,32 @@ func (d LocalLifeTaskInfoDao) GetLocalLifeInfoByTalentId(talentid string, others
 	return projectTaskInfos, total, nil
 
 }
+
+// 获取指定任务阶段的本地生活子任务
+func (d LocalLifeTaskInfoDao) GetListByTaskStage2(localId string, taskStage int64, page int, pageSize int, talentNickname string) ([]*entity.LocalLifeTaskInfo, int64, error) {
+	var taskInfos []*entity.LocalLifeTaskInfo
+	var total int64
+	query := Db.Model(&entity.LocalLifeTaskInfo{})
+	query = query.Where("local_id = ? AND task_stage = ?", localId, taskStage)
+	if talentNickname != "" {
+		//var talentInfos []entity.PlatformKuaishouUserInfo
+		//err1 := Db.Model(&entity.PlatformKuaishouUserInfo{}).Where("nick_name = ?", talentNickname).Find(&talentInfos).Error
+		//if err1 != nil {
+		//	return nil, 0, err1
+		//}
+		//var openIds []string
+		//for _, talentInfo := range talentInfos {
+		//	openIds = append(openIds, talentInfo.OpenID)
+		//}
+		query = query.Where("talent_name = ?", talentNickname)
+	}
+	// 计算偏移量
+	offset := (page - 1) * pageSize
+	var err error
+	query.Count(&total)
+	err = query.Order("complete_date desc").Offset(offset).Limit(pageSize).Find(&taskInfos).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	return taskInfos, total, nil
+}

+ 30 - 1
app/dao/project_task_info_dao.go

@@ -44,7 +44,7 @@ func (d ProjectTaskInfoDao) CountExcuteNumByOpenid(openid string) int64 {
 	return total
 }
 
-// 获取指定任务阶段的种草子任务
+// 获取指定任务阶段的种草子任务(包含时间限制)
 func (d ProjectTaskInfoDao) GetListByTaskStage(projectId string, taskStage int64, time string, page int, pageSize int, talentNickname string) ([]*entity.ProjectTaskInfo, int64, error) {
 	var taskInfos []*entity.ProjectTaskInfo
 	var total int64
@@ -253,3 +253,32 @@ func (d ProjectTaskInfoDao) GetProjectInfoByTalentId(talentid string, others str
 
 	return projectTaskInfos, total, nil
 }
+
+// 获取指定任务阶段的种草子任务
+func (d ProjectTaskInfoDao) GetListByTaskStage2(projectId string, taskStage int64, page int, pageSize int, talentNickname string) ([]*entity.ProjectTaskInfo, int64, error) {
+	var taskInfos []*entity.ProjectTaskInfo
+	var total int64
+	query := Db.Model(&entity.ProjectTaskInfo{})
+	query = query.Where("project_id = ? AND task_stage = ?", projectId, taskStage)
+	if talentNickname != "" {
+		//var talentInfos []entity.PlatformKuaishouUserInfo
+		//err1 := Db.Model(&entity.PlatformKuaishouUserInfo{}).Where("nick_name = ?", talentNickname).Find(&talentInfos).Error
+		//if err1 != nil {
+		//	return nil, 0, err1
+		//}
+		//var openIds []string
+		//for _, talentInfo := range talentInfos {
+		//	openIds = append(openIds, talentInfo.OpenID)
+		//}
+		query = query.Where("talent_name = ?", talentNickname)
+	}
+	// 计算偏移量
+	offset := (page - 1) * pageSize
+	var err error
+	query.Count(&total)
+	err = query.Order("complete_date desc").Offset(offset).Limit(pageSize).Find(&taskInfos).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	return taskInfos, total, nil
+}

+ 1 - 0
app/entity/local_life_info.go

@@ -54,6 +54,7 @@ type LocalLifeInfo struct {
 	ExploredNum         int64     `gorm:"column:explored_num;default:0;NOT NULL"`           // 已探店
 	InvoiceStatus       int64     `gorm:"column:invoice_status;default:0;NOT NULL"`         // 开票状态(1开票中 2已开票)
 	NeedPay             float64   `gorm:"column:need_pay"`                                  // 待支付金额
+	SettleNum           int64     `gorm:"column:settle_num"`
 	SettleFlag          int64     `gorm:"column:settle_flag"`
 }
 

+ 7 - 3
app/entity/local_life_task_info.go

@@ -52,8 +52,6 @@ type LocalLifeTaskInfo struct {
 	DraftFee               float64   `gorm:"column:draft_fee;default:0.00"`               // 达人稿费,达人所见的稿费金额
 	SignedTime             time.Time `gorm:"column:signed_time"`                          // 签收时间
 	FansNum                int64     `gorm:"column:fans_num"`                             // 粉丝数
-	VoteAvg                int64     `gorm:"column:vote_avg"`                             // 平均点赞数
-	CommitAvg              int64     `gorm:"column:commit_avg"`                           // 平均评论数
 	BOperator              string    `gorm:"column:b_operator"`                           // 商家确定达人操作人ID
 	BOperatorType          int64     `gorm:"column:b_operator_type;default:0"`            // 商家操作人类型,1商家用户,2商家子账号,3管理后台
 	SOperator              int64     `gorm:"column:s_operator;default:0"`                 // 服务商提报达人操作人ID
@@ -80,7 +78,13 @@ type LocalLifeTaskInfo struct {
 	ReserveTime            time.Time `gorm:"column:reserve_time"`                         // 预约探店时间
 	ExploreTime            time.Time `gorm:"column:explore_time"`                         // 探店时间
 	FinishExploreTime      time.Time `gorm:"column:finish_explore_time"`                  // 完成探店时间
-	CollectNum             int       `gorm:"column:collect_num"`
+	ViewNum                int64     `gorm:"column:view_num"`
+	VoteAvg                int64     `gorm:"column:vote_avg"`
+	CollectNum             int64     `gorm:"column:collect_num"`
+	CommitAvg              int64     `gorm:"column:commit_avg"`
+
+	SOperateName string `gorm:"column:s_operate_name"`
+	TalentName   string `gorm:"column:talent_name"`
 }
 
 func (m *LocalLifeTaskInfo) TableName() string {

+ 1 - 0
app/entity/project.go

@@ -55,6 +55,7 @@ type Project struct {
 	DeliveryNum       int64     `gorm:"column:delivery_num"`
 	AfterDeliveryNum  int64     `gorm:"column:after_delivery_num"`
 	NeedPay           float64   `gorm:"column:need_pay"` // 待支付金额
+	SettleNum         int64     `gorm:"column:settle_num"`
 	SettleFlag        int64     `gorm:"column:settle_flag"`
 }
 

+ 9 - 6
app/entity/project_task_info.go

@@ -55,13 +55,16 @@ type ProjectTaskInfo struct {
 	TerminateOperator      string    `gorm:"column:terminate_operator"`
 	CancelOperatorType     int64     `gorm:"column:cancel_operator_type;default:0;NOT NULL"`
 	CancelOperator         string    `gorm:"column:cancel_operator"`
-	TalentName             string    `gorm:"column:talent_name"`
 	OpenID                 string    `gorm:"column:open_id"` // 达人报名的唯一标识
-	ViewNum                int       `gorm:"column:view_num"`
-	VoteAvg                int       `gorm:"column:vote_avg"`
-	CollectNum             int       `gorm:"column:collect_num"`
-	CommitAvg              int       `gorm:"column:commit_avg"`
-	PlatformId             int       `gorm:"column:platform_id"`
+	ViewNum                int64     `gorm:"column:view_num"`
+	VoteAvg                int64     `gorm:"column:vote_avg"`
+	CollectNum             int64     `gorm:"column:collect_num"`
+	CommitAvg              int64     `gorm:"column:commit_avg"`
+	PlatformId             int64     `gorm:"column:platform_id"`
+	SupplierId             int64     `gorm:"column:supplier_id"`
+
+	SOperateName string `gorm:"column:s_operate_name"`
+	TalentName   string `gorm:"column:talent_name"`
 }
 
 func (m *ProjectTaskInfo) TableName() string {

+ 175 - 0
app/service/bill_service.go

@@ -359,6 +359,181 @@ func (s BillService) GetBillLocalSupplierList(param *vo.SearchSupplierBillParam)
 	return result, nil
 }
 
+// 品牌种草账单达人列表
+func (s BillService) GetBillProjectTalentList(param *vo.SearchTalentBillParam) (vo.ResultVO, error) {
+	if param.Page == 0 {
+		param.Page = 1
+	}
+	if param.PageSize == 0 {
+		param.PageSize = 10
+	}
+	var result vo.ResultVO
+	var reBillTalents []vo.ReBillTalent
+	var stage int64
+	if param.Status == 1 {
+		stage = 15
+	} else if param.Status == 2 {
+		stage = 15
+	}
+	taskInfos, total, err := dao.ProjectTaskInfoDao{}.GetListByTaskStage2(param.TaskId, stage, param.Page, param.PageSize, param.Others)
+	if err != nil {
+		return result, err
+	}
+	for _, taskInfo := range taskInfos {
+		talentId := taskInfo.TalentID
+		talentInfo, _ := dao.TalentInfoDao{}.GetTalentInfo(talentId)
+		platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.GetUserInfo(taskInfo.OpenID)
+		reBillTalent := vo.ReBillTalent{
+			TalentId:     talentId,
+			OpenId:       platformKuaishouUserInfo.OpenID,
+			PlatformId:   platformKuaishouUserInfo.PlatformID,
+			NickName:     talentInfo.TalentNickname,
+			HeadUri:      platformKuaishouUserInfo.HeadUri,
+			City:         platformKuaishouUserInfo.City,
+			Gender:       platformKuaishouUserInfo.Gender,
+			ViewNum:      taskInfo.ViewNum,
+			VoteAvg:      taskInfo.VoteAvg,
+			CollectNum:   taskInfo.CollectNum,
+			CommitAvg:    taskInfo.CommitAvg,
+			ChargeActual: taskInfo.RealPayment,
+			ChargeSettle: taskInfo.SettleAmount,
+			SettleTime:   taskInfo.CompleteDate.Format("2006-01-02 15:04:05"),
+		}
+		if taskInfo.SupplierId == 0 {
+			reBillTalent.TalentSource = "公海"
+		} else {
+			reBillTalent.TalentSource = taskInfo.SOperateName
+		}
+		reBillTalents = append(reBillTalents, reBillTalent)
+	}
+	result = vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    total,
+		Data:     reBillTalents,
+	}
+	return result, nil
+}
+
+// 本地生活账单达人列表
+func (s BillService) GetBillLocalTalentList(param *vo.SearchTalentBillParam) (vo.ResultVO, error) {
+	if param.Page == 0 {
+		param.Page = 1
+	}
+	if param.PageSize == 0 {
+		param.PageSize = 10
+	}
+	var result vo.ResultVO
+	var reBillTalents []vo.ReBillTalent
+	var stage int64
+	if param.Status == 1 {
+		stage = 15
+	} else if param.Status == 2 {
+		stage = 15
+	}
+	taskInfos, total, err := dao.LocalLifeTaskInfoDao{}.GetListByTaskStage2(param.TaskId, stage, param.Page, param.PageSize, param.Others)
+	if err != nil {
+		return result, err
+	}
+	for _, taskInfo := range taskInfos {
+		talentId := taskInfo.TalentID
+		talentInfo, _ := dao.TalentInfoDao{}.GetTalentInfo(talentId)
+		platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.GetUserInfo(taskInfo.OpenID)
+		reBillTalent := vo.ReBillTalent{
+			TalentId:     talentId,
+			OpenId:       platformKuaishouUserInfo.OpenID,
+			PlatformId:   platformKuaishouUserInfo.PlatformID,
+			NickName:     talentInfo.TalentNickname,
+			HeadUri:      platformKuaishouUserInfo.HeadUri,
+			City:         platformKuaishouUserInfo.City,
+			Gender:       platformKuaishouUserInfo.Gender,
+			ViewNum:      taskInfo.ViewNum,
+			VoteAvg:      taskInfo.VoteAvg,
+			CollectNum:   taskInfo.CollectNum,
+			CommitAvg:    taskInfo.CommitAvg,
+			ChargeActual: taskInfo.RealPayment,
+			ChargeSettle: taskInfo.SettleAmount,
+			SettleTime:   taskInfo.CompleteDate.Format("2006-01-02 15:04:05"),
+		}
+		if taskInfo.SupplierID == 0 {
+			reBillTalent.TalentSource = "公海"
+		} else {
+			reBillTalent.TalentSource = taskInfo.SOperateName
+		}
+		reBillTalents = append(reBillTalents, reBillTalent)
+	}
+	result = vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    total,
+		Data:     reBillTalents,
+	}
+	return result, nil
+}
+
+// 账单查询-顶部数据预览
+func (s BillService) GetBillPreview(param *vo.SearchTalentBillParam) (vo.ReBillDataPreview, error) {
+	var reBillDataPreview vo.ReBillDataPreview
+	if param.Task == 2 {
+		project, err := dao.ProjectDAO{}.GetProjectById(param.TaskId)
+		if err != nil {
+			return reBillDataPreview, err
+		}
+		if project == nil {
+			return reBillDataPreview, nil
+		}
+		var talentTotalAmount, supplierTotalAmount float64
+		taskInfos, _, err2 := dao.ProjectTaskInfoDao{}.GetListByTaskStage2(param.TaskId, 15, param.Page, param.PageSize, "")
+		if err2 != nil || len(taskInfos) == 0 {
+			talentTotalAmount = 0.0
+			supplierTotalAmount = 0.0
+		}
+		for _, taskInfo := range taskInfos {
+			if taskInfo.SupplierId == 0 {
+				talentTotalAmount += taskInfo.SettleAmount
+			} else {
+				supplierTotalAmount += taskInfo.RealServiceCharge
+			}
+		}
+		reBillDataPreview = vo.ReBillDataPreview{
+			FrozenTotalAmount:   project.NeedPay,
+			SettleTotalAmount:   project.SettlementAmount,
+			TalentNum:           project.SettleNum,
+			TalentTotalAmount:   talentTotalAmount,
+			SupplierTotalAmount: supplierTotalAmount,
+		}
+	} else if param.Task == 3 {
+		local, err := dao.LocalLifeDao{}.GetLocalById(param.TaskId)
+		if err != nil {
+			return reBillDataPreview, err
+		}
+		if local == nil {
+			return reBillDataPreview, nil
+		}
+		var talentTotalAmount, supplierTotalAmount float64
+		taskInfos, _, err2 := dao.LocalLifeTaskInfoDao{}.GetListByTaskStage2(param.TaskId, 15, param.Page, param.PageSize, "")
+		if err2 != nil || len(taskInfos) == 0 {
+			talentTotalAmount = 0.0
+			supplierTotalAmount = 0.0
+		}
+		for _, taskInfo := range taskInfos {
+			if taskInfo.SupplierID == 0 {
+				talentTotalAmount += taskInfo.SettleAmount
+			} else {
+				supplierTotalAmount += taskInfo.RealServiceCharge
+			}
+		}
+		reBillDataPreview = vo.ReBillDataPreview{
+			FrozenTotalAmount:   local.NeedPay,
+			SettleTotalAmount:   local.SettlementAmount,
+			TalentNum:           local.SettleNum,
+			TalentTotalAmount:   talentTotalAmount,
+			SupplierTotalAmount: supplierTotalAmount,
+		}
+	}
+	return reBillDataPreview, nil
+}
+
 // 本地生活账单列表
 func (s BillService) GetBillLocalLifeTaskList(param *vo.LocalSearchParam) (vo.ResultVO, error) {
 	if param.Page == 0 {

+ 2 - 2
app/service/cooperation_service.go

@@ -440,10 +440,10 @@ func (t CooperationService) GetTalentPerform(param *vo.TalentDataParam) (vo.Resu
 				perform.MainImage = productMainPhoto.PhotoUrl
 				perform.ProductName = product.ProductName
 				perform.Price = product.ProductPrice
-				perform.VoteCount = int(sectask.VoteAvg)
+				perform.VoteCount = sectask.VoteAvg
 				perform.ViewCount = 0
 				perform.CollectCount = sectask.CollectNum
-				perform.CommentCount = int(sectask.CommitAvg)
+				perform.CommentCount = sectask.CommitAvg
 
 			}
 			talentDataParams = append(talentDataParams, &perform)

+ 9 - 0
app/vo/re_bill_data_preview.go

@@ -0,0 +1,9 @@
+package vo
+
+type ReBillDataPreview struct {
+	FrozenTotalAmount   float64 `json:"frozenTotalAmount"`   // 成本冻结总金额
+	SettleTotalAmount   float64 `json:"settleTotalAmount"`   // 实际结算总金额
+	TalentNum           int64   `json:"talentNum"`           // 已结算达人数
+	TalentTotalAmount   float64 `json:"talentTotalAmount"`   // 公海达人实际结算总金额
+	SupplierTotalAmount float64 `json:"supplierTotalAmount"` // 服务商实际结算总金额
+}

+ 22 - 0
app/vo/re_bill_talent.go

@@ -0,0 +1,22 @@
+package vo
+
+type ReBillTalent struct {
+	TalentId     string `json:"talentId"`
+	OpenId       string `json:"openId"` // 表platform_kuaishou_user_info
+	PlatformId   int64  `json:"platformId"`
+	NickName     string `json:"nickName"`
+	HeadUri      string `json:"headUri"`
+	City         string `json:"city"`
+	Gender       string `json:"gender"` // U:未知;M,m:男;F f女
+	TaskId       string `json:"taskId"` // 任务id
+	TalentSource string `json:"talentSource"`
+
+	ViewNum    int64 `json:"viewNum"`    // 浏览/播放/阅读
+	VoteAvg    int64 `json:"voteAvg"`    // 点赞
+	CollectNum int64 `json:"collectNum"` // 收藏
+	CommitAvg  int64 `json:"commitAvg"`  // 评论
+
+	ChargeActual float64 `json:"chargeActual"` // 应付金额
+	ChargeSettle float64 `json:"chargeSettle"` // 实际结算金额
+	SettleTime   string  `json:"settleTime"`   // 结算时间
+}

+ 4 - 4
app/vo/re_talent_coop_data.go

@@ -45,10 +45,10 @@ type TalentPerformance struct {
 	ProductName string  `json:"productName"`
 	Price       float64 `json:"price"`
 
-	ViewCount    int    `json:"viewCount"`
-	VoteCount    int    `json:"voteCount"`
-	CollectCount int    `json:"collectCount"`
-	CommentCount int    `json:"commentCount"`
+	ViewCount    int64  `json:"viewCount"`
+	VoteCount    int64  `json:"voteCount"`
+	CollectCount int64  `json:"collectCount"`
+	CommentCount int64  `json:"commentCount"`
 	Category     string `json:"category"`
 	SalesNum     int64  `json:"salesNum"`
 }

+ 15 - 0
app/vo/search_talent_bill_param.go

@@ -0,0 +1,15 @@
+package vo
+
+type SearchTalentBillParam struct {
+	EnterpriseId string `json:"enterprise_id"`
+	SubAccountId int64  `json:"sub_account_id"`
+	Page         int    `json:"page"`
+	PageSize     int    `json:"page_size"`
+	TaskId       string `json:"task_id"`
+	Task         int    `json:"task"`      // 2品牌种草,3本地生活
+	Status       int    `json:"status"`    // 1执行中 2已结算
+	TaskType     int64  `json:"task_type"` // 项目类型,1全流程项目,2专项项目
+	Order        int64  `json:"order"`     // 排序 0降序 1升序(默认0)
+
+	Others string `json:"others"` // 达人名称
+}

+ 3 - 0
route/init.go

@@ -384,6 +384,9 @@ func InitRoute(r *gin.Engine) {
 		finance.POST("/bill/local/list", controller.BillController{}.LocalLifeBillList)                  // 账单查询-本地生活列表
 		finance.POST("/bill/project/supplier/list", controller.BillController{}.ProjectSupplierBillList) // 账单查询-品牌种草服务商账单列表
 		finance.POST("/bill/local/supplier/list", controller.BillController{}.LocalSupplierBillList)     // 账单查询-本地生活服务商账单列表
+		finance.POST("/bill/project/talent/list", controller.BillController{}.ProjectTalentBillList)     // 账单查询-品牌种草达人账单列表
+		finance.POST("/bill/local/talent/list", controller.BillController{}.LocalTalentBillList)         // 账单查询-本地生活达人账单列表
+		finance.POST("/bill/data/preview", controller.BillController{}.BillPreview)                      // 账单查询-顶部数据预览
 
 	}
 	// 推广合作-服务商相关接口