Xingyu Xian 3 viikkoa sitten
vanhempi
commit
8ad8ada5d2
42 muutettua tiedostoa jossa 804 lisäystä ja 199 poistoa
  1. 99 9
      db/local_life_task.go
  2. 42 7
      db/project.go
  3. 12 0
      db/recruit_strategy.go
  4. 18 3
      db/s_project.go
  5. 4 3
      db/s_t_cooperate.go
  6. 25 5
      db/task.go
  7. 1 1
      handler/add_to_list.go
  8. 27 0
      handler/local_change_supplier_status.go
  9. 61 0
      handler/local_task_count.go
  10. 1 1
      handler/local_task_list.go
  11. 9 22
      handler/project_change_taskStatus.go
  12. 1 1
      handler/project_taskList.go
  13. 61 0
      handler/project_task_count.go
  14. 1 1
      handler/special_local_add_to_list.go
  15. 1 1
      model/common_model/local_task_list.go
  16. 1 0
      model/common_model/task_conditions.go
  17. 2 0
      model/gorm_model/s_local_life.go
  18. 2 0
      model/gorm_model/s_project.go
  19. 1 1
      model/http_model/add_to_list.go
  20. 4 3
      model/http_model/create_supplier_withdraw.go
  21. 1 0
      model/http_model/find_all_sub_account.go
  22. 3 2
      model/http_model/local_change_supplier_status.go
  23. 1 1
      model/http_model/local_life_add_to_list.go
  24. 5 4
      model/http_model/local_special_add_strategy.go
  25. 25 0
      model/http_model/local_task_count.go
  26. 20 15
      model/http_model/local_task_list.go
  27. 2 5
      model/http_model/project_change_taskStatus.go
  28. 20 16
      model/http_model/project_taskList.go
  29. 25 0
      model/http_model/project_task_count.go
  30. 4 4
      model/http_model/special_add_strategy.go
  31. 1 1
      model/http_model/special_local_add_to_list.go
  32. 2 1
      model/http_model/special_s_project_add_to_list.go
  33. 1 1
      pack/local_task_list.go
  34. 1 1
      pack/project_task_list.go
  35. 4 3
      pack/project_task_list_conditions.go
  36. 3 1
      route/init.go
  37. 75 5
      service/project.go
  38. 87 8
      service/s_local_life.go
  39. 7 1
      service/s_project.go
  40. 53 3
      service/s_t_cooperate.go
  41. 10 0
      service/sub_account.go
  42. 81 69
      service/supplier.go

+ 99 - 9
db/local_life_task.go

@@ -12,7 +12,7 @@ import (
 )
 
 // GetLocalTaskList 本地生活子任务列表
-func GetLocalTaskList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.LocalTaskConditions) ([]*gorm_model.YoungeeLocalTaskInfo, int64, error) {
+func GetLocalTaskList(ctx context.Context, pageSize, pageNum int32, orderBy []string, orderDesc []int, conditions *common_model.LocalTaskConditions) ([]*gorm_model.YoungeeLocalTaskInfo, int64, error) {
 
 	db := GetReadDB(ctx)
 	// 查询task表信息
@@ -34,22 +34,58 @@ func GetLocalTaskList(ctx context.Context, pageSize, pageNum int32, conditions *
 		}
 	}
 
+	// 动态排序逻辑
+	if len(orderBy) > 0 && len(orderDesc) > 0 && len(orderBy) == len(orderDesc) {
+		for i := 0; i < len(orderBy); i++ {
+			orderField := orderBy[i]
+			isDesc := orderDesc[i] == 1 // 1=降序,其他值=升序
+
+			switch orderField {
+			case "fans_num":
+				if isDesc {
+					db = db.Order("fans_num desc")
+				} else {
+					db = db.Order("fans_num asc")
+				}
+			case "vote_avg":
+				if isDesc {
+					db = db.Order("vote_avg desc")
+				} else {
+					db = db.Order("vote_avg asc")
+				}
+			case "commit_avg":
+				if isDesc {
+					db = db.Order("commit_avg desc")
+				} else {
+					db = db.Order("commit_avg asc")
+				}
+			case "collect_avg":
+				if isDesc {
+					db = db.Order("collect_avg desc")
+				} else {
+					db = db.Order("collect_avg asc")
+				}
+			}
+		}
+	} else {
+		// 默认排序
+		db = db.Order("task_id desc")
+	}
+
 	var taskInfos []*gorm_model.YoungeeLocalTaskInfo
 	db = db.Model(gorm_model.YoungeeLocalTaskInfo{})
 	// 查询总数
 	var totalTask int64
-	if err := db.Count(&totalTask).Error; err != nil {
+	if err := db.Model(gorm_model.YoungeeLocalTaskInfo{}).Count(&totalTask).Error; err != nil {
 		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
 		return nil, 0, err
 	}
-	db.Order("task_id").Find(&taskInfos)
 
 	// 查询该页数据
 	limit := pageSize
 	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("task_id").Limit(int(limit)).Offset(int(offset)).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
+	if err := db.Limit(int(limit)).Offset(int(offset)).Find(&taskInfos).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql data, err:%+v", err)
 		return nil, 0, err
 	}
 
@@ -70,12 +106,20 @@ func GetLocalTaskList(ctx context.Context, pageSize, pageNum int32, conditions *
 }
 
 // ChangeLocalTaskStatus 修改服务商本地生活子任务报名状态
-func ChangeLocalTaskStatus(ctx context.Context, taskIds []string, supplierStatus int) ([]int64, error) {
+func ChangeLocalTaskStatus(ctx context.Context, taskIds []string, supplierStatus int, supplierId int, subAccountId int) ([]int64, error) {
 	db := GetReadDB(ctx)
 	taskSta := supplierStatus
-
+	var sOperate int
+	var sOperateType int
+	if subAccountId == 0 {
+		sOperate = supplierId
+		sOperateType = 1
+	} else {
+		sOperate = subAccountId
+		sOperateType = 2
+	}
 	if err := db.Debug().Model(&gorm_model.YoungeeLocalTaskInfo{}).Where("task_id IN ?", taskIds).
-		Updates(gorm_model.YoungeeLocalTaskInfo{SupplierStatus: taskSta}).Error; err != nil {
+		Updates(gorm_model.YoungeeLocalTaskInfo{SupplierStatus: taskSta, SOperator: sOperate, SOperatorType: sOperateType}).Error; err != nil {
 		logrus.WithContext(ctx).Errorf("[ChangeTaskStatus]2 error query mysql total, err:%+v", err)
 		return nil, err
 	}
@@ -131,3 +175,49 @@ func GetSLocalTaskList(ctx context.Context, sLocalId int, talentId string, pageS
 
 	return taskInfos, totalTask, nil
 }
+
+// GetLocalTaskInfoById ID查找子任务
+func GetLocalTaskInfoById(ctx context.Context, taskId string) (*gorm_model.YoungeeLocalTaskInfo, error) {
+	db := GetReadDB(ctx)
+	var taskInfo *gorm_model.YoungeeLocalTaskInfo
+	whereCondition := gorm_model.YoungeeLocalTaskInfo{
+		TaskID: taskId,
+	}
+	err := db.Model(gorm_model.YoungeeLocalTaskInfo{}).Where(whereCondition).Find(&taskInfo).Error
+	if err != nil {
+		return nil, err
+	}
+	return taskInfo, nil
+}
+
+// CountLocalTaskNumByTaskStage 根据子任务状态查找对应的本地子任务数量
+func CountLocalTaskNumByTaskStage(ctx context.Context, taskStage int, supplierStatus int, sLocalId int) (int64, error) {
+	db := GetReadDB(ctx)
+	var taskNum int64
+	if taskStage == 0 && supplierStatus == 0 {
+		err := db.Model(gorm_model.YoungeeLocalTaskInfo{}).Where("s_project_id = ?", sLocalId).Count(&taskNum).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
+			return 0, err
+		}
+	} else if taskStage == 0 {
+		err := db.Model(gorm_model.YoungeeLocalTaskInfo{}).Where("supplier_status = ? and s_project_id = ?", supplierStatus, sLocalId).Count(&taskNum).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
+			return 0, err
+		}
+	} else if supplierStatus == 0 {
+		err := db.Model(gorm_model.YoungeeLocalTaskInfo{}).Where("task_status = ? and s_project_id = ?", taskStage, sLocalId).Count(&taskNum).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
+			return 0, err
+		}
+	} else {
+		err := db.Model(gorm_model.YoungeeLocalTaskInfo{}).Where("task_status = ? and supplier_status = ? and s_project_id = ?", taskStage, supplierStatus, sProjectId).Count(&taskNum).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
+			return 0, err
+		}
+	}
+	return taskNum, nil
+}

+ 42 - 7
db/project.go

@@ -126,7 +126,7 @@ func GetProjectDraftList(ctx context.Context, enterpriseID string, pageSize, pag
 	return projectDrafts, total, nil
 }
 
-func GetProjectTaskList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TaskConditions) ([]*http_model.ProjectTaskInfo, int64, error) {
+func GetProjectTaskList(ctx context.Context, pageSize, pageNum int64, orderBy []string, orderDesc []int, conditions *common_model.TaskConditions) ([]*http_model.ProjectTaskInfo, int64, error) {
 	db := GetReadDB(ctx)
 	// 查询task表信息
 	db = db.Debug().Model(gorm_model.YoungeeTaskInfo{})
@@ -147,22 +147,57 @@ func GetProjectTaskList(ctx context.Context, projectID string, pageSize, pageNum
 		}
 	}
 
+	// 动态排序逻辑
+	if len(orderBy) > 0 && len(orderDesc) > 0 && len(orderBy) == len(orderDesc) {
+		for i := 0; i < len(orderBy); i++ {
+			orderField := orderBy[i]
+			isDesc := orderDesc[i] == 1 // 1=降序,其他值=升序
+
+			switch orderField {
+			case "fans_num":
+				if isDesc {
+					db = db.Order("fans_num desc")
+				} else {
+					db = db.Order("fans_num asc")
+				}
+			case "vote_avg":
+				if isDesc {
+					db = db.Order("vote_avg desc")
+				} else {
+					db = db.Order("vote_avg asc")
+				}
+			case "commit_avg":
+				if isDesc {
+					db = db.Order("commit_avg desc")
+				} else {
+					db = db.Order("commit_avg asc")
+				}
+			case "collect_avg":
+				if isDesc {
+					db = db.Order("collect_avg desc")
+				} else {
+					db = db.Order("collect_avg asc")
+				}
+			}
+		}
+	} else {
+		// 默认排序
+		db = db.Order("task_id desc")
+	}
+
 	var taskInfos []gorm_model.YoungeeTaskInfo
-	db = db.Model(gorm_model.YoungeeTaskInfo{})
 	// 查询总数
 	var totalTask int64
-	if err := db.Count(&totalTask).Error; err != nil {
+	if err := db.Model(gorm_model.YoungeeTaskInfo{}).Count(&totalTask).Error; err != nil {
 		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
 		return nil, 0, err
 	}
-	db.Order("task_id").Find(&taskInfos)
 
 	// 查询该页数据
 	limit := pageSize
 	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("task_id").Limit(int(limit)).Offset(int(offset)).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
+	if err := db.Limit(int(limit)).Offset(int(offset)).Find(&taskInfos).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql data, err:%+v", err)
 		return nil, 0, err
 	}
 

+ 12 - 0
db/recruit_strategy.go

@@ -89,3 +89,15 @@ func GetRecruitStrategyBySLocalId(ctx context.Context, sLocalId int) ([]gorm_mod
 	}
 	return RecruitStrategys, nil
 }
