|
@@ -33,19 +33,17 @@ func (s ProjectService) CreateProject(param *vo.ProjectCreateParam) (*string, er
|
|
|
// d)创建种草任务
|
|
|
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,
|
|
|
- ProductSnap: string(productInfoToJson),
|
|
|
- ProductPhotoSnap: string(productPhotosToJson),
|
|
|
- CreatedAt: t,
|
|
|
- UpdatedAt: t,
|
|
|
- EstimatedCost: 0,
|
|
|
- SettlementAmount: 0,
|
|
|
+ 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,
|
|
|
}
|
|
|
err = dao.ProjectDAO{}.CreateProject(newProject)
|
|
|
if err != nil {
|
|
@@ -95,7 +93,6 @@ func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam)
|
|
|
RecruitDdl: recruitDdl,
|
|
|
ProductSnap: string(productInfoToJson),
|
|
|
ProductPhotoSnap: string(productPhotosToJson),
|
|
|
- CreatedAt: project.CreatedAt,
|
|
|
UpdatedAt: t,
|
|
|
ProjectForm: projectUpdateParam.ProjectForm,
|
|
|
ContentType: projectUpdateParam.ContentType,
|
|
@@ -183,27 +180,16 @@ func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam)
|
|
|
if len(projectUpdateParam.RecruitStrategys) != 0 {
|
|
|
var recruits []entity.RecruitStrategy
|
|
|
for _, strategy := range projectUpdateParam.RecruitStrategys {
|
|
|
- // 查询对应定价策略
|
|
|
- pricingStrategy, err := dao.InfoPricingStrategylDao{}.GetPricingStrategy(strategy.FollowersLow, strategy.FollowersUp, strategy.FeeForm, project.ProjectPlatform)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- // 根据定价策略计算达人所见报价
|
|
|
- if strategy.FeeForm == 2 {
|
|
|
- strategy.TOffer = strategy.Offer * (1 - conv.MustFloat64(pricingStrategy.ServiceRate)/1000)
|
|
|
- }
|
|
|
recruitStrategy := entity.RecruitStrategy{
|
|
|
- FeeForm: conv.MustInt64(strategy.FeeForm),
|
|
|
- StrategyID: conv.MustInt64(strategy.StrategyID),
|
|
|
- FollowersLow: conv.MustInt64(strategy.FollowersLow),
|
|
|
- FollowersUp: conv.MustInt64(strategy.FollowersUp),
|
|
|
- RecruitNumber: conv.MustInt64(strategy.RecruitNumber),
|
|
|
- ServiceCharge: strategy.ServiceCharge,
|
|
|
+ FeeForm: strategy.FeeForm,
|
|
|
+ StrategyID: strategy.StrategyID,
|
|
|
+ FollowersLow: strategy.FollowersLow,
|
|
|
+ FollowersUp: strategy.FollowersUp,
|
|
|
+ RecruitNumber: strategy.RecruitNumber,
|
|
|
Offer: strategy.Offer,
|
|
|
- TOffer: strategy.TOffer,
|
|
|
+ ServiceCharge: strategy.ServiceCharge,
|
|
|
ProjectID: project.ProjectId,
|
|
|
}
|
|
|
- //fmt.Printf("Offer:\t %+v", Strategy.Offer)
|
|
|
recruits = append(recruits, recruitStrategy)
|
|
|
}
|
|
|
err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
|
|
@@ -309,7 +295,6 @@ func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdate
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if projectUpdateParam.ProjectMaterial != nil {
|
|
|
// 删除已有示例
|
|
|
err = dao.ProjectMaterialDao{}.DeleteProjectMaterialByProjectId(project.ProjectId)
|
|
@@ -333,7 +318,7 @@ func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdate
|
|
|
}
|
|
|
|
|
|
println("更新种草任务的招募策略")
|
|
|
- // 更新种草任务的招募策略
|
|
|
+ // 5. 更新种草任务的招募策略
|
|
|
if projectUpdateParam.RecruitStrategys != nil {
|
|
|
// 1. 删除已有的招募策略
|
|
|
err = dao.RecruitStrategyDao{}.DeleteRecruitStrategyByProjectID(projectUpdateParam.ProjectID)
|
|
@@ -344,26 +329,19 @@ func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdate
|
|
|
if len(projectUpdateParam.RecruitStrategys) != 0 {
|
|
|
var recruits []entity.RecruitStrategy
|
|
|
for _, strategy := range projectUpdateParam.RecruitStrategys {
|
|
|
- //// 查询对应定价策略
|
|
|
- //pricingStrategy, err := dao.InfoPricingStrategylDao{}.GetPricingStrategy(strategy.FollowersLow, strategy.FollowersUp, strategy.FeeForm, project.ProjectPlatform)
|
|
|
- //if err != nil {
|
|
|
- // return nil, err
|
|
|
- //}
|
|
|
- //// 根据定价策略计算达人所见报价
|
|
|
- //if strategy.FeeForm == 2 {
|
|
|
- // strategy.TOffer = strategy.Offer * (1 - conv.MustFloat64(pricingStrategy.ServiceRate)/1000)
|
|
|
- //}
|
|
|
recruitStrategy := entity.RecruitStrategy{
|
|
|
- FeeForm: conv.MustInt64(strategy.FeeForm),
|
|
|
- StrategyID: conv.MustInt64(strategy.StrategyID),
|
|
|
- FollowersLow: conv.MustInt64(strategy.FollowersLow),
|
|
|
- FollowersUp: conv.MustInt64(strategy.FollowersUp),
|
|
|
- //ServiceCharge: strategy.ServiceCharge,
|
|
|
- Offer: strategy.Offer,
|
|
|
- //TOffer: strategy.TOffer,
|
|
|
- ProjectID: project.ProjectId,
|
|
|
+ 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)
|
|
|
}
|
|
|
- //fmt.Printf("Offer:\t %+v", Strategy.Offer)
|
|
|
recruits = append(recruits, recruitStrategy)
|
|
|
}
|
|
|
err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
|
|
@@ -378,12 +356,83 @@ func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdate
|
|
|
|
|
|
// 种草任务预览
|
|
|
func (s ProjectService) GetProjectDetail(projectId string) (*vo.ReProjectDetail, error) {
|
|
|
- projectDetail := vo.ReProjectDetail{}
|
|
|
+ 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,
|
|
|
+ }
|
|
|
+ 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)
|
|
@@ -394,28 +443,67 @@ func (s ProjectService) GetProjectDetail(projectId string) (*vo.ReProjectDetail,
|
|
|
logrus.Errorf("[projectDB service] call GetprojectMaterialInfo error,err:%+v", err)
|
|
|
return nil, err
|
|
|
}
|
|
|
- productInfo, err := dao.ProductDAO{}.GetProductByProjectId(projectId)
|
|
|
- if err != nil {
|
|
|
- logrus.Errorf("[projectDB service] call GetProductInfo error,err:%+v", err)
|
|
|
- return nil, err
|
|
|
+ reProjectDetail.ProjectBriefs = projectBriefInfos
|
|
|
+ reProjectDetail.ProjectMaterials = projectMaterials
|
|
|
+
|
|
|
+ return &reProjectDetail, nil
|
|
|
+}
|
|
|
+
|
|
|
+// 公开种草任务列表
|
|
|
+func (s ProjectService) GetProjectTaskList(param *vo.ProjectSearchParam) (vo.ResultVO, error) {
|
|
|
+ if param.Page == 0 {
|
|
|
+ param.Page = 1
|
|
|
}
|
|
|
- productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotosByProjectId(projectId)
|
|
|
- if err != nil {
|
|
|
- logrus.Errorf("[projectDB service] call GetProductPhotoInfo error,err:%+v", err)
|
|
|
- return nil, err
|
|
|
+ if param.PageSize == 0 {
|
|
|
+ param.PageSize = 10
|
|
|
}
|
|
|
- // 查找招募策略
|
|
|
- recruitStrategys, err := dao.RecruitStrategyDao{}.GetRecruitStrategyByProjectId(projectId)
|
|
|
+ var result vo.ResultVO
|
|
|
+ reProjectTaskPreviews, total, err := (&dao.ProjectDAO{}).GetProjectPreviews(param)
|
|
|
if err != nil {
|
|
|
- logrus.Errorf("[projectDB service] call GetRecruitStrategy error,err:%+v", err)
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- projectDetail.ProjectBriefs = projectBriefInfos
|
|
|
- projectDetail.Project = project
|
|
|
- projectDetail.ProjectMaterials = projectMaterials
|
|
|
- projectDetail.ProductInfo = productInfo
|
|
|
- projectDetail.ProductPhotos = productPhotos
|
|
|
- projectDetail.RecruitStrategys = recruitStrategys
|
|
|
- return &projectDetail, 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
|
|
|
}
|