Jelajahi Sumber

结束带货任务

Ethan 2 minggu lalu
induk
melakukan
3a67179076

+ 6 - 5
app/controller/task_controller.go

@@ -216,14 +216,15 @@ func (t TaskController) SelectionClose(c *gin.Context) {
 		returnError(c, 40000, "Parameter Error: "+err.Error())
 		return
 	}
-	selectionId, err := service.SelectionInfoService{}.CloseSelection(param.SelectionId)
-	if err != nil {
-		logrus.Errorf("[CloseSelection] call CloseSelection err:%+v\n", err)
-		returnError(c, 40000, err.Error())
+	todo, err1 := service.SelectionInfoService{}.CloseSelection(param.SelectionId)
+	if err1 != nil {
+		logrus.Errorf("[CloseSelection] call CloseSelection err:%+v\n", err1)
+		returnError(c, 40000, err1.Error())
 		return
 	}
 	resultMap := make(map[string]string)
-	resultMap["selectionId"] = *selectionId
+	resultMap["selectionId"] = param.SelectionId
+	resultMap["todo"] = todo
 	returnSuccess(c, 20000, resultMap)
 }
 

+ 3 - 0
app/service/local_life_service.go

@@ -978,6 +978,9 @@ func (s LocalLifeService) DeleteLocalLife(localId string) (*string, error) {
 
 // 结束本地生活任务
 func (s LocalLifeService) CloseLocalLife(localId string) (*string, error) {
+	// TODO 根据当前任务状态判断是否有待办
+	// 任务待办:待审核、待支付、达人未处理、初稿待审、链接待审、待结算  (待发货、待签收)  达人待预约探店时间、探店时间待确认、达人待探店  未传初稿、未发作品、未传数据
+	// 合作待办:可邀约、邀约中、合作中
 	err := dao.LocalLifeDao{}.UpdateLocal(entity.LocalLifeInfo{
 		LocalID:    localId,
 		TaskStatus: 10,

+ 3 - 0
app/service/project_service.go

@@ -942,6 +942,9 @@ func (s ProjectService) DeleteProject(projectId string) (*string, error) {
 
 // 结束种草任务
 func (s ProjectService) CloseProject(projectId string) (*string, error) {
+	// TODO 根据当前任务状态判断是否有待办
+	// 任务待办:待审核、待支付、达人未处理、初稿待审、链接待审、待结算  待发货、待签收  未传初稿、未发作品、未传数据
+	// 合作待办:可邀约、邀约中、合作中
 	err := dao.ProjectDAO{}.UpdateProject(entity.Project{
 		ProjectId:     projectId,
 		ProjectStatus: 10,

+ 28 - 7
app/service/selection_info_service.go

@@ -888,13 +888,34 @@ func (s SelectionInfoService) DeleteSelection(selectionId string) (*string, erro
 }
 
 // 结束带货任务
-func (s SelectionInfoService) CloseSelection(selectionId string) (*string, error) {
-	err := dao.SelectionInfoDAO{}.UpdateSelectionInfo(entity.SelectionInfo{
-		SelectionID:     selectionId,
-		SelectionStatus: 8,
-		UpdatedAt:       time.Now(),
-	})
-	return &selectionId, err
+func (s SelectionInfoService) CloseSelection(selectionId string) (string, error) {
+	// 任务待办:待审核、待支付、达人未处理  待发货、待签收  未传初稿、未发作品、未传数据
+	selectionInfo, err := dao.SelectionInfoDAO{}.GetSelectionInfoById(selectionId)
+	if err != nil {
+		return "0", err
+	}
+	if selectionInfo == nil {
+		return "0", errors.New("任务不存在")
+	}
+	var needProcess int64
+	var logisticsToDo int64
+	if selectionInfo.SelectionStatus == 6 {
+		// 达人未处理
+		_ = dao.Db.Model(&entity.SecTaskInfo{}).Where("selection_id = ? and task_status = ?", selectionId, 1).Count(&needProcess).Error // task_status=1待选
+		// 物流待办
+		_ = dao.Db.Model(&entity.SecTaskInfo{}).Where("selection_id = ? and logistics_status != ?", selectionId, 3).Count(&logisticsToDo).Error
+	}
+	if selectionInfo.SelectionStatus == 2 || selectionInfo.SelectionStatus == 4 || (selectionInfo.SelectionStatus == 6 && needProcess+logisticsToDo > 0) {
+		// 存在待办不可结束
+		return "1", nil
+	} else {
+		err = dao.SelectionInfoDAO{}.UpdateSelectionInfo(entity.SelectionInfo{
+			SelectionID:     selectionId,
+			SelectionStatus: 8,
+			UpdatedAt:       time.Now(),
+		})
+		return "0", err
+	}
 }
 
 // 电商带货选达人角标 未处理、同意合作、拒绝合作