|
@@ -60,6 +60,8 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
+ lock := GetMutex(param.Uid)
|
|
|
+ lock.Lock()
|
|
|
//a类为即时保存
|
|
|
//b、c、d、e为定时保存
|
|
|
log.Println("---请求", param)
|
|
@@ -73,6 +75,7 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
"s_operation": Message["txt_"+param.Code],
|
|
|
"i_type": 1,
|
|
|
"l_date": time.Now().Unix(),
|
|
|
+ "l_datenm": time.Now().UnixNano() / 1000000,
|
|
|
}
|
|
|
i_scorenow := getCreditById(param.Uid)
|
|
|
switch first {
|
|
@@ -91,8 +94,6 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
case "b":
|
|
|
key := param.Code + "_" + param.Uid
|
|
|
//[0/1,time,alltimes] //是否完成,次数,总次数,
|
|
|
- lock := GetMutex(param.Uid)
|
|
|
- lock.Lock()
|
|
|
if param.Code == "b1" { //签到
|
|
|
now := time.Now()
|
|
|
daykey := key + "_" + fmt.Sprintf("%d", now.Day())
|
|
@@ -114,8 +115,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]
|
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(int(newobj[2]-thist)))
|
|
|
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 {
|
|
|
//不是连续签到
|
|
|
bcon = false
|
|
@@ -133,8 +135,9 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code+"_1"]
|
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(int(newobj[2])))
|
|
|
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 {
|
|
@@ -149,8 +152,9 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
redis.Put(consts.RedisDB, key, newobj, GetSubSecond(1))
|
|
|
creditDoc["i_score"] = 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 {
|
|
|
times := Score[param.Code+"_n"]
|
|
@@ -162,15 +166,12 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
|
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":
|
|
|
- lock := GetMutex(param.Uid)
|
|
|
- lock.Lock()
|
|
|
if param.Code == "c1" { //交易
|
|
|
objid := param.OtherParam["objid"]
|
|
|
if objid != nil {
|
|
@@ -186,13 +187,16 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
"i_type": 1,
|
|
|
"s_sourceid": param.Uid,
|
|
|
"l_date": time.Now().Unix(),
|
|
|
+ "l_datenm": time.Now().UnixNano() / 1000000,
|
|
|
"i_score": 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))
|
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
+ if creditlog.Save(creditDoc) && creditlog.Save(newDoc) {
|
|
|
+ *replay = creditDoc["i_score"].(int)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else if param.Code == "c2" { //评价
|
|
@@ -203,29 +207,33 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
|
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))
|
|
|
- *replay = creditDoc["i_score"].(int)
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
creditDoc["i_score"] = Score[param.Code]
|
|
|
creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
|
|
|
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: //定时任务
|
|
|
sc := util.If(param.Num > 0, param.Num, Score[param.Code]).(int)
|
|
|
if sc > 0 {
|
|
|
creditDoc["i_score"] = 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
|
|
|
}
|
|
|
|
|
@@ -256,6 +264,7 @@ func (c *CreditRpc) OutCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
"s_operation": Message["txt_"+param.Code],
|
|
|
"i_type": 0,
|
|
|
"l_date": now.Unix(),
|
|
|
+ "l_datenm": time.Now().UnixNano() / 1000000,
|
|
|
}
|
|
|
if param.OtherParam != nil && param.OtherParam["i_way"] != nil {
|
|
|
creditDoc["i_way"] = param.OtherParam["i_way"]
|
|
@@ -263,7 +272,7 @@ func (c *CreditRpc) OutCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
var newDate time.Time
|
|
|
switch first {
|
|
|
case "A":
|
|
|
- newDate = GetTimeByNow(now, Hour).AddDate(0, 1, 1)
|
|
|
+ newDate = GetTimeByNow(now, Hour).AddDate(0, 1, -1)
|
|
|
creditDoc["l_enddate"] = newDate.Unix()
|
|
|
creditDoc["i_valid"] = 1
|
|
|
if param.OtherParam != nil {
|
|
@@ -301,7 +310,7 @@ func SendMsgWebAndWx(title, content, userId, umid string) {
|
|
|
ReceiveId: userId,
|
|
|
}
|
|
|
go m.SaveMsg()
|
|
|
- go SendManagerNotifyMsg(&qrpc.NotifyMsg{Openid: umid, Title: title, Detail: "管理员", Remark: content})
|
|
|
+ go SendManagerNotifyMsg(&qrpc.NotifyMsg{Openid: umid, Title: title, Detail: "剑鱼君", Remark: content})
|
|
|
|
|
|
}
|
|
|
|
|
@@ -319,6 +328,7 @@ func SendManagerNotifyMsg(p *qrpc.NotifyMsg) {
|
|
|
}
|
|
|
}()
|
|
|
client, err := rpc.DialHTTP("tcp", Rpcserver)
|
|
|
+ defer client.Close()
|
|
|
if err != nil {
|
|
|
log.Println(err.Error())
|
|
|
return
|