1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

add wallet transaction id to order

This commit is contained in:
Du Peng 2022-08-26 11:19:09 +02:00
parent 8059512f19
commit 939927fb73
4 changed files with 16 additions and 3 deletions

View File

@ -12,4 +12,9 @@ class Order < ApplicationRecord
enum payment_state: PAYMENT_STATES.zip(PAYMENT_STATES).to_h
validates :token, :state, presence: true
def set_wallet_transaction(amount, transaction_id)
self.wallet_amount = amount
self.wallet_transaction_id = transaction_id
end
end

View File

@ -106,9 +106,9 @@ class WalletService
# wallet debit success
raise DebitWalletError unless wallet_transaction
payment.set_wallet_transaction(wallet_amount, wallet_transaction.id) unless payment.is_a? Order
payment.set_wallet_transaction(wallet_amount, wallet_transaction.id)
else
payment.set_wallet_transaction(wallet_amount, nil) unless payment.is_a? Order
payment.set_wallet_transaction(wallet_amount, nil)
end
end
end

View File

@ -0,0 +1,6 @@
class AddWalletAmountAndWalletTransactionIdToOrder < ActiveRecord::Migration[5.2]
def change
add_column :orders, :wallet_amount, :integer
add_column :orders, :wallet_transaction_id, :integer
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_08_26_085923) do
ActiveRecord::Schema.define(version: 2022_08_26_090821) do
# These are extensions that must be enabled in order to support this database
enable_extension "fuzzystrmatch"
@ -468,6 +468,8 @@ ActiveRecord::Schema.define(version: 2022_08_26_085923) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "payment_state"
t.integer "wallet_amount"
t.integer "wallet_transaction_id"
t.index ["statistic_profile_id"], name: "index_orders_on_statistic_profile_id"
end