|
@@ -41,6 +41,7 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+
|
|
|
AutoDefaultID, err := db.GetLastAutoDefaultID()
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
@@ -67,7 +68,10 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
|
|
|
}
|
|
|
feeFroms := strings.Join(feeFrom, ",")
|
|
|
//fmt.Printf("创建项目new %+v", newProject)
|
|
|
- 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)
|
|
|
+ }
|
|
|
fmt.Println("Create RecruitDdl:", newProject.RecruitDdl, RecruitDdl)
|
|
|
projectInfo := gorm_model.ProjectInfo{}
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
@@ -79,26 +83,50 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
|
|
|
td = "0" + td
|
|
|
}
|
|
|
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: feeFroms,
|
|
|
- AutoTaskID: conv.MustInt64(AutoTaskID),
|
|
|
- AutoDefaultID: conv.MustInt64(AutoDefaultID),
|
|
|
- EstimatedCost: ECost,
|
|
|
- IsRead: 0,
|
|
|
- ProductSnap: string(productInfoToJson),
|
|
|
- ProductPhotoSnap: string(productPhotosToJson),
|
|
|
+ // 没有填写DDL
|
|
|
+ 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: feeFroms,
|
|
|
+ AutoTaskID: conv.MustInt64(AutoTaskID),
|
|
|
+ AutoDefaultID: conv.MustInt64(AutoDefaultID),
|
|
|
+ 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: feeFroms,
|
|
|
+ AutoTaskID: conv.MustInt64(AutoTaskID),
|
|
|
+ AutoDefaultID: conv.MustInt64(AutoDefaultID),
|
|
|
+ EstimatedCost: ECost,
|
|
|
+ IsRead: 0,
|
|
|
+ ProductSnap: string(productInfoToJson),
|
|
|
+ ProductPhotoSnap: string(productPhotosToJson),
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
projectInfo = gorm_model.ProjectInfo{
|
|
@@ -145,7 +173,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 {
|
|
|
recruitStrategys := []gorm_model.RecruitStrategy{}
|
|
|
for _, strategy := range newProject.RecruitStrategys {
|
|
|
// 查询对应定价策略
|
|
@@ -182,7 +210,10 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
|
|
|
return res, nil
|
|
|
}
|
|
|
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.Time{} //赋零值
|
|
|
+ if newProject.RecruitDdl != "" {
|
|
|
+ RecruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", newProject.RecruitDdl, time.Local)
|
|
|
+ }
|
|
|
fmt.Println("Update RecruitDdl:", newProject.RecruitDdl, RecruitDdl)
|
|
|
oldProject, err3 := db.GetProjectDetail(ctx, newProject.ProjectID)
|
|
|
if err3 != nil {
|
|
@@ -195,7 +226,7 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
|
|
|
//feeForm += string(strategy.StrategyID)
|
|
|
}
|
|
|
var ECost float64 = 0
|
|
|
- if newProject.ProjectType == int64(1) {
|
|
|
+ if newProject.ProjectType == int64(1) && newProject.RecruitStrategys != nil {
|
|
|
for _, strategy := range newProject.RecruitStrategys {
|
|
|
// 计算预估成本
|
|
|
var tmpCost float64 = 0
|
|
@@ -209,18 +240,34 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
|
|
|
}
|
|
|
feeFroms := strings.Join(feeFrom, ",")
|
|
|
t := time.Now()
|
|
|
- project := gorm_model.ProjectInfo{
|
|
|
- ProjectID: newProject.ProjectID,
|
|
|
- RecruitDdl: &RecruitDdl,
|
|
|
- TalentType: newProject.TalentType,
|
|
|
- ContentType: conv.MustInt64(newProject.ContentType),
|
|
|
- ProjectDetail: newProject.ProjectDetail,
|
|
|
- ProjectForm: conv.MustInt64(newProject.ProjectForm),
|
|
|
- EnterpriseID: enterpriseID,
|
|
|
- ProjectStatus: conv.MustInt64(newProject.ProjectStatus),
|
|
|
- FeeForm: feeFroms,
|
|
|
- EstimatedCost: ECost,
|
|
|
- SubmitAt: &t,
|
|
|
+ project := gorm_model.ProjectInfo{}
|
|
|
+ if newProject.RecruitDdl == "" {
|
|
|
+ project = gorm_model.ProjectInfo{
|
|
|
+ ProjectID: newProject.ProjectID,
|
|
|
+ TalentType: newProject.TalentType,
|
|
|
+ ContentType: conv.MustInt64(newProject.ContentType),
|
|
|
+ ProjectDetail: newProject.ProjectDetail,
|
|
|
+ ProjectForm: conv.MustInt64(newProject.ProjectForm),
|
|
|
+ EnterpriseID: enterpriseID,
|
|
|
+ ProjectStatus: conv.MustInt64(newProject.ProjectStatus),
|
|
|
+ FeeForm: feeFroms,
|
|
|
+ EstimatedCost: ECost,
|
|
|
+ SubmitAt: &t,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ project = gorm_model.ProjectInfo{
|
|
|
+ ProjectID: newProject.ProjectID,
|
|
|
+ RecruitDdl: &RecruitDdl,
|
|
|
+ TalentType: newProject.TalentType,
|
|
|
+ ContentType: conv.MustInt64(newProject.ContentType),
|
|
|
+ ProjectDetail: newProject.ProjectDetail,
|
|
|
+ ProjectForm: conv.MustInt64(newProject.ProjectForm),
|
|
|
+ EnterpriseID: enterpriseID,
|
|
|
+ ProjectStatus: conv.MustInt64(newProject.ProjectStatus),
|
|
|
+ FeeForm: feeFroms,
|
|
|
+ EstimatedCost: ECost,
|
|
|
+ SubmitAt: &t,
|
|
|
+ }
|
|
|
}
|
|
|
projectID, err := db.UpdateProject(ctx, project)
|
|
|
if err != nil {
|
|
@@ -253,8 +300,8 @@ 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 && newProject.ProjectType == int64(1) {
|
|
|
+ fmt.Printf("策略:\t %+v,%+v", newProject.RecruitStrategys, len(newProject.RecruitStrategys) == 0)
|
|
|
+ if len(newProject.RecruitStrategys) != 0 && newProject.ProjectType == int64(1) {
|
|
|
// 新增策略
|
|
|
RecruitStrategys := []gorm_model.RecruitStrategy{}
|
|
|
for _, Strategy := range newProject.RecruitStrategys {
|