浏览代码

Merge branch 'XxY' into develop

Xingyu Xian 4 月之前
父节点
当前提交
58d9d854aa
共有 4 个文件被更改,包括 40 次插入2 次删除
  1. 16 1
      db/sectask.go
  2. 11 0
      db/selection.go
  3. 1 1
      route/init.go
  4. 12 0
      service/sectask_service/logistics.go

+ 16 - 1
db/sectask.go

@@ -180,6 +180,7 @@ func PassSecTaskCoop(ctx context.Context, selectionId string, taskIds []string)
 			if err != nil {
 				return err
 			}
+
 		} else {
 			// 免费领样
 			updateData := gorm_model.YounggeeSecTaskInfo{
@@ -193,14 +194,28 @@ func PassSecTaskCoop(ctx context.Context, selectionId string, taskIds []string)
 			if err != nil {
 				return err
 			}
+			// 3.2  更新带货任务待发货人数
+			err = tx.Model(gorm_model.YounggeeSelectionInfo{}).Where("selection_id = ?", selectionId).Updates(
+				map[string]interface{}{"before_delivery_num": gorm.Expr("before_delivery_num + ?", 1)}).Error
+			if err != nil {
+				return err
+			}
+
 		}
-		// 3. 更新选品剩余数量
+		// 3.1 更新选品剩余数量
 		err = tx.Model(gorm_model.YounggeeSelectionInfo{}).Where("selection_id = ?", selectionId).Updates(
 			map[string]interface{}{"remain_num": gorm.Expr("remain_num - ?", 1)}).Error
 		if err != nil {
 			return err
 		}
 
+		// 3.2  更新带货任务已选人数
+		err = tx.Model(gorm_model.YounggeeSelectionInfo{}).Where("selection_id = ?", selectionId).Updates(
+			map[string]interface{}{"choose_num": gorm.Expr("choose_num + ?", 1)}).Error
+		if err != nil {
+			return err
+		}
+
 		// 4. 生成达人消息
 		for _, talendId := range talentIds {
 			err = CreateMessage(ctx, 1, 1, talendId, selection.SelectionName)

+ 11 - 0
db/selection.go

@@ -328,3 +328,14 @@ func GetSelectionInfoList(ctx context.Context, pageNum, pageSize int64, conditio
 	newSelectionInfos := pack.GormSelectionListToSelectionBriefInfoList(tempList)
 	return newSelectionInfos, total, nil
 }
+
+// UpdateSelectionNum 更新带货任务已发货人数
+func UpdateSelectionNum(ctx context.Context, selectionID string) error {
+	db := GetWriteDB(ctx)
+	err := db.Model(gorm_model.YounggeeSelectionInfo{}).Where("selection_id = ?", selectionID).Updates(
+		map[string]interface{}{"delivery_num": gorm.Expr("delivery_num + ?", 1)}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 1 - 1
route/init.go

@@ -152,7 +152,7 @@ func InitRoute(r *gin.Engine) {
 		s.POST("/selection/task/list", handler.WrapGetSecTaskListHandler)                     // 查询选品的任务列表(确定、发货、结算)
 		s.POST("/selection/task/coop/pass", handler.WrapPassSecTaskCoopHandler)               // 同意任务合作
 		s.POST("/selection/task/coop/refuse", handler.WrapRefuseSecTaskCoopHandler)           // 拒绝任务合作
-		s.POST("/selection/task/logistics/create", handler.WrapCreateSecTaskLogisticsHandler) // 上传物流信息 **
+		s.POST("/selection/task/logistics/create", handler.WrapCreateSecTaskLogisticsHandler) // 上传物流信息
 		s.POST("/selection/task/logistics/update", handler.WrapUpdateSecTaskLogisticsHandler) // 修改物流信息
 		s.POST("/selection/task/settle", handler.WrapSettleSecTaskHandler)                    // 结算
 		s.POST("/selection/getAllSelection", handler.WrapGetAllSelectionHandler)              // 查询选品广场选品列表

+ 12 - 0
service/sectask_service/logistics.go

@@ -49,12 +49,24 @@ func (*logistics) Create(ctx context.Context, request http_model.CreateSecTaskLo
 		DeliveryDate:    time.Now(),
 		FreeStage:       4,
 	}
+
 	_, err = db.UpdateSecTask(ctx, updatdSecTask)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[sectask logistics service] call UpdateSecTask error,err:%+v", err)
 		return nil, err
 	}
 
+	taskInfo, taskErr := db.GetSecTaskById(ctx, request.TaskID)
+	if taskErr != nil {
+		return nil, taskErr
+	}
+
+	// 更新带货任务已发货人数
+	err = db.UpdateSelectionNum(ctx, taskInfo.SelectionID)
+	if err != nil {
+		return nil, err
+	}
+
 	// 插入任务日志、达人消息
 	err = db.CreateTaskLog(ctx, newLogistics.TaskID, "发货时间")
 	if err != nil {