Skip to content

Commit

Permalink
fix: refund bug
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpiotzh committed Mar 21, 2022
1 parent 79c1877 commit 190467b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dao/t_das_order_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (d *DbDao) GetOrderByOrderId(orderId string) (order tables.TableDasOrderInf

func (d *DbDao) UpdatePayStatus(payInfo *tables.TableDasOrderPayInfo) error {
return d.db.Transaction(func(tx *gorm.DB) error {
if err := d.db.Model(tables.TableDasOrderInfo{}).
if err := tx.Model(tables.TableDasOrderInfo{}).
Where("order_id=? AND order_type=? AND pay_status=?",
payInfo.OrderId, tables.OrderTypeSelf, tables.TxStatusDefault).
Updates(map[string]interface{}{
Expand All @@ -23,7 +23,7 @@ func (d *DbDao) UpdatePayStatus(payInfo *tables.TableDasOrderPayInfo) error {
return err
}

if err := d.db.Model(tables.TableDasOrderPayInfo{}).
if err := tx.Model(tables.TableDasOrderPayInfo{}).
Where("order_id=? AND `hash`!=? AND status=? AND refund_status=?",
payInfo.OrderId, payInfo.Hash, tables.OrderTxStatusConfirm, tables.TxStatusDefault).
Updates(map[string]interface{}{
Expand All @@ -32,9 +32,9 @@ func (d *DbDao) UpdatePayStatus(payInfo *tables.TableDasOrderPayInfo) error {
return err
}

if err := d.db.Clauses(clause.OnConflict{
if err := tx.Clauses(clause.OnConflict{
DoUpdates: clause.AssignmentColumns([]string{
"chain_type", "address", "status", "account_id", "refund_status", "refund_hash",
"chain_type", "address", "status", "account_id",
}),
}).Create(&payInfo).Error; err != nil {
return err
Expand Down

0 comments on commit 190467b

Please sign in to comment.