Browse Source

修改剑鱼积分

renzheng 9 years ago
parent
commit
22f3ef29ec

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

@@ -119,13 +119,15 @@ 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 {
 	if len(userId) < 5 {
-		return
+		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, Num: score, OtherParam: param}, &Replay)
 	if err == nil && Replay > 0 {
 	if err == nil && Replay > 0 {
 		b = true
 		b = true
 	}
 	}
-	return
+	return b, Replay
 }
 }

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

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

+ 16 - 0
core/src/qfw/mobile/wxmenu.go

@@ -55,6 +55,22 @@ func (m *Mobile) Wxrssset() error {
 			}, false, false)
 			}, false, false)
 			return m.Redirect("/swordfish/guide")
 			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"]
 		m.T["msgset"] = (*userInfo)["o_msgset"]
 		return m.Render("/swordfish/wxrssset.html", &m.T)
 		return m.Render("/swordfish/wxrssset.html", &m.T)
 	} else {
 	} else {

+ 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 15:10:53"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-15 15:10:53"}},"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}

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

@@ -150,25 +150,64 @@ function getCredit(){
 	return score
 	return score
 }
 }
 var snopshot=[];
 var snopshot=[];
-
 function showAlls(){
 function showAlls(){
-	var n=0,str=[];
+	var n=0,str=[],sel=[];
 	for(var i in snopshot){
 	for(var i in snopshot){
 		if(snopshot[i]){
 		if(snopshot[i]){
 			n++;
 			n++;
 			str.push((i=="tender")?"招标公告":"中标公告")
 			str.push((i=="tender")?"招标公告":"中标公告")
+			sel.push("types="+i)
 		}
 		}
 	}
 	}
 	if(n>0){
 	if(n>0){
 		var num=getCredit();
 		var num=getCredit();
 		var pay=1000*n, rem=num-pay,strs="扣除后将剩余"+rem+"积分";
 		var pay=1000*n, rem=num-pay,strs="扣除后将剩余"+rem+"积分";
+		var contents="您添加了"+n+"个信息栏目("+str.join("、")+"),确认后系统将每月扣除"+pay+"积分,您目前的积分余额是"+num+"积分,";
 		if(rem<0){
 		if(rem<0){
-			$("#credit_yes").hide()
+			$("#credit_yes").unbind("click").hide()
 			strs="请充值或去赚积分。";
 			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("您添加了"+n+"个信息栏目("+str.join("、")+"),确认后系统将每月扣除"+pay+"积分,您目前的积分余额是"+num+"积分,"+strs)
+		$("#txt_tip").text(contents+strs)
 		$(".visible").show()
 		$(".visible").show()
 	}else{
 	}else{
+		$("#credit_yes").unbind("click")
 		$(".visible").hide()		
 		$(".visible").hide()		
 	}
 	}
 }
 }
@@ -181,7 +220,17 @@ function showSnopshot(module,type,on){
 		if (!eval("msgset."+module+".i_status")){
 		if (!eval("msgset."+module+".i_status")){
 			snopshot[module]=true
 			snopshot[module]=true
 			showAlls()
 			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){//提交修改时
 	}else if(type==1){//提交修改时
 		if(on){
 		if(on){
 			if(module=="tender"){
 			if(module=="tender"){
@@ -314,7 +363,9 @@ function commonAjaxReq(object,module){
 		}
 		}
 	});
 	});
 }
 }
+var winWidth=300;
 $(function(){
 $(function(){
+	winWidth=$(window).width();
 	var turnOn = function(obj){
 	var turnOn = function(obj){
 		obj.addClass("open");
 		obj.addClass("open");
 		var liobj = obj.parents("li");
 		var liobj = obj.parents("li");

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

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

+ 4 - 2
core/src/web/templates/swordfish/wxrssset.html

@@ -25,9 +25,10 @@
 	</div>
 	</div>
 </div>
 </div>
 	<ul class="operation">
 	<ul class="operation">
-		<li class="parent-node">
+		<li class="parent-node" id="tender">
 			<img src="/wxswordfish/images/zhaobiao.png">
 			<img src="/wxswordfish/images/zhaobiao.png">
 			招标公告
 			招标公告
+			<day class="show-days"></day>
 			<span class="on-off" id="tender-on-off" v="tender"></span>
 			<span class="on-off" id="tender-on-off" v="tender"></span>
 		</li>
 		</li>
 		<li class="child-node">
 		<li class="child-node">
@@ -40,9 +41,10 @@
 				</li>
 				</li>
 			</ul>
 			</ul>
 		</li>
 		</li>
-		<li class="parent-node">
+		<li class="parent-node" id="bid">
 			<img src="/wxswordfish/images/zhongbiao.png">
 			<img src="/wxswordfish/images/zhongbiao.png">
 			中标公告
 			中标公告
+			<day class="show-days"></day>
 			<span class="on-off" id="bid-on-off" v="bid"></span>
 			<span class="on-off" id="bid-on-off" v="bid"></span>
 		</li>
 		</li>
 		<li class="child-node">
 		<li class="child-node">

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

@@ -41,6 +41,20 @@
 	</div>
 	</div>
 </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">
 <div class="dialog feedback-dialog">

+ 12 - 0
credit/src/main.go

@@ -19,6 +19,7 @@ import (
 	"qfw/util/msg"
 	"qfw/util/msg"
 	"qfw/util/redis"
 	"qfw/util/redis"
 	qrpc "qfw/util/rpc"
 	qrpc "qfw/util/rpc"
+	"runtime"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
 	"time"
 	"time"
@@ -80,6 +81,17 @@ func main() {
 }
 }
 
 
 func quartz() {
 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() {
 	go func() {
 		for {
 		for {

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

@@ -46,10 +46,14 @@ func Save(doc map[string]interface{}) bool {
 				"$inc": map[string]int{
 				"$inc": map[string]int{
 					"i_credit": doc["i_score"].(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)
 			}, false, false)
 		} else {
 		} else {
 			b = mongodb.Update("user", `{"_id":"`+doc["s_uid"].(string)+`"}`, &map[string]interface{}{
 			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"
 	"qfw/util/redis"
 	"qfw/util/redis"
 	qrpc "qfw/util/rpc"
 	qrpc "qfw/util/rpc"
+	"runtime"
+	"strings"
 	"sync"
 	"sync"
 	"time"
 	"time"
 )
 )
@@ -36,6 +38,17 @@ func GetMutex(uid string) *sync.Mutex {
 
 
 //增加积分
 //增加积分
 func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 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类为即时保存
 	//a类为即时保存
 	//b、c、d、e为定时保存
 	//b、c、d、e为定时保存
 	log.Println("---请求", param)
 	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 {
 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
 	*replay = 0
 	lock := GetMutex(param.Uid)
 	lock := GetMutex(param.Uid)
 	lock.Lock()
 	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["l_enddate"] = now.AddDate(0, 1, 0).Unix()
 			creditDoc["i_valid"] = 1
 			creditDoc["i_valid"] = 1
 			if param.OtherParam != nil {
 			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":
 		case "B":
 			creditDoc["i_givestatus"] = 0
 			creditDoc["i_givestatus"] = 0
@@ -237,6 +265,17 @@ func SendWeixin(num int, uid, info string) {
 
 
 //微信远程调用,实现模板发送消息
 //微信远程调用,实现模板发送消息
 func SendManagerNotifyMsg(p *qrpc.NotifyMsg) {
 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)
 	client, err := rpc.DialHTTP("tcp", Rpcserver)
 	if err != nil {
 	if err != nil {
 		log.Println(err.Error())
 		log.Println(err.Error())