Ver a proveniência

更新

master
huangjiajun há 1 ano
ascendente
cometimento
7fcc2e77c9
1 ficheiros alterados com 6 adições e 5 eliminações
  1. +6
    -5
      rule/consume_integral_settlement.go

+ 6
- 5
rule/consume_integral_settlement.go Ver ficheiro

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


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


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

_ = zhios_order_relate_logx.Error(err) _ = zhios_order_relate_logx.Error(err)
} }
}() }()
@@ -70,9 +71,9 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask
_ = session.Rollback() _ = session.Rollback()
return errors.New("今日“消费计费”已结算") return errors.New("今日“消费计费”已结算")
} }
key := fmt.Sprintf(PessimismLockKeyForConsumeIntegral, mid)
//TODO::增加“悲观锁”防止串行 //TODO::增加“悲观锁”防止串行
getString, _ := cache.GetString(PessimismLockKeyForConsumeIntegral)
getString, _ := cache.GetString(key)
//if err != nil { //if err != nil {
// return err // return err
//} //}
@@ -80,7 +81,7 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次结算未执行完") fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次结算未执行完")
return errors.New("上一次结算未执行完") 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) var consumeValueTotal, experienceValueTotal = decimal.NewFromInt(0), decimal.NewFromInt(0)
//1、统计当前拥有多少份消费补贴 //1、统计当前拥有多少份消费补贴
@@ -152,7 +153,7 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask
return errors.New("事务提交失败") return errors.New("事务提交失败")
} }


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


Carregando…
Cancelar
Guardar