瀏覽代碼

会员积分

zhangjinkun@topnet.net.cn 9 年之前
父節點
當前提交
385ea657c7

+ 16 - 18
common/src/qfw/util/credit/credit.go

@@ -3,7 +3,6 @@ package credit
 
 import (
 	"fmt"
-	"github.com/go-xweb/xweb"
 	"qfw/util"
 	mogo "qfw/util/mongodb"
 	"qfw/util/rpc"
@@ -63,36 +62,36 @@ func init() {
 }
 
 //一次性任务积分
-func InCreditA(userId, code string, credit_a int) (bool, int, error) {
+func InCreditA(userId, code string, credit_a int) (bool, int, int, error) {
 	result := false
 	if len(userId) < 1 {
-		return result, credit_a, nil
+		return result, credit_a, 0, nil
 	}
-	var Replay *int
+	var Replay int
 	if !AIsHasDo(code, credit_a) {
 		param := make(map[string]interface{})
-		err := Rc.InCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: 0, OtherParam: param}, Replay)
-		if err == nil && *Replay == 1 {
+		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)
 		}
-		return result, credit_a, err
+		return result, credit_a, Replay, err
 	}
-	return result, credit_a, nil
+	return result, credit_a, 0, nil
 }
 
 //日常任务积分
-func InCreditB(userId, code string) (bool, error) {
+func InCreditB(userId, code string) (bool, int, error) {
 	b := false
 	if len(userId) < 1 {
-		return b, nil
+		return b, 0, nil
 	}
-	var Replay *int
+	var Replay int
 	param := make(map[string]interface{})
-	err := Rc.InCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: 0, OtherParam: param}, Replay)
-	if err == nil && *Replay == 1 {
+	err := Rc.InCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: 0, OtherParam: param}, &Replay)
+	if err == nil && Replay > 0 {
 		b = true
 	}
-	return b, err
+	return b, Replay, err
 }
 
 //更新用户一次性积分状态
@@ -120,13 +119,12 @@ func AIsHasDo(code string, num int) bool {
 }
 
 //扣积分
-func OutCreditB(userId, code string, score int, param map[string]interface{}) (b bool) {
+func OutCreditB(userId, code string, score int, param map[string]interface{}) (b bool, Replay int) {
 	if len(userId) < 5 {
 		return
 	}
-	var Replay *int
-	err := Rc.OutCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: score, OtherParam: param}, Replay)
-	if err == nil && *Replay == 1 {
+	err := Rc.OutCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: score, OtherParam: param}, &Replay)
+	if err == nil && Replay > 0 {
 		b = true
 	}
 	return

+ 2 - 2
common/src/qfw/util/rpc/credit.go

@@ -25,7 +25,7 @@ func (rc *RpcCall) InCreadit(param *CreditData, replay *int) error {
 	if err != nil {
 		return err
 	}
-	err = client.Call("CreditRpc.InCreadit", &param, &replay)
+	err = client.Call("CreditRpc.InCreadit", param, replay)
 	return err
 }
 
@@ -36,6 +36,6 @@ func (rc *RpcCall) OutCreadit(param *CreditData, replay *int) error {
 	if err != nil {
 		return err
 	}
-	err = client.Call("CreditRpc.OutCreadit", &param, &replay)
+	err = client.Call("CreditRpc.OutCreadit", param, replay)
 	return err
 }

+ 5 - 2
core/src/qfw/manage/auditing.go

@@ -775,8 +775,11 @@ func (s *SystemManage) Updateaudit() error {
 		}
 		//认证送积分
 		if flag == "true" {
-			_, credit_a, _ := credit.InCreditA(s_submitid, credit.A_RZ, util.IntAll((*f)["credit_a"]))
-			s.Session().UpdateByCustomField("id", s_submitid, "credit_a", credit_a)
+			b, credit_a, score, _ := credit.InCreditA(s_submitid, credit.A_RZ, util.IntAll((*f)["credit_a"]))
+			if b {
+				s.Session().UpdateByCustomField("id", s_submitid, "i_credit", util.IntAll((*f)["i_credit"])+score)
+				s.Session().UpdateByCustomField("id", s_submitid, "credit_a", credit_a)
+			}
 		}
 		s.Write(`{"flag":"` + flag + `","msg":"` + msg + `"}`)
 	}

