Browse Source

提交修改

renzheng 9 years ago
parent
commit
c6139458d9

+ 7 - 0
common/src/qfw/util/common.go

@@ -341,3 +341,10 @@ func HashCode(uid string) int {
 	}
 	return int(h)
 }
+
+//获取离n天的秒差
+func GetDayStartSecond(n int) int64 {
+	now := time.Now()
+	tom := time.Date(now.Year(), now.Month(), now.Day()+n, 0, 0, 0, 0, time.Local)
+	return tom.Unix()
+}

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

@@ -13,7 +13,7 @@ type Mobile struct {
 	guide         xweb.Mapper `xweb:"/swordfish/guide"`
 	share         xweb.Mapper `xweb:"/swordfish/share"`
 	wxrssset      xweb.Mapper `xweb:"/swordfish/page"`
-	getCredit     xweb.Mapper `xweb:"/credit/getcredit"`
+	getMyCredit   xweb.Mapper `xweb:"/member/credit/getcredit"`
 	msgSet        xweb.Mapper `xweb:"/swordfish/msgpushsetting/msgset"`
 	ajaxReq       xweb.Mapper `xweb:"/swordfish/ajaxReq"`
 	advise        xweb.Mapper `xweb:"/mobile/advise"`

+ 79 - 113
core/src/qfw/mobile/wxmenu.go

@@ -8,7 +8,6 @@ import (
 	"qfw/coreconfig"
 	"qfw/coreutil"
 	"qfw/util"
-	"qfw/util/consts"
 	"qfw/util/mongodb"
 	"qfw/util/redis"
 	"runtime"
@@ -30,6 +29,7 @@ func (m *Mobile) Share() error {
 	return m.Render("/swordfish/wxshare.html", &m.T)
 }
 
+//进入订阅页面
 func (m *Mobile) Wxrssset() error {
 	defer func() {
 		if r := recover(); r != nil {
@@ -44,7 +44,6 @@ func (m *Mobile) Wxrssset() error {
 		}
 	}()
 	userId := m.Session().Get("userId")
-	//userId = "55a39942af53740186000004"
 	if userId != nil {
 		m.T["signature"] = getSignature(m.Url())
 		userInfo := mongodb.FindById("user", userId.(string), nil)
@@ -57,136 +56,103 @@ func (m *Mobile) Wxrssset() error {
 			return m.Redirect("/swordfish/guide")
 		}
 		m.T["msgset"] = (*userInfo)["o_msgset"]
-		entid := util.ObjToString((*userInfo)["s_enterpriseid"])
-		if entid != "" {
-			local := mongodb.FindById("enterprise", entid, `{"_id":0,"OpLocDistrict":1,"i_area":1}`)
-			localids := (*local)["OpLocDistrict"]
-			i_area := (*local)["i_area"]
-			if localids != nil && len(localids.(string)) > 2 {
-				localid := localids.(string)
-				localid = localid[:2]
-				m.T["scode"] = localid
-				m.T["sname"] = consts.SRcode[localid]
-			} else if i_area != nil && len(fmt.Sprintf("%d", i_area)) > 2 {
-				area := fmt.Sprintf("%d", i_area)
-				area = area[:2]
-				m.T["scode"] = area
-				m.T["sname"] = consts.SRcode[area]
-			}
-		}
-		//m.T["mid"] = openid
 		return m.Render("/swordfish/wxrssset.html", &m.T)
 	} else {
 		return m.Render("_err.html")
 	}
-
-	/**
-	enstr := strings.Split(se.DecodeString(str), ",")
-	if len(enstr) >= 3 {
-		openid := enstr[0]
-		if len(openid) == 0 {
-			return nil
-		}
-		userInfo := mongodb.FindOneByField("user", `{"s_m_openid":"`+openid+`"}`, `{"_id":1,"o_msgset":1,"s_enterpriseid":1}`)
-		if userInfo == nil || len(*userInfo) == 0 {
-			return nil
-		} else {
-			m.T["msgset"] = (*userInfo)["o_msgset"]
-			entid := util.ObjToString((*userInfo)["s_enterpriseid"])
-			if entid != "" {
-				local := mongodb.FindById("enterprise", entid, `{"_id":0,"OpLocDistrict":1,"i_area":1}`)
-				localids := (*local)["OpLocDistrict"]
-				i_area := (*local)["i_area"]
-				if localids != nil && len(localids.(string)) > 2 {
-					localid := localids.(string)
-					localid = localid[:2]
-					m.T["scode"] = localid
-					m.T["sname"] = consts.SRcode[localid]
-				} else if i_area != nil && len(fmt.Sprintf("%d", i_area)) > 2 {
-					area := fmt.Sprintf("%d", i_area)
-					area = area[:2]
-					m.T["scode"] = area
-					m.T["sname"] = consts.SRcode[area]
-				}
-			}
-			m.T["mid"] = openid
-			return m.Render("/member/message/wxrssset.html", &m.T)
-		}
-	} else {
-		return m.Render("_err.html")
-	}
-	**/
 }
 
 //获取积分
-func (m *Mobile) GetCredit() error {
+func (m *Mobile) GetMyCredit() error {
 	userId := m.GetSession("userId")
 	res := map[string]interface{}{}
 	if userId != nil {
 		res["flag"] = true
-		user := mongodb.FindById("user", userId.(string), `{"_id":0,"i_credit":1}`)
-		if *user != nil {
-			res["val"] = util.IntAll((*user)["i_credit"])
-		}
+		res["val"] = getCreditById(userId.(string))
 	} else {
 		res["flag"] = false
 	}
+	m.ServeJson(&res)
 	return nil
 }
 
-//订阅消息设置
-func (m *Mobile) MsgSet() error {
-	data := m.GetString("data")
-	/**
-	mid := m.GetString("mid")
-	if mid == "" {
-		return nil
+func getCreditById(userId string) int {
+	user := mongodb.FindById("user", userId, `{"_id":0,"i_credit":1}`)
+	if *user != nil {
+		return util.IntAll((*user)["i_credit"])
 	}
-	**/
-	bcon := true
-	doc := map[string]interface{}{}
-	if data != "" {
-		mson := map[string]interface{}{}
-		err := json.Unmarshal([]byte(data), &mson)
-		if err != nil || mson == nil || len(mson) == 0 {
-			log.Println("保存订阅设置出错", err)
-		} else {
-			for _, v := range mson {
-				util.Try(func() {
-					item := v.(map[string]interface{})
-					a_key := util.ObjArrToStringArr(item["a_key"].([]interface{}))
-					if a_key == nil || len(a_key) == 0 || len(a_key) > 5 {
-						bcon = false
-					} else {
-						for _, v := range a_key {
-							if len(v) > 300 {
-								bcon = false
-								break
+	return 0
+}
+
+//直接查询开启状态和截止日期
+func getMsgSetById(userId string) map[string]interface{} {
+	user := mongodb.FindById("user", userId, `{"_id":0,"i_credit":1,"o_msgset.tender.i_status":1,"o_msgset.tender.l_enddate":1,"o_msgset.bid.i_status":1,"o_msgset.bid.l_enddate":1}`)
+	if *user != nil {
+		return *user
+	}
+	return nil
+}
+
+//扣分操作
+func (m *Mobile) SwordfishPay() {
+	userId := m.GetSession("userId")
+	res := map[string]interface{}{}
+	if userId != nil {
+		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]bool{}
+					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 {
+									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] = true
+							}
+						}, func(e interface{}) {
+							log.Println(e)
+						})
 					}
-				}, func(e interface{}) {
-					log.Println("验证关键词出错", e)
-					bcon = false
-				})
+					for k, _ := range isPay {
+						//先扣分,然后更新,然后返回结果
+
+					}
+				} else {
+					res["credit"] = i_credit
+				}
 			}
 		}
-		mson["l_modifydate"] = time.Now().Unix()
-		doc["o_msgset"] = mson
 	} else {
-		bcon = false
-	}
-	da := map[string]interface{}{
-		"msg": util.If(bcon, "保存成功", "保存失败"),
-	}
-	if bcon {
-		mongodb.Update("user", `{"_id":"`+util.ObjToString(m.GetSession("userId"))+`"}`, &map[string]interface{}{
-			"$set": doc,
-		}, false, false)
+		res["flag"] = false
 	}
-	m.ServeJson(da)
-	return nil
+
 }
+
+//剑鱼保存
 func (m *Mobile) AjaxReq() error {
 	reqType := m.GetString("reqType")
 	var flag = "n"
@@ -229,12 +195,12 @@ func (m *Mobile) AjaxReq() error {
 			set := make(map[string]interface{})
 			for _, v := range []string{"tender", "bid"} {
 				if len(m.GetString(v+"_scope")) > 0 {
-					tmp := make(map[string]interface{})
-					tmp["a_key"] = m.GetSlice(v + "_keys")
-					tmp["s_scope"] = m.GetString(v + "_scope")
-					tmp["i_status"], _ = m.GetInteger(v + "_status")
-					tmp["l_modifydate"] = time.Now().Unix()
-					set["o_msgset."+v] = tmp
+					//还有一个截止时间字段和一个剑鱼服务状态
+					status, _ := m.GetInteger(v + "_status")
+					set["o_msgset."+v+".i_switchstatus"] = status
+					set["o_msgset."+v+".a_key"] = m.GetSlice(v + "_keys")
+					set["o_msgset."+v+".s_scope"] = m.GetString(v + "_scope")
+					set["o_msgset."+v+".l_modifydate"] = time.Now().Unix()
 				}
 			}
 			//更新数据库

+ 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-14 10:26:13"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-14 10:26:13"}},"marketisstart":true,"marketrate":300}
+{"comment":{"c_rate":10,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-14 16:32:50"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-14 16:32:50"}},"marketisstart":true,"marketrate":300}

