Browse Source

修改微信剑鱼

renzheng 9 years ago
parent
commit
5dd4af4068

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

@@ -119,13 +119,13 @@ func AIsHasDo(code string, num int) bool {
 }
 
 //扣积分
-func OutCreditB(userId, code string, score int, param map[string]interface{}) (bool, int) {
+func OutCreditB(userId, code, umid string, score int, param map[string]interface{}) (bool, int) {
 	b := false
 	var Replay int
 	if len(userId) < 5 {
 		return b, Replay
 	}
-	err := Rc.OutCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: score, OtherParam: param}, &Replay)
+	err := Rc.OutCreadit(&rpc.CreditData{Code: code, Uid: userId, Umid: umid, Num: score, OtherParam: param}, &Replay)
 	if err == nil && Replay > 0 {
 		b = true
 	}

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

@@ -1124,6 +1124,7 @@ func UpdateSession(action *xweb.Action, r map[string]interface{}) {
 			setSessMap["nickName"] = r["s_nickname"]
 		}
 		setSessMap["userId"] = r["_id"]
+		setSessMap["s_m_openid"] = r["s_m_openid"]
 		setSessMap["userType"] = IntAllDef(r["i_type"], 2)
 		setSessMap["userInfo"] = &r
 		setSessMap["userName"] = r["s_name"]

+ 78 - 56
core/src/qfw/mobile/wxmenu.go

