|
@@ -31,6 +31,7 @@ const (
|
|
|
A_WCJY = "a14" //完成交易
|
|
|
A_WCJYPJ = "a15" //完成交易评价
|
|
|
A_JYSCTS = "a63" //剑鱼首次推送
|
|
|
+ A_ALL = "a64" //一次性积分任务完成
|
|
|
|
|
|
B_QD = "b1" //签到
|
|
|
B_QD_T = 7 //最高连续签到次数
|
|
@@ -76,6 +77,8 @@ func InCreditA(userId, code string, credit_a int) (bool, int, int, error) {
|
|
|
err := Rc.InCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: 0, OtherParam: param}, &Replay)
|
|
|
if err == nil && Replay > 0 {
|
|
|
result, credit_a = UpuserCreditA(code, userId, credit_a)
|
|
|
+ } else {
|
|
|
+ log.Println("调用rpc出错", err)
|
|
|
}
|
|
|
return result, credit_a, Replay, err
|
|
|
}
|
|
@@ -102,8 +105,10 @@ func InCreditB(userId, code string, param map[string]interface{}) (bool, int, er
|
|
|
}
|
|
|
var Replay int
|
|
|
err := Rc.InCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: 0, OtherParam: param}, &Replay)
|
|
|
- if err == nil && Replay > 0 {
|
|
|
+ if err == nil && Replay != 0 {
|
|
|
b = true
|
|
|
+ } else {
|
|
|
+ log.Println("调用rpc出错", err)
|
|
|
}
|
|
|
return b, Replay, err
|
|
|
}
|
|
@@ -168,7 +173,7 @@ func OutCreditB(userId, code, umid string, score int, param map[string]interface
|
|
|
b = true
|
|
|
}
|
|
|
if b {
|
|
|
- xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))-Replay)
|
|
|
+ xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+Replay)
|
|
|
}
|
|
|
return b, Replay
|
|
|
}
|
|
@@ -177,28 +182,34 @@ func OutCreditB(userId, code, umid string, score int, param map[string]interface
|
|
|
func UpuserCreditSession(userId, code, dtype string, param map[string]interface{}, xb *xweb.Action) bool {
|
|
|
b := false
|
|
|
score := 0
|
|
|
- if dtype == "A" {
|
|
|
- credit_a := util.IntAll(xb.GetSession("credit_a"))
|
|
|
- b, credit_a, score, _ = InCreditA(userId, code, credit_a)
|
|
|
- if b {
|
|
|
- xb.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
|
|
|
- xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
|
|
|
- } else {
|
|
|
- log.Println(userId, code, "一次性任务送积分失败")
|
|
|
- }
|
|
|
- if AAllIsHasDo(credit_a) {
|
|
|
- b, _, _, _ := InCreditA(userId, "a64", credit_a)
|
|
|
+ util.Try(func() {
|
|
|
+ if dtype == "A" {
|
|
|
+ credit_a := util.IntAll(xb.GetSession("credit_a"))
|
|
|
+ b, credit_a, score, _ = InCreditA(userId, code, credit_a)
|
|
|
if b {
|
|
|
- log.Println(userId, "完成所有一次性任务")
|
|
|
+ xb.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
|
|
|
+ xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
|
|
|
+ } else {
|
|
|
+ log.Println(userId, code, "一次性任务送积分失败")
|
|
|
+ }
|
|
|
+ if AAllIsHasDo(credit_a) {
|
|
|
+ b, _, _, err := InCreditA(userId, A_ALL, credit_a)
|
|
|
+ if b {
|
|
|
+ log.Println(userId, "完成所有一次性任务,送分成功")
|
|
|
+ } else {
|
|
|
+ log.Println(userId, "完成所有一次性任务,送分失败", err)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- b, score, _ = InCreditB(userId, code, param)
|
|
|
- if b {
|
|
|
- xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
|
|
|
} else {
|
|
|
- log.Println(userId, code, param, "任务送积分失败")
|
|
|
+ b, score, _ = InCreditB(userId, code, param)
|
|
|
+ if b {
|
|
|
+ xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
|
|
|
+ } else {
|
|
|
+ log.Println(userId, code, param, "任务送积分失败")
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ }, func(e interface{}) {
|
|
|
+ log.Println("更新积分和session出错", e)
|
|
|
+ })
|
|
|
return b
|
|
|
}
|