zhangjinkun@topnet.net.cn 9 gadi atpakaļ
vecāks
revīzija
b2508d831b

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

@@ -3,6 +3,7 @@ package credit
 
 import (
 	"fmt"
+	"github.com/go-xweb/xweb"
 	"qfw/util"
 	mogo "qfw/util/mongodb"
 	"qfw/util/rpc"
@@ -80,13 +81,12 @@ func InCreditA(userId, code string, credit_a int) (bool, int, int, error) {
 }
 
 //日常任务积分
-func InCreditB(userId, code string) (bool, int, error) {
+func InCreditB(userId, code string, param map[string]interface{}) (bool, int, error) {
 	b := false
 	if len(userId) < 1 {
 		return b, 0, nil
 	}
 	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 > 0 {
 		b = true
@@ -129,3 +129,23 @@ func OutCreditB(userId, code string, score int, param map[string]interface{}) (b
 	}
 	return
 }
+
+//更新积分和session
+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 {
+		b, score, _ = InCreditB(userId, code, param)
+		if b {
+			xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
+		}
+	}
+	return b
+}

+ 10 - 2
core/src/qfw/member/bidmanage.go

@@ -10,6 +10,7 @@ import (
 	. "gopkg.in/mgo.v2/bson"
 	"log"
 	util "qfw/util"
+	"qfw/util/credit"
 	elastic "qfw/util/elastic"
 	. "qfw/util/mongodb"
 	msg "qfw/util/msg"
@@ -188,7 +189,6 @@ func (d *BidManage) ChangeStatus() error {
 					}
 					m.SaveMsg()
 				}
-
 			} else if status == 2 {
 				//单独拒绝
 				//通知未被选中的人
@@ -202,7 +202,15 @@ func (d *BidManage) ChangeStatus() error {
 				}
 				m.SaveMsg()
 			}
-
+			//达成交易送积分
+			param := make(map[string]interface{})
+			param["objid"] = wtb["s_userid"].(string)
+			credit_a := util.IntAll(d.GetSession("credit_a"))
+			if credit.AIsHasDo(credit.A_WCJY, credit_a) {
+				credit.UpuserCreditSession(userId, credit.C_JY, "B", param, d.Action)
+			} else {
+				credit.UpuserCreditSession(userId, credit.A_WCJY, "A", param, d.Action)
+			}
 		}
 	}
 	d.ServeJson(M{"result": result})

+ 31 - 11
core/src/qfw/member/credit/creditdetail.go

