| @@ -231,7 +231,7 @@ class PullRequestsController < ApplicationController | |||||
| token_num = token_num.nil? ? 0 : token_num | token_num = token_num.nil? ? 0 : token_num | ||||
| author_id = @pull_request.user_id | author_id = @pull_request.user_id | ||||
| if token_num > 0 | if token_num > 0 | ||||
| Blockchain::FixIssue.call({user_id: author_id.to_s, project_id: project.id.to_s, token_num: token_num}) if Site.has_blockchain? && @project.use_blockchain | |||||
| Blockchain::FixIssue.call({user_id: author_id.to_s, project_id: @project.id.to_s, token_num: token_num}) if Site.has_blockchain? && @project.use_blockchain | |||||
| end | end | ||||
| # update issue to state 5 | # update issue to state 5 | ||||
| issue.update(status_id: 5) | issue.update(status_id: 5) | ||||
| @@ -45,4 +45,9 @@ module Api::V1::Issues::Concerns::Checkable | |||||
| def check_parent_journal(parent_id) | def check_parent_journal(parent_id) | ||||
| raise ApplicationService::Error, "ParentJournal不存在!" unless Journal.find_by_id(parent_id).present? | raise ApplicationService::Error, "ParentJournal不存在!" unless Journal.find_by_id(parent_id).present? | ||||
| end | end | ||||
| def check_blockchain_token_num(user_id, project_id, blockchain_token_num) | |||||
| left_blockchain_token_num = Blockchain::BalanceQueryOneProject.call({"user_id": user_id, "project_id": project_id}) rescue 0 | |||||
| raise ApplicationService::Error, "项目Token不足。" if blockchain_token_num > left_blockchain_token_num | |||||
| end | |||||
| end | end | ||||
| @@ -41,6 +41,7 @@ class Api::V1::Issues::CreateService < ApplicationService | |||||
| check_assigners(assigner_ids) unless assigner_ids.blank? | check_assigners(assigner_ids) unless assigner_ids.blank? | ||||
| check_attachments(attachment_ids) unless attachment_ids.blank? | check_attachments(attachment_ids) unless attachment_ids.blank? | ||||
| check_atme_receivers(receivers_login) unless receivers_login.blank? | check_atme_receivers(receivers_login) unless receivers_login.blank? | ||||
| check_blockchain_token_num(project.user_id, project.id, blockchain_token_num) if blockchain_token_num.present? | |||||
| load_assigners(assigner_ids) unless assigner_ids.blank? | load_assigners(assigner_ids) unless assigner_ids.blank? | ||||
| load_attachments(attachment_ids) unless attachment_ids.blank? | load_attachments(attachment_ids) unless attachment_ids.blank? | ||||
| load_issue_tags(issue_tag_ids) unless issue_tag_ids.blank? | load_issue_tags(issue_tag_ids) unless issue_tag_ids.blank? | ||||
| @@ -42,6 +42,7 @@ class Api::V1::Issues::UpdateService < ApplicationService | |||||
| check_assigners(assigner_ids) unless assigner_ids.nil? | check_assigners(assigner_ids) unless assigner_ids.nil? | ||||
| check_attachments(attachment_ids) unless attachment_ids.nil? | check_attachments(attachment_ids) unless attachment_ids.nil? | ||||
| check_atme_receivers(receivers_login) unless receivers_login.nil? | check_atme_receivers(receivers_login) unless receivers_login.nil? | ||||
| check_blockchain_token_num(project.user_id, project.id, blockchain_token_num) if blockchain_token_num.present? | |||||
| load_assigners(assigner_ids) | load_assigners(assigner_ids) | ||||
| load_attachments(attachment_ids) | load_attachments(attachment_ids) | ||||
| load_issue_tags(issue_tag_ids) | load_issue_tags(issue_tag_ids) | ||||