Browse Source

selection_task_status_code

Xingyu Xian 2 weeks ago
parent
commit
fdb1742d6f
3 changed files with 14 additions and 8 deletions
  1. 1 3
      db/sectask.go
  2. 6 1
      handler/PassSecTaskCoop.go
  3. 7 4
      service/sectask_service/sectask.go

+ 1 - 3
db/sectask.go

@@ -227,9 +227,7 @@ func PassSecTaskCoop(ctx context.Context, selectionId string, taskIds []string,
 		return false, err
 		return false, err
 	}
 	}
 	if int64(selection.RemainNum) < count {
 	if int64(selection.RemainNum) < count {
-		if int64(len(taskIds)) == 0 || count != int64(len(taskIds)) {
-			return true, errors.New("剩余选品数量不足")
-		}
+		return true, errors.New("剩余样品数量不足")
 	}
 	}
 
 
 	err = db.Transaction(func(tx *gorm.DB) error {
 	err = db.Transaction(func(tx *gorm.DB) error {

+ 6 - 1
handler/PassSecTaskCoop.go

@@ -37,11 +37,16 @@ func (c PassSecTaskCoop) run() {
 	data = *c.req
 	data = *c.req
 	//auth := middleware.GetSessionAuth(c.ctx)
 	//auth := middleware.GetSessionAuth(c.ctx)
 	//enterpriseID := auth.EnterpriseID
 	//enterpriseID := auth.EnterpriseID
-	res, err := sectask_service.SelectionTask.PassCoop(c.ctx, data)
+	res, tag, err := sectask_service.SelectionTask.PassCoop(c.ctx, data)
 	if err != nil {
 	if err != nil {
 		logrus.Errorf("[PassSecTaskCoop] call PassSecTaskCoop err:%+v\n", err)
 		logrus.Errorf("[PassSecTaskCoop] call PassSecTaskCoop err:%+v\n", err)
 		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
 		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
 		logrus.Info("PassSecTaskCoop fail,req:%+v", c.req)
 		logrus.Info("PassSecTaskCoop fail,req:%+v", c.req)
+		if tag == 1 {
+			c.resp.Message = err.Error()
+			c.resp.Status = 33000
+			return
+		}
 		c.resp.Message = err.Error()
 		c.resp.Message = err.Error()
 		c.resp.Status = 40000
 		c.resp.Status = 40000
 		return
 		return

+ 7 - 4
service/sectask_service/sectask.go

@@ -69,16 +69,19 @@ func (*selectionTask) GetList(ctx context.Context, request http_model.GetSecTask
 	return &selectionListData, nil
 	return &selectionListData, nil
 }
 }
 
 
-func (*selectionTask) PassCoop(ctx context.Context, request http_model.PassSecTaskCoopRequest) (*http_model.PassSecTaskCoopData, error) {
-	_, err := db.PassSecTaskCoop(ctx, request.SelectionId, request.TaskIds, request.EnterpriseId, request.SubAccountId)
+func (*selectionTask) PassCoop(ctx context.Context, request http_model.PassSecTaskCoopRequest) (*http_model.PassSecTaskCoopData, int, error) {
+	tag, err := db.PassSecTaskCoop(ctx, request.SelectionId, request.TaskIds, request.EnterpriseId, request.SubAccountId)
 	if err != nil {
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[sectask_service service] call PassCoop error,err:%+v", err)
 		logrus.WithContext(ctx).Errorf("[sectask_service service] call PassCoop error,err:%+v", err)
-		return nil, err
+		if tag == true {
+			return nil, 1, err
+		}
+		return nil, 2, err
 	}
 	}
 
 
 	selectionListData := http_model.PassSecTaskCoopData{}
 	selectionListData := http_model.PassSecTaskCoopData{}
 
 
-	return &selectionListData, nil
+	return &selectionListData, 0, nil
 }
 }
 
 
 func (*selectionTask) RefuseCoop(ctx context.Context, request http_model.RefuseSecTaskCoopRequest) (*http_model.RefuseSecTaskCoopData, error) {
 func (*selectionTask) RefuseCoop(ctx context.Context, request http_model.RefuseSecTaskCoopRequest) (*http_model.RefuseSecTaskCoopData, error) {