更改:悬赏金额变更需要同步至链上以及关联疑修新增标记是否解决
This commit is contained in:
parent
d240797c25
commit
6c71994e33
|
@ -227,11 +227,13 @@ class PullRequestsController < ApplicationController
|
|||
|
||||
# 查看是否fix了相关issue,如果fix就转账
|
||||
@pull_request.attached_issues.each do |issue|
|
||||
next if PullAttachedIssue.exist?(issue_id: issue.id, fixed: true)
|
||||
token_num = issue.blockchain_token_num
|
||||
token_num = token_num.nil? ? 0 : token_num
|
||||
author_id = @pull_request.user_id
|
||||
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
|
||||
PullAttachedIssue.find_by(issue_id: issue.id, pull_request_id: @pull_request.id).update(fixed: true)
|
||||
end
|
||||
# update issue to state 5
|
||||
issue.update(status_id: 5)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# issue_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# fixed :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -46,8 +46,8 @@ module Api::V1::Issues::Concerns::Checkable
|
|||
raise ApplicationService::Error, "ParentJournal不存在!" unless Journal.find_by_id(parent_id).present?
|
||||
end
|
||||
|
||||
def check_blockchain_token_num(user_id, project_id, blockchain_token_num)
|
||||
def check_blockchain_token_num(user_id, project_id, blockchain_token_num, now_blockchain_token_num=0)
|
||||
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
|
||||
raise ApplicationService::Error, "项目Token不足。" if blockchain_token_num.to_i > (left_blockchain_token_num+now_blockchain_token_num).to_i
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,7 +42,7 @@ class Api::V1::Issues::UpdateService < ApplicationService
|
|||
check_assigners(assigner_ids) unless assigner_ids.nil?
|
||||
check_attachments(attachment_ids) unless attachment_ids.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?
|
||||
check_blockchain_token_num(project.user_id, project.id, blockchain_token_num, @issue.blockchain_token_num) if blockchain_token_num.present?
|
||||
load_assigners(assigner_ids)
|
||||
load_attachments(attachment_ids)
|
||||
load_issue_tags(issue_tag_ids)
|
||||
|
@ -71,6 +71,7 @@ class Api::V1::Issues::UpdateService < ApplicationService
|
|||
|
||||
build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录
|
||||
build_previous_issue_changes
|
||||
build_cirle_blockchain_token if blockchain_token_num.present?
|
||||
|
||||
# @信息发送
|
||||
AtmeService.call(current_user, @atme_receivers, @issue) unless receivers_login.blank?
|
||||
|
@ -134,6 +135,13 @@ class Api::V1::Issues::UpdateService < ApplicationService
|
|||
end
|
||||
end
|
||||
|
||||
def build_cirle_blockchain_token
|
||||
if @updated_issue.previous_changes["blockchain_token_num"].present?
|
||||
unlock_balance_on_blockchain(@updated_issue.project&.user_id, @updated_issue.project_id, @updated_issue.previous_changes["blockchain_token_num"][0])
|
||||
lock_balance_on_blockchain(@updated_issue.project&.user_id, @updated_issue.project_id, @updated_issue.previous_changes["blockchain_token_num"][1])
|
||||
end
|
||||
end
|
||||
|
||||
def build_issue_project_trends
|
||||
if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][1] == 5
|
||||
@updated_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE})
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddFixedToPullAttachedIssues < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :pull_attached_issues, :fixed, :boolean, default: false
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue