fix tx in tz

This commit is contained in:
boufni95 2024-02-23 17:12:41 +01:00
parent 204d2990cb
commit 02db6f030c
2 changed files with 5 additions and 5 deletions

View file

@ -485,9 +485,9 @@ export default class {
const toIncrement = amount - fee
await this.storage.userStorage.DecrementUserBalance(fromUser.user_id, amount, tx)
await this.storage.userStorage.IncrementUserBalance(toUser.user_id, toIncrement, tx)
await this.storage.paymentStorage.AddUserToUserPayment(fromUserId, toUserId, amount, fee, linkedApplication)
await this.storage.paymentStorage.AddUserToUserPayment(fromUserId, toUserId, amount, fee, linkedApplication, tx)
if (isAppUserPayment && fee > 0) {
await this.storage.userStorage.IncrementUserBalance(linkedApplication.owner.user_id, fee)
await this.storage.userStorage.IncrementUserBalance(linkedApplication.owner.user_id, fee, tx)
}
sentAmount = toIncrement
})

View file

@ -228,8 +228,8 @@ export default class {
return found
}
async AddUserToUserPayment(fromUserId: string, toUserId: string, amount: number, fee: number, linkedApplication: Application) {
const newKey = this.DB.getRepository(UserToUserPayment).create({
async AddUserToUserPayment(fromUserId: string, toUserId: string, amount: number, fee: number, linkedApplication: Application, dbTx: DataSource | EntityManager) {
const newKey = dbTx.getRepository(UserToUserPayment).create({
from_user: await this.userStorage.GetUser(fromUserId),
to_user: await this.userStorage.GetUser(toUserId),
paid_at_unix: Math.floor(Date.now() / 1000),
@ -237,7 +237,7 @@ export default class {
service_fees: fee,
linkedApplication
})
return this.txQueue.PushToQueue<UserToUserPayment>({ exec: async db => db.getRepository(UserToUserPayment).save(newKey), dbTx: false })
return dbTx.getRepository(UserToUserPayment).save(newKey)
}
GetUserToUserReceivedPayments(userId: string, fromIndex: number, take = 50, entityManager = this.DB) {