|
@@ -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
|
|
|
+}
|