fix
This commit is contained in:
parent
23b4d166ec
commit
8fca291eb0
|
@ -108,15 +108,35 @@ func (m *Mysql) CreateZoneUnlock(ctx *gin.Context, tx *sqlx.Tx, mid, zid int64)
|
|||
return nil
|
||||
}
|
||||
|
||||
// 解锁空间动态
|
||||
// 添加到空间成员
|
||||
func (m *Mysql) UnlockZoneMoment(ctx *gin.Context, tx *sqlx.Tx, mid, zid, momentId int64, orderId string) error {
|
||||
var err error
|
||||
sqlStr := "update " + TableVasZoneMomentUnlock + " set moment_id=?, `status`=?, ct=?, order_id=? where mid=? and zid=?"
|
||||
// 先获取,没有再添加
|
||||
var tmpZm dbstruct.ZoneMomentUnlock
|
||||
if tx != nil {
|
||||
_, err = tx.ExecContext(ctx, sqlStr, momentId, dbstruct.ZoneMomentUnlockStatusUnlock, time.Now().Unix(), orderId, mid, zid)
|
||||
err = tx.GetContext(ctx, &tmpZm, fmt.Sprintf("select * from %s where mid=? and zid=? and moment_id=?", TableVasZoneMomentUnlock), mid, zid, momentId)
|
||||
} else {
|
||||
db := m.getDBVas()
|
||||
_, err = db.ExecContext(ctx, sqlStr, momentId, dbstruct.ZoneMomentUnlockStatusUnlock, time.Now().Unix(), orderId, mid, zid)
|
||||
err = db.GetContext(ctx, &tmpZm, fmt.Sprintf("select * from %s where mid=? and zid=? and moment_id=?", TableVasZoneMomentUnlock), mid, zid, momentId)
|
||||
}
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if tmpZm.IsUnlock() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 再添加
|
||||
sqlStr := "insert into " + TableVasZoneMember + " (mid,zid,moment_id,status,ct,order_id) " + " values (?,?,?,?,?,?)"
|
||||
args := []any{mid, zid, momentId, dbstruct.ZoneMomentUnlockStatusLock, time.Now().Unix(), orderId}
|
||||
if tx != nil {
|
||||
_, err = tx.ExecContext(ctx, sqlStr, args...)
|
||||
} else {
|
||||
db := m.getDBVas()
|
||||
_, err = db.ExecContext(ctx, sqlStr, args...)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -417,7 +417,7 @@ func (v *Vas) UnlockZoneIronfanshipReachConsume(ctx *gin.Context, tx *sqlx.Tx, m
|
|||
|
||||
// 获取空间价格
|
||||
zVas, _ := v.store.GetZoneVasById(ctx, zid)
|
||||
if zVas != nil {
|
||||
if zVas == nil {
|
||||
return fmt.Errorf("zone vas not exist, zid: %v", zid)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue