Jelajahi Sumber

fix_create_bug

Ethan 4 bulan lalu
induk
melakukan
ec598897dd

+ 1 - 1
app/dao/local_life_dao.go

@@ -51,7 +51,7 @@ func (d LocalLifeDao) GetLocalListOfDay(enterpriseId string, date time.Time) ([]
 
 // 创建本地生活任务
 func (d LocalLifeDao) CreateLocalLife(localLife entity.LocalLifeInfo) error {
-	err := Db.Omit("recruit_ddl", "auto_fail_at", "pay_at", "submit_at", "pass_at", "finish_at").Create(&localLife).Error
+	err := Db.Omit("auto_fail_at", "pay_at", "submit_at", "pass_at", "finish_at").Create(&localLife).Error
 	if err != nil {
 		return err
 	}

+ 1 - 1
app/dao/project_dao.go

@@ -51,7 +51,7 @@ func (d ProjectDAO) GetProjectListOfDay(enterpriseId string, date time.Time) ([]
 
 // 创建种草任务
 func (d ProjectDAO) CreateProject(project entity.Project) error {
-	err := Db.Omit("recruit_ddl", "auto_fail_at", "auto_script_break_at", "auto_sketch_break_at", "pay_at", "pass_at", "finish_at", "submit_at").Create(&project).Error
+	err := Db.Omit("auto_fail_at", "auto_script_break_at", "auto_sketch_break_at", "pay_at", "pass_at", "finish_at", "submit_at").Create(&project).Error
 	if err != nil {
 		return err
 	}

+ 1 - 1
app/dao/selection_info_dao.go

@@ -40,7 +40,7 @@ func (d SelectionInfoDAO) GetSelectionInfoListOfDay(enterpriseId string, date ti
 
 // 创建带货任务
 func (d SelectionInfoDAO) CreateSelectionInfo(selectionInfo entity.SelectionInfo) error {
-	err := Db.Omit("task_ddl", "submit_at", "pass_at", "pay_at", "finish_at", "auto_fail_at").Create(&selectionInfo).Error
+	err := Db.Omit("submit_at", "pass_at", "pay_at", "finish_at", "auto_fail_at").Create(&selectionInfo).Error
 	if err != nil {
 		return err
 	}

+ 7 - 2
app/service/local_life_service.go

@@ -36,14 +36,19 @@ func (s LocalLifeService) CreateLocalLife(localCreateParam *vo.LocalCreateParam)
 		operatorType = 2
 	}
 	// d) 任务截止时间
-	recruitDdl := time.Time{} //赋零值
-	recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", localCreateParam.RecruitDdl, time.Local)
+	recruitDdl, err1 := time.ParseInLocation("2006-01-02 15:04:05", localCreateParam.RecruitDdl, time.Local)
+	if err1 != nil {
+		return nil, errors.New("failed to parse recruitDdl")
+	}
 	// 获取定时任务配置id
 	infoAutoTask := entity.InfoAutoTask{}
 	infoAutoTask = dao.InfoAutoTaskDao{}.GetAutoTaskLast(localCreateParam.EnterpriseId)
 	infoAutoDefault := entity.InfoAutoDefault{}
 	infoAutoDefault = dao.InfoAutoDefaultDao{}.GetAutoDefaultLast(localCreateParam.EnterpriseId)
 	t := time.Now()
+	if recruitDdl.Before(t) {
+		return nil, errors.New("截止时间异常,请重试")
+	}
 	newLocalLife := entity.LocalLifeInfo{
 		EnterpriseID:        localCreateParam.EnterpriseId,
 		SubAccountID:        localCreateParam.SubAccountId,

+ 7 - 2
app/service/project_service.go

@@ -32,8 +32,10 @@ func (s ProjectService) CreateProject(projectCreateParam *vo.ProjectCreateParam)
 	productInfoToJson, _ := json.Marshal(product)
 	productPhotosToJson, _ := json.Marshal(productPhotos)
 	// d) 任务截止时间
-	recruitDdl := time.Time{} //赋零值
-	recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", projectCreateParam.RecruitDdl, time.Local)
+	recruitDdl, err1 := time.ParseInLocation("2006-01-02 15:04:05", projectCreateParam.RecruitDdl, time.Local)
+	if err1 != nil {
+		return nil, errors.New("failed to parse recruitDdl")
+	}
 	// d)创建种草任务
 	var operatorType int64
 	if projectCreateParam.SubAccountId == 0 {
@@ -48,6 +50,9 @@ func (s ProjectService) CreateProject(projectCreateParam *vo.ProjectCreateParam)
 	infoAutoDefault := entity.InfoAutoDefault{}
 	infoAutoDefault = dao.InfoAutoDefaultDao{}.GetAutoDefaultLast(projectCreateParam.EnterpriseId)
 	t := time.Now()
+	if recruitDdl.Before(t) {
+		return nil, errors.New("截止时间异常,请重试")
+	}
 	newProject := entity.Project{
 		ProjectStatus:    1,
 		ProjectType:      projectCreateParam.ProjectType,

+ 7 - 3
app/service/selection_info_service.go

@@ -69,14 +69,18 @@ func (s SelectionInfoService) CreateSelectionInfo(selectionCreateParam *vo.Selec
 	productInfoToJson, _ := json.Marshal(product)
 	productPhotosToJson, _ := json.Marshal(productPhotos)
 	// 任务截止时间
-	taskDdl := time.Time{} //赋零值
-	taskDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", selectionCreateParam.TaskDdl, time.Local)
-
+	taskDdl, err1 := time.ParseInLocation("2006-01-02 15:04:05", selectionCreateParam.TaskDdl, time.Local)
+	if err1 != nil {
+		return nil, errors.New("failed to parse taskDdl")
+	}
 	// 创建选品
 	// 获取定时任务配置
 	infoAutoTask := entity.InfoAutoTask{}
 	infoAutoTask = dao.InfoAutoTaskDao{}.GetAutoTaskLast(selectionCreateParam.EnterpriseId)
 	t := time.Now()
+	if taskDdl.Before(t) {
+		return nil, errors.New("截止时间异常,请重试")
+	}
 	var sampleMode, taskMode int64
 	var poolRewardSum float64
 	if len(selectionCreateParam.FreeStrategys) > 0 {