dengbiao 1 giorno fa
parent
commit
c368424c34
1 ha cambiato i file con 12 aggiunte e 20 eliminazioni
  1. +12
    -20
      consume/egg_fin_withdraw_apply_consume.go

+ 12
- 20
consume/egg_fin_withdraw_apply_consume.go Vedi File

@@ -61,6 +61,12 @@ func EggFinWithdrawApplyDataConsume(queue md.MqQueue) {
"body": res.Body,
"err": err.Error(),
}))
//// 如果需要重试 推回队尾
//if err.Error() == "Lock wait timeout exceeded; try restarting transaction" {
// var msg *md.CommUserId
// json.Unmarshal(res.Body, &msg)
// ch.Publish(queue.ExchangeName, msg, queue.RoutKey)
//}

var data md2.EggFinWithdrawApplyErrorData
data.ErrorInfo = err.Error()
@@ -108,17 +114,9 @@ func handleEggFinWithdrawApplyDataConsume(msgData []byte, client *alipay.Client,
return errors.New("提现记录无需处理~")
}

session := db.Db.NewSession()
defer func() {
session.Close()
if err := recover(); err != nil {
_ = logx.Error(err)
}
}()
session.Begin()
// 2.3 更新 apply 信息
apply.State = 2
affected, err2 := applyDb.UpdateFinWithdrawApplyBySession(session, apply, "state")
affected, err2 := applyDb.UpdateFinWithdrawApply(apply, "state")
if err2 != nil {
return err2
}
@@ -144,24 +142,18 @@ func handleEggFinWithdrawApplyDataConsume(msgData []byte, client *alipay.Client,
})
_, err = client.FundTransUniTransfer(context.Background(), bm)
if err != nil {
// 如果需要重试 推回队尾
if err.Error() == "Lock wait timeout exceeded; try restarting transaction" {
ch.Publish(md2.EggAppExchange, msg, md2.EggFinWithdrawApply)
return nil
}
//TODO::处理提现失败
err = dealFinWithdrawApplyStateForBad(apply)
if err != nil {
return err
err11 := dealFinWithdrawApplyStateForBad(apply)
if err11 != nil {
return errors.New("处理提现失败:" + err11.Error())
}
session.Rollback()
return err
}
} else if msg.WithdrawKind == 2 {

}

return session.Commit()
return nil
}

func dealFinWithdrawApplyStateForBad(finWithdrawApply *model.FinWithdrawApply) error {
@@ -179,7 +171,7 @@ func dealFinWithdrawApplyStateForBad(finWithdrawApply *model.FinWithdrawApply) e
return errors.New("更新提现单状态失败")
}
dealUserWalletReq := md3.DealUserWalletReq{
Direction: "sub",
Direction: "add",
Kind: int(enum.UserWithdrawBad),
Title: enum.UserWithdrawBad.String(),
Uid: finWithdrawApply.Uid,


Caricamento…
Annulla
Salva