|
@@ -60,6 +60,8 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
|
|
+ lock := GetMutex(param.Uid)
|
|
|
|
+ lock.Lock()
|
|
//a类为即时保存
|
|
//a类为即时保存
|
|
//b、c、d、e为定时保存
|
|
//b、c、d、e为定时保存
|
|
log.Println("---请求", param)
|
|
log.Println("---请求", param)
|
|
@@ -91,8 +93,6 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
case "b":
|
|
case "b":
|
|
key := param.Code + "_" + param.Uid
|
|
key := param.Code + "_" + param.Uid
|
|
//[0/1,time,alltimes] //是否完成,次数,总次数,
|
|
//[0/1,time,alltimes] //是否完成,次数,总次数,
|
|
- lock := GetMutex(param.Uid)
|
|
|
|
- lock.Lock()
|
|
|
|
if param.Code == "b1" { //签到
|
|
if param.Code == "b1" { //签到
|
|
now := time.Now()
|
|
now := time.Now()
|
|
daykey := key + "_" + fmt.Sprintf("%d", now.Day())
|
|
daykey := key + "_" + fmt.Sprintf("%d", now.Day())
|
|
@@ -114,8 +114,9 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code+"_1"] + int(thist)*Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code+"_1"] + int(thist)*Score[param.Code]
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(int(newobj[2]-thist)))
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(int(newobj[2]-thist)))
|
|
redis.Put(consts.RedisDB, daykey, true, GetSubSecond(1))
|
|
redis.Put(consts.RedisDB, daykey, true, GetSubSecond(1))
|
|
- creditlog.AddLog(creditDoc)
|
|
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
|
|
|
+ if creditlog.Save(creditDoc) {
|
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
//不是连续签到
|
|
//不是连续签到
|
|
bcon = false
|
|
bcon = false
|
|
@@ -133,8 +134,9 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code+"_1"]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code+"_1"]
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(int(newobj[2])))
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(int(newobj[2])))
|
|
redis.Put(consts.RedisDB, daykey, true, GetSubSecond(1))
|
|
redis.Put(consts.RedisDB, daykey, true, GetSubSecond(1))
|
|
- creditlog.AddLog(creditDoc)
|
|
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
|
|
|
+ if creditlog.Save(creditDoc) {
|
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -149,8 +151,9 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(1))
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(1))
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
- creditlog.AddLog(creditDoc)
|
|
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
|
|
|
+ if creditlog.Save(creditDoc) {
|
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
times := Score[param.Code+"_n"]
|
|
times := Score[param.Code+"_n"]
|
|
@@ -162,15 +165,12 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(1))
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(1))
|
|
- creditlog.AddLog(creditDoc)
|
|
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
|
|
|
+ if creditlog.Save(creditDoc) {
|
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- lock.Unlock()
|
|
|
|
- //
|
|
|
|
case "c":
|
|
case "c":
|
|
- lock := GetMutex(param.Uid)
|
|
|
|
- lock.Lock()
|
|
|
|
if param.Code == "c1" { //交易
|
|
if param.Code == "c1" { //交易
|
|
objid := param.OtherParam["objid"]
|
|
objid := param.OtherParam["objid"]
|
|
if objid != nil {
|
|
if objid != nil {
|
|
@@ -189,10 +189,12 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
"i_score": Score[param.Code],
|
|
"i_score": Score[param.Code],
|
|
"i_scorenow": i_scorenow + Score[param.Code],
|
|
"i_scorenow": i_scorenow + Score[param.Code],
|
|
}
|
|
}
|
|
- creditlog.AddLog(creditDoc)
|
|
|
|
- creditlog.AddLog(newDoc)
|
|
|
|
|
|
+ //creditlog.AddLog(creditDoc)
|
|
|
|
+ //creditlog.AddLog(newDoc)
|
|
redis.Put(consts.RedisDB, key, true, GetSubSecond(1))
|
|
redis.Put(consts.RedisDB, key, true, GetSubSecond(1))
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
|
|
|
+ if creditlog.Save(creditDoc) && creditlog.Save(newDoc) {
|
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if param.Code == "c2" { //评价
|
|
} else if param.Code == "c2" { //评价
|
|
@@ -203,29 +205,33 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
creditDoc["o_param"] = param.OtherParam
|
|
creditDoc["o_param"] = param.OtherParam
|
|
- creditlog.AddLog(creditDoc)
|
|
|
|
|
|
+ if creditlog.Save(creditDoc) {
|
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
|
+ }
|
|
redis.Put(consts.RedisDB, key, true, GetSubSecond(1))
|
|
redis.Put(consts.RedisDB, key, true, GetSubSecond(1))
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
creditDoc["o_param"] = param.OtherParam
|
|
creditDoc["o_param"] = param.OtherParam
|
|
- creditlog.AddLog(creditDoc)
|
|
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
|
|
|
+ if creditlog.Save(creditDoc) {
|
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- lock.Unlock()
|
|
|
|
default: //定时任务
|
|
default: //定时任务
|
|
sc := util.If(param.Num > 0, param.Num, Score[param.Code]).(int)
|
|
sc := util.If(param.Num > 0, param.Num, Score[param.Code]).(int)
|
|
if sc > 0 {
|
|
if sc > 0 {
|
|
creditDoc["i_score"] = sc
|
|
creditDoc["i_score"] = sc
|
|
creditDoc["i_scorenow"] = i_scorenow + sc
|
|
creditDoc["i_scorenow"] = i_scorenow + sc
|
|
- creditlog.AddLog(creditDoc)
|
|
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
|
|
|
+ if creditlog.Save(creditDoc) {
|
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ lock.Unlock()
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|