+ 5 - 1
core/src/qfw/member/membermanager.go

@@ -877,7 +877,11 @@ func (m *Member) Bindmail() error {
 				bol := Update("user", M{"_id": ObjectIdHex(m.GetSession("userId").(string))}, M{"$set": updateMap}, false, false)
 				if bol {
 					//绑邮箱送积分
-					credit.InCreditA(usid, credit.A_BYX, IntAll(m.GetSession("credit_a")))
+					b, credit_a, score, _ := credit.InCreditA(usid, credit.A_BYX, IntAll(m.GetSession("credit_a")))
+					if b {
+						m.Session().UpdateByCustomField("id", usid, "credit_a", credit_a)
+						m.Session().UpdateByCustomField("id", usid, "i_credit", IntAll(m.GetSession("i_credit"))+score)
+					}
 					//邮箱绑定认证
 					if contype == "1" {
 						r := *FindById("enterprise", entid, nil)

+ 16 - 5
core/src/qfw/member/yellowpage.go

@@ -233,8 +233,11 @@ func (yp *Yellowpage) Dosave() error {
 		info = "保存信息失败"
 	} else { //首次创建企业名片,送积分
 		userId := util.ObjToString(yp.GetSession("userId"))
-		_, credit_a, _ := credit.InCreditA(userId, credit.A_CJMP, util.IntAll(yp.GetSession("credit_a")))
-		yp.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
+		b, credit_a, score, _ := credit.InCreditA(userId, credit.A_CJMP, util.IntAll(yp.GetSession("credit_a")))
+		if b {
+			yp.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
+			yp.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(yp.GetSession("i_credit"))+score)
+		}
 	}
 	return yp.Write("{\"info\":\"" + info + "\",\"status\":\"" + status + "\"}")
 }
@@ -431,13 +434,21 @@ func (yp *Yellowpage) AddService() error {
 		//发服务送积分
 		if tempFlag {
 			credit_a := util.IntAll(yp.GetSession("credit_a"))
+			userid := util.ObjToString(userid)
 			if credit.AIsHasDo(credit.A_FFW, credit_a) {
 				//日常任务
-				credit.InCreditB(util.ObjToString(userid), credit.B_FFW)
+				b, score, _ := credit.InCreditB(userid, credit.B_FFW)
+				if b {
+					yp.Session().UpdateByCustomField("id", userid, "i_credit", util.IntAll(yp.GetSession("i_credit"))+score)
+				}
 			} else {
 				//一次性任务
-				credit.InCreditB(util.ObjToString(userid), credit.B_FFW)
-				credit.InCreditA(util.ObjToString(userid), credit.A_FFW, credit_a)
+				b, score, _ := credit.InCreditB(userid, credit.B_FFW)
+				b, credit_a, score, _ = credit.InCreditA(util.ObjToString(userid), credit.A_FFW, credit_a)
+				if b {
+					yp.Session().UpdateByCustomField("id", userid, "i_credit", util.IntAll(yp.GetSession("i_credirt"))+score)
+					yp.Session().UpdateByCustomField("id", userid, "credit_a", credit_a)
+				}
 			}
 		}
 	}

+ 1 - 1
core/src/qfw/mobile/wxmenu.go

@@ -139,7 +139,7 @@ func (m *Mobile) SwordfishPay() {
 					}
 					i_credit -= len(isPay) * 1000
 					if i_credit >= 0 {
-						if credit.OutCreditB(userId.(string), credit.V_JY, -len(isPay)*1000, isPay) {
+						if b, _ := credit.OutCreditB(userId.(string), credit.V_JY, -len(isPay)*1000, isPay); b {
 							//先扣分,然后更新,然后返回结果
 							res["credit"] = i_credit
 							res["oprstatus"] = true

+ 11 - 4
core/src/qfw/search/searchService.go

@@ -109,12 +109,19 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 				credit_a := IntAll(n.GetSession("credit_a"))
 				if credit.AIsHasDo(credit.A_QYCX, credit_a) {
 					//日常任务
-					credit.InCreditB(userId, credit.B_QYCX)
+					b, score, _ := credit.InCreditB(userId, credit.B_QYCX)
+					if b {
+						n.Session().UpdateByCustomField("id", userId, "i_credit", IntAll(n.GetSession("i_credit"))+score)
+					}
 				} else {
 					//一次性任务
-					credit.InCreditB(userId, credit.A_QYCX)
-					credit.InCreditA(userId, credit.B_QYCX, credit_a)
-					n.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
+					log.Println("chaxun", "一次性任务")
+					b, score, _ := credit.InCreditB(userId, credit.B_QYCX)
+					b, credit_a, score, _ := credit.InCreditA(userId, credit.A_QYCX, credit_a)
+					if b {
+						n.Session().UpdateByCustomField("id", userId, "i_credit", IntAll(n.GetSession("i_credit"))+score)
+						n.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
+					}
 				}
 			}
 		}

+ 10 - 3
core/src/qfw/searchmarket/demand.go

@@ -177,11 +177,18 @@ func (d *Demand) AddDemand() error {
 				credit_a := util.IntAll(d.GetSession("credit_a"))
 				if credit.AIsHasDo(credit.A_FXQ, credit_a) {
 					//日常任务
-					credit.InCreditB(util.ObjToString(s_userid), credit.B_FXQ)
+					b, score, _ := credit.InCreditB(util.ObjToString(s_userid), credit.B_FXQ)
+					if b {
+						d.Session().UpdateByCustomField("id", s_userid, "i_credit", util.IntAll(d.GetSession("i_credit"))+score)
+					}
 				} else {
 					//一次性任务
-					credit.InCreditB(util.ObjToString(s_userid), credit.B_FXQ)
-					credit.InCreditA(util.ObjToString(s_userid), credit.A_FXQ, credit_a)
+					b, score, _ := credit.InCreditB(util.ObjToString(s_userid), credit.B_FXQ)
+					b, credit_a, score, _ = credit.InCreditA(util.ObjToString(s_userid), credit.A_FXQ, credit_a)
+					if b {
+						d.Session().UpdateByCustomField("id", s_userid, "i_credit", util.IntAll(d.GetSession("i_credit"))+score)
+						d.Session().UpdateByCustomField("id", s_userid, "credit_a", credit_a)
+					}
 				}
 			}
 			if s_userid == nil {

+ 6 - 4
core/src/qfw/swordfish/swordfishmanage.go

@@ -55,10 +55,12 @@ func (s *SwordFish) RsssetAjaxReq() error {
 	if mongodb.Update("user", `{"_id":"`+userId+`"}`, &map[string]interface{}{"$set": map[string]interface{}{"o_msgset": msgset}}, false, false) {
 		flag = "y"
 	}
-	//使用剑鱼送积分
-	if flag == "y" {
-		_, credit_a, _ := credit.InCreditA(userId, credit.V_JY, util.IntAll(s.GetSession("credit_a")))
-		s.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
+	//首次使用剑鱼送积分
+	if flag == "y" && credit.AIsHasDo(credit.A_SYJY, util.IntAll(s.GetSession("credit_a"))) {
+		b, _, score, _ := credit.InCreditA(userId, credit.V_JY, util.IntAll(s.GetSession("credit_a")))
+		if b {
+			s.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(s.GetSession("i_credit"))+score)
+		}
 	}
 	s.ServeJson(map[string]interface{}{
 		"flag": flag,