+ 14 - 9
core/src/web/staticres/wxswordfish/main.js

@@ -133,7 +133,7 @@ function getCredit(){
 	var score=0
 	$.ajax({
 		dataType:"json",
-		url:"/credit/getcredit",
+		url:"/member/credit/getcredit",
 		type:"POST",
 		async:false,
 		success:function(msg){
@@ -145,8 +145,8 @@ function getCredit(){
 				}
 			}			
 		},
-		error:function(err){
-			alert("请稍后再试")
+		error:function(x,st,err){
+			alert("请稍后再试"+st)
 		}
 	})
 	return score
@@ -165,21 +165,25 @@ function commonAjaxReq(object,module){
 				alert(getCredit())
 				//提示扣积分
 				//先取积分,规则然后提示
-				$(".creditTip-dialog").show()
-				$("html,body").addClass("overflow-hidden")
+				$(".credit-tip").show()
 				//生成快照
-				dataObj["snopshot"]=true
+				dataObj[module+"_snopshot"]=true
 			}
 		}else if(module=="bid"){
 			if(!Bid.status){
 				//提示扣积分
 				alert(getCredit())
-				$(".creditTip-dialog").show()
-				$("html,body").addClass("overflow-hidden")
+				$(".credit-tip").show()
 				//生成快照
-				dataObj["snopshot"]=true
+				dataObj[module+"_snopshot"]=true
 			}
 		}
