Răsfoiți Sursa

公开&定向任务待办

Ethan 1 lună în urmă
părinte
comite
e9517c0b2e

+ 72 - 0
app/controller/workspace_controller.go

@@ -2,13 +2,16 @@ package controller
 
 import (
 	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
 	"youngee_b_api/app/service"
+	"youngee_b_api/app/vo"
 )
 
 type WorkspaceController struct{}
 
 type GetTakegoodsInfoParam struct {
 	EnterpriseId string `json:"enterprise_id"`
+	SubAccountId int64  `json:"sub_account_id"`
 	DateRange    string `json:"days"`
 }
 
@@ -16,6 +19,7 @@ func (w WorkspaceController) GetTakegoodsInfo(c *gin.Context) {
 	search := &GetTakegoodsInfoParam{}
 	err := c.BindJSON(&search)
 	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
 		returnError(c, 40000, "Parameter Error: "+err.Error())
 		return
 	}
@@ -23,3 +27,71 @@ func (w WorkspaceController) GetTakegoodsInfo(c *gin.Context) {
 
 	returnSuccess(c, 20000, result)
 }
+
+// 任务待办-公开任务
+func (t WorkspaceController) GetPublicTask(c *gin.Context) {
+	param := &vo.CommonParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "Parameter Error: "+err.Error())
+		return
+	}
+	selectionToDo, err1 := service.SelectionInfoService{}.GetSelectionToDo(param.EnterpriseId, param.SubAccountId)
+	if err1 != nil {
+		logrus.Errorf("[SelectionInfoService] call Show err:%+v\n", err1)
+		returnError(c, 40000, err1.Error())
+		return
+	}
+	projectToDo, err2 := service.ProjectService{}.GetProjectToDo(param.EnterpriseId, param.SubAccountId, 1)
+	if err2 != nil {
+		logrus.Errorf("[ProjectService] call Show err:%+v\n", err2)
+		returnError(c, 40000, err2.Error())
+		return
+	}
+	localLifeToDo, err3 := service.LocalLifeService{}.GetLocalLifeToDo(param.EnterpriseId, param.SubAccountId, 1)
+	if err3 != nil {
+		logrus.Errorf("[LocalLifeService] call Show err:%+v\n", err3)
+		returnError(c, 40000, err3.Error())
+		return
+	}
+	resultMap := make(map[string]*map[string]map[string]int64)
+	resultMap["selectionToDo"] = &selectionToDo
+	resultMap["projectToDo"] = &projectToDo
+	resultMap["localLifeToDo"] = &localLifeToDo
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 任务待办-定向任务
+func (t WorkspaceController) GetTargetTask(c *gin.Context) {
+	param := &vo.CommonParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "Parameter Error: "+err.Error())
+		return
+	}
+	selectionToDo, err1 := service.SelectionInfoService{}.GetSelectionToDo(param.EnterpriseId, param.SubAccountId)
+	if err1 != nil {
+		logrus.Errorf("[SelectionInfoService] call Show err:%+v\n", err1)
+		returnError(c, 40000, err1.Error())
+		return
+	}
+	projectToDo, err2 := service.ProjectService{}.GetProjectToDo(param.EnterpriseId, param.SubAccountId, 2)
+	if err2 != nil {
+		logrus.Errorf("[ProjectService] call Show err:%+v\n", err2)
+		returnError(c, 40000, err2.Error())
+		return
+	}
+	localLifeToDo, err3 := service.LocalLifeService{}.GetLocalLifeToDo(param.EnterpriseId, param.SubAccountId, 2)
+	if err3 != nil {
+		logrus.Errorf("[LocalLifeService] call Show err:%+v\n", err3)
+		returnError(c, 40000, err3.Error())
+		return
+	}
+	resultMap := make(map[string]*map[string]map[string]int64)
+	resultMap["selectionToDo"] = &selectionToDo
+	resultMap["projectToDo"] = &projectToDo
+	resultMap["localLifeToDo"] = &localLifeToDo
+	returnSuccess(c, 20000, resultMap)
+}

+ 95 - 0
app/dao/local_life_dao.go

@@ -314,3 +314,98 @@ func (d LocalLifeDao) GetBillLocalPreviews(param *vo.LocalSearchParam) ([]vo.ReB
 
 	return reBillLocalTaskPreviews, total, nil
 }
