Update:余量更新增加redis锁

This commit is contained in:
jiaji.H 2026-04-13 11:05:04 +08:00
parent 4c8db9bec8
commit c267a2781d
2 changed files with 12 additions and 1 deletions

View File

@ -504,6 +504,14 @@ func ArtistAutoConfirmAnalysisTask() {
} }
func UpdateBundleBalance() { func UpdateBundleBalance() {
reply := cache.RedisClient.SetNX(bundleModel.UpdateBundleBalanceLockKey, "1", 30*time.Minute)
if !reply.Val() {
zap.L().Warn("UpdateBundleBalance 任务正在被其他实例处理")
return
}
defer func() {
cache.RedisClient.Del(bundleModel.UpdateBundleBalanceLockKey)
}()
service.BundleProvider.UpdateBundleBalance(context.Background(), &bundle.UpdateBundleBalanceReq{}) service.BundleProvider.UpdateBundleBalance(context.Background(), &bundle.UpdateBundleBalanceReq{})
} }

View File

@ -1,5 +1,9 @@
package bundle package bundle
const (
UpdateBundleBalanceLockKey = "update_bundle_balance:lock"
)
type UserWorkConfirmReq struct { type UserWorkConfirmReq struct {
WorkUuid string `json:"workUuid"` WorkUuid string `json:"workUuid"`
ConfirmRemark string `json:"confirmRemark"` ConfirmRemark string `json:"confirmRemark"`
@ -13,7 +17,6 @@ type UserWorkAnalysisConfirmReq struct {
} }
type GetBundleBalanceListResp struct { type GetBundleBalanceListResp struct {
Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total"` Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total"`
Data []*BundleBalanceItem `protobuf:"bytes,2,rep,name=data,proto3" json:"data"` Data []*BundleBalanceItem `protobuf:"bytes,2,rep,name=data,proto3" json:"data"`
} }