Răsfoiți Sursa

剑鱼订阅

zhangjinkun@topnet.net.cn 9 ani în urmă
părinte
comite
984f875fc7

+ 32 - 21
common/src/qfw/util/credit/credit.go

@@ -31,6 +31,7 @@ const (
 	A_WCJY   = "a14" //完成交易
 	A_WCJYPJ = "a15" //完成交易评价
 	A_JYSCTS = "a63" //剑鱼首次推送
+	A_ALL    = "a64" //一次性积分任务完成
 
 	B_QD       = "b1" //签到
 	B_QD_T     = 7    //最高连续签到次数
@@ -76,6 +77,8 @@ func InCreditA(userId, code string, credit_a int) (bool, int, int, error) {
 		err := Rc.InCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: 0, OtherParam: param}, &Replay)
 		if err == nil && Replay > 0 {
 			result, credit_a = UpuserCreditA(code, userId, credit_a)
+		} else {
+			log.Println("调用rpc出错", err)
 		}
 		return result, credit_a, Replay, err
 	}
@@ -102,8 +105,10 @@ func InCreditB(userId, code string, param map[string]interface{}) (bool, int, er
 	}
 	var Replay int
 	err := Rc.InCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: 0, OtherParam: param}, &Replay)
-	if err == nil && Replay > 0 {
+	if err == nil && Replay != 0 {
 		b = true
+	} else {
+		log.Println("调用rpc出错", err)
 	}
 	return b, Replay, err
 }
@@ -168,7 +173,7 @@ func OutCreditB(userId, code, umid string, score int, param map[string]interface
 		b = true
 	}
 	if b {
-		xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))-Replay)
+		xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+Replay)
 	}
 	return b, Replay
 }