+
+// 待办
+func (d LocalLifeDao) GetLocalLifeToDo(enterpriseId string, subAccountId int64, platform int64, taskType int64) (map[string]int64, error) {
+	resultMap := make(map[string]int64)
+	var needReview int64 // 待审核
+	var needPay int64
+	var needProcess int64
+	var needCheck int64     // 初稿待审
+	var needQuality int64   // 链接待审
+	var needCalculate int64 // 待结算
+	var localInfos []entity.LocalLifeInfo
+	//query := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+	if subAccountId == 0 {
+		// 待审核、待支付、达人未处理
+		query1 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+		query1.Where("task_status = ?", 2).Count(&needReview)
+		query2 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+		query2.Where("task_status = ?", 6).Count(&needPay)
+		query3 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+		err := query3.Where("task_status = ?", 8).Select("local_id").Find(&localInfos).Error
+		if err != nil {
+			if errors.Is(err, gorm.ErrRecordNotFound) {
+				needProcess = 0
+			} else {
+				return resultMap, err
+			}
+		} else if len(localInfos) > 0 {
+			var localIDs []string
+			for _, info := range localInfos {
+				localIDs = append(localIDs, info.LocalID)
+			}
+			if len(localIDs) > 0 {
+				err1 := Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id in ? and task_status = ?", localIDs, 1).Count(&needProcess).Error // task_status=1待选
+				if err1 != nil {
+					needProcess = 0
+				}
+			}
+		}
+		query4 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+		err1 := query4.Select("need_review, need_quality, need_calculate").Find(&localInfos).Error
+		if err1 != nil {
+			return resultMap, err1
+		} else if len(localInfos) > 0 {
+			for _, info := range localInfos {
+				needCheck += info.NeedReview
+				needQuality += info.NeedQuality
+				needCalculate += info.NeedCalculate
+			}
+		}
+	} else {
+		// 待审核、待支付、达人未处理
+		query1 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+		query1.Where("sub_account_id = ? and task_status = ?", subAccountId, 2).Count(&needReview)
+		query2 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+		query2.Where("sub_account_id = ? and task_status = ?", subAccountId, 6).Count(&needPay)
+		query3 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+		err := query3.Where("sub_account_id = ? and task_status = ?", subAccountId, 8).Select("local_id").Find(&localInfos).Error
+		if err != nil {
+			if errors.Is(err, gorm.ErrRecordNotFound) {
+				needProcess = 0
+			} else {
+				return resultMap, err
+			}
+		} else {
+			var localIDs []string
+			for _, info := range localInfos {
+				localIDs = append(localIDs, info.LocalID)
+			}
+			if len(localIDs) > 0 {
+				err1 := Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id in ? and task_status = ?", localIDs, 1).Count(&needProcess).Error // task_status=1待选
+				if err1 != nil {
+					needProcess = 0
+				}
+			}
+		}
+		query4 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+		err1 := query4.Select("need_review, need_quality, need_calculate").Find(&localInfos).Error
+		if err1 != nil {
+			return resultMap, err1
+		} else if len(localInfos) > 0 {
+			for _, info := range localInfos {
+				needCheck += info.NeedReview
+				needQuality += info.NeedQuality
+				needCalculate += info.NeedCalculate
+			}
+		}
+	}
+	resultMap["needReview"] = needReview
+	resultMap["needPay"] = needPay
+	resultMap["needProcess"] = needProcess
+	resultMap["needCheck"] = needCheck
+	resultMap["needQuality"] = needQuality
+	resultMap["needCalculate"] = needCalculate
+	return resultMap, nil
+}

+ 95 - 0
app/dao/project_dao.go

@@ -388,3 +388,98 @@ func (d ProjectDAO) GetBillProjectPreviews(param *vo.ProjectSearchParam) ([]vo.R
 
 	return reBillProjectTaskPreviews, total, nil
 }
