Quellcode durchsuchen

Merge branch 'develop' of 192.168.3.17:zhanghongbo/qfw into develop

renzheng vor 9 Jahren
Ursprung
Commit
8597c8707b

+ 11 - 1
common/src/github.com/go-xweb/httpsession/memorystore.go

@@ -44,7 +44,17 @@ func (node *sessionNode) UpdateByCustomField(findkey string, findvalue interface
 	if v2, ok := node.kvs[findkey]; ok && v2 == findvalue {
 		//存在
 		if setkey != "" {
-			node.kvs[setkey] = setvalue
+			flag := setkey[:1]
+			switch flag {
+			case "+":
+				nkey := setkey[1:]
+				node.kvs[nkey] = node.kvs[nkey].(int) + setvalue.(int)
+			case "-":
+				nkey := setkey[1:]
+				node.kvs[nkey] = node.kvs[nkey].(int) - setvalue.(int)
+			default:
+				node.kvs[setkey] = setvalue
+			}
 			node.last = time.Now()
 		} else {
 			mapVal := setvalue.(*map[string]interface{})

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

@@ -62,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
 }
 
 //更新用户一次性积分状态
@@ -119,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

+ 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 + `"}`)
 	}

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

@@ -668,6 +668,7 @@ func (m *Member) Logout() error {
 	m.DelSession("audittype")     //认证后是否是第一次登录的标识第一次:y
 	m.DelSession("promotion_id")  //推广id
 	m.DelSession("promotion_c")   //推广邮件代码
+	m.DelSession("i_credit")      //用户积分
 	m.DelSession("credit_a")      //a积分任务
 
 	deleteCookie(m)
@@ -876,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)
@@ -1128,6 +1133,7 @@ func UpdateSession(action *xweb.Action, r map[string]interface{}) {
 		setSessMap["identWay"] = IntAll(r["i_identificationway"])
 		setSessMap["opLocDistrict"] = r["opLocDistrict"]
 		setSessMap["credit_a"] = IntAll(r["credit_a"])
+		setSessMap["i_credit"] = IntAll(r["i_credit"])
 		if r["s_phone"] == nil || r["s_phone"].(string) == "" {
 			setSessMap["phone"] = ""
 		} else {

+ 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() error {
 					}
 					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,

+ 13 - 11
core/src/web/templates/common/memberleft.html

@@ -66,17 +66,19 @@
 {{$s_role := printf "%v" (index (session "userInfo") "s_role")}}
 <div class="list-group" id="member-left-nav">
 	<a class="list-group-item" id="member-left-headInfo">
-		<div id="member_headImg">
-			{{$s_avatar := printf "%v" (index (session "userInfo") "s_avatar")}}
-			{{if session "headImg"}}
-				<img class="img-circle" src="{{$s_avatar}}" onerror="this.src='{{session "headImg"}}'">
-			{{else}}
-				<img class="img-circle" src="{{$s_avatar}}" onerror="this.className='img-circle defaultHeadImg';this.src='/images/image_radius_bg.png'">
-			{{end}}
-		</div>
-		<div>
-			<span class="member-loginName text-primary cursor-pointer" onclick="window.location.href = '/member/show/memberindex'">{{session "nickName"}}</span>
-			<div style="margin-top: 10px;" class="identType text-muted font-size-12">
+		<div style="width:185px;text-align:center;">
+			<div id="member_headImg">
+				{{$s_avatar := printf "%v" (index (session "userInfo") "s_avatar")}}
+				{{if session "headImg"}}
+					<img class="img-circle" src="{{$s_avatar}}" onerror="this.src='{{session "headImg"}}'">
+				{{else}}
+					<img class="img-circle" src="{{$s_avatar}}" onerror="this.className='img-circle defaultHeadImg';this.src='/images/image_radius_bg.png'">
+				{{end}}
+			</div>
+			<div><span class="member-loginName cursor-pointer" onclick="window.location.href = '/member/show/memberindex'">{{session "nickName"}}</span></div>
+			<div><button style="width:100px" class="btn btn-primary" onclick="">签到</button></div>
+			<div>
+				
 				{{if session "identType"}}
 					{{$identType := session "identType"}}
 					{{if eq 1 $identType}}