Kaynağa Gözat

更新

master
huangjiajun 10 ay önce
ebeveyn
işleme
7fcc2e77c9
1 değiştirilmiş dosya ile 6 ekleme ve 5 silme
  1. +6
    -5
      rule/consume_integral_settlement.go

+ 6
- 5
rule/consume_integral_settlement.go Dosyayı Görüntüle

@@ -25,7 +25,7 @@ func InitForConsumeIntegral(redisAddr string) (err error) {
return
}

const PessimismLockKeyForConsumeIntegral = "daily_settlement_consume_integral_lock_key"
const PessimismLockKeyForConsumeIntegral = "daily_settlement_consume_integral_lock_key:%s"
const PessimismLockValueForConsumeIntegral = "running"

// DailySettlementBlockConsumeIntegral 每日结算“消费积分”
@@ -34,6 +34,7 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask
defer func() {
session.Close()
if err := recover(); err != nil {

_ = zhios_order_relate_logx.Error(err)
}
}()
@@ -70,9 +71,9 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask
_ = session.Rollback()
return errors.New("今日“消费计费”已结算")
}
key := fmt.Sprintf(PessimismLockKeyForConsumeIntegral, mid)
//TODO::增加“悲观锁”防止串行
getString, _ := cache.GetString(PessimismLockKeyForConsumeIntegral)
getString, _ := cache.GetString(key)
//if err != nil {
// return err
//}
@@ -80,7 +81,7 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次结算未执行完")
return errors.New("上一次结算未执行完")
}
cache.SetEx(PessimismLockKeyForConsumeIntegral, PessimismLockValueForConsumeIntegral, 3600*8) //8小时
cache.SetEx(key, PessimismLockValueForConsumeIntegral, 3600*8) //8小时

var consumeValueTotal, experienceValueTotal = decimal.NewFromInt(0), decimal.NewFromInt(0)
//1、统计当前拥有多少份消费补贴
@@ -152,7 +153,7 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask
return errors.New("事务提交失败")
}

cache.Del(PessimismLockKeyForConsumeIntegral)
cache.Del(key)
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>消费积分结束<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
return nil
}


Yükleniyor…
İptal
Kaydet