Browse Source

update tccAdjust

topic
yedf2 4 years ago
parent
commit
7f91f54d36
  1. 2
      admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue
  2. 25
      admin/src/views/Dashboard/GlobalTransactions/_Components/DialogTransactionDetail.vue
  3. 10
      test/busi/busi.go

2
admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue

@ -4,7 +4,7 @@
<template #bodyCell="{column, record}"> <template #bodyCell="{column, record}">
<template v-if="column.key === 'status'"> <template v-if="column.key === 'status'">
<span> <span>
<a-tag :key="record.status" :color="record.status === 'succeed' ? 'green' : 'volcano'">{{ record.status.toUpperCase() }}</a-tag> <a-tag :key="record.status" :color="record.status === 'succeed' ? 'green' : 'volcano'">{{ record.status }}</a-tag>
</span> </span>
</template> </template>
<template v-else-if="column.key === 'action'"> <template v-else-if="column.key === 'action'">

25
admin/src/views/Dashboard/GlobalTransactions/_Components/DialogTransactionDetail.vue

@ -1,14 +1,8 @@
<template> <template>
<div> <div>
<a-modal v-model:visible="visible" title="Transaction Detail" width="80%"> <a-modal v-model:visible="visible" title="Transaction Detail" width="100%" wrap-class-name="full-modal">
<a-table :columns="columns" :data-source="dataSource" :pagination="false"> <a-table :columns="columns" :data-source="dataSource" :pagination="false">
<template #bodyCell="{column, record}"> <template #bodyCell="{column, record}">
<template v-if="column.key === 'op'">
<span class="font-medium">{{ record.op.toUpperCase()}}</span>
</template>
<template v-if="column.key === 'status'">
<span class="font-medium">{{ record.status.toUpperCase()}}</span>
</template>
</template> </template>
</a-table> </a-table>
<div class="mt-10 relative"> <div class="mt-10 relative">
@ -104,3 +98,20 @@ defineExpose({
}) })
</script> </script>
<style lang="postcss">
.full-modal .ant-modal {
max-width: 100%;
top: 0;
padding-bottom: 0;
margin: 0;
}
.full-modal .ant-modal-content {
display: flex;
flex-direction: column;
height: calc(100vh);
}
.full-modal .ant-modal-body {
flex: 1;
}
</style>

10
test/busi/busi.go

@ -106,8 +106,9 @@ func SagaMongoAdjustBalance(ctx context.Context, mc *mongo.Client, uid int, amou
} }
func tccAdjustTrading(db dtmcli.DB, uid int, amount int) error { func tccAdjustTrading(db dtmcli.DB, uid int, amount int) error {
affected, err := dtmimp.DBExec(db, `update dtm_busi.user_account set trading_balance=trading_balance+? affected, err := dtmimp.DBExec(db, `update dtm_busi.user_account
where user_id=? and trading_balance + ? + balance >= 0`, amount, uid, amount) set trading_balance=trading_balance+?
where user_id=? and trading_balance + ? + balance >= 0`, amount, uid, amount)
if err == nil && affected == 0 { if err == nil && affected == 0 {
return fmt.Errorf("update error, maybe balance not enough") return fmt.Errorf("update error, maybe balance not enough")
} }
@ -115,8 +116,9 @@ func tccAdjustTrading(db dtmcli.DB, uid int, amount int) error {
} }
func tccAdjustBalance(db dtmcli.DB, uid int, amount int) error { func tccAdjustBalance(db dtmcli.DB, uid int, amount int) error {
affected, err := dtmimp.DBExec(db, `update dtm_busi.user_account set trading_balance=trading_balance-?, affected, err := dtmimp.DBExec(db, `update dtm_busi.user_account
balance=balance+? where user_id=?`, amount, amount, uid) set trading_balance=trading_balance-?,
balance=balance+? where user_id=?`, amount, amount, uid)
if err == nil && affected == 0 { if err == nil && affected == 0 {
return fmt.Errorf("update user_account 0 rows") return fmt.Errorf("update user_account 0 rows")
} }

Loading…
Cancel
Save