@@ -177,28 +182,34 @@ func OutCreditB(userId, code, umid string, score int, param map[string]interface
 func UpuserCreditSession(userId, code, dtype string, param map[string]interface{}, xb *xweb.Action) bool {
 	b := false
 	score := 0
-	if dtype == "A" {
-		credit_a := util.IntAll(xb.GetSession("credit_a"))
-		b, credit_a, score, _ = InCreditA(userId, code, credit_a)
-		if b {
-			xb.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
-			xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
-		} else {
-			log.Println(userId, code, "一次性任务送积分失败")
-		}
-		if AAllIsHasDo(credit_a) {
-			b, _, _, _ := InCreditA(userId, "a64", credit_a)
+	util.Try(func() {
+		if dtype == "A" {
+			credit_a := util.IntAll(xb.GetSession("credit_a"))
+			b, credit_a, score, _ = InCreditA(userId, code, credit_a)
 			if b {
-				log.Println(userId, "完成所有一次性任务")
+				xb.Session().UpdateByCustomField("id", userId, "credit_a", credit_a)
+				xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
+			} else {
+				log.Println(userId, code, "一次性任务送积分失败")
+			}
+			if AAllIsHasDo(credit_a) {
+				b, _, _, err := InCreditA(userId, A_ALL, credit_a)
+				if b {
+					log.Println(userId, "完成所有一次性任务,送分成功")
+				} else {
+					log.Println(userId, "完成所有一次性任务,送分失败", err)
+				}
 			}
-		}
-	} else {
-		b, score, _ = InCreditB(userId, code, param)
-		if b {
-			xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
 		} else {
-			log.Println(userId, code, param, "任务送积分失败")
+			b, score, _ = InCreditB(userId, code, param)
+			if b {
+				xb.Session().UpdateByCustomField("id", userId, "i_credit", util.IntAll(xb.GetSession("i_credit"))+score)
+			} else {
+				log.Println(userId, code, param, "任务送积分失败")
+			}
 		}
-	}
+	}, func(e interface{}) {
+		log.Println("更新积分和session出错", e)
+	})
 	return b
 }

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

@@ -172,13 +172,14 @@ 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, m.Action); b {
+							credit_a := util.IntAll(m.GetSession("credit_a"))
+							b := false
+							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
 								//初次提交积分时
 								//加上剑鱼是否推送过的逻辑判断
-								credit_a := util.IntAll(m.GetSession("credit_a"))
 								if !credit.AIsHasDo(credit.A_JYSCTS, credit_a) {
 									util.Try(func() {
 										//对用户进行推送
@@ -199,6 +200,10 @@ func (m *Mobile) SwordfishPay() error {
 									})
 								}
 							}
+							//首次使用剑鱼送积分
+							if b && !credit.AIsHasDo(credit.A_SYJY, credit_a) {
+								credit.UpuserCreditSession(userId.(string), credit.A_SYJY, "A", nil, m.Action)
+							}
 						} else {
 							res["credit"] = i_credit
 						}

+ 6 - 7
core/src/qfw/swordfish/swordfish.go

@@ -9,13 +9,12 @@ import (
 
 type SwordFish struct {
 	*xweb.Action
-	swordfish     xweb.Mapper `xweb:"/front/swordfish"`                 //剑鱼
-	rsssetAjaxReq xweb.Mapper `xweb:"/member/swordfish/rssset/ajaxReq"` //订阅消息设置ajax请求
-	rssSet        xweb.Mapper `xweb:"/member/swordfish/rssset"`         //订阅消息设置
-	infolist      xweb.Mapper `xweb:"/member/swordfish/infolist"`       //剑鱼
-	swordfishlist xweb.Mapper `xweb:"/member/swordfish/swordfishlist"`  //剑鱼列表
-	setVisited    xweb.Mapper `xweb:"/member/swordfish/setVisited"`     //已经访问过的列表
-	visitRedirect xweb.Mapper `xweb:"/visit/redirect"`                  //剑鱼跳转访问请求,后续统计
+	swordfish     xweb.Mapper `xweb:"/front/swordfish"`                //剑鱼
+	rssSet        xweb.Mapper `xweb:"/member/swordfish/rssset"`        //订阅消息设置
+	infolist      xweb.Mapper `xweb:"/member/swordfish/infolist"`      //剑鱼
+	swordfishlist xweb.Mapper `xweb:"/member/swordfish/swordfishlist"` //剑鱼列表
+	setVisited    xweb.Mapper `xweb:"/member/swordfish/setVisited"`    //已经访问过的列表
+	visitRedirect xweb.Mapper `xweb:"/visit/redirect"`                 //剑鱼跳转访问请求,后续统计
 }
 
 func init() {

+ 0 - 38
core/src/qfw/swordfish/swordfishmanage.go

@@ -2,9 +2,6 @@ package swordfish
 
 import (
 	"gopkg.in/mgo.v2/bson"
-	"log"
-	"qfw/util"
-	credit "qfw/util/credit"
 	"qfw/util/mongodb"
 	"qfw/util/redis"
 	"time"
@@ -52,43 +49,8 @@ func (s *SwordFish) RssSet() error {
 		}
 	}
 	s.T["msgset"] = msgset
-	log.Println("msgset", msgset)
 	return s.Render("/swordfish/rssset.html", &s.T)
 }
-func (s *SwordFish) RsssetAjaxReq() error {
-	userId := s.GetSession("userId").(string)
-	var flag = "n"
-	msgset := make(map[string]interface{})
-	//投标公告
-	if tender_flag, _ := s.GetBool("tender_flag"); tender_flag {
-		tender := make(map[string]interface{})
-		tender["a_key"] = s.GetSlice("tender_keys")
-		tender["s_scope"] = s.GetString("tender_scope")
-		msgset["tender"] = tender
-	}
-	//中标公告
-	if bid_flag, _ := s.GetBool("bid_flag"); bid_flag {
-		bid := make(map[string]interface{})
-		bid["a_key"] = s.GetSlice("bid_keys")
-		bid["s_scope"] = s.GetString("bid_scope")
-		msgset["bid"] = bid
-	}
-	//更新数据库
-	msgset["l_modifydate"] = time.Now().Unix()
-	if mongodb.Update("user", `{"_id":"`+userId+`"}`, &map[string]interface{}{"$set": map[string]interface{}{"o_msgset": msgset}}, false, false) {
-		flag = "y"
-	}
-	//首次使用剑鱼送积分
-	if flag == "y" {
-		if credit.AIsHasDo(credit.A_SYJY, util.IntAll(s.GetSession("credit_a"))) {
-			credit.UpuserCreditSession(userId, credit.A_SYJY, "A", nil, s.Action)
-		}
-	}
-	s.ServeJson(map[string]interface{}{
-		"flag": flag,
-	})
-	return nil
-}
 
 //跳转到用户中心剑鱼信息列表
 func (s *SwordFish) Infolist() error {

+ 6 - 0
core/src/web/staticres/css/dev-qfw.css

@@ -2331,6 +2331,12 @@ style="color:#D03102;margin-right:5px;"
 	padding: 10px 10px 10px 20px;
 	font-size: 16px;
 }
+.b-modal .modal-header-jy{
+	background-color: #37C6DA;
+	color: #FFFFFF;
+	padding: 10px 10px 10px 20px;
+	font-size: 16px;
+}
 .b-modal .modal-header .close{
 	opacity: 1;
 	text-shadow: none;

+ 9 - 0
core/src/web/staticres/css/swordfish.css

@@ -88,6 +88,11 @@ a:focus, a:hover{
 	border: 1px solid #F5DC99;
 	text-indent: 2em;
 }
+.swordfish-explain2{
+	background-color: #FCF8E3;
+	padding: 10px 30px;
+	text-indent: 2em;
+}
 .swordfish-explain span{
 	color: #A0A0A0;
 }
@@ -329,6 +334,10 @@ a:focus, a:hover{
 	border-radius: 8px !important;
 	margin-right: 10px;
 }
+.btn-primary, .btn-primary:hover, .btn-primary:focus, .btn-primary:active {
+    background-color: #37C6DA;
+    border-color: #37C6DA;
+}
 @media (max-width: 1200px) {
 	.b-left{
 		width: 100%;

+ 79 - 9
core/src/web/templates/swordfish/rssset.html

@@ -11,10 +11,10 @@
 	<div class="b-left">
 		<div class="swordfish-page-title">
 			<i class="img-circle glyphicon jianyu"></i>订阅设置
-			<span >继续使用表明你已经同意了<span><a>剑鱼用户服务协议</a>
+			<!--<span >继续使用表明你已经同意了<span><a onclick="$('#yhxyModal').modal('show')">剑鱼用户服务协议</a>-->
 			<span style="float:right;width:190px">
 			<a id="ckys">查看演示&nbsp;&nbsp;</a>
-			<a id="sfbz">收费标准</a>
+			<a id="sfbz" onclick="$('#sfbzModal').modal('show')">收费标准</a>
 			<a id="yjfk">去提意见</a>
 			</span>
 		</div>
@@ -251,16 +251,64 @@
   	</div>
 </div>
 
-<!-- tishi -->
+<!-- tishiModal -->
 <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">
+		  	<div class="modal-header-jy">
 				<span data-dismiss="modal" aria-label="Close" class="close glyphicon guanbi1"></span>
 				<span class="modal-title" id="vipcreditModalLabel">提示信息</span>
 			</div>
-			<div>
+			<div class="swordfish-explain2">
 				<div id="swordfish-tishi"></div>
+				<div id="btn-tijiao" style="text-align:center;padding:10px 0;"></div>
+			</div>
+		</div>
+	</div>
+</div>
+
+<!-- 用户协议 -->
+<div class="modal fade b-modal" id="yhxyModal" tabindex="-1" role="dialog" aria-labelledby="yhxyModalLabel">
+  	<div class="modal-dialog" role="document">
+		<div class="modal-content">
+		  	<div class="modal-header-jy">
+				<span data-dismiss="modal" aria-label="Close" class="close glyphicon guanbi1"></span>
+				<span class="modal-title" id="yhxyModalLabel">用户协议</span>
+			</div>
+			<div style="background-color: #FCF8E3;padding:10px;line-height:25px">
+				<div>
+					<p style="margin-left:5px">剑鱼用户协议:</p>
+					<p style="margin-left:15px">
+					 
+					</p>
+				</div>
+				<div style="text-align:center;padding:10px 0;">
+					<button class='btn btn-primary' onclick="$('#yhxyModal').modal('hide')">确定</button>
+				</div>
+			</div>
+		</div>
+	</div>
+</div>
+
+<!-- 收费标准 -->
+<div class="modal fade b-modal" id="sfbzModal" tabindex="-1" role="dialog" aria-labelledby="sfbzModalLabel">
+  	<div class="modal-dialog" role="document">
+		<div class="modal-content">
+		  	<div class="modal-header-jy">
+				<span data-dismiss="modal" aria-label="Close" class="close glyphicon guanbi1"></span>
+				<span class="modal-title" id="sfbzModalLabel">用户协议</span>
+			</div>
+			<div style="background-color: #FCF8E3;padding:10px 20px;line-height:25px">
+				<div>
+					<p style="margin-left:5px">剑鱼收费标准:</p>
+					<p style="margin-left:35px">
+					每个栏目、每月1000积分。
+					积分按月扣除,到期后默认自动扣除下月积分,积分不足则停止服务。如果您不希望下月继续服务,可提前将服务关闭。
+					</p>
+				</div>
+				<div style="text-align:center;padding:10px 0;">
+					<button class='btn btn-primary' onclick="$('#sfbzModal').modal('hide')">确定</button>
+				</div>
 			</div>
 		</div>
 	</div>
@@ -357,11 +405,22 @@ $(function(){
 		if(type=="bid"&&bid_i_status==0){
 			oprarr.push("types=bid");
 		}
+		var typeinfo="";
+		if(type=="tender"){
+			typeinfo="招标公告";
+		}else{
+			typeinfo="中标公告 ";
+		}
 		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);
+			var str1="您选择了<span style='color:red'>"+oprarr.length+"</span>个信息栏目(<span style='color:red'>"+typeinfo+"</span>),确认后系统将每月扣除<span style='color:red'>"+oprarr.length*1000+"</span>积分,您目前的积分余额<span style='color:red'>("+i_credit+")</span>不足,<a href='/member/credit/myCredit' style='color:#37C6DA'>去做任务赚积分</a>";
+			str2="<button class='btn btn-primary' onclick='swordfishpay(1)'>取消</button>";
+			if((i_credit-oprarr.length*1000)>0){				
+				str1="您选择了<span style='color:red'>"+oprarr.length+"</span>个信息栏目(<span style='color:red'>"+typeinfo+"</span>),确认后系统将每月扣除<span style='color:red'>"+oprarr.length*1000+"</span>积分,您目前的积分余额是<span style='color:red'>"+i_credit+"</span>积分,扣除后将剩余<span style='color:red'>"+(i_credit-oprarr.length*1000)+"</span>积分。";
+				str2="<button class='btn btn-primary' onclick='swordfishpay(0)'>提交</button>"
+				+"&nbsp;<button class='btn btn-primary' onclick='swordfishpay(1)'>取消</button>";
+			}
+			$("#swordfish-tishi").html(str1);
+			$("#btn-tijiao").html(str2);
 			$("#tishiModal").modal("show");
 		}
 		$(this).hide();
@@ -373,6 +432,17 @@ $(function(){
 		$(this).hide();
 		ajaxReq();
 	});
+	//针对页面异常关闭
+	if(typeof(msgset.tender) != "undefined"&&typeof(msgset.tender.i_switchstatus) != "undefined"&&msgset.tender.i_switchstatus==1){
+		if(tender_i_status==0){
+			$("#tender").children(".swordfish-panel-t").children(".swordfish-uncheck").click();
+		}
+	}
+	if(typeof(msgset.bid) != "undefined"&&typeof(msgset.bid.i_switchstatus) != "undefined"&&msgset.bid.i_switchstatus==1){
+		if(bid_i_status==0){
+			$("#bid").children(".swordfish-panel-t").children(".swordfish-uncheck").click();
+		}
+	}
 });
 function afterSelectScope(type,btn){
 	var text = btn.text();