XingYuXian il y a 1 an
Parent
commit
b5a92b81c1
5 fichiers modifiés avec 243 ajouts et 213 suppressions
  1. 1 0
      db/operate.go
  2. 58 30
      db/sectask.go
  3. 182 181
      db/talent.go
  4. 1 1
      service/auto_task.go
  5. 1 1
      service/sec_task.go

+ 1 - 0
db/operate.go

@@ -729,6 +729,7 @@ func GetAutoPostReviewTask() error {
 	return nil
 }
 
+// GetAutoCaseCloseTask 项目结案自动处理
 func GetAutoCaseCloseTask() error {
 	// 1. 补全dataInfo表中的自动审核数据时间
 	db := GetReadDB(context.Background())

+ 58 - 30
db/sectask.go

@@ -30,41 +30,67 @@ func GetSecTaskById(ctx context.Context, secTaskId string) (*gorm_model.Younggee
 	return &secTaskInfo, nil
 }
 
-func GetSecTaskList(ctx context.Context, selectionId string, taskStatus int, searchValue string, pageSize, pageNum int64, taskStage int) ([]*http_model.SecTaskInfo, int64, error) {
+func GetSecTaskList(ctx context.Context, selectionId string, taskStatus int, searchValue string, pageSize, pageNum int64) ([]*http_model.SecTaskInfo, int64, error) {
 	db := GetReadDB(ctx)
+	var taskStages []int
+	switch taskStatus {
+	case 3:
+		taskStages = []int{3}
+		break
+	case 4:
+		taskStages = []int{4, 6, 7, 8, 9, 10}
+		break
+	case 6:
+		taskStages = []int{6}
+		break
+	case 7:
+		taskStages = []int{7}
+		break
+	case 8:
+		taskStages = []int{8, 9, 10}
+	case 9:
+		taskStages = []int{9}
+		break
+	case 10:
+		taskStages = []int{10}
+		break
+	}
+	println("task_stages: ", taskStages)
+	db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ? and task_stage in ?", selectionId, taskStages)
 	//var taskStages []int
 	/*
-		switch taskStatus {
-		case 1:
-			//hhh = []int{3}
-			println("case 1")
-			break
-					case 4:
-					taskStages = []int{4, 6, 7, 8, 9, 10}
-					break
-				case 6:
-					taskStages = []int{6}
-					break
-				case 7:
-					taskStages = []int{7, 8, 9, 10}
-					break
-				case 9:
-					taskStages = []int{9}
-					break
-				case 10:
-					taskStages = []int{10}
-					break
+			switch taskStatus {
+			case 1:
+				//hhh = []int{3}
+				println("case 1")
+				break
+						case 4:
+						taskStages = []int{4, 6, 7, 8, 9, 10}
+						break
+					case 6:
+						taskStages = []int{6}
+						break
+					case 7:
+						taskStages = []int{7, 8, 9, 10}
+						break
+					case 9:
+						taskStages = []int{9}
+						break
+					case 10:
+						taskStages = []int{10}
+						break
+
+			}
 
+		//println("taskStage: ", taskStages)
+		if taskStage == 7 || taskStage == 6 {
+			println("if")
+			db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ? and task_stage = ?", selectionId, taskStage)
+		} else {
+			println("else")
+			db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ? and task_status = ?", selectionId, taskStatus)
 		}
 	*/
-	//println("taskStage: ", taskStages)
-	if taskStage == 7 || taskStage == 6 {
-		println("if")
-		db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ? and task_stage = ?", selectionId, taskStage)
-	} else {
-		println("else")
-		db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ? and task_status = ?", selectionId, taskStatus)
-	}
 
 	// 查询总数
 	var total int64
@@ -88,7 +114,9 @@ func GetSecTaskList(ctx context.Context, selectionId string, taskStatus int, sea
 	fmt.Println("newSecTaskInfoList:", newSecTaskInfoList)
 
 	for i, secTask := range newSecTaskInfoList {
-		newSecTaskInfoList[i].DetailAddr = GetRegion(ctx, secTask.RegionCode) + secTask.DetailAddr
+		if secTask.RegionCode != 0 {
+			newSecTaskInfoList[i].DetailAddr = GetRegion(ctx, secTask.RegionCode) + secTask.DetailAddr
+		}
 	}
 	var resSecTaskInfoList []*http_model.SecTaskInfo
 	if searchValue != "" {

+ 182 - 181
db/talent.go

@@ -1,181 +1,182 @@
-package db
-
-import (
-	"context"
-	"fmt"
-	"github.com/caixw/lib.go/conv"
-	"github.com/sirupsen/logrus"
-	"gorm.io/gorm"
-	"youngee_m_api/consts"
-	"youngee_m_api/model/gorm_model"
-	"youngee_m_api/model/http_model"
-	"youngee_m_api/pack"
-)
-
-func PlatformAccInfo(ctx context.Context, talentId string) (*http_model.PlatformAccInfoPreView, error) {
-	db := GetReadDB(ctx)
-	var gormPlatform []*gorm_model.YoungeePlatformAccountInfo
-	// 根据 talent_id 进行筛选
-	db = db.Debug().Model(gorm_model.YoungeePlatformAccountInfo{}).Where("talent_id = ?", talentId)
-	err := db.Find(&gormPlatform).Order("bind_date").Error
-	if err != nil {
-		if err == gorm.ErrRecordNotFound {
-			return nil, nil
-		} else {
-			return nil, err
-		}
-	}
-	// 查询总数
-	var total int64
-	if err = db.Count(&total).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[PlatformAccInfo] error query mysql total, err:%+v", err)
-		return nil, err
-	}
-	platform := new(http_model.PlatformAccInfoPreView)
-	platform.PlatformAccInfoData = pack.GormPlatformToHttpPlatform(gormPlatform)
-	platform.Total = conv.MustString(total, "")
-	return platform, err
-}
-
-func AccountIncome(ctx context.Context, talentId string) (*http_model.TalentInfoResponse, error) {
-	db := GetReadDB(ctx)
-	var talentInfo *gorm_model.YoungeeTalentInfo
-	// 根据 talent_id 进行筛选
-	err := db.Model(gorm_model.YoungeeTalentInfo{}).Where("id = ?", talentId).
-		First(&talentInfo).Error
-	if err != nil {
-		if err == gorm.ErrRecordNotFound {
-			return nil, nil
-		} else {
-			return nil, err
-		}
-	}
-	data := new(http_model.TalentInfoResponse)
-	data.Income = float32(talentInfo.Income)
-	data.Withdrawed = float32(talentInfo.Withdrawed)
-	data.Canwithdraw = float32(talentInfo.Canwithdraw)
-	data.Withdrawing = float32(talentInfo.Withdrawing)
-
-	// 查询是否绑定物流地址
-	IsBindLocation := talentInfo.IsBindLocation
-	if IsBindLocation == 1 {
-		var deliveryInfo *gorm_model.YoungeeTalentDeliveryAddress
-		db1 := GetReadDB(ctx)
-		err = db1.Debug().Model(gorm_model.YoungeeTalentDeliveryAddress{}).
-			Where("talent_id = ? AND default_tag = ?", talentId, 1).
-			First(&deliveryInfo).Error
-		//fmt.Printf("deliveryInfo%+v\n", deliveryInfo)
-		if err != nil {
-			if err == gorm.ErrRecordNotFound {
-				return nil, nil
-			} else {
-				return nil, err
-			}
-		}
-		region := GetRegion(ctx, deliveryInfo.RegionCode)
-		data.ReceiverName = deliveryInfo.ReceiverName
-		data.PhoneNumber = deliveryInfo.PhoneNumber
-		data.DetailAddr = region + deliveryInfo.DetailAddr
-	} else {
-		data.ReceiverName = "暂无"
-		data.PhoneNumber = "暂无"
-		data.DetailAddr = "暂无"
-	}
-	region := ""
-	if talentInfo.IsBindBank == 1 {
-		db2 := GetReadDB(ctx)
-		var talentBankInfo *gorm_model.YounggeeTalentBank
-		err = db2.Model(gorm_model.YounggeeTalentBank{}).Where("talent_id = ?", talentId).
-			First(&talentBankInfo).Error
-		if err != nil {
-			if err == gorm.ErrRecordNotFound {
-				return nil, nil
-			} else {
-				return nil, err
-			}
-		}
-		if talentBankInfo.BankOpenAddress != 0 {
-			region = GetRegion(ctx, talentBankInfo.BankOpenAddress)
-		}
-		data.Bank = talentBankInfo.Bank
-		data.BankOpenAddress = region
-		data.BankCardNumber = talentBankInfo.BankCardNumber
-		data.Name = talentBankInfo.Name
-		data.AliPayNumber = "暂无"
-		data.AliPayRealName = "暂无"
-	} else {
-		data.Bank = "暂无"
-		data.BankCardNumber = "暂无"
-		data.BankOpenAddress = "暂无"
-		data.Name = "暂无"
-		data.AliPayNumber = "暂无"
-		data.AliPayRealName = "暂无"
-	}
-	return data, err
-}
-
-func GetRegion(ctx context.Context, regionCode int) string {
-	db4 := GetReadDB(ctx)
-	var infoRegion *gorm_model.InfoRegion
-	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", regionCode).First(&infoRegion)
-
-	provinceCode := conv.MustString(regionCode, "")[0:2] + "0000"
-	var province *gorm_model.InfoRegion
-	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", conv.MustInt(provinceCode, 0)).First(&province)
-
-	cityCode := conv.MustString(regionCode, "")[0:4] + "00"
-	var city *gorm_model.InfoRegion
-	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", conv.MustInt(cityCode, 0)).First(&city)
-	fmt.Println("province,city,infoRegion Code :", provinceCode, cityCode, regionCode)
-	fmt.Println("province,city,infoRegion RegionName :", province.RegionName, city.RegionName, infoRegion.RegionName)
-	return province.RegionName + city.RegionName + infoRegion.RegionName
-}
-
-func GetTaskRecord(ctx context.Context, talentId string) (*http_model.GetTaskRecordResponse, error) {
-	db := GetReadDB(ctx)
-	var taskInfos []*gorm_model.YoungeeTaskInfo
-	// 根据 talent_id 进行筛选
-	db = db.Debug().Model(gorm_model.YoungeeTaskInfo{}).Where("talent_id = ?", talentId)
-	// 查询总数
-	var total int64
-	if err := db.Count(&total).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[GetTaskRecord] error query mysql total, err:%+v", err)
-		return nil, err
-	}
-	err := db.Order("update_at desc").Find(&taskInfos).Error
-	if err != nil {
-		if err == gorm.ErrRecordNotFound {
-			return nil, nil
-		} else {
-			return nil, err
-		}
-	}
-	projectIdMap := map[string]gorm_model.ProjectInfo{}
-	for _, taskInfo := range taskInfos {
-		if _, ok := projectIdMap[taskInfo.ProjectId]; !ok {
-			db1 := GetReadDB(ctx)
-			projectInfo := gorm_model.ProjectInfo{}
-			db1.Where("project_id = ?", taskInfo.ProjectId).First(&projectInfo)
-			projectIdMap[taskInfo.ProjectId] = projectInfo
-		}
-	}
-	var taskRecordDatas []*http_model.TaskRecordData
-	for _, taskInfo := range taskInfos {
-		updateAt := conv.MustString(taskInfo.UpdateAt, "")
-		updateAt = updateAt[0:19]
-		taskRecordData := http_model.TaskRecordData{
-			ProjectId:       conv.MustString(taskInfo.ProjectId, ""),
-			ProjectName:     projectIdMap[taskInfo.ProjectId].ProjectName,
-			ProjectType:     consts.GetProjectType(projectIdMap[taskInfo.ProjectId].ProjectType),
-			ProjectPlatform: consts.GetProjectPlatform(projectIdMap[taskInfo.ProjectId].ProjectPlatform),
-			TaskId:          conv.MustString(taskInfo.TaskId, ""),
-			TaskStage:       consts.GetTaskStage(taskInfo.TaskStage),
-			UpdatedAt:       updateAt,
-		}
-		taskRecordDatas = append(taskRecordDatas, &taskRecordData)
-	}
-	taskRecordResponse := new(http_model.GetTaskRecordResponse)
-	taskRecordResponse.TaskRecordData = taskRecordDatas
-	taskRecordResponse.Total = conv.MustString(total, "")
-	return taskRecordResponse, nil
-}
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+)
+
+func PlatformAccInfo(ctx context.Context, talentId string) (*http_model.PlatformAccInfoPreView, error) {
+	db := GetReadDB(ctx)
+	var gormPlatform []*gorm_model.YoungeePlatformAccountInfo
+	// 根据 talent_id 进行筛选
+	db = db.Debug().Model(gorm_model.YoungeePlatformAccountInfo{}).Where("talent_id = ?", talentId)
+	err := db.Find(&gormPlatform).Order("bind_date").Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	// 查询总数
+	var total int64
+	if err = db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[PlatformAccInfo] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+	platform := new(http_model.PlatformAccInfoPreView)
+	platform.PlatformAccInfoData = pack.GormPlatformToHttpPlatform(gormPlatform)
+	platform.Total = conv.MustString(total, "")
+	return platform, err
+}
+
+func AccountIncome(ctx context.Context, talentId string) (*http_model.TalentInfoResponse, error) {
+	db := GetReadDB(ctx)
+	var talentInfo *gorm_model.YoungeeTalentInfo
+	// 根据 talent_id 进行筛选
+	err := db.Model(gorm_model.YoungeeTalentInfo{}).Where("id = ?", talentId).
+		First(&talentInfo).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	data := new(http_model.TalentInfoResponse)
+	data.Income = float32(talentInfo.Income)
+	data.Withdrawed = float32(talentInfo.Withdrawed)
+	data.Canwithdraw = float32(talentInfo.Canwithdraw)
+	data.Withdrawing = float32(talentInfo.Withdrawing)
+
+	// 查询是否绑定物流地址
+	IsBindLocation := talentInfo.IsBindLocation
+	if IsBindLocation == 1 {
+		var deliveryInfo *gorm_model.YoungeeTalentDeliveryAddress
+		db1 := GetReadDB(ctx)
+		err = db1.Debug().Model(gorm_model.YoungeeTalentDeliveryAddress{}).
+			Where("talent_id = ? AND default_tag = ?", talentId, 1).
+			First(&deliveryInfo).Error
+		//fmt.Printf("deliveryInfo%+v\n", deliveryInfo)
+		if err != nil {
+			if err == gorm.ErrRecordNotFound {
+				return nil, nil
+			} else {
+				return nil, err
+			}
+		}
+		region := GetRegion(ctx, deliveryInfo.RegionCode)
+		data.ReceiverName = deliveryInfo.ReceiverName
+		data.PhoneNumber = deliveryInfo.PhoneNumber
+		data.DetailAddr = region + deliveryInfo.DetailAddr
+	} else {
+		data.ReceiverName = "暂无"
+		data.PhoneNumber = "暂无"
+		data.DetailAddr = "暂无"
+	}
+	region := ""
+	if talentInfo.IsBindBank == 1 {
+		db2 := GetReadDB(ctx)
+		var talentBankInfo *gorm_model.YounggeeTalentBank
+		err = db2.Model(gorm_model.YounggeeTalentBank{}).Where("talent_id = ?", talentId).
+			First(&talentBankInfo).Error
+		if err != nil {
+			if err == gorm.ErrRecordNotFound {
+				return nil, nil
+			} else {
+				return nil, err
+			}
+		}
+		if talentBankInfo.BankOpenAddress != 0 {
+			region = GetRegion(ctx, talentBankInfo.BankOpenAddress)
+		}
+		data.Bank = talentBankInfo.Bank
+		data.BankOpenAddress = region
+		data.BankCardNumber = talentBankInfo.BankCardNumber
+		data.Name = talentBankInfo.Name
+		data.AliPayNumber = "暂无"
+		data.AliPayRealName = "暂无"
+	} else {
+		data.Bank = "暂无"
+		data.BankCardNumber = "暂无"
+		data.BankOpenAddress = "暂无"
+		data.Name = "暂无"
+		data.AliPayNumber = "暂无"
+		data.AliPayRealName = "暂无"
+	}
+	return data, err
+}
+
+func GetRegion(ctx context.Context, regionCode int) string {
+	db4 := GetReadDB(ctx)
+	var infoRegion *gorm_model.InfoRegion
+	println(regionCode)
+	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", regionCode).First(&infoRegion)
+
+	provinceCode := conv.MustString(regionCode, "")[0:2] + "0000"
+	var province *gorm_model.InfoRegion
+	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", conv.MustInt(provinceCode, 0)).First(&province)
+
+	cityCode := conv.MustString(regionCode, "")[0:4] + "00"
+	var city *gorm_model.InfoRegion
+	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", conv.MustInt(cityCode, 0)).First(&city)
+	fmt.Println("province,city,infoRegion Code :", provinceCode, cityCode, regionCode)
+	fmt.Println("province,city,infoRegion RegionName :", province.RegionName, city.RegionName, infoRegion.RegionName)
+	return province.RegionName + city.RegionName + infoRegion.RegionName
+}
+
+func GetTaskRecord(ctx context.Context, talentId string) (*http_model.GetTaskRecordResponse, error) {
+	db := GetReadDB(ctx)
+	var taskInfos []*gorm_model.YoungeeTaskInfo
+	// 根据 talent_id 进行筛选
+	db = db.Debug().Model(gorm_model.YoungeeTaskInfo{}).Where("talent_id = ?", talentId)
+	// 查询总数
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetTaskRecord] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+	err := db.Order("update_at desc").Find(&taskInfos).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	projectIdMap := map[string]gorm_model.ProjectInfo{}
+	for _, taskInfo := range taskInfos {
+		if _, ok := projectIdMap[taskInfo.ProjectId]; !ok {
+			db1 := GetReadDB(ctx)
+			projectInfo := gorm_model.ProjectInfo{}
+			db1.Where("project_id = ?", taskInfo.ProjectId).First(&projectInfo)
+			projectIdMap[taskInfo.ProjectId] = projectInfo
+		}
+	}
+	var taskRecordDatas []*http_model.TaskRecordData
+	for _, taskInfo := range taskInfos {
+		updateAt := conv.MustString(taskInfo.UpdateAt, "")
+		updateAt = updateAt[0:19]
+		taskRecordData := http_model.TaskRecordData{
+			ProjectId:       conv.MustString(taskInfo.ProjectId, ""),
+			ProjectName:     projectIdMap[taskInfo.ProjectId].ProjectName,
+			ProjectType:     consts.GetProjectType(projectIdMap[taskInfo.ProjectId].ProjectType),
+			ProjectPlatform: consts.GetProjectPlatform(projectIdMap[taskInfo.ProjectId].ProjectPlatform),
+			TaskId:          conv.MustString(taskInfo.TaskId, ""),
+			TaskStage:       consts.GetTaskStage(taskInfo.TaskStage),
+			UpdatedAt:       updateAt,
+		}
+		taskRecordDatas = append(taskRecordDatas, &taskRecordData)
+	}
+	taskRecordResponse := new(http_model.GetTaskRecordResponse)
+	taskRecordResponse.TaskRecordData = taskRecordDatas
+	taskRecordResponse.Total = conv.MustString(total, "")
+	return taskRecordResponse, nil
+}

+ 1 - 1
service/auto_task.go

@@ -105,7 +105,7 @@ func AutoTask() error {
 		}
 		log.Println("GetAutoPostReviewTask is running ,Time :", time.Now())
 	}
-	// 定时任务6 ,结案自动处理
+	// 定时任务6 ,项目结案自动处理
 	task6 := func() {
 		DB := db.GetReadDB(context.Background())
 		autoTaskTime := gorm_model.InfoAutoTask{}

+ 1 - 1
service/sec_task.go

@@ -26,7 +26,7 @@ func (*selectionTask) GetList(ctx context.Context, request http_model.GetSecTask
 	// selection_info: 返现金额、悬赏金额
 	// 1. 根据选品任务阶段、账号昵称or任务id查询任务基本信息(包括任务id、账号昵称、粉丝数、主页截图、主页链接、申请时间)
 	println("查找信息:", request.SelectionId, request.SecTaskStatus)
-	secTaskList, total, err := db.GetSecTaskList(ctx, request.SelectionId, request.SecTaskStatus, request.SearchValue, request.PageSize, request.PageNum, request.TaskStage)
+	secTaskList, total, err := db.GetSecTaskList(ctx, request.SelectionId, request.SecTaskStatus, request.SearchValue, request.PageSize, request.PageNum)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[sectask_service service] call GetSecTaskList error,err:%+v", err)
 		return nil, err