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

+ 5 - 3
common/src/qfw/util/credit/credit.go

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

+ 3 - 2
core/src/qfw/coreutil/weixinrpc_test.go

@@ -107,9 +107,10 @@ func Test_credit(t *testing.T) {
 	client, _ := rpc.DialHTTP("tcp", "127.0.0.1:8765")
 	defer client.Close()
 	data := qrpc.CreditData{}
-	data.Code = "d1"
+	data.Code = "b2"
 	data.Uid = "55a39942af53740186000004"
-	data.Num = 3000
+	//data.Num = 3000
 	var reply int
 	client.Call("CreditRpc.InCreadit", &data, &reply)
+	log.Println("reply:", reply)
 }

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

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

+ 19 - 2
core/src/qfw/mobile/wxmenu.go

@@ -55,6 +55,22 @@ func (m *Mobile) Wxrssset() error {
 			}, 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
+							}
+						}
+					}
+				}
+			}
+		}
 		m.T["msgset"] = (*userInfo)["o_msgset"]
 		return m.Render("/swordfish/wxrssset.html", &m.T)
 	} else {
@@ -94,7 +110,7 @@ func getMsgSetById(userId string) map[string]interface{} {
 }
 
 //扣分操作
-func (m *Mobile) SwordfishPay() {
+func (m *Mobile) SwordfishPay() error {
 	userId := m.GetSession("userId")
 	res := map[string]interface{}{}
 	if userId != nil {
@@ -156,7 +172,8 @@ func (m *Mobile) SwordfishPay() {
 	} else {
 		res["flag"] = false
 	}
-
+	m.ServeJson(&res)
+	return nil
 }
 
 //剑鱼保存

+ 4 - 1
core/src/timetask.json

@@ -1 +1,4 @@
-{"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}
+<<<<<<< HEAD
+{"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}
+=======
+{"comment":{"c_rate":10,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-15 18:09:09"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-15 18:09:09"}},"marketisstart":true,"marketrate":300}

+ 119 - 21
core/src/web/staticres/wxswordfish/main.js

@@ -1,6 +1,5 @@
 //招标公告
 var Tender = {
-	status:false,
 	keyWordDialog: null,
 	getKeyWordDialog: function(clickLi){
 		if(this.keyWordDialog == null){
@@ -18,7 +17,6 @@ var Tender = {
 };
 //中标公告
 var Bid = {
-	status:false,
 	keyWordDialog: null,
 	getKeyWordDialog: function(clickLi){
 		if(this.keyWordDialog == null){
@@ -152,11 +150,120 @@ function getCredit(){
 	return score
 }
 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)
+		}
+	}
+	if(n>0){
+		var num=getCredit();
+		var pay=1000*n, rem=num-pay,strs="扣除后将剩余"+rem+"积分";
+		var contents="您添加了"+n+"个信息栏目("+str.join("、")+"),确认后系统将每月扣除"+pay+"积分,您目前的积分余额是"+num+"积分,";
+		if(rem<0){
+			$("#credit_yes").unbind("click").hide()
+			strs="请充值或去赚积分。";
+		}else{
+			$("#credit_yes").unbind("click").bind("click",function(e){
+				$("#rule-content").text(contents+strs)
+				$(".tip-dialog").show();
+				$("#tip-dialog-back").unbind("click").bind("click",function(e){
+					$("#tip-dialog-back").unbind("click");
+					$.ajax({
+						dataType:"json",
+						url:"/member/credit/swordfishpay",
+						data:sel.join("&"),
+						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()
+				})
+				$("html,body").addClass("overflow-hidden");
+			})
+		}
+		$("#txt_tip").text(contents+strs)
+		$(".visible").show()
+	}else{
+		$("#credit_yes").unbind("click")
+		$(".visible").hide()		
+	}
+}
 
-function showSnopshot(){
+function showSnopshot(module,type,on){
 	//提示扣积分
-	alert(getCredit())
-	$(".credit-tip").show()
+	//alert(getCredit())
+	if(type==0){//初始化
+		//是开启状态
+		if (!eval("msgset."+module+".i_status")){
+			snopshot[module]=true
+			showAlls()
+		}else{
+			//显示天数
+			var days=eval("msgset."+module+".days")	
+			var tiptxt="本栏目推送服务期还剩<d style='color:red'>"+days+"</d>天"
+			if(winWidth<341){
+				tiptxt="服务期还剩<d style='color:red'>"+days+"</d>天"
+			}
+			$("#"+module+" .show-days").html(tiptxt)
+		}
+		
+		
+	}else if(type==1){//提交修改时
+		if(on){
+			if(module=="tender"){
+				if(typeof(msgset.tender) != "undefined"){
+					if(!msgset.tender.i_status){
+						if (!msgset.tender.i_status){
+							snopshot[module]=true
+						}else{
+							snopshot[module]=false
+						}
+					}
+				}else{
+					snopshot[module]=true
+				}
+			}else if(module=="bid"){
+				if(typeof(msgset.bid) != "undefined"){
+					if(!msgset.bid.i_status){
+						if (!msgset.bid.i_status){
+							snopshot[module]=true
+						}else{
+							snopshot[module]=false
+						}
+					}
+				}else{
+					snopshot[module]=true
+				}
+			}
+			showAlls()
+		}else{
+			snopshot[module]=false
+			showAlls()
+		}		
+	}
 }
 
 function commonAjaxReq(object,module){
@@ -167,21 +274,9 @@ function commonAjaxReq(object,module){
 	};
 	if($("#"+module+"-on-off").hasClass("open")){
 		//开服务要校验
-		if(module=="tender"){
-			if(typeof(msgset.tender) != "undefined"){
-				if(!msgset.tender.i_switchstatus){
-					snopshot["tender"]=true	
-					showSnopshot()
-				}
-			}
-		}else if(module=="bid"){
-			if(typeof(msgset.bid) != "undefined"){
-				if(!msgset.bid.i_switchstatus){
-					snopshot["bid"]=true
-					showSnopshot()	
-				}
-			}
-		}
+		showSnopshot(module,1,1)
+	}else{
+		showSnopshot(module,1,0)
 	}
 	var keysString = "",scopeString = "";
 	var thisClass = this;
@@ -268,7 +363,9 @@ function commonAjaxReq(object,module){
 		}
 	});
 }
+var winWidth=300;
 $(function(){
+	winWidth=$(window).width();
 	var turnOn = function(obj){
 		obj.addClass("open");
 		var liobj = obj.parents("li");
@@ -318,7 +415,7 @@ $(function(){
 		if(msgset.tender.i_switchstatus){
 			turnOn($("#tender-on-off"));
 			//判断要不要还原提示
-			if
+			showSnopshot("tender",0)
 		}
 	}
 	if(typeof(msgset.bid) != "undefined"){
@@ -327,6 +424,7 @@ $(function(){
 		if(msgset.bid.i_switchstatus){
 			turnOn($("#bid-on-off"));
 			//判断要不要还原提示
+			showSnopshot("bid",0)
 		}
 	}
 	//开关

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

@@ -545,4 +545,11 @@ img{
 }
 .visible{
 	display:none;
-}
+}
+.show-days{
+	font-size:10px;
+	display:inline-block;
+	margin-left:2px;
+	color:#999;
+}
+	

+ 5 - 3
core/src/web/templates/swordfish/wxrssset.html

@@ -16,7 +16,7 @@
 <body>
 <div class="credit-tip visible">
 	<div class="tip">
-		<div>您添加了1个信息栏目(招标公告),确认后系统将每月扣除1000积分,您目前的积分余额是1500积分,扣除后将剩余500积分。</div>
+		<div id="txt_tip"></div>
 		<div class="tip-button">
 		<span id="credit_yes">提交</span>
 		<span id="credit_no">取消</span>
@@ -25,9 +25,10 @@
 	</div>
 </div>
 	<ul class="operation">
-		<li class="parent-node">
+		<li class="parent-node" id="tender">
 			<img src="/wxswordfish/images/zhaobiao.png">
 			招标公告
+			<day class="show-days"></day>
 			<span class="on-off" id="tender-on-off" v="tender"></span>
 		</li>
 		<li class="child-node">
@@ -40,9 +41,10 @@
 				</li>
 			</ul>
 		</li>
-		<li class="parent-node">
+		<li class="parent-node" id="bid">
 			<img src="/wxswordfish/images/zhongbiao.png">
 			中标公告
+			<day class="show-days"></day>
 			<span class="on-off" id="bid-on-off" v="bid"></span>
 		</li>
 		<li class="child-node">

+ 14 - 0
core/src/web/templates/swordfish/wxtoolbar.html

@@ -41,6 +41,20 @@
 	</div>
 </div>
 
+<div class="dialog tip-dialog">
+	<div class="dialog-main">
+		<div class="dialog-head">
+			<div>提示信息</div>
+			<div><span id="tip-dialog-back" style="cursor:pointer">确定</span></div>
+		</div>
+		<div class="dialog-content" style="height:115px;">
+			<div id="rule-content">
+				
+			</div>
+		</div>
+	</div>
+</div>
+
 
 <!--意见反馈-->
 <div class="dialog feedback-dialog">

+ 12 - 0
credit/src/main.go

@@ -19,6 +19,7 @@ import (
 	"qfw/util/msg"
 	"qfw/util/redis"
 	qrpc "qfw/util/rpc"
+	"runtime"
 	"strconv"
 	"strings"
 	"time"
@@ -80,6 +81,17 @@ func main() {
 }
 
 func quartz() {
+	defer func() {
+		if r := recover(); r != nil {
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
 	//定时保存日志
 	go func() {
 		for {

+ 8 - 4
credit/src/qfw/creditlog/creditlog.go

@@ -46,10 +46,14 @@ func Save(doc map[string]interface{}) bool {
 				"$inc": map[string]int{
 					"i_credit": doc["i_score"].(int),
 				},
-				"$set": map[string]interface{}{
-					"o_msgset." + doc["s_type"].(string) + ".l_enddate": doc["l_enddate"],
-					"o_msgset." + doc["s_type"].(string) + ".i_status":  1,
-				},
+				"$set": func() map[string]interface{} {
+					tmp := map[string]interface{}{}
+					for _, ty := range strings.Split(doc["s_type"].(string), ",") {
+						tmp["o_msgset."+ty+".l_enddate"] = doc["l_enddate"]
+						tmp["o_msgset."+ty+".i_status"] = 1
+					}
+					return tmp
+				}(),
 			}, false, false)
 		} else {
 			b = mongodb.Update("user", `{"_id":"`+doc["s_uid"].(string)+`"}`, &map[string]interface{}{

+ 40 - 1
credit/src/qfw/creditrpc/creditrpc.go

@@ -9,6 +9,8 @@ import (
 	"qfw/util"
 	"qfw/util/redis"
 	qrpc "qfw/util/rpc"
+	"runtime"
+	"strings"
 	"sync"
 	"time"
 )
@@ -36,6 +38,17 @@ func GetMutex(uid string) *sync.Mutex {
 
 //增加积分
 func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
+	defer func() {
+		if r := recover(); r != nil {
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
 	//a类为即时保存
 	//b、c、d、e为定时保存
 	log.Println("---请求", param)
@@ -193,6 +206,17 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 
 //消费积分,增加扣费方式、手动还是自动
 func (c *CreditRpc) OutCreadit(param *qrpc.CreditData, replay *int) error {
+	defer func() {
+		if r := recover(); r != nil {
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
 	*replay = 0
 	lock := GetMutex(param.Uid)
 	lock.Lock()
@@ -215,7 +239,11 @@ func (c *CreditRpc) OutCreadit(param *qrpc.CreditData, replay *int) error {
 			creditDoc["l_enddate"] = now.AddDate(0, 1, 0).Unix()
 			creditDoc["i_valid"] = 1
 			if param.OtherParam != nil {
-				creditDoc["s_type"] = param.OtherParam["s_type"]
+				str := []string{}
+				for k, _ := range param.OtherParam {
+					str = append(str, k)
+				}
+				creditDoc["s_type"] = strings.Join(str, ",")
 			}
 		case "B":
 			creditDoc["i_givestatus"] = 0
@@ -237,6 +265,17 @@ func SendWeixin(num int, uid, info string) {
 
 //微信远程调用,实现模板发送消息
 func SendManagerNotifyMsg(p *qrpc.NotifyMsg) {
+	defer func() {
+		if r := recover(); r != nil {
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
 	client, err := rpc.DialHTTP("tcp", Rpcserver)
 	if err != nil {
 		log.Println(err.Error())