瀏覽代碼

发货管理

unknown 2 年之前
父節點
當前提交
4485f5d6b7
共有 6 個文件被更改,包括 37 次插入12 次删除
  1. 10 0
      db/recruit_strategy.go
  2. 1 1
      model/http_model/logistics_create.go
  3. 1 0
      pack/task_logistics_list.go
  4. 0 1
      route/init.go
  5. 24 9
      service/logistics.go
  6. 1 1
      service/project.go

+ 10 - 0
db/recruit_strategy.go

@@ -39,6 +39,16 @@ func CalculateSelectedNumberByRecruitStrategyID(ctx context.Context, recruitstra
 	return nil
 }
 
+func UpdateSelectedNumber(ctx context.Context, RecruitStrategyID int64, selected_number int64) error {
+	db := GetReadDB(ctx)
+	err := db.Model(gorm_model.RecruitStrategy{}).Where("recruit_strategy_id = ?", RecruitStrategyID).Update("selected_number", gorm.Expr("selected_number + ?", selected_number)).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics db] call CreateLogistics error,err:%+v", err)
+		return err
+	}
+	return nil
+}
+
 func UpdateLogisticsNumber(ctx context.Context, RecruitStrategyID int64, delivered_value int64, waiting_value int64, signed_value int64) error {
 	db := GetReadDB(ctx)
 	err := db.Model(gorm_model.RecruitStrategy{}).Where("recruit_strategy_id = ?", RecruitStrategyID).

+ 1 - 1
model/http_model/logistics_create.go

@@ -3,7 +3,7 @@ package http_model
 import "time"
 
 type CreateLogisticsRequest struct {
-	RecruitStrategyID     int64     `json:"recruit_strategy_id"`     //招募策略id
+	StrategyID            int64     `json:"strategy_id"`             //招募策略id
 	LogisticsID           int64     `json:"logistics_id"`            // 货物-id
 	CompanyName           string    `json:"company_name"`            // 实物商品-物流公司名称
 	LogisticsNumber       string    `json:"logistics_number"`        // 实物商品-物流单号

+ 1 - 0
pack/task_logistics_list.go

@@ -61,5 +61,6 @@ func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.Ta
 		ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime,
 		ExplorestoreEndtime:   TaskLogistics.Logistics.ExplorestoreEndtime,
 		ExplorestorePeriod:    TaskLogistics.Logistics.ExplorestorePeriod,
+		CouponCode:            TaskLogistics.Logistics.CouponCodeInformation,
 	}
 }

+ 0 - 1
route/init.go

@@ -60,5 +60,4 @@ func InitRoute(r *gin.Engine) {
 		m.POST("/project/createlogistics", handler.WrapCreateLogisticsHandler)
 		m.POST("/project/signforreceipt", handler.WrapSignForReceiptHandler)
 	}
-
 }

+ 24 - 9
service/logistics.go

@@ -21,7 +21,7 @@ type logistics struct {
 // 在物流信息表插入记录
 func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogisticsRequest) (*http_model.CreateLogisticsData, error) {
 	ThingsType := newLogistics.ThingsType
-	RecruitStrategyID := newLogistics.RecruitStrategyID
+	StrategyID := newLogistics.StrategyID
 	Logistics := gorm_model.YoungeeTaskLogistics{
 		LogisticsID:           newLogistics.LogisticsID,
 		TaskID:                newLogistics.TaskID,
@@ -46,15 +46,30 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 		Logistics.CouponCodeInformation = newLogistics.CouponCodeInformation
 	}
 
-	logisticsID, err := db.CreateLogistics(ctx, Logistics, RecruitStrategyID)
+	logisticsID, err := db.CreateLogistics(ctx, Logistics, StrategyID)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[logistics service] call CreateLogistics error,err:%+v", err)
 		return nil, err
 	}
-	// 修改招募策略中已发货待发货数量
-	err = db.UpdateLogisticsNumber(ctx, RecruitStrategyID, 1, -1, 0)
+
+	projectId, err1 := db.GetProjectIdByTaskId(ctx, newLogistics.TaskID)
+	if err1 != nil {
+		logrus.WithContext(ctx).Errorf("[project service] call GetProjectIdByTaskId error,err:%+v", err1)
+		return nil, err1
+	}
+
+	// 查询StrategyID 通过 StrategyID 和 projectId
+	RecruitStrategyId, err2 := db.GetRecruitStrategyIdByTS(ctx, *projectId, StrategyID)
+	if err2 != nil {
+		logrus.WithContext(ctx).Errorf("[project service] call GetStrategyIDByTS error,err:%+v", err1)
+		return nil, err2
+	}
+
+	fmt.Println("RecruitStrategyId: ", *RecruitStrategyId)
+	// 修改招募策略中已签收数量
+	err = db.UpdateLogisticsNumber(ctx, *RecruitStrategyId, 1, -1, 0)
 	if err != nil {
-		logrus.WithContext(ctx).Errorf("[logistics service] call UpdateLogisticsNumber error,err:%+v", err)
+		logrus.WithContext(ctx).Errorf("[project service] call UpdateLogisticsNumber error,err:%+v", err)
 		return nil, err
 	}
 	// 修改task_info中发货状态
@@ -129,15 +144,15 @@ func (*logistics) SignForReceipt(ctx *gin.Context, data http_model.SignForReceip
 			return err1
 		}
 
-		// 查询recruitStrategyID 通过 StrategyID 和 projectId
-		recruitStrategyId, err2 := db.GetRecruitStrategyIdByTS(ctx, *projectId, strategyId)
+		// 查询StrategyID 通过 StrategyID 和 projectId
+		StrategyID, err2 := db.GetRecruitStrategyIdByTS(ctx, *projectId, strategyId)
 		if err2 != nil {
-			logrus.WithContext(ctx).Errorf("[project service] call GetRecruitStrategyIdByTS error,err:%+v", err1)
+			logrus.WithContext(ctx).Errorf("[project service] call GetStrategyIDByTS error,err:%+v", err1)
 			return err2
 		}
 
 		// 修改招募策略中已签收数量
-		err = db.UpdateLogisticsNumber(ctx, *recruitStrategyId, 0, 0, 1)
+		err = db.UpdateLogisticsNumber(ctx, *StrategyID, 0, 0, 1)
 		if err != nil {
 			logrus.WithContext(ctx).Errorf("[project service] call UpdateLogisticsNumber error,err:%+v", err)
 			return err

+ 1 - 1
service/project.go

@@ -110,7 +110,7 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
 		ProjectDetail: newProject.ProjectDetail,
 		ProjectForm:   conv.MustInt64(newProject.ProjectForm),
 		EnterpriseID:  enterpriseID,
-		ProjectStatus: 4,
+		ProjectStatus: 2,
 	}
 	projectID, err := db.UpdateProject(ctx, project)
 	if err != nil {