+	}else{
+		if(module=="tender"){
+			Tender.status=false
+		}else if(module=="bid"){
+			Bid.status=false
+		}
 	}
 
 	var keysString = "",scopeString = "";
@@ -249,6 +253,7 @@ function commonAjaxReq(object,module){
 		dataObj[module+"_scope"] = "A";
 	}
 	dataObj[module+"_status"] = $("#"+module+"-on-off").hasClass("open")?1:0
+	
 	/*****************************************/
 	$.ajax({
 		type: "POST",

+ 4 - 1
core/src/web/staticres/wxswordfish/style.css

@@ -525,12 +525,12 @@ img{
 	margin:1px;
 	padding:5px;
 	background-color:#FAF5DF;
-	height:130px;
 	border:1px solid #F5DC9A;
 }
 .tip-button{
 	float: right;
  	margin-right: 50px;
+	margin-top:5px;
 }
 .tip-button span{
 	border-radius:5px;
@@ -542,4 +542,7 @@ img{
 }
 .tip-button span:nth-child(1){
 	background-color:#24C0D7;
+}
+.visible{
+	display:none;
 }

+ 12 - 0
core/src/web/templates/swordfish/wxrssset.html

@@ -10,10 +10,22 @@
 <script src="/wxswordfish/share.js"></script>
 <script>
 	var msgset= {{.T.msgset}};
+	var snopshot_tender= "{{.T.snopshot_tender}}";
+	var snopshot_bid= "{{.T.snopshot_bid}}";
 </script>
 <script src="/wxswordfish/main.js"></script>
 </head>
 <body>
+<div class="credit-tip visible">
+	<div class="tip">
+		<div>您添加了1个信息栏目(招标公告),确认后系统将每月扣除1000积分,您目前的积分余额是1500积分,扣除后将剩余500积分。</div>
+		<div class="tip-button">
+		<span id="credit_yes">提交</span>
+		<span id="credit_no">取消</span>
+		</div>
+		<div style="clear:both"></div>
+	</div>
+</div>
 	<ul class="operation">
 		<li class="parent-node">
 			<img src="/wxswordfish/images/zhaobiao.png">

+ 1 - 10
core/src/web/templates/swordfish/wxtoolbar.html

@@ -41,15 +41,6 @@
 	</div>
 </div>
 
-<div class="dialog creditTip-dialog">
-	<div class="tip">
-		<div>您添加了1个信息栏目(招标公告),确认后系统将每月扣除1000积分,您目前的积分余额是1500积分,扣除后将剩余500积分。</div>
-		<div class="tip-button">
-		<span id="credit_yes">提交</span>
-		<span id="credit_no">取消</span>
-		</div>
-	</div>
-</div>
 
 <!--意见反馈-->
 <div class="dialog feedback-dialog">
@@ -91,7 +82,7 @@ $(function(){
 	//弹出框消失
 	$(".dialog").click(function(e){
 		var et=$(e.target)
-		if(et.hasClass("dialog")&&!et.hasClass("creditTip-dialog")){
+		if(et.hasClass("dialog")){
 			$(this).hide();
 			$("html,body").removeClass("overflow-hidden");
 		}

+ 1 - 0
push/src/qfw/push/bid/bidpushjob.go

@@ -194,6 +194,7 @@ func sendWeixin(k *push.MemberInterest, TITLE, str, nowtime, wxstr string, now t
 		"s_content":     str,
 		"s_type":        "bid",
 		"a_publishtime": publishTimes,
+		"i_size":        len(publishTimes),
 	}
 	wid := mongodb.Save("wxpush", &wxpush)
 	wxstr = "\n点击下方“详情”查看详细信息。\n以上中标信息,是剑鱼根据关键字“" + strings.Join(k.Interest, ";") + "”奋力查找并推送,如不合您心意,请猛戳企明星菜单“会员服务—剑鱼”进行修改。"

+ 1 - 0
push/src/qfw/push/tender/tenderpushjob.go

@@ -191,6 +191,7 @@ func sendWeixin(k *push.MemberInterest, TITLE, str, nowtime, wxstr string, now t
 		"s_content":     str,
 		"s_type":        "tender",
 		"a_publishtime": publishTimes,
+		"i_size":        len(publishTimes),
 	}
 	wid := mongodb.Save("wxpush", &wxpush)
 	wxDate := ""