@@ -47,31 +47,38 @@ func (m *Mobile) Wxrssset() error {
 	if m.Session().Get("userId") != nil {
 		m.T["signature"] = GetSignature(m.Url())
 		userInfo := mongodb.FindById("user", m.GetSession("userId").(string), nil)
-		if i_m_guide := (*userInfo)["i_m_guide"]; util.IntAll(i_m_guide) == 0 {
-			mongodb.Update("user", `{"_id":"`+m.GetSession("userId").(string)+`"}`, map[string]interface{}{
-				"$set": map[string]interface{}{
-					"i_m_guide": 1,
-				},
-			}, false, false)
-			return m.Redirect("/swordfish/guide")
-		}
-		for _, v := range (*userInfo)["o_msgset"].(map[string]interface{}) {
-			if vobj, ok := v.(map[string]interface{}); ok {
-				if vobj["l_enddate"] != nil && vobj["i_status"] != nil {
-					if util.IntAll(vobj["i_status"]) == 1 {
-						sub := vobj["l_enddate"].(int64) - time.Now().Unix()
-						if sub >= 0 {
-							if sub%86400 == 0 {
-								vobj["days"] = sub / 86400
-							} else {
-								vobj["days"] = sub/86400 + 1
+		if *userInfo != nil {
+			if i_m_guide := (*userInfo)["i_m_guide"]; util.IntAll(i_m_guide) == 0 {
+				mongodb.Update("user", `{"_id":"`+m.GetSession("userId").(string)+`"}`, map[string]interface{}{
+					"$set": map[string]interface{}{
+						"i_m_guide": 1,
+					},
+				}, false, false)
+				return m.Redirect("/swordfish/guide")
+			}
+			if (*userInfo)["o_msgset"] != nil {
+				for _, v := range (*userInfo)["o_msgset"].(map[string]interface{}) {
+					if vobj, ok := v.(map[string]interface{}); ok {
+						if vobj["l_enddate"] != nil && vobj["i_status"] != nil {
+							if util.IntAll(vobj["i_status"]) == 1 {
+								sub := vobj["l_enddate"].(int64) - time.Now().Unix()
+								if sub >= 0 {
+									if sub%86400 == 0 {
+										vobj["days"] = sub / 86400
+									} else {
+										vobj["days"] = sub/86400 + 1
+									}
+								} else {
+									vobj["days"] = 0
+								}
 							}
 						}
 					}
 				}
 			}
+			m.T["msgset"] = (*userInfo)["o_msgset"]
 		}
-		m.T["msgset"] = (*userInfo)["o_msgset"]
+
 		return m.Render("/swordfish/wxrssset.html", &m.T)
 	} else {
 		return m.Render("_err.html")
@@ -117,55 +124,70 @@ func (m *Mobile) SwordfishPay() error {
 		types := m.GetSlice("types")
 		res["flag"] = true
 		if len(types) > 0 {
-			//获取积分
-			user := getMsgSetById(userId.(string))
-			if user == nil {
-				res["flag"] = false
-			} else {
-				i_credit := util.IntAll(user["i_credit"])
-				if i_credit > 0 {
-					isPay := map[string]interface{}{}
-					for _, v := range types {
-						util.Try(func() {
-							obj_typei := user["o_msgset"].(map[string]interface{})[v]
-							b_newopen := false
-							if obj_typei == nil {
-								b_newopen = true
-							} else {
-								obj_type := obj_typei.(map[string]interface{})
-								st := obj_type["i_status"]
-								objt := obj_type["l_enddate"]
-								if st == nil || objt == nil {
+			no, _ := m.GetInteger("no")
+			if no == 0 {
+				//获取积分
+				user := getMsgSetById(userId.(string))
+				if user == nil {
+					res["flag"] = false
+				} else {
+					i_credit := util.IntAll(user["i_credit"])
+					if i_credit > 0 {
+						isPay := map[string]interface{}{}
+						for _, v := range types {
+							util.Try(func() {
+								obj_typei := user["o_msgset"].(map[string]interface{})[v]
+								b_newopen := false
+								if obj_typei == nil {
 									b_newopen = true
 								} else {
-									//判断是否开启
-									i_st := st.(int)
-									l_objt := objt.(int64)
-									if !(i_st == 1 && l_objt > util.GetDayStartSecond(0)) {
+									obj_type := obj_typei.(map[string]interface{})
+									st := obj_type["i_status"]
+									objt := obj_type["l_enddate"]
+									if st == nil || objt == nil {
 										b_newopen = true
+									} else {
+										//判断是否开启
+										i_st := st.(int)
+										l_objt := objt.(int64)
+										if !(i_st == 1 && l_objt > util.GetDayStartSecond(0)) {
+											b_newopen = true
+										}
 									}
 								}
+								if b_newopen { //进行扣费操作
+									isPay[v] = v
+								}
+							}, func(e interface{}) {
+								log.Println(e)
+							})
+						}
+						//i_credit -= len(isPay) * 1000
+						if i_credit >= 0 {
+							if b, _ := credit.OutCreditB(userId.(string), credit.V_JY, util.ObjToString(m.GetSession("s_m_openid")), 0, isPay); b {
+								//先扣分,然后更新,然后返回结果
+								res["credit"] = i_credit
+								res["oprstatus"] = true
 							}
-							if b_newopen { //进行扣费操作
-								isPay[v] = v
-							}
-						}, func(e interface{}) {
-							log.Println(e)
-						})
-					}
-					i_credit -= len(isPay) * 1000
-					if i_credit >= 0 {
-						if b, _ := credit.OutCreditB(userId.(string), credit.V_JY, -len(isPay)*1000, isPay); b {
-							//先扣分,然后更新,然后返回结果
+						} else {
 							res["credit"] = i_credit
-							res["oprstatus"] = true
 						}
+
 					} else {
 						res["credit"] = i_credit
 					}
+				}
 
-				} else {
-					res["credit"] = i_credit
+			} else if no == 1 {
+				//取消操作
+				set := map[string]interface{}{}
+				for _, v := range types {
+					set["o_msgset."+v+".i_switchstatus"] = 0
+				}
+				if mongodb.Update("user", `{"_id":"`+userId.(string)+`"}`, &map[string]interface{}{
+					"$set": set,
+				}, false, false) {
+					res["oprstatus"] = true
 				}
 			}
 		}

+ 1 - 28
core/src/timetask.json

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

+ 55 - 13
core/src/web/staticres/wxswordfish/main.js

@@ -151,12 +151,13 @@ function getCredit(){
 }
 var snopshot=[];
 function showAlls(){
+	
 	var n=0,str=[],sel=[];
 	for(var i in snopshot){
 		if(snopshot[i]){
 			n++;
 			str.push((i=="tender")?"招标公告":"中标公告")
-			sel.push("types="+i)
+			sel.push("types="+i)	
 		}
 	}
 	if(n>0){
@@ -204,6 +205,36 @@ function showAlls(){
 				$("html,body").addClass("overflow-hidden");
 			})
 		}
+		$("#credit_no").unbind("click").bind("click",function(e){
+			$.ajax({
+					dataType:"json",
+					url:"/member/credit/swordfishpay",
+					data:sel.join("&")+"&no=1",
+					type:"POST",
+					async:false,
+					success:function(msg){
+						if(msg){
+							if(msg.flag){
+								//有session
+								if(msg.oprstatus){
+									//取消操作成功
+									$(".visible").hide()
+								}else{
+									//取消操作无效
+									alert("操作无效,请重新进入页剑鱼页面后操作")
+								}				
+							}else{
+								//无session
+								alert("请重新进入页剑鱼页面后操作")
+							}
+						}			
+					},
+					error:function(x,st,err){
+						alert("请稍后再试"+st)
+					}
+				})
+				window.location.reload()
+		})
 		$("#txt_tip").text(contents+strs)
 		$(".visible").show()
 	}else{
@@ -217,20 +248,25 @@ function showSnopshot(module,type,on){
 	//alert(getCredit())
 	if(type==0){//初始化
 		//是开启状态
-		if (!eval("msgset."+module+".i_status")){
-			snopshot[module]=true
-			showAlls()
-		}else{
-			//显示天数
+		//显示天数
+		try{
 			var days=eval("msgset."+module+".days")	
-			var tiptxt="本栏目推送服务期还剩<d style='color:red'>"+days+"</d>天"
-			if(winWidth<341){
-				tiptxt="服务期还剩<d style='color:red'>"+days+"</d>天"
+			if(days){
+				var tiptxt="本栏目推送服务期还剩<d style='color:red'>"+days+"</d>天"
+				if(winWidth<341){
+					tiptxt="服务期还剩<d style='color:red'>"+days+"</d>天"
+				}
+			}
+		}catch(e){}
+		if(on){
+			if (!eval("msgset."+module+".i_status")){
+				snopshot[module]=true
+				showAlls()
 			}
 			$("#"+module+" .show-days").html(tiptxt)
+		}else{
+			$("#"+module+" .show-days").html(tiptxt).hide()
 		}
-		
-		
 	}else if(type==1){//提交修改时
 		if(on){
 			if(module=="tender"){
@@ -275,8 +311,10 @@ function commonAjaxReq(object,module){
 	if($("#"+module+"-on-off").hasClass("open")){
 		//开服务要校验
 		showSnopshot(module,1,1)
+		$("#"+module+" .show-days").show()
 	}else{
 		showSnopshot(module,1,0)
+		$("#"+module+" .show-days").hide()
 	}
 	var keysString = "",scopeString = "";
 	var thisClass = this;
@@ -415,7 +453,9 @@ $(function(){
 		if(msgset.tender.i_switchstatus){
 			turnOn($("#tender-on-off"));
 			//判断要不要还原提示
-			showSnopshot("tender",0)
+			showSnopshot("tender",0,1)
+		}else{
+			showSnopshot("tender",0,0)			
 		}
 	}
 	if(typeof(msgset.bid) != "undefined"){
@@ -424,7 +464,9 @@ $(function(){
 		if(msgset.bid.i_switchstatus){
 			turnOn($("#bid-on-off"));
 			//判断要不要还原提示
-			showSnopshot("bid",0)
+			showSnopshot("bid",0,1)
+		}else{
+			showSnopshot("bid",0,0)
 		}
 	}
 	//开关