|
@@ -31,19 +31,28 @@ func (s ProjectService) CreateProject(param *vo.ProjectCreateParam) (*string, er
|
|
|
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,
|
|
|
- ServiceChargeRate: param.ServiceChargeRate,
|
|
|
- ProductSnap: string(productInfoToJson),
|
|
|
- ProductPhotoSnap: string(productPhotosToJson),
|
|
|
- CreatedAt: t,
|
|
|
+ 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 {
|
|
@@ -64,6 +73,41 @@ func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam)
|
|
|
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)
|
|
@@ -168,8 +212,23 @@ func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- println("更新种草任务的招募策略")
|
|
|
- // 更新种草任务的招募策略
|
|
|
+ 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)
|
|
@@ -186,10 +245,12 @@ func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam)
|
|
|
FollowersLow: strategy.FollowersLow,
|
|
|
FollowersUp: strategy.FollowersUp,
|
|
|
RecruitNumber: strategy.RecruitNumber,
|
|
|
- Offer: strategy.Offer,
|
|
|
- ServiceCharge: strategy.ServiceCharge,
|
|
|
ProjectID: project.ProjectId,
|
|
|
}
|
|
|
+ totalRecruitNum += strategy.RecruitNumber
|
|
|
+ if strategy.FeeForm == 2 {
|
|
|
+ recruitStrategy.Offer = strategy.Offer // 报价
|
|
|
+ }
|
|
|
recruits = append(recruits, recruitStrategy)
|
|
|
}
|
|
|
err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
|
|
@@ -198,21 +259,6 @@ func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- 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("种草项目不存在")
|
|
|
- }
|
|
|
// 2. 数据准备
|
|
|
// a) 查找关联商品信息
|
|
|
product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
|
|
@@ -247,6 +293,7 @@ func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdate
|
|
|
ProjectForm: projectUpdateParam.ProjectForm,
|
|
|
ContentType: projectUpdateParam.ContentType,
|
|
|
ProjectDetail: projectUpdateParam.ProjectDetail,
|
|
|
+ Tools: projectUpdateParam.Tools,
|
|
|
}
|
|
|
if projectUpdateParam.ProjectStatus == 2 {
|
|
|
updateProject.SubmitAt = t
|
|
@@ -317,40 +364,6 @@ func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- println("更新种草任务的招募策略")
|
|
|
- // 5. 更新种草任务的招募策略
|
|
|
- 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,
|
|
|
- Offer: strategy.Offer, // 报价
|
|
|
- ProjectID: project.ProjectId,
|
|
|
- }
|
|
|
- if strategy.FeeForm == 2 {
|
|
|
- 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
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
return &updateProject.ProjectId, nil
|
|
|
}
|
|
|
|
|
@@ -428,6 +441,7 @@ func (s ProjectService) GetProjectDetail(projectId string) (*vo.ReProjectDetail,
|
|
|
TOffer: recruitStrategy.TOffer,
|
|
|
ServiceCharge: recruitStrategy.ServiceCharge,
|
|
|
SelectedNumber: recruitStrategy.SelectedNumber,
|
|
|
+ TotalOffer: recruitStrategy.TotalOffer,
|
|
|
}
|
|
|
recruitStrategysPreviews = append(recruitStrategysPreviews, recruitStrategysPreview)
|
|
|
}
|
|
@@ -445,6 +459,7 @@ func (s ProjectService) GetProjectDetail(projectId string) (*vo.ReProjectDetail,
|
|
|
}
|
|
|
reProjectDetail.ProjectBriefs = projectBriefInfos
|
|
|
reProjectDetail.ProjectMaterials = projectMaterials
|
|
|
+ reProjectDetail.Tools = project.Tools
|
|
|
|
|
|
return &reProjectDetail, nil
|
|
|
}
|