This commit is contained in:
@@ -131,9 +131,8 @@ func (l *CloseOrderLogic) CloseOrder(req *types.CloseOrderRequest) error {
|
||||
)
|
||||
return err
|
||||
}
|
||||
// update user cache
|
||||
return l.svcCtx.UserModel.UpdateUserCache(l.ctx, userInfo)
|
||||
}
|
||||
// Note: user cache will be updated after transaction commits
|
||||
if sub.Inventory != -1 {
|
||||
sub.Inventory++
|
||||
if e := l.svcCtx.SubscribeModel.Update(l.ctx, sub, tx); e != nil {
|
||||
@@ -151,6 +150,19 @@ func (l *CloseOrderLogic) CloseOrder(req *types.CloseOrderRequest) error {
|
||||
logger.Errorf("[CloseOrder] Transaction failed: %v", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
// Update user cache after transaction commits successfully
|
||||
if orderInfo.GiftAmount > 0 && orderInfo.UserId != 0 {
|
||||
if userInfo, findErr := l.svcCtx.UserModel.FindOne(l.ctx, orderInfo.UserId); findErr == nil {
|
||||
if clearErr := l.svcCtx.UserModel.ClearUserCache(l.ctx, userInfo); clearErr != nil {
|
||||
l.Errorw("[CloseOrder] failed to clear user cache",
|
||||
logger.Field("error", clearErr.Error()),
|
||||
logger.Field("user_id", orderInfo.UserId),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user