+
+// UpdateRecruitStrategyById 根据ID更新策略
+func UpdateRecruitStrategyById(ctx context.Context, strategy *gorm_model.RecruitStrategy) error {
+	db := GetWriteDB(ctx)
+	whereCondition := gorm_model.RecruitStrategy{RecruitStrategyID: strategy.RecruitStrategyID}
+	err := db.Model(&gorm_model.RecruitStrategy{}).Where(whereCondition).Updates(strategy).Error
+	if err != nil {
+		return err
+	}
+	return nil
+
+}

+ 18 - 3
db/s_project.go

@@ -113,11 +113,17 @@ func GetSpecialProjectList(ctx context.Context, supplierId int, pageSize, pageNu
 // UpdateSProjectStatus 更新SProject信息
 func UpdateSProjectStatus(ctx context.Context, newSProject *http_model.SpecialSProjectAddToListRequest) error {
 	db := GetWriteDB(ctx)
+	var operatorType int
+	if newSProject.SubAccountId == 0 {
+		operatorType = 1
+	} else {
+		operatorType = 2
+	}
 	whereCondition := gorm_model.SProjectInfo{SProjectId: newSProject.SProjectId}
 	sProjectInfo := gorm_model.SProjectInfo{
 		SProjectStatus: newSProject.SProjectStatus,
 		SubAccountId:   newSProject.SubAccountId,
-		OperatorType:   newSProject.OperatorType,
+		OperatorType:   operatorType,
 	}
 	err := db.Model(&gorm_model.SProjectInfo{}).Where(whereCondition).Updates(sProjectInfo).Error
 	if err != nil {
@@ -140,10 +146,19 @@ func CreateSpecialStrategy(ctx context.Context, recruitStrategy []gorm_model.Rec
 func UpdateSProjectStrategyStatus(ctx context.Context, req *http_model.SpecialAddStrategyRequest) error {
 	db := GetWriteDB(ctx)
 	whereCondition := gorm_model.SProjectInfo{SProjectId: req.SProjectId}
+	var createStrategyId int
+	var createStrategyType int
+	if req.SubAccountId == 0 {
+		createStrategyId = 1
+		createStrategyType = req.SupplierId
+	} else {
+		createStrategyType = 2
+		createStrategyId = req.SubAccountId
+	}
 	sProjectInfo := gorm_model.SProjectInfo{
-		CreateStrategyId:   req.CreateStrategyId,
+		CreateStrategyId:   createStrategyId,
 		StrategyStatus:     1,
-		CreateStrategyType: req.CreateStrategyType,
+		CreateStrategyType: createStrategyType,
 	}
 	err := db.Model(&gorm_model.SProjectInfo{}).Where(whereCondition).Updates(sProjectInfo).Error
 	if err != nil {

+ 4 - 3
db/s_t_cooperate.go

@@ -18,11 +18,12 @@ func CreateSTCooperateInfo(ctx context.Context, cooperateInfo *gorm_model.Suppli
 }
 
 // CountCooperateInfoBySupplierAndPlatform 查找服务商-商家是否建立合作关系
-func CountCooperateInfoBySupplierAndPlatform(ctx context.Context, supplierId int, platformUserId int) (int64, error) {
+func CountCooperateInfoBySupplierAndPlatform(ctx context.Context, supplierId int, platformUserId int, taskType int) (int64, error) {
 	db := GetReadDB(ctx)
 	whereCondition := gorm_model.SupplierTalentCooperate{
 		PlatformUserId: platformUserId,
 		SupplierId:     supplierId,
+		TaskType:       taskType,
 	}
 	db = db.Debug().Model(gorm_model.SupplierTalentCooperate{}).Where(whereCondition)
 	var total int64
@@ -34,9 +35,9 @@ func CountCooperateInfoBySupplierAndPlatform(ctx context.Context, supplierId int
 }
 
 // UpdateSTCooperateInfo 更新服务商-达人合作关系
-func UpdateSTCooperateInfo(ctx context.Context, supplierId int, platformUserId int) error {
+func UpdateSTCooperateInfo(ctx context.Context, supplierId int, platformUserId int, taskType int) error {
 	db := GetWriteDB(ctx)
-	whereCondition := gorm_model.SupplierTalentCooperate{SupplierId: supplierId, PlatformUserId: platformUserId}
+	whereCondition := gorm_model.SupplierTalentCooperate{SupplierId: supplierId, PlatformUserId: platformUserId, TaskType: taskType}
 	err := db.Model(&gorm_model.SupplierTalentCooperate{}).
 		Where(whereCondition).
 		Update("cooperate_num", gorm.Expr("cooperate_num + 1")).

+ 25 - 5
db/task.go

@@ -436,13 +436,33 @@ func GetTaskByTaskId(ctx context.Context, taskId string) (*gorm_model.YoungeeTas
 }
 
 // CountTaskNumByTaskStage 根据子任务状态查找对应的种草子任务数量
-func CountTaskNumByTaskStage(ctx context.Context, taskStage int, openId string) (int64, error) {
+func CountTaskNumByTaskStage(ctx context.Context, taskStage int, supplierStatus int, sProjectId int) (int64, error) {
 	db := GetReadDB(ctx)
 	var taskNum int64
-	err := db.Model(gorm_model.YoungeeTaskInfo{}).Where("task_stage = ? and open_id = ?", taskStage, openId).Count(&taskNum).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
-		return 0, err
+	if taskStage == 0 && supplierStatus == 0 {
+		err := db.Model(gorm_model.YoungeeTaskInfo{}).Where("s_project_id = ?", sProjectId).Count(&taskNum).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
+			return 0, err
+		}
+	} else if taskStage == 0 {
+		err := db.Model(gorm_model.YoungeeTaskInfo{}).Where("supplier_status = ? and s_project_id = ?", supplierStatus, sProjectId).Count(&taskNum).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
+			return 0, err
+		}
+	} else if supplierStatus == 0 {
+		err := db.Model(gorm_model.YoungeeTaskInfo{}).Where("task_status = ? and s_project_id = ?", taskStage, sProjectId).Count(&taskNum).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
+			return 0, err
+		}
+	} else {
+		err := db.Model(gorm_model.YoungeeTaskInfo{}).Where("task_status = ? and supplier_status = ? and s_project_id = ?", taskStage, supplierStatus, sProjectId).Count(&taskNum).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
+			return 0, err
+		}
 	}
 	return taskNum, nil
 }

+ 1 - 1
handler/add_to_list.go

@@ -56,7 +56,7 @@ func (h *AddToListHandler) run() {
 		h.resp.Data = createCooperateErr
 	} else {
 		h.resp.Status = 20000
-		h.resp.Message = "加入商单成功"
+		h.resp.Message = "ok"
 	}
 }
 

+ 27 - 0
handler/local_change_supplier_status.go

@@ -2,7 +2,11 @@ package handler
 
 import (
 	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
 	"youngee_b_api/model/http_model"
+	"youngee_b_api/service"
+	"youngee_b_api/util"
 )
 
 func WrapLocalChangeTaskStatusHandler(ctx *gin.Context) {
@@ -37,6 +41,29 @@ func (p *LocalChangeTaskStatusHandler) getRequest() interface{} {
 }
 
 func (p *LocalChangeTaskStatusHandler) run() {
+	// 1. 同意或拒绝
+	err := service.SLocalLife.ChangeTaskSupplierStatus(p.ctx, p.req)
+	if err != nil {
+		logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v\n", err)
+		util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+		logrus.Info("ChangeTaskStatus fail,req:%+v", p.req)
+		p.resp.Message = "状态变更失败"
+		p.resp.Status = 40000
+		return
+	}
+
+	// 变更达人和服务商合作次数
+	if p.req.SupplierStatus == 2 {
+		cooperateErr := service.STCooperate.CreateSTCooperate(p.ctx, p.req.SupplierId, p.req.TaskIds)
+		if cooperateErr != nil {
+			logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v", cooperateErr)
+			util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+			logrus.Info("ChangeTaskStatus fail,req:%+v", p.req)
+			p.resp.Message = "合作次数修改失败"
+			p.resp.Status = 40000
+			return
+		}
+	}
 	p.resp.Message = "任务状态更换成功"
 }
 

+ 61 - 0
handler/local_task_count.go

@@ -0,0 +1,61 @@
+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"
+
+	"github.com/gin-gonic/gin"
+)
+
+func WrapLocalTaskCountHandler(ctx *gin.Context) {
+	handler := newLocalTaskCountHandler(ctx)
+	baseRun(handler)
+}
+
+func newLocalTaskCountHandler(ctx *gin.Context) *LocalTaskCountHandler {
+	return &LocalTaskCountHandler{
+		req:  http_model.NewLocalTaskCountRequest(),
+		resp: http_model.NewLocalTaskCountResponse(),
+		ctx:  ctx,
+	}
+}
+
+type LocalTaskCountHandler struct {
+	req  *http_model.LocalTaskCountRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (p *LocalTaskCountHandler) getContext() *gin.Context {
+	return p.ctx
+}
+
+func (p *LocalTaskCountHandler) getResponse() interface{} {
+	return p.resp
+}
+
+func (p *LocalTaskCountHandler) getRequest() interface{} {
+	return p.req
+}
+
+func (p *LocalTaskCountHandler) run() {
+	data, err := service.SLocalLife.CountLocalTask(p.ctx, p.req)
+	if err != nil {
+		logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v\n", err)
+		util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+		logrus.Info("ChangeTaskStatus fail,req:%+v", p.req)
+		p.resp.Message = "状态变更失败"
+		p.resp.Status = 40000
+		return
+	}
+	p.resp.Message = "ok"
+	p.resp.Data = data
+}
+
+func (p *LocalTaskCountHandler) checkParam() error {
+	return nil
+}

+ 1 - 1
handler/local_task_list.go

@@ -40,7 +40,7 @@ func (h *LocalTaskListHandler) getResponse() interface{} {
 }
 func (h *LocalTaskListHandler) run() {
 	conditions := pack.HttpLocalTaskRequestToCondition(h.req)
-	data, err := service.SLocalLife.GetLocalTaskList(h.ctx, h.req.PageSize, h.req.PageNum, conditions)
+	data, err := service.SLocalLife.GetLocalTaskList(h.ctx, h.req.PageSize, h.req.PageNum, h.req.OrderBy, h.req.OrderDesc, conditions)
 	if err != nil {
 		logrus.WithContext(h.ctx).Errorf("[LocalTaskListHandler] error LocalTaskList, err:%+v", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)

+ 9 - 22
handler/project_change_taskStatus.go

@@ -45,28 +45,15 @@ func (p *ProjectChangeTaskStatusHandler) getRequest() interface{} {
 func (p *ProjectChangeTaskStatusHandler) run() {
 	data := http_model.ProjectChangeTaskStatusRequest{}
 	data = *p.req
-	if data.IsSpecial == "1" {
-		// 定向种草
-		err := service.Project.ChangeSpecialTaskStatus(p.ctx, data)
-		if err != nil {
-			logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v\n", err)
-			util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
-			logrus.Info("ChangeTaskStatus fail,req:%+v", p.req)
-			p.resp.Message = "状态变更失败"
-			p.resp.Status = 40000
-			return
-		}
-	} else {
-		// 公开种草
-		err := service.Project.ChangeTaskStatus(p.ctx, data)
-		if err != nil {
-			logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v\n", err)
-			util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
-			logrus.Info("ChangeTaskStatus fail,req:%+v", p.req)
-			p.resp.Message = "状态变更失败"
-			p.resp.Status = 40000
-			return
-		}
+	// 种草同意提报达人
+	err := service.Project.ChangeTaskStatus(p.ctx, data)
+	if err != nil {
+		logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v\n", err)
+		util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+		logrus.Info("ChangeTaskStatus fail,req:%+v", p.req)
+		p.resp.Message = "状态变更失败"
+		p.resp.Status = 40000
+		return
 	}
 
 	// 变更达人和服务商合作次数

+ 1 - 1
handler/project_taskList.go

@@ -41,7 +41,7 @@ func (h *ProjectTaskListHandler) getResponse() interface{} {
 }
 func (h *ProjectTaskListHandler) run() {
 	conditions := pack.HttpProjectTaskRequestToCondition(h.req)
-	data, err := service.Project.GetProjectTaskList(h.ctx, h.req.ProjectId, h.req.PageSize, h.req.PageNum, conditions)
+	data, err := service.Project.GetProjectTaskList(h.ctx, h.req.PageSize, h.req.PageNum, h.req.OrderBy, h.req.OrderDesc, conditions)
 	if err != nil {
 		logrus.WithContext(h.ctx).Errorf("[ProjectTaskListHandler] error GetProjectTaskList, err:%+v", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)

+ 61 - 0
handler/project_task_count.go

@@ -0,0 +1,61 @@
+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"
+
+	"github.com/gin-gonic/gin"
+)
+
+func WrapProjectTaskCountHandler(ctx *gin.Context) {
+	handler := newProjectTaskCountHandler(ctx)
+	baseRun(handler)
+}
+
+func newProjectTaskCountHandler(ctx *gin.Context) *ProjectTaskCountHandler {
+	return &ProjectTaskCountHandler{
+		req:  http_model.NewProjectTaskCountRequest(),
+		resp: http_model.NewProjectTaskCountResponse(),
+		ctx:  ctx,
+	}
+}
+
+type ProjectTaskCountHandler struct {
+	req  *http_model.ProjectTaskCountRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (p *ProjectTaskCountHandler) getContext() *gin.Context {
+	return p.ctx
+}
+
+func (p *ProjectTaskCountHandler) getResponse() interface{} {
+	return p.resp
+}
+
+func (p *ProjectTaskCountHandler) getRequest() interface{} {
+	return p.req
+}
+
+func (p *ProjectTaskCountHandler) run() {
+	data, err := service.Project.CountProjectTask(p.ctx, p.req.SProjectId)
+	if err != nil {
+		logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v\n", err)
+		util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+		logrus.Info("ChangeTaskStatus fail,req:%+v", p.req)
+		p.resp.Message = "状态变更失败"
+		p.resp.Status = 40000
+		return
+	}
+	p.resp.Message = "ok"
+	p.resp.Data = data
+}
+
+func (p *ProjectTaskCountHandler) checkParam() error {
+	return nil
+}

+ 1 - 1
handler/special_local_add_to_list.go

@@ -7,7 +7,7 @@ import (
 )
 
 func WrapSpecialLocalAddToListHandler(ctx *gin.Context) {
-	handler := newLocalLifeAddToListHandler(ctx)
+	handler := newSpecialLocalAddToListHandler(ctx)
 	baseRun(handler)
 }
 

+ 1 - 1
model/common_model/local_task_list.go

@@ -3,7 +3,7 @@ package common_model
 type LocalTaskConditions struct {
 	LocalId          string `condition:"local_id"`          // 本地生活ID
 	SLocalId         int    `condition:"s_local_id"`        // 服务商加入商单的本地生活ID
-	TaskStatus       string `condition:"task_status"`       // 任务状态
+	TaskStatus       int    `condition:"task_status"`       // 任务状态
 	SupplierStatus   int    `condition:"supplier_status"`   // 服务商任务状态 0表示达人来源非服务商 1待选 2已选 3落选
 	TaskStage        int    `condition:"task_stage"`        // 任务阶段,1:已报名, 2:申请成功, 3:申请失败, 4:待预约探店, 5:预约确认中 6:预约成功 7:待传脚本, 8:脚本待审, 9:待传初稿, 10:初稿待审, 11:待传链接, 12:链接待审, 13:待传数据, 14:数据待审, 15:已结案, 16:解约, 17:终止合作(过渡态)
 	PlatformNickname string `condition:"platform_nickname"` // 账号昵称

+ 1 - 0
model/common_model/task_conditions.go

@@ -2,6 +2,7 @@ package common_model
 
 type TaskConditions struct {
 	SProjectId       int    `condition:"s_project_id"`      // 服务商种草任务ID
+	TaskStage        int    `condition:"task_stage"`        // 任务状态
 	ProjectId        string `condition:"project_id"`        // 项目ID
 	TaskStatus       int64  `condition:"task_status"`       // 任务状态
 	StrategyId       int64  `condition:"strategy_id"`       // 策略ID

+ 2 - 0
model/gorm_model/s_local_life.go

@@ -25,6 +25,8 @@ type YounggeeSLocalLifeInfo struct {
 	ServiceCharge       float64    `gorm:"column:service_charge"`         // 服务商预估可赚服务费
 	ServiceChargeActual float64    `gorm:"column:service_charge_actual"`  // 服务商实际可赚服务费
 	ServiceChargeSettle float64    `gorm:"column:service_charge_settle"`  // 服务商已结算服务费
+	EstimateDraftFee    float64    `gorm:"column:estimate_draft_fee"`     // 预估达人总稿费
+	EstimateSupportFee  float64    `gorm:"column:estimate_support_fee"`   // 预估提报价格总额
 	OperatorType        int        `gorm:"column:operator_type"`          // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
 	SLocalStatus        int        `gorm:"column:s_local_status"`         // 服务商本地生活任务状态,1待确认,2已确认,3已拒绝
 	StrategyStatus      int        `gorm:"column:strategy_status"`        // 定向本地生活任务是否替换招募策略

+ 2 - 0
model/gorm_model/s_project.go

@@ -23,6 +23,8 @@ type SProjectInfo struct {
 	ServiceCharge       float64    `gorm:"column:service_charge"`                          // 服务商预估可赚服务费
 	ServiceChargeActual float64    `gorm:"column:service_charge_actual"`                   // 服务商实际可赚服务费
 	ServiceChargeSettle float64    `gorm:"column:service_charge_settle"`                   // 服务商已结算服务费
+	EstimateDraftFee    float64    `gorm:"column:estimate_draft_fee"`                      // 预估达人总稿费
+	EstimateSupportFee  float64    `gorm:"column:estimate_support_fee"`                    // 预估提报价格总额
 	OperatorType        int        `gorm:"column:operator_type"`                           // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
 	SProjectStatus      int        `gorm:"column:s_project_status"`                        // 服务商种草任务状态,1待确认,2已确认,3已拒绝
 	StrategyStatus      int        `gorm:"column:strategy_status"`                         // 定向种草任务是否替换招募策略,0无,1有

+ 1 - 1
model/http_model/add_to_list.go

@@ -5,7 +5,7 @@ type AddToListRequest struct {
 	EnterpriseId string `json:"enterprise_id"`  // 商家ID
 	SupplierId   int    `json:"supplier_id"`    // 服务商ID
 	SubAccountId int    `json:"sub_account_id"` // 子账号ID
-	OperatorType int    `json:"operator_type"`  // 账号类型,1为主账号,2为子账号
+	// OperatorType int    `json:"operator_type"`  // 账号类型,1为主账号,2为子账号
 }
 
 func NewAddToListRequest() *AddToListRequest {

+ 4 - 3
model/http_model/create_supplier_withdraw.go

@@ -1,9 +1,10 @@
 package http_model
 
 type CreateSupplierWithdrawRequest struct {
-	SupplierId                    int                       `json:"supplier_id"`                      // 服务商ID
-	CreateCompanySupplierWithdraw []CompanySupplierWithdraw `json:"create_company_supplier_withdraw"` // 机构服务商提现列表
-	CreatePersonSupplierWithdraw  []PersonSupplierWithdraw  `json:"create_person_supplier_withdraw"`  // 个人服务商提现列表
+	SupplierId   int   `json:"supplier_id"`    // 服务商ID
+	SubAccountId int   `json:"sub_account_id"` // 子账号ID
+	InvoiceIds   []int `json:"invoice_ids"`    // 机构服务商提现列表
+	IncomeIds    []int `json:"income_ids"`     // 个人服务商提现列表
 }
 
 type CompanySupplierWithdraw struct {

+ 1 - 0
model/http_model/find_all_sub_account.go

@@ -13,6 +13,7 @@ type FindAllSubAccountInfo struct {
 	JobId          int    `json:"job_id"`           // 岗位ID
 	JobName        string `json:"job_name"`         // 岗位名称
 	SupplierId     int    `json:"supplier_id"`      // 所属服务商ID
+	SupplierName   string `json:"supplier_name"`    // 所属服务商名称
 	AccountStatus  int    `json:"account_status"`   // 账号状态,1为正常,2为停用
 	UserId         int    `json:"user_id"`          // 用户表中ID
 }

+ 3 - 2
model/http_model/local_change_supplier_status.go

@@ -3,8 +3,9 @@ package http_model
 type LocalChangeSupplierStatusRequest struct {
 	TaskIds        []string `json:"task_ids"`
 	TaskStatus     string   `json:"task_status"`
-	TaskStage      string   `json:"task_stage"`
-	LocalId        string   `json:"local_id"`
+	SLocalId       int      `json:"s_local_id"`      // 服务商加入商单后的本地生活ID
+	SupplierId     int      `json:"supplier_id"`     // 服务商ID
+	SubAccountId   int      `json:"sub_account_id"`  // 子任务ID
 	SupplierStatus int      `json:"supplier_status"` // 服务商任务状态 0表示达人来源非服务商 1待选 2已选 3落选
 }
 

+ 1 - 1
model/http_model/local_life_add_to_list.go

@@ -5,7 +5,7 @@ type LocalLifeAddToListRequest struct {
 	EnterpriseId string `json:"enterprise_id"`  // 商家ID
 	SupplierId   int    `json:"supplier_id"`    // 服务商ID
 	SubAccountId int    `json:"sub_account_id"` // 子账号ID
-	OperatorType int    `json:"operator_type"`  // 账号类型,1为主账号,2为子账号
+	// OperatorType int    `json:"operator_type"`  // 账号类型,1为主账号,2为子账号
 }
 
 func NewLocalLifeAddToListRequest() *LocalLifeAddToListRequest {

+ 5 - 4
model/http_model/local_special_add_strategy.go

@@ -3,10 +3,11 @@ package http_model
 import "youngee_b_api/model/gorm_model"
 
 type LocalSpecialAddStrategyRequest struct {
-	SLocalId           int                          `json:"s_local_id"`           // 服务商本地生活任务ID
-	RecruitStrategys   []gorm_model.RecruitStrategy `json:"recruit_strategys"`    // 招募策略
-	CreateStrategyId   int                          `json:"create_strategy_id"`   // 替换招募策略操作人ID
-	CreateStrategyType int                          `json:"create_strategy_type"` // 服务商修改服务费操作人类型:1服务商主账号,2子账号
+	SLocalId         int                          `json:"s_local_id"`        // 服务商本地生活任务ID
+	RecruitStrategys []gorm_model.RecruitStrategy `json:"recruit_strategys"` // 招募策略
+	SupplierId       int                          `json:"supplier_id"`       // 服务商ID
+	SubAccountId     int                          `json:"sub_account_id"`    // 子账号ID
+	// CreateStrategyType int                          `json:"create_strategy_type"` // 服务商修改服务费操作人类型:1服务商主账号,2子账号
 }
 
 func NewLocalSpecialAddStrategyRequest() *LocalSpecialAddStrategyRequest {

+ 25 - 0
model/http_model/local_task_count.go

@@ -0,0 +1,25 @@
+package http_model
+
+type LocalTaskCountRequest struct {
+	SLocalId int `json:"s_local_id"` // 服务商本地生活任务ID
+}
+
+type LocalTaskCountData struct {
+	Stage1 int64 `json:"stage_1"` // 达人未处理
+	Stage2 int64 `json:"stage_2"` // 已提报
+	Stage3 int64 `json:"stage_3"` // 拒绝合作
+	Stage4 int64 `json:"stage_4"` // 已提报-未处理
+	Stage5 int64 `json:"stage_5"` // 已提报-同意合作
+	Stage6 int64 `json:"stage_6"` // 已提报-品牌拒绝
+	Stage7 int64 `json:"stage_7"` // 全部报名达人
+}
+
+func NewLocalTaskCountRequest() *LocalTaskCountRequest {
+	return new(LocalTaskCountRequest)
+}
+
+func NewLocalTaskCountResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(LocalTaskCountData)
+	return resp
+}

+ 20 - 15
model/http_model/local_task_list.go

@@ -1,14 +1,15 @@
 package http_model
 
 type LocalTaskListRequest struct {
-	PageSize         int32  `json:"page_size"`
-	PageNum          int32  `json:"page_num"`
-	LocalId          string `json:"local_id"`          // 本地生活ID
-	SLocalId         int    `json:"s_local_id"`        // 服务商加入商单的本地生活ID
-	TaskStatus       string `json:"task_status"`       // 任务状态
-	SupplierStatus   int    `json:"supplier_status"`   // 服务商任务状态 0表示达人来源非服务商 1待选 2已选 3落选
-	TaskStage        int    `json:"task_stage"`        // 任务阶段,1:已报名, 2:申请成功, 3:申请失败, 4:待预约探店, 5:预约确认中 6:预约成功 7:待传脚本, 8:脚本待审, 9:待传初稿, 10:初稿待审, 11:待传链接, 12:链接待审, 13:待传数据, 14:数据待审, 15:已结案, 16:解约, 17:终止合作(过渡态)
-	PlatformNickname string `json:"platform_nickname"` // 账号昵称
+	PageSize         int32    `json:"page_size"`
+	PageNum          int32    `json:"page_num"`
+	SLocalId         int      `json:"s_local_id"`        // 服务商加入商单的本地生活ID
+	TaskStatus       int      `json:"task_status"`       // 任务状态
+	SupplierStatus   int      `json:"supplier_status"`   // 服务商任务状态 0表示达人来源非服务商 1待选 2已选 3落选
+	TaskStage        int      `json:"task_stage"`        // 任务阶段,1:已报名, 2:申请成功, 3:申请失败, 4:待预约探店, 5:预约确认中 6:预约成功 7:待传脚本, 8:脚本待审, 9:待传初稿, 10:初稿待审, 11:待传链接, 12:链接待审, 13:待传数据, 14:数据待审, 15:已结案, 16:解约, 17:终止合作(过渡态)
+	PlatformNickname string   `json:"platform_nickname"` // 账号昵称
+	OrderBy          []string `json:"order_by"`          // 排序条件 fans_num,vote_avg,commit_avg,collect_avg
+	OrderDesc        []int    `json:"order_desc"`        // 是否降序 1是,2否
 }
 
 type LocalTaskPreview struct {
@@ -31,6 +32,7 @@ type LocalTaskPreview struct {
 	FansNum          int     `json:"fans_num"`          // 粉丝数
 	VoteAvg          int     `json:"vote_avg"`          // 平均点赞数
 	CommitAvg        int     `json:"commit_avg"`        // 平均评论数
+	CollectAvg       int     `json:"collect_avg"`       // 平均收藏数
 	BOperator        string  `json:"b_operator"`        // 商家确定达人操作人ID
 	BOperatorType    int     `json:"b_operator_type"`   // 商家操作人类型,1商家用户,2商家子账号,3管理后台
 	SOperator        int     `json:"s_operator"`        // 服务商确定达人操作人ID
@@ -39,13 +41,16 @@ type LocalTaskPreview struct {
 }
 
 type LocalTaskListData struct {
-	LocalTaskPreview    []*LocalTaskPreview `json:"local_task_pre_view"`   // Task
-	RecruitNum          int                 `json:"recruit_num"`           // 执行人数
-	QuitNum             int                 `json:"quit_num"`              // 解约人数
-	SettleNum           int                 `json:"settle_num"`            // 结算人数
-	ServiceChargeActual float64             `json:"service_charge_actual"` // 服务费总额
-	ServiceChargeSettle float64             `json:"service_charge_settle"` // 服务费已结算
-	Total               int64               `json:"total"`
+	LocalTaskPreview      []*LocalTaskPreview `json:"local_task_pre_view"`     // Task
+	RecruitNum            int                 `json:"recruit_num"`             // 执行人数
+	QuitNum               int                 `json:"quit_num"`                // 解约人数
+	SettleNum             int                 `json:"settle_num"`              // 结算人数
+	ServiceChargeActual   float64             `json:"service_charge_actual"`   // 服务费总额
+	ServiceChargeSettle   float64             `json:"service_charge_settle"`   // 服务费已结算
+	EstimateServiceCharge float64             `json:"estimate_service_charge"` // 预估服务费总额
+	EstimateDraftFee      float64             `json:"estimate_draft_fee"`      // 预估达人总稿费
+	EstimateSupportFee    float64             `json:"estimate_support_fee"`    // 预估提报价格总额
+	Total                 int64               `json:"total"`
 }
 
 func NewLocalTaskListRequest() *LocalTaskListRequest {

+ 2 - 5
model/http_model/project_change_taskStatus.go

@@ -2,14 +2,11 @@ package http_model
 
 type ProjectChangeTaskStatusRequest struct {
 	TaskIds        []string `json:"task_ids"`        // 子任务ID
-	TaskStatus     string   `json:"task_status"`     // 子任务状态
-	TaskStage      string   `json:"task_stage"`      // 子任务阶段
-	IsSpecial      string   `json:"is_special"`      // 1为定向种草
-	ProjectId      string   `json:"project_id"`      // 种草任务ID
 	SupplierId     int      `json:"supplier_id"`     // 服务商ID
 	SubAccountId   int      `json:"sub_account_id"`  // 子账号ID,若提报或拒绝达人操作人不是子账号则0,否则填入ID
-	SOperatorType  int      `json:"s_operator_type"` // 服务商提报或拒绝达人操作人类型,1服务商主账号,2服务商子账号,3管理后台
 	SupplierStatus int      `json:"supplier_status"` // 服务商任务状态 0表示达人来源非服务商 1待选 2已选 3落选
+	// SOperatorType  int      `json:"s_operator_type"` // 服务商提报或拒绝达人操作人类型,1服务商主账号,2服务商子账号,3管理后台
+	// IsSpecial      string   `json:"is_special"`      // 1为定向种草
 }
 
 func NewProjectChangeTaskStatusRequst() *ProjectChangeTaskStatusRequest {

+ 20 - 16
model/http_model/project_taskList.go

@@ -5,15 +5,15 @@ import (
 )
 
 type ProjectTaskListRequest struct {
-	PageSize         int64  `json:"page_size"`
-	PageNum          int64  `json:"page_num"`
-	ProjectId        string `json:"project_id"`        // 种草任务ID
-	TaskId           string `json:"task_id"`           // 任务ID
-	StrategyId       string `json:"strategy_id"`       // 策略ID
-	TaskStatus       string `json:"task_status"`       // 任务状态
-	PlatformNickname string `json:"platform_nickname"` // 账号昵称
-	SProjectId       int    `json:"s_project_id"`      // 服务商种草任务ID
-	SupplierStatus   int    `json:"supplier_status"`   // 服务商任务状态 0表示达人来源非服务商 1待选 2已选 3落选
+	PageSize         int64    `json:"page_size"`
+	PageNum          int64    `json:"page_num"`
+	TaskStage        int      `json:"task_stage"`        // 子任务阶段
+	TaskStatus       int      `json:"task_status"`       // 任务状态
+	PlatformNickname string   `json:"platform_nickname"` // 账号昵称
+	SProjectId       int      `json:"s_project_id"`      // 服务商种草任务ID
+	SupplierStatus   int      `json:"supplier_status"`   // 服务商任务状态 0表示达人来源非服务商 1待选 2已选 3落选
+	OrderBy          []string `json:"order_by"`          // 排序条件 fans_num,vote_avg,commit_avg,collect_avg
+	OrderDesc        []int    `json:"order_desc"`        // 是否降序 1是,2否
 }
 
 type ProjectTaskPreview struct {
@@ -36,6 +36,7 @@ type ProjectTaskPreview struct {
 	FansNum          int     `json:"fans_num"`          // 粉丝数
 	VoteAvg          int     `json:"vote_avg"`          // 平均点赞数
 	CommitAvg        int     `json:"commit_avg"`        // 平均评论数
+	CollectAvg       int     `json:"collect_avg"`       // 平均收藏数
 	BOperator        string  `json:"b_operator"`        // 商家确定达人操作人ID
 	BOperatorType    int     `json:"b_operator_type"`   // 商家操作人类型,1商家用户,2商家子账号,3管理后台
 	SOperator        int     `json:"s_operator"`        // 服务商确定达人操作人ID
@@ -71,13 +72,16 @@ type ProjectTaskInfo struct {
 }
 
 type ProjectTaskListData struct {
-	ProjectTaskPreview  []*ProjectTaskPreview `json:"project_task_pre_view"` // Task
-	RecruitNum          int                   `json:"recruit_num"`           // 执行人数
-	QuitNum             int                   `json:"quit_num"`              // 解约人数
-	SettleNum           int                   `json:"settle_num"`            // 结算人数
-	ServiceChargeActual float64               `json:"service_charge_actual"` // 服务费总额
-	ServiceChargeSettle float64               `json:"service_charge_settle"` // 服务费已结算
-	Total               string                `json:"total"`
+	ProjectTaskPreview    []*ProjectTaskPreview `json:"project_task_pre_view"`   // Task
+	RecruitNum            int                   `json:"recruit_num"`             // 执行人数
+	QuitNum               int                   `json:"quit_num"`                // 解约人数
+	SettleNum             int                   `json:"settle_num"`              // 结算人数
+	ServiceChargeActual   float64               `json:"service_charge_actual"`   // 服务费总额
+	ServiceChargeSettle   float64               `json:"service_charge_settle"`   // 服务费已结算
+	EstimateServiceCharge float64               `json:"estimate_service_charge"` // 预估服务费总额
+	EstimateDraftFee      float64               `json:"estimate_draft_fee"`      // 预估达人总稿费
+	EstimateSupportFee    float64               `json:"estimate_support_fee"`    // 预估提报价格总额
+	Total                 string                `json:"total"`
 }
 
 func NewProjectTaskListRequest() *ProjectTaskListRequest {

+ 25 - 0
model/http_model/project_task_count.go

@@ -0,0 +1,25 @@
+package http_model
+
+type ProjectTaskCountRequest struct {
+	SProjectId int `json:"s_project_id"` // 服务商种草任务ID
+}
+
+type ProjectTaskCountData struct {
+	Stage1 int64 `json:"stage_1"` // 达人未处理
+	Stage2 int64 `json:"stage_2"` // 已提报
+	Stage3 int64 `json:"stage_3"` // 拒绝合作
+	Stage4 int64 `json:"stage_4"` // 已提报-未处理
+	Stage5 int64 `json:"stage_5"` // 已提报-同意合作
+	Stage6 int64 `json:"stage_6"` // 已提报-品牌拒绝
+	Stage7 int64 `json:"stage_7"` // 全部报名达人
+}
+
+func NewProjectTaskCountRequest() *ProjectTaskCountRequest {
+	return new(ProjectTaskCountRequest)
+}
+
+func NewProjectTaskCountResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(ProjectTaskCountData)
+	return resp
+}

+ 4 - 4
model/http_model/special_add_strategy.go

@@ -3,10 +3,10 @@ package http_model
 import "youngee_b_api/model/gorm_model"
 
 type SpecialAddStrategyRequest struct {
-	SProjectId         int                          `json:"s_project_id"`         // 服务商种草任务ID
-	RecruitStrategys   []gorm_model.RecruitStrategy `json:"recruit_strategys"`    // 招募策略
-	CreateStrategyId   int                          `json:"create_strategy_id"`   // 替换招募策略操作人ID
-	CreateStrategyType int                          `json:"create_strategy_type"` // 服务商修改服务费操作人类型:1服务商主账号,2子账号
+	SProjectId       int                          `json:"s_project_id"`      // 服务商种草任务ID
+	RecruitStrategys []gorm_model.RecruitStrategy `json:"recruit_strategys"` // 招募策略
+	SubAccountId     int                          `json:"sub_account_id"`    // 子账号ID
+	SupplierId       int                          `json:"supplier_id"`       // 服务商ID
 }
 
 func NewSpecialAddStrategyRequest() *SpecialAddStrategyRequest {

+ 1 - 1
model/http_model/special_local_add_to_list.go

@@ -4,8 +4,8 @@ type SpecialLocalAddToListRequest struct {
 	SLocalId     int `json:"sLocalId"`       //
 	SupplierId   int `json:"supplier_id"`    // 服务商ID
 	SubAccountId int `json:"sub_account_id"` // 子账号ID
-	OperatorType int `json:"operator_type"`  // 账号类型,1为主账号,2为子账号
 	SLocalStatus int `json:"s_local_status"` // 服务商本地生活任务状态,1待确认,2已确认,3已拒绝
+	// OperatorType int `json:"operator_type"`  // 账号类型,1为主账号,2为子账号
 }
 
 func NewSpecialLocalAddToListRequest() *SpecialLocalAddToListRequest {

+ 2 - 1
model/http_model/special_s_project_add_to_list.go

@@ -4,8 +4,9 @@ type SpecialSProjectAddToListRequest struct {
 	SProjectId     int `json:"s_project_id"`     // 待加入商单的种草任务ID
 	SupplierId     int `json:"supplier_id"`      // 服务商ID
 	SubAccountId   int `json:"sub_account_id"`   // 子账号ID
-	OperatorType   int `json:"operator_type"`    // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
 	SProjectStatus int `json:"s_project_status"` // 服务商种草任务状态,1待确认,2已确认,3已拒绝
+	// OperatorType   int `json:"operator_type"`    // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
+
 }
 
 func NewSpecialSProjectAddToListRequest() *SpecialSProjectAddToListRequest {

+ 1 - 1
pack/local_task_list.go

@@ -7,7 +7,7 @@ import (
 
 func HttpLocalTaskRequestToCondition(req *http_model.LocalTaskListRequest) *common_model.LocalTaskConditions {
 	return &common_model.LocalTaskConditions{
-		LocalId:          req.LocalId,
+		// LocalId:          req.LocalId,
 		SLocalId:         req.SLocalId,
 		TaskStatus:       req.TaskStatus,
 		SupplierStatus:   req.SupplierStatus,

+ 1 - 1
pack/project_task_list.go

@@ -26,7 +26,7 @@ func GormFullProjectToHttpProjectTaskPreview(projectTaskInfo *http_model.Project
 		PlatformNickname: conv.MustString(projectTaskInfo.PlatformNickname),
 		FansCount:        conv.MustString(projectTaskInfo.FansCount),
 		StrategyId:       conv.MustString(projectTaskInfo.StrategyID),
-		TaskStatus:       conv.MustString(projectTaskInfo.TaskStatus),
+		TaskStatus:       projectTaskInfo.TaskStatus,
 		CreateDate:       createDate,
 		FansNum:          projectTaskInfo.FansNum,
 		VoteAvg:          projectTaskInfo.VoteAvg,

+ 4 - 3
pack/project_task_list_conditions.go

@@ -10,11 +10,12 @@ import (
 func HttpProjectTaskRequestToCondition(req *http_model.ProjectTaskListRequest) *common_model.TaskConditions {
 	return &common_model.TaskConditions{
 		SProjectId:       req.SProjectId,
-		ProjectId:        req.ProjectId,
 		TaskStatus:       conv.MustInt64(req.TaskStatus),
-		StrategyId:       conv.MustInt64(req.StrategyId),
-		TaskId:           conv.MustString(req.TaskId),
 		PlatformNickname: conv.MustString(req.PlatformNickname),
 		SupplierStatus:   req.SupplierStatus,
+		TaskStage:        req.TaskStage,
+		//StrategyId:       conv.MustInt64(req.StrategyId),
+		//TaskId:           conv.MustString(req.TaskId),
+		//ProjectId:        req.ProjectId,
 	}
 }

+ 3 - 1
route/init.go

@@ -66,7 +66,8 @@ func InitRoute(r *gin.Engine) {
 		m.POST("/sProject/showSProject", handler.WrapShowSProjectHandler)                // 服务商种草任务内容
 		m.POST("/sProject/product/find", handler.WrapFindProductHandler)                 // 查找单个产品
 		m.POST("/sProject/projectStrategy", handler.WrapProjectStrategyHandler)          // 招募策略查询
-		m.POST("/sProject/taskList", handler.WrapProjectTaskListHandler)                 // 任务列表
+		m.POST("/sProject/taskList", handler.WrapProjectTaskListHandler)                 // 子任务列表
+		m.POST("/sProject/taskCount", handler.WrapProjectTaskCountHandler)               // 子任务数量统计
 		m.POST("/sProject/changeTaskStatus", handler.WrapProjectChangeTaskStatusHandler) // 改变子任务的状态 报名通过,拒绝报名
 		m.POST("/sProject/showTaskProgress", handler.WrapShowTaskProgressHandler)        // 展示子任务进度
 		m.POST("/qrcode/getWxQrcode", handler.WrapGetWxQRCodeHandler)                    // 获取微信二维码
@@ -206,6 +207,7 @@ func InitRoute(r *gin.Engine) {
 		l.POST("/sLocalLife/fullSLocalList", handler.WrapFullSLocalListHandler)          // 商单管理-公开本地生活任务列表
 		l.POST("/sLocalLife/showSLocal", handler.WrapShowSLocalHandler)                  // 服务商本地生活任务详情
 		l.POST("/sLocalLife/taskList", handler.WrapLocalTaskListHandler)                 // 子任务列表
+		l.POST("/sLocalLife/taskCount", handler.WrapLocalTaskCountHandler)               // 子任务数量统计
 		l.POST("/sLocalLife/changeTaskStatus", handler.WrapLocalChangeTaskStatusHandler) // 改变子任务的状态 报名通过,拒绝报名
 		l.POST("/sLocalLife/teamBuying/find", handler.WrapFindTeamBuyingHandler)         // 查找团购
 		l.POST("/sLocalLife/store/find", handler.WrapFindStoreHandler)                   // 查找门店

+ 75 - 5
service/project.go

@@ -448,15 +448,16 @@ func (*project) GetProjectDraftList(ctx context.Context, enterpriseID string, pa
 	return ProjectDraftListData, nil
 }
 
-func (*project) GetProjectTaskList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TaskConditions) (*http_model.ProjectTaskListData, error) {
+func (*project) GetProjectTaskList(ctx context.Context, pageSize, pageNum int64, orderBy []string, orderDesc []int, conditions *common_model.TaskConditions) (*http_model.ProjectTaskListData, error) {
 
 	// 1. 根据SProject和condition查询所有Task
-	projectTasks, total, err := db.GetProjectTaskList(ctx, projectID, pageSize, pageNum, conditions)
+	projectTasks, total, err := db.GetProjectTaskList(ctx, pageSize, pageNum, orderBy, orderDesc, conditions)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call GetProjectTaskList error,err:%+v", err)
 		return nil, err
 	}
 	projectTaskListData := new(http_model.ProjectTaskListData)
+	// fmt.Println(projectTasks)
 	projectTaskListData.ProjectTaskPreview = pack.MGormProjectTaskToHttpProjectTaskPreview(projectTasks)
 
 	// 2. 查找SProject中其他信息
@@ -470,6 +471,9 @@ func (*project) GetProjectTaskList(ctx context.Context, projectID string, pageSi
 		projectTaskListData.QuitNum = sProjectInfo.QuitNum
 		projectTaskListData.ServiceChargeSettle = sProjectInfo.ServiceChargeSettle
 		projectTaskListData.ServiceChargeActual = sProjectInfo.ServiceChargeActual
+		projectTaskListData.EstimateServiceCharge = sProjectInfo.ServiceChargeActual
+		projectTaskListData.EstimateDraftFee = sProjectInfo.EstimateDraftFee
+		projectTaskListData.EstimateSupportFee = sProjectInfo.EstimateSupportFee
 	}
 	projectTaskListData.Total = conv.MustString(total)
 	return projectTaskListData, nil
@@ -571,16 +575,23 @@ func (*project) GetTaskLogisticsList(ctx context.Context, projectID string, page
 
 // ChangeTaskStatus 提报达人或拒绝提报达人
 func (*project) ChangeTaskStatus(ctx *gin.Context, data http_model.ProjectChangeTaskStatusRequest) interface{} {
-	RecruitStrategyIDs, err := db.ChangeTaskStatus(ctx, data.TaskIds, data.SupplierStatus, data.SupplierId, data.SubAccountId, data.SOperatorType)
+	var sOperatorType int
+	if data.SubAccountId == 0 {
+		sOperatorType = 1
+	} else {
+		sOperatorType = 2
+	}
+	RecruitStrategyIDs, err := db.ChangeTaskStatus(ctx, data.TaskIds, data.SupplierStatus, data.SupplierId, data.SubAccountId, sOperatorType)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call ChangeTaskStatus error,err:%+v", err)
 		return err
 	}
 	fmt.Println(RecruitStrategyIDs)
+
 	// 已选数量
 	//if data.SupplierStatus == 2 {
 	//	for _, RecruitStrategyID := range RecruitStrategyIDs {
-	//		err = db.CalculateSelectedNumberByRecruitStrategyID(ctx, RecruitStrategyID, 0)
+	//		err = db.CalculateSelectedNumberByRecruitStrategyID(ctx, RecruitStrategyID, 1)
 	//		if err != nil {
 	//			logrus.WithContext(ctx).Errorf("[project service] call ChangeTaskStatus error,err:%+v", err)
 	//			return err
@@ -588,7 +599,7 @@ func (*project) ChangeTaskStatus(ctx *gin.Context, data http_model.ProjectChange
 	//	}
 	//} else if data.SupplierStatus == 3 {
 	//	for _, RecruitStrategyID := range RecruitStrategyIDs {
-	//		err = db.CalculateSelectedNumberByRecruitStrategyID(ctx, RecruitStrategyID, 0)
+	//		err = db.CalculateSelectedNumberByRecruitStrategyID(ctx, RecruitStrategyID, 1)
 	//		if err != nil {
 	//			logrus.WithContext(ctx).Errorf("[project service] call ChangeTaskStatus error,err:%+v", err)
 	//			return err
@@ -599,14 +610,17 @@ func (*project) ChangeTaskStatus(ctx *gin.Context, data http_model.ProjectChange
 }
 
 // ChangeSpecialTaskStatus 定向种草任务 提报达人,拒绝提报
+/*
 func (*project) ChangeSpecialTaskStatus(ctx *gin.Context, data http_model.ProjectChangeTaskStatusRequest) interface{} {
 	err := db.ChangeSpecialTaskStatus(ctx, data.TaskIds, data.SupplierStatus, data.SupplierId, data.SubAccountId, data.SOperatorType)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call ChangeSpecialTaskStatus error,err:%+v", err)
 		return err
 	}
+
 	return nil
 }
+*/
 
 func (p *project) GetTaskScriptList(ctx *gin.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TalentConditions) (*http_model.TaskScriptListData, error) {
 	TaskScripts, total, err := db.GetTaskScriptList(ctx, projectID, pageSize, pageNum, conditions)
@@ -877,3 +891,59 @@ func (*project) GetProjectDetail(ctx context.Context, ProjectId string) (*http_m
 
 	return sProjectData, nil
 }
+
+// CountProjectTask 按照状态统计子任务数量
+func (*project) CountProjectTask(ctx context.Context, sProjectId int) (*http_model.ProjectTaskCountData, error) {
+	var counter *http_model.ProjectTaskCountData
+	counter = &http_model.ProjectTaskCountData{}
+
+	// 1. Stage1
+	stage1, stage1Err := db.CountTaskNumByTaskStage(ctx, 0, 1, sProjectId)
+	if stage1Err != nil {
+		return nil, stage1Err
+	}
+	counter.Stage1 = stage1
+
+	// 2. Stage2
+	stage2, stage2Err := db.CountTaskNumByTaskStage(ctx, 0, 2, sProjectId)
+	if stage2Err != nil {
+		return nil, stage2Err
+	}
+	counter.Stage2 = stage2
+
+	// 3. Stage3
+	stage3, stage3Err := db.CountTaskNumByTaskStage(ctx, 0, 3, sProjectId)
+	if stage3Err != nil {
+		return nil, stage3Err
+	}
+	counter.Stage3 = stage3
+
+	// 4. Stage4
+	stage4, stage4Err := db.CountTaskNumByTaskStage(ctx, 1, 2, sProjectId)
+	if stage4Err != nil {
+		return nil, stage4Err
+	}
+	counter.Stage4 = stage4
+
+	// 5. Stage5
+	stage5, stage5Err := db.CountTaskNumByTaskStage(ctx, 2, 2, sProjectId)
+	if stage5Err != nil {
+		return nil, stage5Err
+	}
+	counter.Stage5 = stage5
+
+	// 6. Stage6
+	stage6, stage6Err := db.CountTaskNumByTaskStage(ctx, 3, 2, sProjectId)
+	if stage6Err != nil {
+		return nil, stage6Err
+	}
+	counter.Stage6 = stage6
+
+	// 7. Stage7
+	stage7, stage7Err := db.CountTaskNumByTaskStage(ctx, 0, 0, sProjectId)
+	if stage7Err != nil {
+		return nil, stage7Err
+	}
+	counter.Stage7 = stage7
+	return counter, nil
+}

+ 87 - 8
service/s_local_life.go

@@ -44,9 +44,15 @@ func (*sLocalLife) CreateSLocalLife(ctx context.Context, request *http_model.Loc
 		sLocalLifeInfo.SLocalStatus = 2
 
 		// 1.2. 填入加入商单操作人信息
+		var operatorType int
+		if request.SubAccountId == 0 {
+			operatorType = 1
+		} else {
+			operatorType = 2
+		}
 		sLocalLifeInfo.SubAccountId = request.SubAccountId
 		sLocalLifeInfo.SupplierId = request.SupplierId
-		sLocalLifeInfo.OperatorType = request.OperatorType
+		sLocalLifeInfo.OperatorType = operatorType
 		currTime := time.Now()
 		sLocalLifeInfo.CreateTime = &currTime
 
@@ -57,7 +63,7 @@ func (*sLocalLife) CreateSLocalLife(ctx context.Context, request *http_model.Loc
 		}
 
 		// 2. 建立新的recruitStrategy
-		// 2.1. 根据projectId去查找原来的recruitStrategy
+		// 2.1. 根据localId去查找原来的recruitStrategy
 		recruitStrategys, strategyErr := db.GetRecruitStrategyByProjectId(ctx, request.LocalId)
 		if strategyErr != nil {
 			return strategyErr
@@ -272,13 +278,13 @@ func (*sLocalLife) GetFullSLocalLifeList(ctx context.Context, pageSize, pageNum
 }
 
 // GetLocalTaskList 查询本地生活子任务
-func (*sLocalLife) GetLocalTaskList(ctx context.Context, pageSize, pageNum int32, condition *common_model.LocalTaskConditions) (*http_model.LocalTaskListData, error) {
+func (*sLocalLife) GetLocalTaskList(ctx context.Context, pageSize, pageNum int32, orderBy []string, orderDesc []int, condition *common_model.LocalTaskConditions) (*http_model.LocalTaskListData, error) {
 
 	var localTaskListData *http_model.LocalTaskListData
 	localTaskListData = &http_model.LocalTaskListData{}
 
 	// 1. 根据condition查询子任务信息
-	localTaskList, total, localTaskErr := db.GetLocalTaskList(ctx, pageSize, pageNum, condition)
+	localTaskList, total, localTaskErr := db.GetLocalTaskList(ctx, pageSize, pageNum, orderBy, orderDesc, condition)
 	if localTaskErr != nil {
 		return nil, localTaskErr
 	}
@@ -331,6 +337,10 @@ func (*sLocalLife) GetLocalTaskList(ctx context.Context, pageSize, pageNum int32
 			localTaskListData.SettleNum = sLocalInfo.SettleNum
 			localTaskListData.RecruitNum = sLocalInfo.RecruitNum
 			localTaskListData.ServiceChargeActual = sLocalInfo.ServiceChargeActual
+			localTaskListData.ServiceChargeSettle = sLocalInfo.ServiceChargeSettle
+			localTaskListData.EstimateServiceCharge = sLocalInfo.ServiceChargeActual
+			localTaskListData.EstimateDraftFee = sLocalInfo.EstimateDraftFee
+			localTaskListData.EstimateSupportFee = sLocalInfo.EstimateSupportFee
 		}
 	}
 	return localTaskListData, nil
@@ -338,7 +348,8 @@ func (*sLocalLife) GetLocalTaskList(ctx context.Context, pageSize, pageNum int32
 
 // ChangeTaskSupplierStatus 本地生活达人报名通过、拒绝报名
 func (*sLocalLife) ChangeTaskSupplierStatus(ctx context.Context, req *http_model.LocalChangeSupplierStatusRequest) error {
-	RecruitStrategyIDs, err := db.ChangeLocalTaskStatus(ctx, req.TaskIds, req.SupplierStatus)
+	// 1. 同意/拒绝
+	RecruitStrategyIDs, err := db.ChangeLocalTaskStatus(ctx, req.TaskIds, req.SupplierStatus, req.SupplierId, req.SubAccountId)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call ChangeTaskStatus error,err:%+v", err)
 		return err
@@ -351,10 +362,16 @@ func (*sLocalLife) ChangeTaskSupplierStatus(ctx context.Context, req *http_model
 func (*sLocalLife) ChangeSupplierStatus(ctx context.Context, req *http_model.SpecialLocalAddToListRequest) error {
 	var sLocalInfo *gorm_model.YounggeeSLocalLifeInfo
 	sLocalInfo = &gorm_model.YounggeeSLocalLifeInfo{}
+	var operatorType int
+	if req.SubAccountId == 0 {
+		operatorType = 1
+	} else {
+		operatorType = 2
+	}
 	sLocalInfo.SLocalId = req.SLocalId
 	sLocalInfo.SupplierId = req.SupplierId
 	sLocalInfo.SubAccountId = req.SubAccountId
-	sLocalInfo.OperatorType = req.OperatorType
+	sLocalInfo.OperatorType = operatorType
 	sLocalInfo.SLocalStatus = req.SLocalStatus
 	err := db.UpdateSLocal(ctx, sLocalInfo)
 	if err != nil {
@@ -383,10 +400,16 @@ func (*sLocalLife) CreateSpecialStrategy(ctx context.Context, request *http_mode
 	// 2. 修改sProject中的字段
 	var sLocalInfo *gorm_model.YounggeeSLocalLifeInfo
 	sLocalInfo = &gorm_model.YounggeeSLocalLifeInfo{}
+	if request.SubAccountId == 0 {
+		sLocalInfo.CreateStrategyType = 1
+		sLocalInfo.CreateStrategyId = request.SupplierId
+	} else {
+		sLocalInfo.CreateStrategyType = 2
+		sLocalInfo.CreateStrategyId = request.SubAccountId
+	}
 	sLocalInfo.SLocalId = request.SLocalId
 	sLocalInfo.StrategyStatus = 1
-	sLocalInfo.CreateStrategyId = request.CreateStrategyId
-	sLocalInfo.CreateStrategyType = request.CreateStrategyType
+
 	updateErr := db.UpdateSLocal(ctx, sLocalInfo)
 	if updateErr != nil {
 		return updateErr
@@ -504,3 +527,59 @@ func (*sLocalLife) FullSLocalTaskBillList(ctx context.Context, request *http_mod
 	}
 	return currSLocalTaskBillData, nil
 }
+
+// CountLocalTask 按照状态统计子任务数量
+func (*sLocalLife) CountLocalTask(ctx context.Context, req *http_model.LocalTaskCountRequest) (*http_model.LocalTaskCountData, error) {
+	var counter *http_model.LocalTaskCountData
+	counter = &http_model.LocalTaskCountData{}
+
+	// 1. Stage1
+	stage1, stage1Err := db.CountLocalTaskNumByTaskStage(ctx, 0, 1, req.SLocalId)
+	if stage1Err != nil {
+		return nil, stage1Err
+	}
+	counter.Stage1 = stage1
+
+	// 2. Stage2
+	stage2, stage2Err := db.CountLocalTaskNumByTaskStage(ctx, 0, 2, req.SLocalId)
+	if stage2Err != nil {
+		return nil, stage2Err
+	}
+	counter.Stage2 = stage2
+
+	// 3. Stage3
+	stage3, stage3Err := db.CountLocalTaskNumByTaskStage(ctx, 0, 3, req.SLocalId)
+	if stage3Err != nil {
+		return nil, stage3Err
+	}
+	counter.Stage3 = stage3
+
+	// 4. Stage4
+	stage4, stage4Err := db.CountLocalTaskNumByTaskStage(ctx, 1, 2, req.SLocalId)
+	if stage4Err != nil {
+		return nil, stage4Err
+	}
+	counter.Stage4 = stage4
+
+	// 5. Stage5
+	stage5, stage5Err := db.CountLocalTaskNumByTaskStage(ctx, 2, 2, req.SLocalId)
+	if stage5Err != nil {
+		return nil, stage5Err
+	}
+	counter.Stage5 = stage5
+
+	// 6. Stage6
+	stage6, stage6Err := db.CountLocalTaskNumByTaskStage(ctx, 3, 2, req.SLocalId)
+	if stage6Err != nil {
+		return nil, stage6Err
+	}
+	counter.Stage6 = stage6
+
+	// 7. Stage7
+	stage7, stage7Err := db.CountLocalTaskNumByTaskStage(ctx, 0, 0, req.SLocalId)
+	if stage7Err != nil {
+		return nil, stage7Err
+	}
+	counter.Stage7 = stage7
+	return counter, nil
+}

+ 7 - 1
service/s_project.go

@@ -22,12 +22,18 @@ func (*sProject) CreateSProject(ctx context.Context, request http_model.AddToLis
 
 	// 1. 建立SProject信息
 	// 1.1. 根据传入的ProjectId去Project表查找信息补全SProject
+	var operatorType int
+	if request.SubAccountId == 0 {
+		operatorType = 1
+	} else {
+		operatorType = 2
+	}
 	newSProject := gorm_model.SProjectInfo{
 		EnterpriseId:   request.EnterpriseId,
 		SupplierId:     request.SupplierId,
 		ProjectId:      request.ProjectId,
 		SubAccountId:   request.SubAccountId,
-		OperatorType:   request.OperatorType,
+		OperatorType:   operatorType,
 		SProjectStatus: 2,
 		StrategyStatus: 1,
 	}

+ 53 - 3
service/s_t_cooperate.go

@@ -28,7 +28,7 @@ func (*stcooperate) CreateSTCooperate(ctx context.Context, supplierId int, TaskI
 			}
 			if platformUserInfo != nil {
 				// 根据platformUserId判断需要新增一条记录还是合作次数增加
-				total, countErr := db.CountCooperateInfoBySupplierAndPlatform(ctx, supplierId, platformUserInfo.Id)
+				total, countErr := db.CountCooperateInfoBySupplierAndPlatform(ctx, supplierId, platformUserInfo.Id, 1)
 				if countErr != nil {
 					return countErr
 				}
@@ -40,7 +40,7 @@ func (*stcooperate) CreateSTCooperate(ctx context.Context, supplierId int, TaskI
 					cooperateInfo.CooperateNum = 1
 					cooperateInfo.TalentID = taskInfo.TalentID
 					cooperateInfo.TaskType = 1
-					// cooperateInfo.ProjectTaskId = taskId
+					cooperateInfo.ProjectTaskId = taskId
 					cooperateInfo.Platform = platformUserInfo.PlatformId
 					cooperateInfo.PlatformUserId = platformUserInfo.Id
 					current := time.Now()
@@ -52,7 +52,57 @@ func (*stcooperate) CreateSTCooperate(ctx context.Context, supplierId int, TaskI
 
 				} else {
 					// +1
-					plusErr := db.UpdateSTCooperateInfo(ctx, supplierId, platformUserInfo.Id)
+					plusErr := db.UpdateSTCooperateInfo(ctx, supplierId, platformUserInfo.Id, 1)
+					if plusErr != nil {
+						return plusErr
+					}
+				}
+			}
+		}
+	}
+	return nil
+}
+
+// CreateSTLocalCooperate 创建或更新服务商-达人本地生活合作关系
+func (*stcooperate) CreateSTLocalCooperate(ctx context.Context, supplierId int, TaskIds []string) error {
+	// 1. 根据taskId取出对应的platform_user_id
+	for _, taskId := range TaskIds {
+		taskInfo, taskInfoErr := db.GetLocalTaskInfoById(ctx, taskId)
+		if taskInfoErr != nil {
+			return taskInfoErr
+		}
+		if taskInfo != nil {
+			platformUserInfo, platformUserInfoErr := db.FindUserInfoByOpenId(ctx, taskInfo.OpenID)
+			if platformUserInfoErr != nil {
+				return platformUserInfoErr
+			}
+			if platformUserInfo != nil {
+				// 根据platformUserId判断需要新增一条记录还是合作次数增加
+				total, countErr := db.CountCooperateInfoBySupplierAndPlatform(ctx, supplierId, platformUserInfo.Id, 2)
+				if countErr != nil {
+					return countErr
+				}
+				if total == 0 {
+					// create
+					var cooperateInfo *gorm_model.SupplierTalentCooperate
+					cooperateInfo = &gorm_model.SupplierTalentCooperate{}
+					cooperateInfo.SupplierId = supplierId
+					cooperateInfo.CooperateNum = 1
+					cooperateInfo.TalentID = taskInfo.TalentID
+					cooperateInfo.TaskType = 2
+					cooperateInfo.LocalTaskID = taskId
+					cooperateInfo.Platform = platformUserInfo.PlatformId
+					cooperateInfo.PlatformUserId = platformUserInfo.Id
+					current := time.Now()
+					cooperateInfo.CreateTime = &current
+					createErr := db.CreateSTCooperateInfo(ctx, cooperateInfo)
+					if createErr != nil {
+						return createErr
+					}
+
+				} else {
+					// +1
+					plusErr := db.UpdateSTCooperateInfo(ctx, supplierId, platformUserInfo.Id, 2)
 					if plusErr != nil {
 						return plusErr
 					}

+ 10 - 0
service/sub_account.go

@@ -104,6 +104,16 @@ func (*subaccount) FindSubAccountBySupplierId(ctx context.Context, request http_
 			if jobInfo != nil {
 				subAccountInfo.JobName = jobInfo.JobName
 			}
+
+			// 3. 服务商信息
+			supplierInfo, supplierErr := db.GetSupplierById(ctx, s.SupplierId)
+			if supplierErr != nil {
+				return nil, supplierErr
+			}
+			if supplierInfo != nil {
+				subAccountInfo.SupplierName = supplierInfo.SupplierName
+			}
+
 			subAccountResp.SubAccountInfo = append(subAccountResp.SubAccountInfo, subAccountInfo)
 		}
 	}

+ 81 - 69
service/supplier.go

@@ -438,84 +438,96 @@ func (*supplier) CreateSupplierWithdraw(ctx context.Context, req *http_model.Cre
 	if supplierInfo != nil {
 		if supplierInfo.SupplierType == 1 {
 			// 1.1. 个人服务商
-			for _, withdrawInfo := range req.CreatePersonSupplierWithdraw {
-				var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
-				supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
-
-				// 1.2.1. 接口传入信息填入
-				supplierWithdrawInfo.SupplierId = req.SupplierId
-				supplierWithdrawInfo.WithdrawStatus = 2
-				supplierWithdrawInfo.BankName = withdrawInfo.BankName
-				supplierWithdrawInfo.BankNumber = withdrawInfo.BankNumber
-				var currentTime time.Time
-				currentTime = time.Now()
-				supplierWithdrawInfo.SupplyTime = &currentTime
-				supplierWithdrawInfo.WithdrawAmount = 0.0
-
-				// 1.2.2. 查找服务商信息填入
-				supplierWithdrawInfo.Name = supplierInfo.Name
-				supplierWithdrawInfo.Phone = withdrawInfo.Phone
-
-				// 1.2.3. 收入信息填入
-				currIncome, incomeInfoErr := db.GetIncomeInfoByIncomeId(ctx, withdrawInfo.IncomeId)
-				if incomeInfoErr != nil {
-					return incomeInfoErr
-				}
-				if currIncome != nil {
-					supplierWithdrawInfo.WithdrawAmount += currIncome.ServiceChargeSettle
+			supplierPaymentInfo, supplierPaymentErr := db.GetSupplierPaymentInfoById(ctx, supplierInfo.SupplierId)
+			if supplierPaymentErr != nil {
+				return supplierPaymentErr
+			}
+			if supplierPaymentInfo != nil {
+				for _, withdrawInfo := range req.IncomeIds {
+					var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
+					supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
+
+					// 1.2.1. 接口传入信息填入
+					supplierWithdrawInfo.SupplierId = req.SupplierId
+					supplierWithdrawInfo.WithdrawStatus = 2
+					supplierWithdrawInfo.BankName = supplierPaymentInfo.BankName
+					supplierWithdrawInfo.BankNumber = supplierPaymentInfo.BankNumber
+					var currentTime time.Time
+					currentTime = time.Now()
+					supplierWithdrawInfo.SupplyTime = &currentTime
+					supplierWithdrawInfo.WithdrawAmount = 0.0
+
+					// 1.2.2. 查找服务商信息填入
+					supplierWithdrawInfo.Name = supplierInfo.Name
+					supplierWithdrawInfo.Phone = supplierPaymentInfo.Phone
+
+					// 1.2.3. 收入信息填入
+					currIncome, incomeInfoErr := db.GetIncomeInfoByIncomeId(ctx, withdrawInfo)
+					if incomeInfoErr != nil {
+						return incomeInfoErr
+					}
+					if currIncome != nil {
+						supplierWithdrawInfo.WithdrawAmount += currIncome.ServiceChargeSettle
+					}
+					supplierWithdrawInfo.AmountPayable = supplierWithdrawInfo.WithdrawAmount
+					supplierWithdrawInfoList = append(supplierWithdrawInfoList, supplierWithdrawInfo)
 				}
-				supplierWithdrawInfo.AmountPayable = supplierWithdrawInfo.WithdrawAmount
-				supplierWithdrawInfoList = append(supplierWithdrawInfoList, supplierWithdrawInfo)
 			}
 		} else if supplierInfo.SupplierType == 2 {
 			// 1.2. 机构服务商
-			for _, withdrawInfo := range req.CreateCompanySupplierWithdraw {
-				var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
-				supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
-
-				// 1.2.1. 接口传入信息填入
-				supplierWithdrawInfo.SupplierId = req.SupplierId
-				supplierWithdrawInfo.WithdrawStatus = 2
-				supplierWithdrawInfo.BankName = withdrawInfo.BankName
-				supplierWithdrawInfo.BankNumber = withdrawInfo.BankNumber
-				var currentTime time.Time
-				currentTime = time.Now()
-				supplierWithdrawInfo.SupplyTime = &currentTime
-				supplierWithdrawInfo.WithdrawAmount = 0.0
-
-				// 1.2.2. 查找服务商信息填入
-				supplierWithdrawInfo.Name = supplierInfo.Name
-				supplierWithdrawInfo.Phone = supplierInfo.PhoneNumber
-				supplierWithdrawInfo.Company = supplierInfo.CompanyName
-
-				// 1.2.3. 收入信息填入
-				incomeIds, incomeErr := db.GetIncomeIdsByInvoiceId(ctx, withdrawInfo.InvoiceId)
-				if incomeErr != nil {
-					return incomeErr
-				}
-				if incomeIds != "" {
-					strSlice := strings.Split(incomeIds, ",")
-					intSlice := make([]int, len(strSlice))
-					for i, s := range strSlice {
-						num, err := strconv.Atoi(s)
-						if err != nil {
-							fmt.Println("转换错误:", err)
-							return err
-						}
-						intSlice[i] = num
+			supplierPaymentInfo, supplierPaymentErr := db.GetSupplierPaymentInfoById(ctx, supplierInfo.SupplierId)
+			if supplierPaymentErr != nil {
+				return supplierPaymentErr
+			}
+			if supplierPaymentInfo != nil {
+				for _, withdrawInfo := range req.InvoiceIds {
+					var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
+					supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
+
+					// 1.2.1. 接口传入信息填入
+					supplierWithdrawInfo.SupplierId = req.SupplierId
+					supplierWithdrawInfo.WithdrawStatus = 2
+					supplierWithdrawInfo.BankName = supplierPaymentInfo.BankName
+					supplierWithdrawInfo.BankNumber = supplierPaymentInfo.BankNumber
+					var currentTime time.Time
+					currentTime = time.Now()
+					supplierWithdrawInfo.SupplyTime = &currentTime
+					supplierWithdrawInfo.WithdrawAmount = 0.0
+
+					// 1.2.2. 查找服务商信息填入
+					supplierWithdrawInfo.Name = supplierInfo.Name
+					supplierWithdrawInfo.Phone = supplierInfo.PhoneNumber
+					supplierWithdrawInfo.Company = supplierInfo.CompanyName
+
+					// 1.2.3. 收入信息填入
+					incomeIds, incomeErr := db.GetIncomeIdsByInvoiceId(ctx, withdrawInfo)
+					if incomeErr != nil {
+						return incomeErr
 					}
-					for _, incomeId := range intSlice {
-						currIncome, incomeInfoErr := db.GetIncomeInfoByIncomeId(ctx, incomeId)
-						if incomeInfoErr != nil {
-							return incomeInfoErr
+					if incomeIds != "" {
+						strSlice := strings.Split(incomeIds, ",")
+						intSlice := make([]int, len(strSlice))
+						for i, s := range strSlice {
+							num, err := strconv.Atoi(s)
+							if err != nil {
+								fmt.Println("转换错误:", err)
+								return err
+							}
+							intSlice[i] = num
 						}
-						if currIncome != nil {
-							supplierWithdrawInfo.WithdrawAmount += currIncome.ServiceChargeSettle
+						for _, incomeId := range intSlice {
+							currIncome, incomeInfoErr := db.GetIncomeInfoByIncomeId(ctx, incomeId)
+							if incomeInfoErr != nil {
+								return incomeInfoErr
+							}
+							if currIncome != nil {
+								supplierWithdrawInfo.WithdrawAmount += currIncome.ServiceChargeSettle
+							}
 						}
+						supplierWithdrawInfo.AmountPayable = supplierWithdrawInfo.WithdrawAmount
 					}
-					supplierWithdrawInfo.AmountPayable = supplierWithdrawInfo.WithdrawAmount
+					supplierWithdrawInfoList = append(supplierWithdrawInfoList, supplierWithdrawInfo)
 				}
-				supplierWithdrawInfoList = append(supplierWithdrawInfoList, supplierWithdrawInfo)
 			}
 		}
 	}