+
+// 待办
+func (d ProjectDAO) GetProjectToDo(enterpriseId string, subAccountId int64, platform int64, taskType int64) (map[string]int64, error) {
+	resultMap := make(map[string]int64)
+	var needReview int64 // 待审核
+	var needPay int64
+	var needProcess int64
+	var needCheck int64     // 初稿待审
+	var needQuality int64   // 链接待审
+	var needCalculate int64 // 待结算
+	var projectInfos []entity.Project
+	//query := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+	if subAccountId == 0 {
+		// 待审核、待支付、达人未处理
+		query1 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+		query1.Where("project_status = ?", 2).Count(&needReview)
+		query2 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+		query2.Debug().Where("project_status = ?", 6).Count(&needPay)
+		query3 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+		err := query3.Where("project_status = ?", 8).Select("project_id").Find(&projectInfos).Error
+		if err != nil {
+			if errors.Is(err, gorm.ErrRecordNotFound) {
+				needProcess = 0
+			} else {
+				return resultMap, err
+			}
+		} else if len(projectInfos) > 0 {
+			var projectIDs []string
+			for _, info := range projectInfos {
+				projectIDs = append(projectIDs, info.ProjectId)
+			}
+			if len(projectIDs) > 0 {
+				err1 := Db.Model(&entity.ProjectTaskInfo{}).Where("project_id in ? and task_status = ?", projectIDs, 1).Count(&needProcess).Error // task_status=1待选
+				if err1 != nil {
+					needProcess = 0
+				}
+			}
+		}
+		query4 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+		err1 := query4.Select("need_review, need_quality, need_calculate").Find(&projectInfos).Error
+		if err1 != nil {
+			return resultMap, err1
+		} else if len(projectInfos) > 0 {
+			for _, info := range projectInfos {
+				needCheck += info.NeedReview
+				needQuality += info.NeedQuality
+				needCalculate += info.NeedCalculate
+			}
+		}
+	} else {
+		// 待审核、待支付、达人未处理
+		query1 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+		query1.Where("sub_account_id = ? and project_status = ?", subAccountId, 2).Count(&needReview)
+		query2 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+		query2.Where("sub_account_id = ? and project_status = ?", subAccountId, 6).Count(&needPay)
+		query3 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+		err := query3.Where("sub_account_id = ? and project_status = ?", subAccountId, 8).Select("selection_id").Find(&projectInfos).Error
+		if err != nil {
+			if errors.Is(err, gorm.ErrRecordNotFound) {
+				needProcess = 0
+			} else {
+				return resultMap, err
+			}
+		} else {
+			var projectIDs []string
+			for _, info := range projectInfos {
+				projectIDs = append(projectIDs, info.ProjectId)
+			}
+			if len(projectIDs) > 0 {
+				err1 := Db.Model(&entity.ProjectTaskInfo{}).Where("project_id in ? and task_status = ?", projectIDs, 1).Count(&needProcess).Error // task_status=1待选
+				if err1 != nil {
+					needProcess = 0
+				}
+			}
+		}
+		query4 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+		err1 := query4.Select("need_review, need_quality, need_calculate").Find(&projectInfos).Error
+		if err1 != nil {
+			return resultMap, err1
+		} else if len(projectInfos) > 0 {
+			for _, info := range projectInfos {
+				needCheck += info.NeedReview
+				needQuality += info.NeedQuality
+				needCalculate += info.NeedCalculate
+			}
+		}
+	}
+	resultMap["needReview"] = needReview
+	resultMap["needPay"] = needPay
+	resultMap["needProcess"] = needProcess
+	resultMap["needCheck"] = needCheck
+	resultMap["needQuality"] = needQuality
+	resultMap["needCalculate"] = needCalculate
+	return resultMap, nil
+}

+ 67 - 0
app/dao/selection_info_dao.go

@@ -274,3 +274,70 @@ func (d SelectionInfoDAO) GetBillSelectionPreviews(param *vo.SelectionSearchPara
 
 	return reBillSelectionTaskPreviews, total, nil
 }
