Procházet zdrojové kódy

发货时更新task表中发货时间

unknown před 2 roky
rodič
revize
dab2a50527
2 změnil soubory, kde provedl 19 přidání a 1 odebrání
  1. 12 0
      db/task.go
  2. 7 1
      service/logistics.go

+ 12 - 0
db/task.go

@@ -3,6 +3,7 @@ package db
 import (
 	"context"
 	"strconv"
+	"time"
 	"youngee_b_api/model/gorm_model"
 
 	"github.com/sirupsen/logrus"
@@ -30,6 +31,17 @@ func UpdateLogisticsStatus(ctx context.Context, taskID int64, status int64) erro
 	return nil
 }
 
+func UpdateLogisticsDate(ctx context.Context, taskID int64) error {
+
+	db := GetReadDB(ctx)
+	err := db.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskID).Update("delivery_date", time.Now()).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[task db] call UpdateLogisticsDate error,err:%+v", err)
+		return err
+	}
+	return nil
+}
+
 func GetProjectIdByTaskId(ctx context.Context, taskID int64) (*int, error) {
 	db := GetReadDB(ctx)
 	task := &gorm_model.YoungeeTaskInfo{}

+ 7 - 1
service/logistics.go

@@ -38,7 +38,6 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 		Logistics.LogisticsNumber = newLogistics.LogisticsNumber
 		Logistics.DeliveryTime = time.Now()
 	} else if ThingsType == 3 {
-		fmt.Println("开始时间:", newLogistics.ExplorestoreStarttime)
 		Logistics.ExplorestoreStarttime = newLogistics.ExplorestoreStarttime
 		Logistics.ExplorestoreEndtime = newLogistics.ExplorestoreEndtime
 		// Logistics.ExplorestorePeriod = newLogistics.ExplorestorePeriod
@@ -79,6 +78,13 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 		return nil, err
 	}
 
+	// 修改task_info中发货状态
+	err = db.UpdateLogisticsDate(ctx, Logistics.TaskID)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics service] call UpdateLogisticsDate error,err:%+v", err)
+		return nil, err
+	}
+
 	// 对应招募策略待发货--,已发货++
 
 	res := &http_model.CreateLogisticsData{