Переглянути джерело

修改线下探店签收及违约处理

yuliang1112 2 роки тому
батько
коміт
93b6943945

+ 2 - 1
db/logistics.go

@@ -43,9 +43,10 @@ func UpdateLogistics(ctx context.Context, logistics gorm_model.YoungeeTaskLogist
 // 更改签收时间
 func SignForReceipt(ctx context.Context, taskID string) error {
 	db := GetReadDB(ctx)
+	t := time.Now()
 	err := db.Model(gorm_model.YoungeeTaskLogistics{}).Where("task_id = ?", taskID).Updates(gorm_model.YoungeeTaskLogistics{
 		Status:     1,
-		SignedTime: time.Now(),
+		SignedTime: &t,
 	}).Error
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[logistics db] call UpdateLogistics error,err:%+v", err)

+ 2 - 1
db/number_info.go

@@ -239,7 +239,8 @@ func SignLogistic(logisticId int64) string {
 	db.Model(gorm_model.YoungeeTaskLogistics{}).Select("task_id").Where("logistics_id = ?", logisticId).Find(&taskId)
 	db.Model(gorm_model.YoungeeTaskInfo{}).Select("project_id").Where("task_id = ?", taskId).Find(&projectId)
 	db.Model(gorm_model.ProjectInfo{}).Select("content_type").Where("project_id = ?", projectId).Find(&contentType)
-	db.Model(gorm_model.YoungeeTaskLogistics{}).Where("logistics_id = ?", logisticId).Updates(&gorm_model.YoungeeTaskLogistics{SignedTime: time.Now(), Status: 1})
+	t := time.Now()
+	db.Model(gorm_model.YoungeeTaskLogistics{}).Where("logistics_id = ?", logisticId).Updates(&gorm_model.YoungeeTaskLogistics{SignedTime: &t, Status: 1})
 	if contentType == 1 {
 		db.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskId).Updates(&gorm_model.YoungeeTaskInfo{LogisticsStatus: 3, TaskStage: 9})
 		fmt.Printf("任务 %v 物流状态为已签收,已更新任务状态为 待传初稿\n", taskId)

+ 9 - 6
db/operate.go

@@ -320,13 +320,15 @@ func GetSignInOfflineTask(projectForm int32) error {
 		signedTaskId = append(signedTaskId, logisticInfo.TaskID)
 		if logisticInfo.Status == 0 {
 			if logisticInfo.ThingsType == 3 {
+				t := time.Now()
 				db6 := GetReadDB(context.Background())
 				db6.Model(gorm_model.YoungeeTaskLogistics{}).Where("logistics_id = ?", logisticInfo.LogisticsID).Updates(
-					&gorm_model.YoungeeTaskLogistics{Status: 1})
+					&gorm_model.YoungeeTaskLogistics{SignedTime: &t, Status: 1})
 			} else {
 				db6 := GetReadDB(context.Background())
+				t := time.Now()
 				db6.Model(gorm_model.YoungeeTaskLogistics{}).Where("logistics_id = ?", logisticInfo.LogisticsID).Updates(
-					&gorm_model.YoungeeTaskLogistics{SignedTime: time.Now(), Status: 1})
+					&gorm_model.YoungeeTaskLogistics{SignedTime: &t, Status: 1})
 			}
 			err = CreateTaskLog(context.Background(), logisticInfo.TaskID, "签收时间")
 			if err != nil {
@@ -956,7 +958,7 @@ func GetAutoDraftDefaultInPicTask() error {
 		}
 
 		//	添加初稿违约自动处理时间
-		if taskLogisticNeedMod.TaskID != "" && taskLogisticNeedMod.AutoSketchBreakAt == nil || taskLogisticNeedMod.AutoSketchBreakAt.IsZero() {
+		if taskLogisticNeedMod.Status == 1 && taskLogisticNeedMod.TaskID != "" && taskLogisticNeedMod.AutoSketchBreakAt == nil || taskLogisticNeedMod.AutoSketchBreakAt.IsZero() {
 			dd, _ := time.ParseDuration(conv.MustString(DraftDefaultInPic, "") + "h")
 			db4 := GetReadDB(context.Background())
 			t := taskLogisticNeedMod.SignedTime.Add(dd)
@@ -1124,7 +1126,8 @@ func GetAutoDraftDefaultInMvTask() error {
 
 		var videoTaskInfos []*gorm_model.YoungeeTaskInfo
 		db1 := GetReadDB(context.Background())
-		db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND task_status = ? AND task_stage = ? AND cur_default_type = ? AND logistics_status = 3", projectInfo.ProjectID, 2, 9, 0).Find(&videoTaskInfos)
+		db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND task_status = ? AND task_stage = ? AND cur_default_type = ? AND logistics_status = 3",
+			projectInfo.ProjectID, 2, 9, 0).Find(&videoTaskInfos)
 		for _, videoTaskInfo := range videoTaskInfos {
 			taskIdToProjectIdMap[videoTaskInfo.TaskId] = projectInfo.ProjectID
 			taskIdToFeeFormMap[videoTaskInfo.TaskId] = videoTaskInfo.FeeForm
@@ -1391,7 +1394,7 @@ func GetAutoScriptDefaultTask() error {
 			t := taskLogisticInfo.SignedTime.Add(dd)
 			db1.Where("task_id = ?", videoTaskNeedModId).Updates(&gorm_model.YoungeeTaskLogistics{AutoScriptBreakAt: &t})
 			fmt.Println("已添加视频形式的脚本违约自动处理时间")
-			if taskLogisticInfo.TaskID != "" && taskLogisticInfo.SignedTime.Add(dd).Sub(time.Now()) <= 0 {
+			if taskLogisticInfo.Status == 1 && taskLogisticInfo.TaskID != "" && taskLogisticInfo.SignedTime.Add(dd).Sub(time.Now()) <= 0 {
 				db4 := GetReadDB(context.Background())
 				err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
 					TaskID: videoTaskNeedModId, ProjectID: taskIdToProjectIdMap[videoTaskNeedModId], BreakType: 1, BreakAt: time.Now(), DefaultStatus: 1}).Error
@@ -1435,7 +1438,7 @@ func GetAutoScriptDefaultTask() error {
 				fmt.Println("创建时已违约则创建视频类型的脚本违约记录")
 			}
 		} else {
-			if taskLogisticInfo.TaskID != "" && taskLogisticInfo.AutoScriptBreakAt.Sub(time.Now()) <= 0 {
+			if taskLogisticInfo.Status == 1 && taskLogisticInfo.TaskID != "" && taskLogisticInfo.AutoScriptBreakAt.Sub(time.Now()) <= 0 {
 				db4 := GetReadDB(context.Background())
 				err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
 					TaskID: videoTaskNeedModId, ProjectID: taskIdToProjectIdMap[videoTaskNeedModId], BreakType: 1, BreakAt: time.Now(), DefaultStatus: 1}).Error

+ 1 - 1
model/gorm_model/task_logistic.go

@@ -16,7 +16,7 @@ type YoungeeTaskLogistics struct {
 	TaskID                string     `gorm:"column:task_id;NOT NULL"`                        // 任务id
 	DeliveryTime          time.Time  `gorm:"column:delivery_time"`                           // 发货时间
 	ThingsType            int64      `gorm:"column:things_type;NOT NULL"`                    // 任务类型:1 实物,2:线下探店,3:虚拟产品
-	SignedTime            time.Time  `gorm:"column:signed_time"`                             // 实物商品-签收时间
+	SignedTime            *time.Time `gorm:"column:signed_time"`                             // 实物商品-签收时间
 	AutoSignAt            *time.Time `gorm:"column:auto_sign_at"`                            // 自动签收时间
 	AutoScriptBreakAt     *time.Time `gorm:"column:auto_script_break_at"`                    // 脚本违约自动处理时间
 	AutoSketchBreakAt     *time.Time `gorm:"column:auto_sketch_break_at"`                    // 初稿违约自动处理时间

+ 14 - 2
pack/task_logistics_list.go

@@ -19,6 +19,12 @@ func MGormTaskLogisticsInfoListToHttpTaskLogisticsPreviewList(gormTaskLogisticsI
 func MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(TaskLogisticsInfo *http_model.TaskLogisticsInfo) *http_model.TaskLogisticsPreview {
 	deliveryTime := conv.MustString(TaskLogisticsInfo.DeliveryTime, "")
 	deliveryTime = deliveryTime[0:19]
+	SignedTime := ""
+	if TaskLogisticsInfo.SignedTime == "" {
+		SignedTime = ""
+	} else {
+		SignedTime = TaskLogisticsInfo.SignedTime[:19]
+	}
 	return &http_model.TaskLogisticsPreview{
 		TaskID:                conv.MustString(TaskLogisticsInfo.TaskID, ""),
 		PlatformNickname:      conv.MustString(TaskLogisticsInfo.PlatformNickname, ""),
@@ -33,7 +39,7 @@ func MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(TaskLogisticsInfo *http_mo
 		ExplorestoreEndtime:   TaskLogisticsInfo.ExplorestoreEndtime,
 		ExplorestorePeriod:    conv.MustString(TaskLogisticsInfo.ExplorestorePeriod, ""),
 		CouponCode:            conv.MustString(TaskLogisticsInfo.CouponCode, ""),
-		SignedTime:            conv.MustString(TaskLogisticsInfo.SignedTime, "")[:19],
+		SignedTime:            SignedTime,
 	}
 }
 
@@ -49,6 +55,12 @@ func TaskLogisticsToTaskInfo(TaskLogisticss []*http_model.TaskLogistics) []*http
 func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.TaskLogisticsInfo {
 	TalentPlatformInfoSnap := TaskLogistics.Talent.TalentPlatformInfoSnap
 	TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap
+	SignedTime := ""
+	if TaskLogistics.Logistics.SignedTime == nil {
+		SignedTime = ""
+	} else {
+		SignedTime = conv.MustString(TaskLogistics.Logistics.SignedTime, "")
+	}
 	return &http_model.TaskLogisticsInfo{
 		TaskID:                TaskLogistics.Talent.TaskId,
 		PlatformNickname:      conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname"), ""),
@@ -62,6 +74,6 @@ func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.Ta
 		ExplorestoreEndtime:   TaskLogistics.Logistics.ExplorestoreEndtime,
 		ExplorestorePeriod:    TaskLogistics.Logistics.ExplorestorePeriod,
 		CouponCode:            TaskLogistics.Logistics.CouponCodeInformation,
-		SignedTime:            conv.MustString(TaskLogistics.Logistics.SignedTime, ""),
+		SignedTime:            SignedTime,
 	}
 }

+ 0 - 4
service/logistics.go

@@ -30,7 +30,6 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 		ExplorestoreStarttime: time.Now(),
 		ExplorestoreEndtime:   time.Now(),
 		DeliveryTime:          time.Now(),
-		SignedTime:            time.Now(),
 	}
 	//fmt.Println("ThingsType:", ThingsType)
 	//实物
@@ -45,7 +44,6 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 		ExplorestoreEndtime, _ := time.ParseInLocation("2006-01-02 15:04:05", newLogistics.ExplorestoreEndtime, time.Local)
 		Logistics.ExplorestoreStarttime = ExplorestoreStarttime
 		Logistics.ExplorestoreEndtime = ExplorestoreEndtime
-		Logistics.SignedTime = ExplorestoreEndtime
 	} else {
 		Logistics.CouponCodeInformation = newLogistics.CouponCodeInformation
 	}
@@ -125,7 +123,6 @@ func (*logistics) Update(ctx context.Context, newLogistics http_model.CreateLogi
 		TaskID:       newLogistics.TaskID,
 		ThingsType:   int64(ThingsType),
 		DeliveryTime: time.Now(),
-		SignedTime:   time.Now(),
 	}
 	//实物
 	if ThingsType == 1 {
@@ -138,7 +135,6 @@ func (*logistics) Update(ctx context.Context, newLogistics http_model.CreateLogi
 		ExplorestoreEndtime, _ := time.ParseInLocation("2006-01-02 15:04:05", newLogistics.ExplorestoreEndtime, time.Local)
 		Logistics.ExplorestoreStarttime = ExplorestoreStarttime
 		Logistics.ExplorestoreEndtime = ExplorestoreEndtime
-		// Logistics.ExplorestorePeriod = newLogistics.ExplorestorePeriod
 	} else {
 		Logistics.CouponCodeInformation = newLogistics.CouponCodeInformation
 	}