@@ -6,7 +6,6 @@ package credit
 import (
 	"github.com/go-xweb/xweb"
 	. "gopkg.in/mgo.v2/bson"
-	"log"
 	"qfw/util"
 	cd "qfw/util/credit"
 	"qfw/util/mongodb"
@@ -16,9 +15,10 @@ import (
 
 type credit struct {
 	*xweb.Action
-	myCredit    xweb.Mapper `xweb:"/member/credit/myCredit"`    //我的积分
-	creditRule  xweb.Mapper `xweb:"/member/credit/creditRule"`  //积分规则
-	inCreditAjx xweb.Mapper `xweb:"/member/credit/inCreditAjx"` //ajx调用
+	myCredit     xweb.Mapper `xweb:"/member/credit/myCredit"`     //我的积分
+	creditRule   xweb.Mapper `xweb:"/member/credit/creditRule"`   //积分规则
+	inCreditAjx  xweb.Mapper `xweb:"/member/credit/inCreditAjx"`  //ajx调用
+	sessionQdAjx xweb.Mapper `xweb:"/member/credit/sessionQdAjx"` //查看签到
 }
 
 func (c *credit) MyCredit() error {
@@ -85,28 +85,48 @@ func (c *credit) MyCredit() error {
 func (c *credit) InCreditAjx() error {
 	userId := util.ObjToString(c.GetSession("userId"))
 	result := make(M)
+	result["result"] = "n"
 	if len(userId) > 0 {
 		credit_a := util.IntAll(c.GetSession("credit_a"))
 		param := c.GetString("param")
 		//分享服务
 		if param == "fx" {
 			if cd.AIsHasDo(cd.A_FXFWXQ, credit_a) {
-				//日常任务
-				cd.InCreditB(userId, cd.B_FXFWXQ)
+				cd.UpuserCreditSession(userId, cd.B_FXFWXQ, "B", nil, c.Action)
 			} else {
-				//一次性任务
-				cd.InCreditA(userId, cd.A_FXFWXQ, credit_a)
-				cd.InCreditB(userId, cd.B_FXFWXQ)
+				cd.UpuserCreditSession(userId, cd.A_FXFWXQ, "A", nil, c.Action)
 			}
 		}
 		if param == "qd" {
-			cd.InCreditB(userId, cd.B_QD)
-			log.Println("qiandao")
+			b := cd.UpuserCreditSession(userId, cd.B_QD, "A", nil, c.Action)
+			if b {
+				c.Session().UpdateByCustomField("id", userId, "credit_qd", "y")
+				result["result"] = "y"
+			}
 		}
 	}
 	c.ServeJson(result)
 	return nil
 }
+
+//会员中心更新session签到信息
+func (c *credit) SessionQdAjx() error {
+	credit_qd := util.ObjToString(c.GetSession("credit_qd"))
+	if credit_qd == "y" {
+		return nil
+	}
+	userId := util.ObjToString(c.GetSession("userId"))
+	if ret := redis.Get("other", cd.B_QD+"_"+userId); ret != nil {
+		tmp := util.InterfaceArrTointArr(ret.([]interface{}))
+		if time.Unix(int64(tmp[0]), 0).Day() == time.Now().Day() {
+			c.Session().UpdateByCustomField("id", userId, "credit_qd", "y")
+		}
+	} else {
+		c.Session().UpdateByCustomField("id", userId, "credit_qd", "n")
+	}
+	return nil
+}
+
 func (c *credit) CreditRule() error {
 	return c.Render("/member/credit/creditrule.html")
 }

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

@@ -670,6 +670,7 @@ func (m *Member) Logout() error {
 	m.DelSession("promotion_c")   //推广邮件代码
 	m.DelSession("i_credit")      //用户积分
 	m.DelSession("credit_a")      //a积分任务
+	m.DelSession("credit_qd")     //签到
 
 	deleteCookie(m)
 	return m.Redirect("/")
@@ -877,10 +878,8 @@ func (m *Member) Bindmail() error {
 				bol := Update("user", M{"_id": ObjectIdHex(m.GetSession("userId").(string))}, M{"$set": updateMap}, false, false)
 				if bol {
 					//绑邮箱送积分
-					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 !credit.AIsHasDo(credit.A_BYX, IntAll(m.GetSession("credit_a"))) {
+						credit.UpuserCreditSession(usid, credit.A_BYX, "A", nil, m.Action)
 					}
 					//邮箱绑定认证
 					if contype == "1" {
@@ -966,6 +965,10 @@ func (m *Member) Bindphone() error {
 				}
 				bol := Update("user", M{"_id": ObjectIdHex(m.GetSession("userId").(string))}, M{"$set": updateMap}, false, false)
 				if bol {
+					//绑手机送积分
+					if !credit.AIsHasDo(credit.A_BSJ, IntAll(m.GetSession("credit_a"))) {
+						credit.UpuserCreditSession(m.GetSession("userId").(string), credit.A_BSJ, "A", nil, m.Action)
+					}
 					UpdateCookieSession(m.Action, m.GetSession("loginType").(string), false, *FindById("user", m.GetSession("userId").(string), nil))
 					result = "y"
 				} else {
@@ -1056,8 +1059,6 @@ func (m *Member) Updatephone() error {
 				if bol {
 					result = "y"
 					encryPhone = newPhone
-					//绑定手机送积分
-					credit.InCreditA(ObjToString(m.GetSession("userId")), credit.A_BSJ, IntAll(m.GetSession("credit_a")))
 					UpdateCookieSession(m.Action, m.GetSession("loginType").(string), false, *FindById("user", m.GetSession("userId").(string), nil))
 				} else {
 					result = "n"

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

@@ -232,11 +232,8 @@ func (yp *Yellowpage) Dosave() error {
 		status = "n"
 		info = "保存信息失败"
 	} else { //首次创建企业名片,送积分
-		userId := util.ObjToString(yp.GetSession("userId"))
-		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)
+		if !credit.AIsHasDo(credit.A_CJMP, util.IntAll(yp.GetSession("credit_a"))) {
+			credit.UpuserCreditSession(util.ObjToString(yp.GetSession("userId")), credit.A_CJMP, "A", nil, yp.Action)
 		}
 	}
 	return yp.Write("{\"info\":\"" + info + "\",\"status\":\"" + status + "\"}")
@@ -433,22 +430,10 @@ func (yp *Yellowpage) AddService() error {
 		tempFlag = len(_id) > 0
 		//发服务送积分
 		if tempFlag {
-			credit_a := util.IntAll(yp.GetSession("credit_a"))
-			userid := util.ObjToString(userid)
-			if credit.AIsHasDo(credit.A_FFW, credit_a) {
-				//日常任务
-				b, score, _ := credit.InCreditB(userid, credit.B_FFW)
-				if b {
-					yp.Session().UpdateByCustomField("id", userid, "i_credit", util.IntAll(yp.GetSession("i_credit"))+score)
-				}
+			if credit.AIsHasDo(credit.A_FFW, util.IntAll(yp.GetSession("credit_a"))) {
+				credit.UpuserCreditSession(yp.GetSession("userId").(string), credit.B_FFW, "B", nil, yp.Action)
 			} else {
-				//一次性任务
-				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)
-				}
+				credit.UpuserCreditSession(yp.GetSession("userId").(string), credit.A_FFW, "A", nil, yp.Action)
 			}
 		}
 	}

+ 2 - 13
core/src/qfw/search/searchService.go

@@ -108,20 +108,9 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 			if len(userId) > 0 {
 				credit_a := IntAll(n.GetSession("credit_a"))
 				if credit.AIsHasDo(credit.A_QYCX, credit_a) {
-					//日常任务
-					b, score, _ := credit.InCreditB(userId, credit.B_QYCX)
-					if b {
-						n.Session().UpdateByCustomField("id", userId, "i_credit", IntAll(n.GetSession("i_credit"))+score)
-					}
+					credit.UpuserCreditSession(userId, credit.B_QYCX, "B", nil, n.Action)
 				} else {
-					//一次性任务
-					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)
-					}
+					credit.UpuserCreditSession(userId, credit.A_QYCX, "A", nil, n.Action)
 				}
 			}
 		}

+ 2 - 12
core/src/qfw/searchmarket/demand.go

@@ -176,19 +176,9 @@ func (d *Demand) AddDemand() error {
 			if b {
 				credit_a := util.IntAll(d.GetSession("credit_a"))
 				if credit.AIsHasDo(credit.A_FXQ, credit_a) {
-					//日常任务
-					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)
-					}
+					credit.UpuserCreditSession(util.ObjToString(s_userid), credit.B_FXQ, "B", nil, d.Action)
 				} else {
-					//一次性任务
-					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)
-					}
+					credit.UpuserCreditSession(util.ObjToString(s_userid), credit.A_FXQ, "A", nil, d.Action)
 				}
 			}
 			if s_userid == nil {

+ 11 - 0
core/src/qfw/searchmarket/service.go

@@ -10,6 +10,7 @@ import (
 	"log"
 	webcentent "qfw/front"
 	"qfw/util"
+	"qfw/util/credit"
 	"qfw/util/image"
 	mongo "qfw/util/mongodb"
 	"strings"
@@ -266,6 +267,16 @@ func (s *Service) Comment() error {
 							mongo.Update("service", `{"_id":"`+s_serviceid+`"}`, M{"$set": M{"i_comments": i_comments, "i_score": i_score}}, false, false)
 							mongo.Update("serviceorder", `{"_id":"`+s_orderid+`"}`, M{"$set": M{"i_status": 4}}, false, false)
 						}
+
+						//评价送积分
+						param := make(map[string]interface{})
+						param["serviceid"] = s_serviceid
+						credit_a := util.IntAll(s.GetSession("credit_a"))
+						if credit.AIsHasDo(credit.A_WCJYPJ, credit_a) {
+							credit.UpuserCreditSession(s_userid, credit.C_PJ, "B", param, s.Action)
+						} else {
+							credit.UpuserCreditSession(s_userid, credit.A_WCJYPJ, "A", param, s.Action)
+						}
 						return s.Write("{'success':'true','content':'y'}")
 					} else {
 						content = "保存失败!"

+ 1 - 1
core/src/timetask.json

@@ -1 +1 @@
-{"comment":{"c_rate":10,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-15 13:30:53"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-15 13:30:53"}},"marketisstart":true,"marketrate":300}
+{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-15 18:18:32"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-15 18:18:32"}},"marketisstart":true,"marketrate":300}

+ 26 - 7
core/src/web/templates/common/memberleft.html

@@ -76,24 +76,36 @@
 				{{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 "credit_qd"}}
+				{{if eq (session "credit_qd") "y"}}
+					<button style="width:100px" class="btn" disabled>签到</button>
+				{{else}}
+					<button style="width:100px" class="btn btn-primary" onclick="qd()">签到</button>
+				{{end}}	
+			{{else}}
+				<button style="width:100px" class="btn btn-primary" onclick="qd()">签到</button>
+			{{end}}	
+			</div>
+			<div>
+				<i class="glyphicon jinbi" style="color:red"></i>{{session "i_credit"}}
 				{{if session "identType"}}
 					{{$identType := session "identType"}}
 					{{if eq 1 $identType}}
 						{{if eq 1 $identWay}}
-						<span class="glyphicon qyrz   margin-l-10 " style="color:#FF5A5F;top:4px;"></span>已认证企业
+						<span class="glyphicon qyrz" style="color:#FF5A5F;top:4px;"></span>已认证企业
 						{{end}}
 					{{else if eq 2 $identType}}
 						{{if eq 1 $identWay}}
-						<span class="glyphicon grrz   margin-l-10 " style="color:#FF5A5F;top:4px;"></span>已认证个人
+						<span class="glyphicon grrz" style="color:#FF5A5F;top:4px;"></span>已认证个人
 						{{end}}
 					{{else if eq 3 $identType}}
 						{{if eq 1 $identWay}}
-						<span class="glyphicon jgrz   margin-l-10" style="color:#FF5A5F;top:4px;"></span>已认证机构
+						<span class="glyphicon jgrz" style="color:#FF5A5F;top:4px;"></span>已认证机构
 						{{end}}
 					{{end}}
+				{{else}}
+					<span class="glyphicon grrz" style="top:4px;"></span>未认证
 				{{end}}
 			</div>
 		</div>
@@ -202,7 +214,7 @@ var MemberLeftMenu = {
 	},
 	//vip会有菜单
 	vipMenu: function(){
-		return '<a class="list-group-item" id="vipMenu"><i class="glyphicon zhanghao"></i>会员中心<i class="a-com-collapse2 bootstrap-glyphicon glyphicon glyphicon-menu-down"></i></a>';
+		return '<a class="list-group-item" id="vipMenu"><i class="glyphicon jinbi"></i>会员中心<i class="a-com-collapse2 bootstrap-glyphicon glyphicon glyphicon-menu-down"></i></a>';
 	},
 	//我的积分
 	myCredit: function(){
@@ -216,6 +228,7 @@ var MemberLeftMenu = {
 $(function (){
 	//初始化菜单
 	MemberLeftMenu.init();
+	$.post("/member/credit/sessionQdAjx",{},function(r){});
 });
 function openSChat() {
 	try {
@@ -223,5 +236,11 @@ function openSChat() {
 		window.open(url, "Topchat", "toolbar=0,scrollbars=0,location=0,menubar=0,resizable=1,width=920,height=620");
 	} catch (e) {}
 }
-
+function qd(){
+	$.post("/member/credit/inCreditAjx",{"param":"qd"},function(r){
+		if (r.result=="y"){
+			window.location.reload()
+		}
+	});
+}
 </script>