+
+// 待办
+func (d SelectionInfoDAO) GetSelectionToDo(enterpriseId string, subAccountId int64, platform int64) (map[string]int64, error) {
+	resultMap := make(map[string]int64)
+	var needReview int64
+	var needPay int64
+	var needProcess int64
+	var selectionInfos []entity.SelectionInfo
+	//query := Db.Model(&entity.SelectionInfo{}).Where("enterprise_id = ? and platform = ?", enterpriseId, platform)
+	if subAccountId == 0 {
+		// 待审核、待支付、达人未处理
+		query1 := Db.Model(&entity.SelectionInfo{}).Where("enterprise_id = ? and platform = ?", enterpriseId, platform)
+		query1.Where("selection_status = ?", 2).Count(&needReview)
+		query2 := Db.Model(&entity.SelectionInfo{}).Where("enterprise_id = ? and platform = ?", enterpriseId, platform)
+		query2.Where("selection_status = ?", 4).Count(&needPay)
+		query3 := Db.Model(&entity.SelectionInfo{}).Where("enterprise_id = ? and platform = ?", enterpriseId, platform)
+		err := query3.Where("selection_status = ? and sample_mode = ?", 6, 1).Select("selection_id").Find(&selectionInfos).Error
+		if err != nil {
+			if errors.Is(err, gorm.ErrRecordNotFound) {
+				needProcess = 0
+			} else {
+				return resultMap, err
+			}
+		} else {
+			var selectionIDs []string
+			for _, info := range selectionInfos {
+				selectionIDs = append(selectionIDs, info.SelectionID)
+			}
+			if len(selectionIDs) > 0 {
+				err1 := Db.Model(&entity.SecTaskInfo{}).Where("selection_id in ? and task_status = ?", selectionIDs, 1).Count(&needProcess).Error // task_status=1待选
+				if err1 != nil {
+					needProcess = 0
+				}
+			}
+		}
+	} else {
+		// 待审核、待支付、达人未处理
+		query1 := Db.Model(&entity.SelectionInfo{}).Where("enterprise_id = ? and platform = ?", enterpriseId, platform)
+		query1.Where("sub_account_id = ? and selection_status = ?", subAccountId, 2).Count(&needReview)
+		query2 := Db.Model(&entity.SelectionInfo{}).Where("enterprise_id = ? and platform = ?", enterpriseId, platform)
+		query2.Where("sub_account_id = ? and selection_status = ?", subAccountId, 4).Count(&needPay)
+		query3 := Db.Model(&entity.SelectionInfo{}).Where("enterprise_id = ? and platform = ?", enterpriseId, platform)
+		err := query3.Where("sub_account_id = ? and selection_status = ? and sample_mode = ?", subAccountId, 6, 1).Select("selection_id").Find(&selectionInfos).Error
+		if err != nil {
+			if errors.Is(err, gorm.ErrRecordNotFound) {
+				needProcess = 0
+			} else {
+				return resultMap, err
+			}
+		} else {
+			var selectionIDs []string
+			for _, info := range selectionInfos {
+				selectionIDs = append(selectionIDs, info.SelectionID)
+			}
+			if len(selectionIDs) > 0 {
+				err1 := Db.Model(&entity.SecTaskInfo{}).Where("selection_id in ? and task_status = ?", selectionIDs, 1).Count(&needProcess).Error // task_status=1待选
+				if err1 != nil {
+					needProcess = 0
+				}
+			}
+		}
+	}
+	resultMap["needReview"] = needReview
+	resultMap["needPay"] = needPay
+	resultMap["needProcess"] = needProcess
+	return resultMap, nil
+}

+ 37 - 0
app/service/local_life_service.go

@@ -1232,3 +1232,40 @@ func (s LocalLifeService) StoreExploreOperate(param *vo.LocalTalentOperateParam)
 
 	return nil
 }
+
+// 本地生活任务待办
+func (p LocalLifeService) GetLocalLifeToDo(enterpriseId string, subAccountId int64, taskType int64) (map[string]map[string]int64, error) {
+	res := make(map[string]map[string]int64)
+	redbook, err1 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 1, taskType)
+	if err1 != nil {
+		logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err1)
+		return res, err1
+	}
+	douyin, err2 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 2, taskType)
+	if err2 != nil {
+		logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err2)
+		return res, err2
+	}
+	kuaishou, err3 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 4, taskType)
+	if err3 != nil {
+		logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err3)
+		return res, err3
+	}
+	weibo, err4 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 3, taskType)
+	if err4 != nil {
+		logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err4)
+		return res, err4
+	}
+	bilibili, err5 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 5, taskType)
+	if err5 != nil {
+		logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err5)
+		return res, err5
+	}
+	res["redbook"] = redbook
+	res["douyin"] = douyin
+	res["kuaishou"] = kuaishou
+	res["weibo"] = weibo
+	res["bilibili"] = bilibili
+
+	return res, nil
+}

