|
@@ -153,8 +153,12 @@ func (*project) GetProjectTaskList(ctx context.Context, projectID string, pageSi
|
|
|
}
|
|
|
|
|
|
func (*project) Create(ctx context.Context, newProject http_model.CreateProjectRequest, enterpriseID string) (*http_model.CreateProjectData, error) {
|
|
|
- fmt.Println("newProject:", newProject)
|
|
|
- RecruitDdl, _ := time.ParseInLocation("2006-01-02 15:04:05", newProject.RecruitDdl, time.Local)
|
|
|
+ fmt.Printf("newProject:%+v\n", newProject)
|
|
|
+ fmt.Println("newProject.RecruitDdl:", newProject.RecruitDdl)
|
|
|
+ RecruitDdl := time.Time{} //赋零值
|
|
|
+ if newProject.RecruitDdl != "" {
|
|
|
+ RecruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", newProject.RecruitDdl, time.Local)
|
|
|
+ }
|
|
|
// 查询关联商品信息
|
|
|
product, err := db.GetProductByID(ctx, newProject.ProductID)
|
|
|
if err != nil {
|
|
@@ -201,27 +205,51 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
|
|
|
}
|
|
|
td = "0" + td
|
|
|
}
|
|
|
+ fmt.Printf("RecruitDdl:%+v\n", RecruitDdl)
|
|
|
if newProject.ProjectType == int64(1) {
|
|
|
- projectInfo = gorm_model.ProjectInfo{
|
|
|
- ProjectID: conv.MustString(time.Now().Year(), "")[2:] + td + conv.MustString(rand.Intn(100000-10000)+10000, ""),
|
|
|
- ProjectName: projectName,
|
|
|
- ProjectStatus: 1,
|
|
|
- ProjectType: newProject.ProjectType,
|
|
|
- TalentType: newProject.TalentType,
|
|
|
- ProjectPlatform: newProject.ProjectPlatform,
|
|
|
- ProjectForm: newProject.ProjectForm,
|
|
|
- RecruitDdl: &RecruitDdl,
|
|
|
- ProjectDetail: newProject.ProjectDetail,
|
|
|
- ContentType: newProject.ContentType,
|
|
|
- EnterpriseID: enterpriseID,
|
|
|
- ProductID: newProject.ProductID,
|
|
|
- FeeForm: feeForms,
|
|
|
- AutoTaskID: conv.MustInt64(AutoTaskID, 0),
|
|
|
- AutoDefaultID: conv.MustInt64(AutoDefaultID, 0),
|
|
|
- EstimatedCost: ECost,
|
|
|
- IsRead: 0,
|
|
|
- ProductSnap: string(productInfoToJson),
|
|
|
- ProductPhotoSnap: string(productPhotosToJson),
|
|
|
+ if newProject.RecruitDdl == "" {
|
|
|
+ projectInfo = gorm_model.ProjectInfo{
|
|
|
+ ProjectID: conv.MustString(time.Now().Year(), "")[2:] + td + conv.MustString(rand.Intn(100000-10000)+10000, ""),
|
|
|
+ ProjectName: projectName,
|
|
|
+ ProjectStatus: 1,
|
|
|
+ ProjectType: newProject.ProjectType,
|
|
|
+ TalentType: newProject.TalentType,
|
|
|
+ ProjectPlatform: newProject.ProjectPlatform,
|
|
|
+ ProjectForm: newProject.ProjectForm,
|
|
|
+ ProjectDetail: newProject.ProjectDetail,
|
|
|
+ ContentType: newProject.ContentType,
|
|
|
+ EnterpriseID: enterpriseID,
|
|
|
+ ProductID: newProject.ProductID,
|
|
|
+ FeeForm: feeForms,
|
|
|
+ AutoTaskID: conv.MustInt64(AutoTaskID, 0),
|
|
|
+ AutoDefaultID: conv.MustInt64(AutoDefaultID, 0),
|
|
|
+ EstimatedCost: ECost,
|
|
|
+ IsRead: 0,
|
|
|
+ ProductSnap: string(productInfoToJson),
|
|
|
+ ProductPhotoSnap: string(productPhotosToJson),
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ projectInfo = gorm_model.ProjectInfo{
|
|
|
+ ProjectID: conv.MustString(time.Now().Year(), "")[2:] + td + conv.MustString(rand.Intn(100000-10000)+10000, ""),
|
|
|
+ ProjectName: projectName,
|
|
|
+ ProjectStatus: 1,
|
|
|
+ ProjectType: newProject.ProjectType,
|
|
|
+ TalentType: newProject.TalentType,
|
|
|
+ ProjectPlatform: newProject.ProjectPlatform,
|
|
|
+ ProjectForm: newProject.ProjectForm,
|
|
|
+ RecruitDdl: &RecruitDdl,
|
|
|
+ ProjectDetail: newProject.ProjectDetail,
|
|
|
+ ContentType: newProject.ContentType,
|
|
|
+ EnterpriseID: enterpriseID,
|
|
|
+ ProductID: newProject.ProductID,
|
|
|
+ FeeForm: feeForms,
|
|
|
+ AutoTaskID: conv.MustInt64(AutoTaskID, 0),
|
|
|
+ AutoDefaultID: conv.MustInt64(AutoDefaultID, 0),
|
|
|
+ EstimatedCost: ECost,
|
|
|
+ IsRead: 0,
|
|
|
+ ProductSnap: string(productInfoToJson),
|
|
|
+ ProductPhotoSnap: string(productPhotosToJson),
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
projectInfo = gorm_model.ProjectInfo{
|
|
@@ -266,7 +294,7 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
|
|
|
}
|
|
|
}
|
|
|
// build
|
|
|
- if newProject.ProjectType == int64(1) {
|
|
|
+ if newProject.ProjectType == int64(1) && newProject.RecruitStrategys != nil {
|
|
|
var recruitStrategys []gorm_model.RecruitStrategy
|
|
|
for _, strategy := range newProject.RecruitStrategys {
|
|
|
// 查询对应定价策略
|
|
@@ -303,12 +331,16 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
|
|
|
}
|
|
|
|
|
|
func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectRequest, enterpriseID string) (*http_model.UpdateProjectData, error) {
|
|
|
- RecruitDdl, _ := time.ParseInLocation("2006-01-02 15:04:05", newProject.RecruitDdl, time.Local)
|
|
|
+ //RecruitDdl, _ := time.ParseInLocation("2006-01-02 15:04:05", newProject.RecruitDdl, time.Local)
|
|
|
+ RecruitDdl := time.Time{} //赋零值
|
|
|
+ if newProject.RecruitDdl != "" {
|
|
|
+ RecruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", newProject.RecruitDdl, time.Local)
|
|
|
+ }
|
|
|
oldProject, err3 := db.GetProjectDetail(ctx, newProject.ProjectID)
|
|
|
if err3 != nil {
|
|
|
return nil, err3
|
|
|
}
|
|
|
- feeFrom := []string{}
|
|
|
+ var feeFrom []string
|
|
|
for _, strategy := range newProject.RecruitStrategys {
|
|
|
feeFrom = append(feeFrom, strconv.FormatInt(strategy.FeeForm, 10))
|
|
|
}
|
|
@@ -325,20 +357,38 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
|
|
|
ECost += tmpCost
|
|
|
}
|
|
|
}
|
|
|
- feeFroms := strings.Join(feeFrom, ",")
|
|
|
+ feeForms := strings.Join(feeFrom, ",")
|
|
|
t := time.Now()
|
|
|
- project := gorm_model.ProjectInfo{
|
|
|
- ProjectID: newProject.ProjectID,
|
|
|
- RecruitDdl: &RecruitDdl,
|
|
|
- TalentType: newProject.TalentType,
|
|
|
- ContentType: conv.MustInt64(newProject.ContentType, 0),
|
|
|
- ProjectDetail: newProject.ProjectDetail,
|
|
|
- ProjectForm: conv.MustInt64(newProject.ProjectForm, 0),
|
|
|
- EnterpriseID: enterpriseID,
|
|
|
- ProjectStatus: int64(newProject.ProjectStatus),
|
|
|
- FeeForm: feeFroms,
|
|
|
- EstimatedCost: ECost,
|
|
|
- SubmitAt: &t,
|
|
|
+ project := gorm_model.ProjectInfo{}
|
|
|
+ if newProject.RecruitDdl == "" {
|
|
|
+ project = gorm_model.ProjectInfo{
|
|
|
+ ProjectType: newProject.ProjectType,
|
|
|
+ ProjectID: newProject.ProjectID,
|
|
|
+ TalentType: newProject.TalentType,
|
|
|
+ ContentType: conv.MustInt64(newProject.ContentType, 0),
|
|
|
+ ProjectDetail: newProject.ProjectDetail,
|
|
|
+ ProjectForm: conv.MustInt64(newProject.ProjectForm, 0),
|
|
|
+ EnterpriseID: enterpriseID,
|
|
|
+ ProjectStatus: int64(newProject.ProjectStatus),
|
|
|
+ FeeForm: feeForms,
|
|
|
+ EstimatedCost: ECost,
|
|
|
+ SubmitAt: &t,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ project = gorm_model.ProjectInfo{
|
|
|
+ ProjectType: newProject.ProjectType,
|
|
|
+ ProjectID: newProject.ProjectID,
|
|
|
+ RecruitDdl: &RecruitDdl,
|
|
|
+ TalentType: newProject.TalentType,
|
|
|
+ ContentType: conv.MustInt64(newProject.ContentType, 0),
|
|
|
+ ProjectDetail: newProject.ProjectDetail,
|
|
|
+ ProjectForm: conv.MustInt64(newProject.ProjectForm, 0),
|
|
|
+ EnterpriseID: enterpriseID,
|
|
|
+ ProjectStatus: int64(newProject.ProjectStatus),
|
|
|
+ FeeForm: feeForms,
|
|
|
+ EstimatedCost: ECost,
|
|
|
+ SubmitAt: &t,
|
|
|
+ }
|
|
|
}
|
|
|
projectID, err := db.UpdateProject(ctx, project)
|
|
|
if err != nil {
|
|
@@ -349,10 +399,10 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- fmt.Printf("照片:\t %+v", newProject.ProjectPhotos)
|
|
|
+ fmt.Printf("照片:\t %+v\n", newProject.ProjectPhotos)
|
|
|
if len(newProject.ProjectPhotos) != 0 {
|
|
|
// 新增图片
|
|
|
- projectPhotos := []gorm_model.ProjectPhoto{}
|
|
|
+ var projectPhotos []gorm_model.ProjectPhoto
|
|
|
for _, photo := range newProject.ProjectPhotos {
|
|
|
projectPhoto := gorm_model.ProjectPhoto{
|
|
|
ProjectID: project.ProjectID,
|
|
@@ -371,10 +421,10 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- //fmt.Printf("策略:\t %+v", newProject.RecruitStrategys)
|
|
|
- if newProject.RecruitStrategys != nil {
|
|
|
+ fmt.Printf("招募策略:%+v \n", newProject.RecruitStrategys)
|
|
|
+ if newProject.RecruitStrategys != nil && newProject.ProjectType == 1 {
|
|
|
// 新增策略
|
|
|
- RecruitStrategys := []gorm_model.RecruitStrategy{}
|
|
|
+ var RecruitStrategys []gorm_model.RecruitStrategy
|
|
|
for _, Strategy := range newProject.RecruitStrategys {
|
|
|
// 查询对应定价策略
|
|
|
pricingStrategy, err := db.GetPricingStrategy(ctx, Strategy.FollowersLow, Strategy.FollowersUp, Strategy.FeeForm, oldProject.ProjectPlatform)
|