|
@@ -0,0 +1,524 @@
|
|
|
+package service
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "errors"
|
|
|
+ "github.com/issue9/conv"
|
|
|
+ "github.com/sirupsen/logrus"
|
|
|
+ "reflect"
|
|
|
+ "time"
|
|
|
+ "youngee_b_api/app/dao"
|
|
|
+ "youngee_b_api/app/entity"
|
|
|
+ "youngee_b_api/app/util"
|
|
|
+ "youngee_b_api/app/vo"
|
|
|
+)
|
|
|
+
|
|
|
+type ProjectService struct{}
|
|
|
+
|
|
|
+// 创建种草任务
|
|
|
+func (s ProjectService) CreateProject(param *vo.ProjectCreateParam) (*string, error) {
|
|
|
+ // a) 生成种草项目id
|
|
|
+ projectId := util.GetProjectID()
|
|
|
+ // b) 查找关联商品信息
|
|
|
+ product, err := dao.ProductDAO{}.GetProductByID(conv.MustInt64(param.ProductId, 0))
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if product == nil {
|
|
|
+ return nil, errors.New("未找到关联商品")
|
|
|
+ }
|
|
|
+ productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(param.ProductId)
|
|
|
+ productInfoToJson, _ := json.Marshal(product)
|
|
|
+ productPhotosToJson, _ := json.Marshal(productPhotos)
|
|
|
+ // d)创建种草任务
|
|
|
+ var operatorType int64
|
|
|
+ if param.SubAccountId == 0 {
|
|
|
+ operatorType = 1
|
|
|
+ } else {
|
|
|
+ operatorType = 2
|
|
|
+ }
|
|
|
+ t := time.Now()
|
|
|
+ newProject := entity.Project{
|
|
|
+ ProjectStatus: 1,
|
|
|
+ ProjectType: param.ProjectType,
|
|
|
+ ProjectId: projectId,
|
|
|
+ ProductID: param.ProductId,
|
|
|
+ EnterpriseID: param.EnterpriseId,
|
|
|
+ SubAccountId: param.SubAccountId,
|
|
|
+ ProjectPlatform: param.Platform,
|
|
|
+ OperatorType: operatorType,
|
|
|
+ ProductSnap: string(productInfoToJson),
|
|
|
+ ProductPhotoSnap: string(productPhotosToJson),
|
|
|
+ CreatedAt: t,
|
|
|
+ }
|
|
|
+ if param.ProjectType == 1 {
|
|
|
+ newProject.ServiceChargeRate = param.ServiceChargeRate
|
|
|
+ }
|
|
|
+ err = dao.ProjectDAO{}.CreateProject(newProject)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return &projectId, nil
|
|
|
+}
|
|
|
+
|
|
|
+// 更新公开种草任务(招募要求、执行要求)
|
|
|
+func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam) (*string, error) {
|
|
|
+ // 1. 检查该企业id和商品id有无种草任务
|
|
|
+ projectID := projectUpdateParam.ProjectID
|
|
|
+ project, err := dao.ProjectDAO{}.GetProjectById(projectID)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if project == nil {
|
|
|
+ return nil, errors.New("种草项目不存在")
|
|
|
+ }
|
|
|
+ println("更新公开种草任务的招募策略")
|
|
|
+ // 更新公开种草任务的招募策略
|
|
|
+ var totalRecruitNum int64
|
|
|
+ if projectUpdateParam.RecruitStrategys != nil {
|
|
|
+ // 1. 删除已有的招募策略
|
|
|
+ err = dao.RecruitStrategyDao{}.DeleteRecruitStrategyByProjectID(projectUpdateParam.ProjectID)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 2. 接收并创建新的招募策略
|
|
|
+ if len(projectUpdateParam.RecruitStrategys) != 0 {
|
|
|
+ var recruits []entity.RecruitStrategy
|
|
|
+ for _, strategy := range projectUpdateParam.RecruitStrategys {
|
|
|
+ recruitStrategy := entity.RecruitStrategy{
|
|
|
+ FeeForm: strategy.FeeForm,
|
|
|
+ StrategyID: strategy.StrategyID,
|
|
|
+ FollowersLow: strategy.FollowersLow,
|
|
|
+ FollowersUp: strategy.FollowersUp,
|
|
|
+ RecruitNumber: strategy.RecruitNumber,
|
|
|
+ ProjectID: project.ProjectId,
|
|
|
+ }
|
|
|
+ totalRecruitNum += strategy.RecruitNumber
|
|
|
+ if strategy.FeeForm == 2 {
|
|
|
+ recruitStrategy.Offer = strategy.Offer
|
|
|
+ recruitStrategy.ServiceCharge = strategy.Offer * projectUpdateParam.ServiceChargeRate
|
|
|
+ recruitStrategy.TOffer = strategy.Offer * (1 - projectUpdateParam.ServiceChargeRate)
|
|
|
+ }
|
|
|
+ recruits = append(recruits, recruitStrategy)
|
|
|
+ }
|
|
|
+ err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2. 数据准备
|
|
|
+ // a) 查找关联商品信息
|
|
|
+ product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(project.ProductID)
|
|
|
+ productInfoToJson, _ := json.Marshal(product)
|
|
|
+ productPhotosToJson, _ := json.Marshal(productPhotos)
|
|
|
+ // d) 任务截止时间
|
|
|
+ recruitDdl := time.Time{} //赋零值
|
|
|
+ recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", projectUpdateParam.RecruitDdl, time.Local)
|
|
|
+ // f) 更新选品状态
|
|
|
+ if projectUpdateParam.ProjectStatus != 2 && projectUpdateParam.ProjectStatus != 8 {
|
|
|
+ projectUpdateParam.ProjectStatus = 1
|
|
|
+ }
|
|
|
+ t := time.Now()
|
|
|
+ updateProject := entity.Project{
|
|
|
+ EnterpriseID: projectUpdateParam.EnterpriseId,
|
|
|
+ SubAccountId: projectUpdateParam.SubAccountId,
|
|
|
+ ProjectId: projectUpdateParam.ProjectID,
|
|
|
+ ProjectType: projectUpdateParam.ProjectType,
|
|
|
+ ProjectStatus: projectUpdateParam.ProjectStatus,
|
|
|
+ ProjectName: projectUpdateParam.ProjectName,
|
|
|
+ ProductID: projectUpdateParam.ProductId,
|
|
|
+ TalentType: projectUpdateParam.TalentType,
|
|
|
+ RecruitDdl: recruitDdl,
|
|
|
+ ProductSnap: string(productInfoToJson),
|
|
|
+ ProductPhotoSnap: string(productPhotosToJson),
|
|
|
+ UpdatedAt: t,
|
|
|
+ ProjectForm: projectUpdateParam.ProjectForm,
|
|
|
+ ContentType: projectUpdateParam.ContentType,
|
|
|
+ ProjectDetail: projectUpdateParam.ProjectDetail,
|
|
|
+ }
|
|
|
+ if projectUpdateParam.ProjectStatus == 2 {
|
|
|
+ updateProject.SubmitAt = t
|
|
|
+ }
|
|
|
+ // 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
|
|
|
+ result := util.MergeStructValue(&updateProject, project)
|
|
|
+ // 利用反射机制将interface类型转换为结构体类型
|
|
|
+ v := reflect.ValueOf(&result).Elem()
|
|
|
+ if v.Kind() == reflect.Struct {
|
|
|
+ updateProject = v.Interface().(entity.Project)
|
|
|
+ //fmt.Println(p)
|
|
|
+ }
|
|
|
+ // c) 计算预估成本(如果有)
|
|
|
+ /*
|
|
|
+ var estimatedCost float64
|
|
|
+ if conv.MustInt(updateSelection.TaskMode, 0) == 1 {
|
|
|
+ estimatedCost = conv.MustFloat64(updateSelection.TaskReward, 0) * conv.MustFloat64(updateSelection.SampleNum, 0)
|
|
|
+ }
|
|
|
+ estimatedCostToString, _ := conv.String(estimatedCost)
|
|
|
+ updateSelection.EstimatedCost = estimatedCostToString
|
|
|
+ */
|
|
|
+ // 3. 更新选品
|
|
|
+ err = dao.ProjectDAO{}.UpdateProject(updateProject)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 4. 更新选品brief和示例(种草任务补充信息)
|
|
|
+ if projectUpdateParam.ProjectBrief != nil {
|
|
|
+ // 删除已有brief
|
|
|
+ err = dao.ProjectBriefDao{}.DeleteSecBriefBySelectionId(project.ProjectId)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 插入新的brief
|
|
|
+ for _, v := range projectUpdateParam.ProjectBrief {
|
|
|
+ brief := entity.ProjectBrief{
|
|
|
+ ProjectID: project.ProjectId,
|
|
|
+ FileUid: v.FileUid,
|
|
|
+ FileName: v.Name,
|
|
|
+ FileUrl: v.FileUrl,
|
|
|
+ CreatedAt: time.Now(),
|
|
|
+ }
|
|
|
+ err = dao.ProjectBriefDao{}.CreateProjectBrief(brief)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if projectUpdateParam.ProjectMaterial != nil {
|
|
|
+ // 删除已有示例
|
|
|
+ err = dao.ProjectMaterialDao{}.DeleteProjectMaterialByProjectId(project.ProjectId)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 插入新的示例
|
|
|
+ for _, v := range projectUpdateParam.ProjectMaterial {
|
|
|
+ projectMaterial := entity.ProjectMaterial{
|
|
|
+ ProjectID: project.ProjectId,
|
|
|
+ FileUid: v.FileUid,
|
|
|
+ FileName: v.Name,
|
|
|
+ FileUrl: v.FileUrl,
|
|
|
+ CreatedAt: time.Now(),
|
|
|
+ }
|
|
|
+ err = dao.ProjectMaterialDao{}.CreateProjectMaterial(projectMaterial)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return &updateProject.ProjectId, nil
|
|
|
+}
|
|
|
+
|
|
|
+// 更新定向种草任务(招募要求、执行要求)
|
|
|
+func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdateParam) (*string, error) {
|
|
|
+ // 1. 检查该企业id和商品id有无种草任务
|
|
|
+ projectID := projectUpdateParam.ProjectID
|
|
|
+ project, err := dao.ProjectDAO{}.GetProjectById(projectID)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if project == nil {
|
|
|
+ return nil, errors.New("种草项目不存在")
|
|
|
+ }
|
|
|
+ println("更新定向种草任务的招募策略")
|
|
|
+ // 更新定向种草任务的招募策略
|
|
|
+ var totalRecruitNum int64
|
|
|
+ if projectUpdateParam.RecruitStrategys != nil {
|
|
|
+ // 1. 删除已有的招募策略
|
|
|
+ err = dao.RecruitStrategyDao{}.DeleteRecruitStrategyByProjectID(projectUpdateParam.ProjectID)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 2. 接收并创建新的招募策略
|
|
|
+ if len(projectUpdateParam.RecruitStrategys) != 0 {
|
|
|
+ var recruits []entity.RecruitStrategy
|
|
|
+ for _, strategy := range projectUpdateParam.RecruitStrategys {
|
|
|
+ recruitStrategy := entity.RecruitStrategy{
|
|
|
+ FeeForm: strategy.FeeForm,
|
|
|
+ StrategyID: strategy.StrategyID,
|
|
|
+ FollowersLow: strategy.FollowersLow,
|
|
|
+ FollowersUp: strategy.FollowersUp,
|
|
|
+ RecruitNumber: strategy.RecruitNumber,
|
|
|
+ ProjectID: project.ProjectId,
|
|
|
+ }
|
|
|
+ totalRecruitNum += strategy.RecruitNumber
|
|
|
+ if strategy.FeeForm == 2 {
|
|
|
+ recruitStrategy.Offer = strategy.Offer // 报价
|
|
|
+ }
|
|
|
+ recruits = append(recruits, recruitStrategy)
|
|
|
+ }
|
|
|
+ err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2. 数据准备
|
|
|
+ // a) 查找关联商品信息
|
|
|
+ product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(project.ProductID)
|
|
|
+ productInfoToJson, _ := json.Marshal(product)
|
|
|
+ productPhotosToJson, _ := json.Marshal(productPhotos)
|
|
|
+ // d) 任务截止时间
|
|
|
+ recruitDdl := time.Time{} //赋零值
|
|
|
+ recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", projectUpdateParam.RecruitDdl, time.Local)
|
|
|
+ // f) 更新选品状态
|
|
|
+ if projectUpdateParam.ProjectStatus != 2 && projectUpdateParam.ProjectStatus != 8 {
|
|
|
+ projectUpdateParam.ProjectStatus = 1
|
|
|
+ }
|
|
|
+ t := time.Now()
|
|
|
+ updateProject := entity.Project{
|
|
|
+ EnterpriseID: projectUpdateParam.EnterpriseId,
|
|
|
+ SubAccountId: projectUpdateParam.SubAccountId,
|
|
|
+ ProjectId: projectUpdateParam.ProjectID,
|
|
|
+ ProjectType: projectUpdateParam.ProjectType,
|
|
|
+ ProjectStatus: projectUpdateParam.ProjectStatus,
|
|
|
+ ProjectName: projectUpdateParam.ProjectName,
|
|
|
+ ProductID: projectUpdateParam.ProductId,
|
|
|
+ TalentType: projectUpdateParam.TalentType,
|
|
|
+ RecruitDdl: recruitDdl,
|
|
|
+ ProductSnap: string(productInfoToJson),
|
|
|
+ ProductPhotoSnap: string(productPhotosToJson),
|
|
|
+ CreatedAt: project.CreatedAt,
|
|
|
+ UpdatedAt: t,
|
|
|
+ ProjectForm: projectUpdateParam.ProjectForm,
|
|
|
+ ContentType: projectUpdateParam.ContentType,
|
|
|
+ ProjectDetail: projectUpdateParam.ProjectDetail,
|
|
|
+ Tools: projectUpdateParam.Tools,
|
|
|
+ }
|
|
|
+ if projectUpdateParam.ProjectStatus == 2 {
|
|
|
+ updateProject.SubmitAt = t
|
|
|
+ }
|
|
|
+ // 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
|
|
|
+ result := util.MergeStructValue(&updateProject, project)
|
|
|
+ // 利用反射机制将interface类型转换为结构体类型
|
|
|
+ v := reflect.ValueOf(&result).Elem()
|
|
|
+ if v.Kind() == reflect.Struct {
|
|
|
+ updateProject = v.Interface().(entity.Project)
|
|
|
+ //fmt.Println(p)
|
|
|
+ }
|
|
|
+ // c) 计算预估成本(如果有)
|
|
|
+ /*
|
|
|
+ var estimatedCost float64
|
|
|
+ if conv.MustInt(updateSelection.TaskMode, 0) == 1 {
|
|
|
+ estimatedCost = conv.MustFloat64(updateSelection.TaskReward, 0) * conv.MustFloat64(updateSelection.SampleNum, 0)
|
|
|
+ }
|
|
|
+ estimatedCostToString, _ := conv.String(estimatedCost)
|
|
|
+ updateSelection.EstimatedCost = estimatedCostToString
|
|
|
+ */
|
|
|
+ // 3. 更新选品
|
|
|
+ err = dao.ProjectDAO{}.UpdateProject(updateProject)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 4. 更新选品brief和示例(种草任务补充信息)
|
|
|
+ if projectUpdateParam.ProjectBrief != nil {
|
|
|
+ // 删除已有brief
|
|
|
+ err = dao.ProjectBriefDao{}.DeleteSecBriefBySelectionId(project.ProjectId)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 插入新的brief
|
|
|
+ for _, v := range projectUpdateParam.ProjectBrief {
|
|
|
+ brief := entity.ProjectBrief{
|
|
|
+ ProjectID: project.ProjectId,
|
|
|
+ FileUid: v.FileUid,
|
|
|
+ FileName: v.Name,
|
|
|
+ FileUrl: v.FileUrl,
|
|
|
+ CreatedAt: time.Now(),
|
|
|
+ }
|
|
|
+ err = dao.ProjectBriefDao{}.CreateProjectBrief(brief)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if projectUpdateParam.ProjectMaterial != nil {
|
|
|
+ // 删除已有示例
|
|
|
+ err = dao.ProjectMaterialDao{}.DeleteProjectMaterialByProjectId(project.ProjectId)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 插入新的示例
|
|
|
+ for _, v := range projectUpdateParam.ProjectMaterial {
|
|
|
+ projectMaterial := entity.ProjectMaterial{
|
|
|
+ ProjectID: project.ProjectId,
|
|
|
+ FileUid: v.FileUid,
|
|
|
+ FileName: v.Name,
|
|
|
+ FileUrl: v.FileUrl,
|
|
|
+ CreatedAt: time.Now(),
|
|
|
+ }
|
|
|
+ err = dao.ProjectMaterialDao{}.CreateProjectMaterial(projectMaterial)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return &updateProject.ProjectId, nil
|
|
|
+}
|
|
|
+
|
|
|
+// 种草任务预览
|
|
|
+func (s ProjectService) GetProjectDetail(projectId string) (*vo.ReProjectDetail, error) {
|
|
|
+ reProjectDetail := vo.ReProjectDetail{}
|
|
|
+ project, err := dao.ProjectDAO{}.GetProjectById(projectId)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Errorf("[projectDB service] call GetProject error,err:%+v", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 系统信息
|
|
|
+ reProjectDetail.ProjectId = projectId
|
|
|
+ reProjectDetail.ProjectStatus = project.ProjectStatus
|
|
|
+ reProjectDetail.ProjectPlatform = project.ProjectPlatform
|
|
|
+ reProjectDetail.CreatedAt = project.CreatedAt
|
|
|
+ reProjectDetail.EstimatedCost = project.EstimatedCost
|
|
|
+ reProjectDetail.ServiceChargeRate = project.ServiceChargeRate
|
|
|
+ var creatorName, phone string
|
|
|
+ if project.SubAccountId == 0 {
|
|
|
+ enterprise, err := dao.EnterpriseDao{}.GetEnterprise(project.EnterpriseID)
|
|
|
+ if err == nil && enterprise != nil {
|
|
|
+ creatorName = enterprise.BusinessName
|
|
|
+ phone, err = dao.UserDao{}.GetPhoneByUserId(enterprise.UserId)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ subAccount, err := dao.SubAccountDao{}.GetSubAccount(project.SubAccountId)
|
|
|
+ if err == nil && subAccount != nil {
|
|
|
+ creatorName = subAccount.SubAccountName
|
|
|
+ phone, err = dao.UserDao{}.GetPhoneByUserId(subAccount.UserId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reProjectDetail.CreatorName = creatorName
|
|
|
+ reProjectDetail.Phone = phone
|
|
|
+ // 关联商品
|
|
|
+ var reProduct vo.ReTaskProduct
|
|
|
+ product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
|
|
|
+ if err == nil {
|
|
|
+ photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByProductID(product.ProductID)
|
|
|
+ if e != nil {
|
|
|
+ photoUrl = ""
|
|
|
+ }
|
|
|
+ reProduct = vo.ReTaskProduct{
|
|
|
+ ProductID: product.ProductID,
|
|
|
+ ProductName: product.ProductName,
|
|
|
+ ProductType: product.ProductType,
|
|
|
+ ProductCategory: product.ProductCategory,
|
|
|
+ ProductPrice: product.ProductPrice,
|
|
|
+ ProductDetail: product.ProductDetail,
|
|
|
+ CreatedAt: product.CreatedAt,
|
|
|
+ PhotoUrl: photoUrl,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reProjectDetail.ProductInfo = &reProduct
|
|
|
+ // 招募要求
|
|
|
+ reProjectDetail.TalentType = project.TalentType
|
|
|
+ reProjectDetail.RecruitDdl = project.RecruitDdl
|
|
|
+ reProjectDetail.ProjectForm = project.ProjectForm
|
|
|
+ reProjectDetail.ContentType = project.ContentType
|
|
|
+ reProjectDetail.ProjectDetail = project.ProjectDetail
|
|
|
+ var recruitStrategysPreviews []*vo.RecruitStrategyPreview
|
|
|
+ recruitStrategys, err := dao.RecruitStrategyDao{}.GetRecruitStrategyByProjectId(projectId)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Errorf("[projectDB service] call GetRecruitStrategy error,err:%+v", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ for _, recruitStrategy := range recruitStrategys {
|
|
|
+ recruitStrategysPreview := &vo.RecruitStrategyPreview{
|
|
|
+ StrategyId: recruitStrategy.StrategyID,
|
|
|
+ FeeForm: recruitStrategy.FeeForm,
|
|
|
+ FollowersLow: recruitStrategy.FollowersLow,
|
|
|
+ FollowersUp: recruitStrategy.FollowersUp,
|
|
|
+ RecruitNumber: recruitStrategy.RecruitNumber,
|
|
|
+ Offer: recruitStrategy.Offer,
|
|
|
+ TOffer: recruitStrategy.TOffer,
|
|
|
+ ServiceCharge: recruitStrategy.ServiceCharge,
|
|
|
+ SelectedNumber: recruitStrategy.SelectedNumber,
|
|
|
+ TotalOffer: recruitStrategy.TotalOffer,
|
|
|
+ }
|
|
|
+ recruitStrategysPreviews = append(recruitStrategysPreviews, recruitStrategysPreview)
|
|
|
+ }
|
|
|
+ reProjectDetail.RecruitStrategys = recruitStrategysPreviews
|
|
|
+ // 执行要求
|
|
|
+ projectBriefInfos, err := dao.ProjectBriefDao{}.GetProjectBriefInfo(projectId)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Errorf("[projectDB service] call GetProjectBriefInfo error,err:%+v", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ projectMaterials, err := dao.ProjectMaterialDao{}.GetProjectMaterialInfo(projectId)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Errorf("[projectDB service] call GetprojectMaterialInfo error,err:%+v", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ reProjectDetail.ProjectBriefs = projectBriefInfos
|
|
|
+ reProjectDetail.ProjectMaterials = projectMaterials
|
|
|
+ reProjectDetail.Tools = project.Tools
|
|
|
+
|
|
|
+ return &reProjectDetail, nil
|
|
|
+}
|
|
|
+
|
|
|
+// 公开种草任务列表
|
|
|
+func (s ProjectService) GetProjectTaskList(param *vo.ProjectSearchParam) (vo.ResultVO, error) {
|
|
|
+ if param.Page == 0 {
|
|
|
+ param.Page = 1
|
|
|
+ }
|
|
|
+ if param.PageSize == 0 {
|
|
|
+ param.PageSize = 10
|
|
|
+ }
|
|
|
+ var result vo.ResultVO
|
|
|
+ reProjectTaskPreviews, total, err := (&dao.ProjectDAO{}).GetProjectPreviews(param)
|
|
|
+ if err != nil {
|
|
|
+ return result, err
|
|
|
+ }
|
|
|
+ for i := range reProjectTaskPreviews {
|
|
|
+ var creatorName string
|
|
|
+ var productName string
|
|
|
+ var productPrice float64
|
|
|
+ var mainImage string
|
|
|
+ if reProjectTaskPreviews[i].SubAccountId == 0 {
|
|
|
+ enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reProjectTaskPreviews[i].EnterpriseId)
|
|
|
+ if err == nil && enterprise != nil {
|
|
|
+ creatorName = enterprise.BusinessName
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ subAccount, err := dao.SubAccountDao{}.GetSubAccount(reProjectTaskPreviews[i].SubAccountId)
|
|
|
+ if err == nil && subAccount != nil {
|
|
|
+ creatorName = subAccount.SubAccountName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ product, err := dao.ProductDAO{}.GetProductByID(reProjectTaskPreviews[i].ProductId)
|
|
|
+ if err == nil && product != nil {
|
|
|
+ productName = product.ProductName
|
|
|
+ productPrice = product.ProductPrice
|
|
|
+ }
|
|
|
+ mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reProjectTaskPreviews[i].ProductId)
|
|
|
+ reProjectTaskPreviews[i].CreatorName = creatorName
|
|
|
+ reProjectTaskPreviews[i].ProductName = productName
|
|
|
+ reProjectTaskPreviews[i].ProductPrice = productPrice
|
|
|
+ reProjectTaskPreviews[i].MainImage = mainImage
|
|
|
+ }
|
|
|
+ result = vo.ResultVO{
|
|
|
+ Page: param.Page,
|
|
|
+ PageSize: param.PageSize,
|
|
|
+ Total: total,
|
|
|
+ Data: reProjectTaskPreviews,
|
|
|
+ }
|
|
|
+ return result, nil
|
|
|
+}
|
|
|
+
|
|
|
+// 删除种草任务
|
|
|
+func (s ProjectService) DeleteProject(projectId string) (*string, error) {
|
|
|
+ res, err := dao.ProjectDAO{}.DeleteProject(projectId)
|
|
|
+ if err != nil {
|
|
|
+ logrus.Errorf("[projectDB service] call DeleteProject error,err:%+v", err)
|
|
|
+ return res, err
|
|
|
+ }
|
|
|
+ return res, nil
|
|
|
+}
|