zhangjinkun@topnet.net.cn пре 9 година
родитељ
комит
2944fb353c
2 измењених фајлова са 27 додато и 3 уклоњено
  1. 17 0
      common/src/qfw/util/credit/credit.go
  2. 10 3
      core/src/qfw/active/flop.go

+ 17 - 0
common/src/qfw/util/credit/credit.go

@@ -8,6 +8,7 @@ import (
 	"qfw/util"
 	mogo "qfw/util/mongodb"
 	"qfw/util/rpc"
+	"time"
 )
 
 var Rc rpc.RpcCall
@@ -215,3 +216,19 @@ func UpuserCreditSession(userId, code, dtype string, param map[string]interface{
 	})
 	return b
 }
+
+//其他更新积分接口--如 翻牌
+func OtherUpuserCredit(userId string, value int, clog map[string]interface{}, xb *xweb.Action) bool {
+	b := mogo.Update("user", `{"_id":"`+userId+`"}`, &map[string]interface{}{"$set": &map[string]interface{}{"i_credit": value}}, false, false)
+	if b {
+		//更新session
+		xb.Session().UpdateByCustomField("id", userId, "i_credit", value)
+		//记录日志
+		clog["s_uid"] = userId
+		clog["i_scorenow"] = value
+		clog["l_date"] = time.Now().Unix()
+		clog["l_datenm"] = time.Now().UnixNano() / 1000000
+		mogo.Save("creditlog", clog)
+	}
+	return b
+}

+ 10 - 3
core/src/qfw/active/flop.go

@@ -1,8 +1,10 @@
 package active
 
 import (
+	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
 	"qfw/coreutil"
+	"qfw/util/credit"
 	"qfw/util/mongodb"
 )
 
@@ -22,7 +24,12 @@ func (a *Activemanage) Flop(openid string) error {
 	return a.Render("/active/flop.html", &a.T)
 }
 
-//修改积分
-func updateCredit(id string, value int) bool {
-	return true
+//翻福卡修改积分
+func updateCredit(id string, o_value1, n_value int, xb *xweb.Action) bool {
+	clog := make(map[string]interface{})
+	clog["s_code"] = "o_fp" //福卡翻牌
+	clog["i_score"] = n_value - o_value1
+	clog["s_operation"] = "福卡翻牌"
+	clog["i_type"] = 1
+	return credit.OtherUpuserCredit(id, n_value, clog, xb)
 }