+ 37 - 0
app/service/project_service.go

@@ -1010,3 +1010,40 @@ func (p ProjectService) GetTalentCategory() ([]vo.ReTalentCategory, error) {
 	}
 	return reTalentCategories, nil
 }
+
+// 种草任务待办
+func (p ProjectService) GetProjectToDo(enterpriseId string, subAccountId int64, taskType int64) (map[string]map[string]int64, error) {
+	res := make(map[string]map[string]int64)
+	redbook, err1 := dao.ProjectDAO{}.GetProjectToDo(enterpriseId, subAccountId, 1, taskType)
+	if err1 != nil {
+		logrus.Errorf("[GetProjectToDo service] call GetProjectToDo error,err:%+v", err1)
+		return res, err1
+	}
+	douyin, err2 := dao.ProjectDAO{}.GetProjectToDo(enterpriseId, subAccountId, 2, taskType)
+	if err2 != nil {
+		logrus.Errorf("[GetProjectToDo service] call GetProjectToDo error,err:%+v", err2)
+		return res, err2
+	}
+	kuaishou, err3 := dao.ProjectDAO{}.GetProjectToDo(enterpriseId, subAccountId, 4, taskType)
+	if err3 != nil {
+		logrus.Errorf("[GetProjectToDo service] call GetProjectToDo error,err:%+v", err3)
+		return res, err3
+	}
+	weibo, err4 := dao.ProjectDAO{}.GetProjectToDo(enterpriseId, subAccountId, 3, taskType)
+	if err4 != nil {
+		logrus.Errorf("[GetProjectToDo service] call GetProjectToDo error,err:%+v", err4)
+		return res, err4
+	}
+	bilibili, err5 := dao.ProjectDAO{}.GetProjectToDo(enterpriseId, subAccountId, 5, taskType)
+	if err5 != nil {
+		logrus.Errorf("[GetProjectToDo service] call GetProjectToDo error,err:%+v", err5)
+		return res, err5
+	}
+	res["redbook"] = redbook
+	res["douyin"] = douyin
+	res["kuaishou"] = kuaishou
+	res["weibo"] = weibo
+	res["bilibili"] = bilibili
+
+	return res, nil
+}

+ 13 - 0
app/service/selection_info_service.go

@@ -945,3 +945,16 @@ func (s SelectionInfoService) GetSelectionDraftList(param *vo.SelectionDraftPara
 	}
 	return result, nil
 }
+
+// 电商带货任务待办
+func (s SelectionInfoService) GetSelectionToDo(enterpriseId string, subAccountId int64) (map[string]map[string]int64, error) {
+	res := make(map[string]map[string]int64)
+	kuaishou, err1 := dao.SelectionInfoDAO{}.GetSelectionToDo(enterpriseId, subAccountId, 4)
+	if err1 != nil {
+		logrus.Errorf("[GetSelectionToDo service] call GetSelectionToDo error,err:%+v", err1)
+		return res, err1
+	}
+	res["kuaishou"] = kuaishou
+
+	return res, nil
+}

+ 6 - 0
app/vo/common_param.go

@@ -0,0 +1,6 @@
+package vo
+
+type CommonParam struct {
+	EnterpriseId string `json:"enterprise_id"`
+	SubAccountId int64  `json:"sub_account_id"`
+}

+ 5 - 0
route/init.go

@@ -168,6 +168,11 @@ func InitRoute(r *gin.Engine) {
 	{
 		workspace.Use(middleware.LoginAuthMiddleware)
 		workspace.POST("/takegoods", controller.WorkspaceController{}.GetTakegoodsInfo) //工作台数据概览
+
+		// 任务待办
+		workspace.POST("/publicTask", controller.WorkspaceController{}.GetPublicTask) // 任务待办-公开任务
+		workspace.POST("/targetTask", controller.WorkspaceController{}.GetTargetTask) // 任务待办-定向任务
+
 	}
 	// 任务中心相关接口
 	task := r.Group("/youngee/b/task")