zhangjinkun@topnet.net.cn 9 سال پیش
والد
کامیت
dc76326a4a

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

@@ -156,16 +156,20 @@ func AAllIsHasDo(num int) bool {
 }
 
 //扣积分
-func OutCreditB(userId, code, umid string, score int, param map[string]interface{}) (bool, int) {
+func OutCreditB(userId, code, umid string, score int, param map[string]interface{},
+	xb *xweb.Action) (bool, int) {
 	b := false
 	var Replay int
 	if len(userId) < 5 {
 		return b, Replay
 	}
 	err := Rc.OutCreadit(&rpc.CreditData{Code: code, Uid: userId, Umid: umid, Num: score, OtherParam: param}, &Replay)
-	if err == nil && Replay > 0 {
+	if err == nil && Replay != 0 {
 		b = true
 	}
+	if b {
+		xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))-Replay)
+	}
 	return b, Replay
 }
 

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

@@ -139,22 +139,26 @@ func (m *Mobile) SwordfishPay() error {
 						mapPush := map[string]string{}
 						for _, v := range types {
 							util.Try(func() {
-								obj_typei := user["o_msgset"].(map[string]interface{})[v]
 								b_newopen := false
-								if obj_typei == nil {
+								if user["o_msgset"] == 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 {
+									obj_typei := user["o_msgset"].(map[string]interface{})[v]
+									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
+											}
 										}
 									}
 								}
@@ -168,7 +172,7 @@ func (m *Mobile) SwordfishPay() error {
 						}
 						//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 {
+							if b, _ := credit.OutCreditB(userId.(string), credit.V_JY, util.ObjToString(m.GetSession("s_m_openid")), 0, isPay, m.Action); b {
 								//先扣分,然后更新,然后返回结果
 								res["credit"] = i_credit
 								res["oprstatus"] = true
@@ -185,7 +189,7 @@ func (m *Mobile) SwordfishPay() error {
 											Mopenid:  m.GetSession("s_m_openid").(string),
 											PushType: mapPush,
 										}
-										go clent.Call("PushInfo.PushMsg", &rpcData, &repl)
+										clent.Call("PushInfo.PushMsg", &rpcData, &repl)
 										if errs == nil {
 											//修改剑鱼占位值
 											credit.CheckSword(userId.(string), credit.A_JYSCTS, credit_a, m.Action)

+ 24 - 3
core/src/qfw/swordfish/swordfishmanage.go

@@ -2,6 +2,7 @@ package swordfish
 
 import (
 	"gopkg.in/mgo.v2/bson"
+	"log"
 	"qfw/util"
 	credit "qfw/util/credit"
 	"qfw/util/mongodb"
@@ -29,9 +30,29 @@ func (s *SwordFish) Swordfish() error {
 //跳转到订阅设置页面
 func (s *SwordFish) RssSet() error {
 	u := mongodb.FindById("user", s.GetSession("userId").(string), `{"o_msgset":1}`)
-	s.T["msgset"] = (*u)["o_msgset"]
-	//判断是否使用过剑鱼
-
+	msgset := (*u)["o_msgset"]
+	if msgset != nil {
+		if set, _ := msgset.(map[string]interface{}); set != nil {
+			if set["tender"] != nil {
+				tender, _ := set["tender"].(map[string]interface{})
+				if tender["l_enddate"] != nil {
+					t := tender["l_enddate"].(int64) - time.Now().Unix()
+					tender["day"] = t / (60 * 60 * 24)
+				}
+			}
+		}
+		if set, _ := msgset.(map[string]interface{}); set != nil {
+			if set["bid"] != nil {
+				bid, _ := set["bid"].(map[string]interface{})
+				if bid["l_enddate"] != nil {
+					t := bid["l_enddate"].(int64) - time.Now().Unix()
+					bid["day"] = t / (60 * 60 * 24)
+				}
+			}
+		}
+	}
+	s.T["msgset"] = msgset
+	log.Println("msgset", msgset)
 	return s.Render("/swordfish/rssset.html", &s.T)
 }
 func (s *SwordFish) RsssetAjaxReq() error {

+ 99 - 13
core/src/web/templates/swordfish/rssset.html

@@ -18,7 +18,7 @@
 			<a id="yjfk">去提意见</a>
 			</span>
 		</div>
-		<div id="swordfish-tishi" class="swordfish-explain">
+		<div class="swordfish-explain">
 			“剑鱼”是企明星的特色产品,它借助内置的互联网搜索引擎、大数据平台和自然语言分析系统,
 			为企业从互联网上自动抓取、分析、筛选并推送富有价值的信息情报,
 			比如本企业或其他企业的失信行为信息、受到行政处罚的信息、招标公告、中标公告等等。
@@ -30,7 +30,15 @@
 				<img class="swordfish-uncheck" src="/images/swordfish/checkbox.png">
 				<img class="swordfish-checked" src="/images/swordfish/checkbox-a.png">
 				招标公告
-				<span id="tender-panel-info">本栏目推送服务期还剩3天。想要服务不间断,请确保积分充足。 <a href="/member/credit/myCredit">去做任务赚积分</a></span>
+				<span>
+				{{if .T.msgset}}
+					{{if .T.msgset.tender}}
+						{{if .T.msgset.tender.day}}
+						本栏目推送服务期还剩{{.T.msgset.tender.day}}天。想要服务不间断,请确保积分充足。 <a href="/member/credit/myCredit">去做任务赚积分</a>
+						{{end}}
+					{{end}}
+				{{end}}
+				</span>
 			</div>
 			<div class="swordfish-panel-c">
 				<div>
@@ -56,7 +64,15 @@
 				<img class="swordfish-uncheck" src="/images/swordfish/checkbox.png">
 				<img class="swordfish-checked" src="/images/swordfish/checkbox-a.png">
 				中标公告
-				<span id="bid-panel-info">本栏目推送服务期还剩3天。想要服务不间断,请确保积分充足。 <a href="/member/credit/myCredit">去做任务赚积分</a></span>
+				<span id="bid-panel-info">
+				{{if .T.msgset}}
+					{{if .T.msgset.bid}}
+						{{if .T.msgset.bid.day}}
+						本栏目推送服务期还剩{{.T.msgset.bid.day}}天。想要服务不间断,请确保积分充足。 <a href="/member/credit/myCredit">去做任务赚积分</a>
+						{{end}}
+					{{end}}
+				{{end}}
+				</span>
 			</div>
 			<div class="swordfish-panel-c">
 				<div>
@@ -234,10 +250,27 @@
 	    </div>
   	</div>
 </div>
+
+<!-- tishi -->
+<div class="modal fade b-modal" id="tishiModal" tabindex="-1" role="dialog" aria-labelledby="tishiModalLabel">
+  	<div class="modal-dialog" role="document">
+		<div class="modal-content">
+		  	<div class="modal-header">
+				<span data-dismiss="modal" aria-label="Close" class="close glyphicon guanbi1"></span>
+				<span class="modal-title" id="vipcreditModalLabel">提示信息</span>
+			</div>
+			<div>
+				<div id="swordfish-tishi"></div>
+			</div>
+		</div>
+	</div>
+</div>
 <!-- 底部 -->
 {{include "/common/bottom.html"}}
 <script type="text/javascript">
-
+//Array.prototype.indexOf = function (val) {for (var i = 0; i < this.length; i++) {if (this[i] == val) {return i;}} return -1;};  
+//Array.prototype.removevalue = function (val){var index=this.indexOf(val);if(index > -1){this.splice(index, 1);}}; 
+var oprarr = new Array();
 $(function(){
 	var selectKeyword = function(type,keyword,i_switchstatus){
 		if(keyword == "" || typeof(keyword) == "undefined"){
@@ -306,19 +339,39 @@ $(function(){
 	$("#bid-scope-dialog").find("li .btn").click(function(){
 		afterSelectScope("bid",$(this));
 	});
+	var tender_i_status=0;
+	var bid_i_status=0;
+	var i_credit={{session "i_credit"}}
+	if(typeof(msgset.tender) != "undefined"&&typeof(msgset.tender.i_status) != "undefined"&&msgset.tender.i_status==1){
+		tender_i_status=1;
+	}
+	if(typeof(msgset.bid) != "undefined"&&typeof(msgset.bid.i_status) != "undefined"&&msgset.bid.i_status==1){
+		bid_i_status=1;
+	}
 	$(".swordfish-uncheck").click(function(){
-		$(this).next().show();
+		var type=$(this).parent().parent().attr("id");
+		//如果新增功能扣积分
+		if(type=="tender"&&tender_i_status==0){
+			oprarr.push("types=tender");
+		}
+		if(type=="bid"&&bid_i_status==0){
+			oprarr.push("types=bid");
+		}
+		if(oprarr.length>0){
+			str="您选择了"+oprarr.length+"个信息栏目,确认后系统将每月扣除"+oprarr.length*1000+"积分,您目前的积分余额是"+i_credit+"积分,扣除后将剩余"+(i_credit-oprarr.length*1000)+"积分。"
+				+"<button class='btn' onclick='swordfishpay(0)'>提交</button>"
+				+"<button class='btn' onclick='swordfishpay(1)'>取消</button>";
+			$("#swordfish-tishi").html(str);
+			$("#tishiModal").modal("show");
+		}
 		$(this).hide();
 		autoChecked($(this).parents(".swordfish-panel").attr("id"),true,1);
 	});
-	var arrinfo=["您选择了?个信息栏目,确认后系统将每月扣除?积分,您目前的积分余额是?积分,扣除后将剩余?积分。",
-				"ss"];
 	$(".swordfish-checked").click(function(){
 		$(this).parents(".swordfish-panel").removeClass("swordfish-panel-a");
 		$(this).prev().show();
 		$(this).hide();
-		$(this).next().css('display','none');
-		//ajaxReq();
+		ajaxReq();
 	});
 });
 function afterSelectScope(type,btn){
@@ -362,7 +415,6 @@ function autoChecked(type,flag,i_switchstatus){
 		obj.find(".swordfish-checked").show();
 		obj.find(".swordfish-checked").next().css('display','');
 	}
-	
 	if(obj.find(".swordfish-keywords").children(".swordfish-keyword").length == 0){
 		appendKeyWord(type,"",false);
 	}
@@ -401,17 +453,14 @@ function appendKeyWord(type,value,isFocus){
 		obj.find(".swordfish-keyword").each(function(i){
 			$(this).children("b").children("font").text(i+1);
 		});
-		//autoChecked(type,false,i_switchstatus);
 		ajaxReq();
 	});
 	node.children("[type='text']").blur(function(){
-		//autoChecked(type,false,i_switchstatus);
 		ajaxReq();
 	});
 	if(isFocus){
 		node.children("[type='text']").focus()
 	}
-	//autoChecked(type,false,i_switchstatus);
 }
 function ajaxReq(){
 	var thisClass = this;
@@ -480,6 +529,43 @@ function ajaxReq(){
 		}
 	});
 }
+
+//扣积分
+function swordfishpay(oprtype){
+	$("#tishiModal").modal("hide");
+	$.ajax({
+		dataType:"json",
+		url:"/member/credit/swordfishpay",
+		data:oprarr.join("&")+"&no="+oprtype,
+		type:"POST",
+		async:false,
+		success:function(msg){
+			if(msg){
+				if(msg.flag){
+					//有session
+					if(msg.oprstatus){
+						//扣积分操作成功
+						$("#tishiModal").hide()
+					}else{
+						//扣积分操作无效
+						alert("操作无效,请重新进入页剑鱼页面后操作")
+					}				
+				}else{
+					//无session
+					alert("请重新进入页剑鱼页面后操作")
+				}
+			}			
+		},
+		error:function(x,st,err){
+			alert("请稍后再试"+st)
+		}
+	})
+	window.location.reload()
+}
+//弹窗关闭,取消
+$('#tishiModal').on('hidden.bs.modal', function () {
+  swordfishpay(1);
+})
 </script>
 </body>
 </html>

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

@@ -281,7 +281,7 @@ func (c *CreditRpc) OutCreadit(param *qrpc.CreditData, replay *int) error {
 			creditDoc["i_givestatus"] = 0
 		}
 		if creditlog.Save(creditDoc) {
-			*replay = 1
+			*replay = creditDoc["i_score"].(int)
 			//发送微信通知扣积分成功
 			if first == "A" {
 				go SendMsgWebAndWx(Message["swordfish_payTitle"], fmt.Sprintf(Message["swordfish_pay"], creditDoc["i_score"], creditDoc["i_scorenow"], util.FormatDate(&newDate, util.Date_Full_Layout)), param.Uid, param.Umid)