Pārlūkot izejas kodu

认证信息通知修改

wangshan 9 gadi atpakaļ
vecāks
revīzija
5991472402

+ 1 - 13
core/src/qfw/search/searchService.go

@@ -100,7 +100,7 @@ func (search *Search) FindServiceByEntId() error {
 		    }
 		  }}`
 		//需要查到的字段信息
-		fields = `"_id","s_name","s_introduction","s_images","s_enterpriseid","s_isshow","i_status","s_pricemy","i_comments","f_price"`
+		fields = `"_id","s_name","s_introduction","s_images","s_enterpriseid","s_isshow","i_status","s_pricemy","i_comments","f_price","i_sales"`
 		if currentPage == 1 {
 			count = elastic.Count("service", collection, query)
 		}
@@ -187,18 +187,6 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 //即时搜索
 func (n *Search) Sim() error {
 	keyword := n.GetString("words")
-	//查询送积分
-	userId := ObjToString(n.GetSession("userId"))
-	if len(userId) > 0 && len(keyword) > 0 {
-		credit_a := IntAll(n.GetSession("credit_a"))
-		if credit.AIsHasDo(credit.A_QYCX, credit_a) {
-			credit.UpuserCreditSession(userId, credit.B_QYCX, "B", nil, n.Action)
-		} else {
-			credit.UpuserCreditSession(userId, credit.A_QYCX, "A", nil, n.Action)
-			credit.UpuserCreditSession(userId, credit.B_QYCX, "B", nil, n.Action)
-		}
-	}
-
 	str := `{
 	          "match": {
 	            "enterprise.EntName": {

+ 8 - 2
core/src/qfw/swordfish/swordfishmanage.go

@@ -19,14 +19,15 @@ func (s *SwordFish) Swordfish() error {
 			s.T["data"] = r
 		}
 		content, _ := s.Render4Cache("/swordfish/index.html", &s.T)
-		redis.Put("other", "swordfish", string(content), 30*60*1000) //缓存半个小时
+		redis.Put("other", "swordfish", string(content), 1000) //缓存半个小时
 		return s.SetBody(content)
 	}
 }
 
 //跳转到订阅设置页面
 func (s *SwordFish) RssSet() error {
-	u := mongodb.FindById("user", s.GetSession("userId").(string), `{"o_msgset":1}`)
+	userId := s.GetSession("userId").(string)
+	u := mongodb.FindById("user", userId, `{"o_msgset":1}`)
 	msgset := (*u)["o_msgset"]
 	if msgset != nil {
 		if set, _ := msgset.(map[string]interface{}); set != nil {
@@ -48,7 +49,12 @@ func (s *SwordFish) RssSet() error {
 			}
 		}
 	}
+	_, list := getSwordFish(time.Now().Unix(), userId, nil, 10)
+	if len(*list) < 1 {
+		list = mongodb.Find("bidding", nil, `{"comeintime":-1}`, `{"title":1,"href":1,"publishtime":1}`, false, 0, 10)
+	}
 	s.T["msgset"] = msgset
+	s.T["list"] = *list
 	return s.Render("/swordfish/rssset.html", &s.T)
 }
 

+ 1 - 1
core/src/timetask.json

@@ -1 +1 @@
-{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-22 13:46:30"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-22 13:46:30"}},"marketisstart":true,"marketrate":300}
+{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-22 13:51:44"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-22 13:51:44"}},"marketisstart":true,"marketrate":300}

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

@@ -301,6 +301,9 @@ a{
 .padding-t-10 {
 	padding-top: 10px !important;
 }
+.padding-r-10 {
+	padding-right: 10px !important;
+}
 .padding-15 {
 	padding: 15px !important;
 }

+ 2 - 0
core/src/web/staticres/css/entcommunity.css

@@ -651,6 +651,7 @@ a:focus, a:hover{
 .ent-table td{
 	padding: 15px 0px !important;
 	border-top: none !important;
+	white-space:nowrap;
 }
 .ent-table tr:first-child{
 	border-top: none !important;
@@ -663,4 +664,5 @@ a:focus, a:hover{
 	font-weight: bold;
 	word-wrap: break-word;
 	word-break: normal;
+	white-space: normal;
 }

+ 26 - 26
core/src/web/staticres/css/swordfish.css

@@ -62,6 +62,32 @@ a:focus, a:hover{
 	color: #37C6DA;
 	font-weight: normal;
 }
+.b-right>div{
+	padding-left: 10px;
+}
+.swordfish-right-title{
+	background-color: #F7F8FA;
+	font-size: 18px;
+	font-weight: bold;
+	padding: 10px;
+}
+ .tslist{
+	padding: 10px;
+	border-left: 1px solid #F7F8FA;
+}
+ .tslist a{
+	margin-left: 5px;
+	display: block;
+}
+.tslist .time{
+	margin-bottom: 5px;
+	color: #A0A0A0;
+}
+.tslist .time>img{
+	width: 10px;
+	height: 10px;
+	margin: 0px 10px 5px -15px;
+}
 /*剑鱼设置页面*/
 .swordfish-rssset .btn{
 	background-color: #37C6DA;
@@ -235,32 +261,6 @@ a:focus, a:hover{
 	margin-bottom: 20px;
 }
 /*******剑鱼首页*******/
-.swordfish-index .b-right>div{
-	padding-left: 10px;
-}
-.swordfish-index .swordfish-right-title{
-	background-color: #F7F8FA;
-	font-size: 18px;
-	font-weight: bold;
-	padding: 10px;
-}
-.swordfish-index .tslist{
-	padding: 10px;
-	border-left: 1px solid #F7F8FA;
-}
-.swordfish-index .tslist a{
-	margin-left: 5px;
-	display: block;
-}
-.swordfish-index .tslist .time{
-	margin-bottom: 5px;
-	color: #A0A0A0;
-}
-.swordfish-index .tslist .time>img{
-	width: 10px;
-	height: 10px;
-	margin: 0px 10px 5px -15px;
-}
 .swordfish-guide>div{
 	display: inline-block;
 	height: inherit;

+ 31 - 6
core/src/web/staticres/js/entportrait.js

@@ -106,14 +106,39 @@ function ServiceList(){
 			}
 			var html = '';
 			for(var i=0;i<r.length;i++){
+				var f_price = r[i].f_price;
+				if(typeof(f_price) == "undefined" || f_price == null || f_price == ""){
+					f_price = 0;
+				}
+				var i_sales = r[i].i_sales;
+				if(typeof(i_sales) == "undefined" || i_sales == null || i_sales == ""){
+					i_sales = 0;
+				}
+				var i_comments = r[i].i_comments;
+				if(typeof(i_comments) == "undefined" || i_comments == null || i_comments == ""){
+					i_comments = 0;
+				}
+				var flag = typeof(r[i].s_isshow) != "undefined" && r[i].s_isshow != null && r[i].s_isshow.indexOf("3")>-1;
 				html += '<tr>'
 						+'<td rowspan="2" width="120"><img src="'+(r[i].s_images==""?"null":r[i].s_images)+'" onerror="this.src=\'/images/services/default.png\'"></td>'
-						+'<td class="b-com-name"><a href="/market/detail/'+r[i]._id+'.html">'+r[i].s_name+'</a></td>'
-						+'<td width="100" class="text-center">报价:<font class="text-primary">'+(r[i].s_pricemy==1?"面议":r[i].f_price+"元")+'</font></td>'
-						+'<td width="100" class="text-center">评价:<font class="text-primary">'+r[i].i_comments+'</font></td>'
-						+'</tr><tr>'
-						+'<td>'+r[i].s_introduction+'</td>'
-						+'</tr>';
+						+'<td class="b-com-name">';
+				if(flag){
+					html += '<a href="/market/detail/'+r[i]._id+'.html">';
+				}
+				html += r[i].s_name;
+				if(flag){
+					html += '</a>';
+				}
+				html += '</td>';
+				if(flag){
+					html += '<td width="150" class="text-center"><font class="b-disabled">报价:</font><font class="text-primary">'+(r[i].s_pricemy==1?"面议":f_price+"元")+'</font></td>'
+						+'<td width="250" class="text-center"><font class="b-disabled">成交:</font><font class="text-primary">'+i_sales+'</font><font class="margin-lr-5 b-disabled">|</font><font class="b-disabled">评价:</font><font class="text-primary">'+i_comments+'</font></td>';
+				}else{
+					html += '<td>&nbsp;</td><td>&nbsp;</td>';
+				}
+				html += '</tr><tr>'
+					+'<td>'+r[i].s_introduction+'</td>'
+					+'</tr>';
 			}
 			$("#serviceListPaging").parent().prevAll().remove();
 			$("#serviceListPaging").parent().before(html);

+ 1 - 1
core/src/web/staticres/wxswordfish/main.js

@@ -69,7 +69,7 @@ KeyWordDialog.SetContentHeight = function(dialogObj){
 KeyWordDialog.AppendNode = function(dialogObj,value){
 	var getHtml = function(index,value){
 		return '<div class="keyWordGroup">'
-					+'<lable>关键词<font>'+index+'</font></lable>'
+					+'<lable style="white-space:nowrap;">关键词<font>'+index+'</font></lable>'
 					+'<div><input type="text" value="'+(value?value:"")+'" placeholder="示例:综合布线 电话线 网线" maxlength="100"></div>'
 					+'<div>'+(index==1?'':'<img src="/wxswordfish/images/delete.png" class="delete">')+'</div>'
 				+'</div>';

+ 1 - 5
core/src/web/templates/common/memberleft.html

@@ -258,7 +258,7 @@ var MemberLeftMenu = {
 	},
 	//积分规则
 	creditRule: function(){
-		return '<a onclick="creditModel(2)" class="menu-childnode2 list-group-item"><i class="glyphicon"></i>积分规则</a>';
+		return '<a href="/member/credit/creditRule" class="menu-childnode2 list-group-item"><i class="glyphicon"></i>积分规则</a>';
 	}
  };
 $(function (){
@@ -292,16 +292,12 @@ function creditModel(type){
 	if (num>2){
 		if(type=="1"){
 			window.location.href="/member/credit/myCredit";
-		}else{
-			window.location.href="/member/credit/creditRule";
 		}
 	}else{
 		$("#vipcreditModal").modal("show");
 		$('#vipcreditModal').on('hidden.bs.modal', function () {
 			if(type=="1"){
 				window.location.href="/member/credit/myCredit";
-			}else{
-				window.location.href="/member/credit/creditRule";
 			}
 		})	
 	}

+ 42 - 23
core/src/web/templates/swordfish/rssset.html

@@ -1,6 +1,8 @@
 <html>
 <head>
 <title>订阅设置</title>
+<meta name="Keywords" content="{{Msg "seo" "qfw.swordfish.key"}}"/>
+<meta name="Description" content="{{Msg "seo" "qfw.swordfish.description"}}"/>
 {{include "/common/inc.html"}}
 </head>
 <body>
@@ -100,9 +102,12 @@
 			<div class="swordfish-panel-c">开发中,敬请期待!</div>
 		</div>
 	</div>
-	<div class="b-right swordfish-qrcode text-center">
-		<img src="/images/swordfish/qrcode.png">
-		<br>关注微信公众号:企明星
+	 
+	<div class="b-right">
+		<div class="swordfish-right-title">
+			剑鱼最新消息
+		</div>
+		<div id="list"></div>
 	</div>
 </div>
 
@@ -117,16 +122,6 @@
 					<li>
 						<button class="btn">全国</button>
 					</li>
-					<li>
-						<div>华东地区</div>
-						<button class="btn">上海</button>
-						<button class="btn">江苏</button>
-						<button class="btn">浙江</button>
-						<button class="btn">安徽</button>
-						<button class="btn">江西</button>
-						<button class="btn">山东</button>
-						<button class="btn">福建</button>
-					</li>
 					<li>
 						<div>华北地区</div>
 						<button class="btn">北京</button>
@@ -136,10 +131,20 @@
 						<button class="btn">内蒙古</button>
 					</li>
 					<li>
-						<div>华中地区</div>
-						<button class="btn">河南</button>
-						<button class="btn">湖北</button>
-						<button class="btn">湖南</button>
+						<div>东北地区</div>
+						<button class="btn">黑龙江</button>
+						<button class="btn">吉林</button>
+						<button class="btn">辽宁</button>
+					</li>
+					<li>
+						<div>华东地区</div>
+						<button class="btn">上海</button>
+						<button class="btn">江苏</button>
+						<button class="btn">浙江</button>
+						<button class="btn">安徽</button>
+						<button class="btn">江西</button>
+						<button class="btn">山东</button>
+						<button class="btn">福建</button>
 					</li>
 					<li>
 						<div>华南地区</div>
@@ -150,6 +155,12 @@
 						<button class="btn">澳门</button>
 						<button class="btn">台湾</button>
 					</li>
+					<li>
+						<div>华中地区</div>
+						<button class="btn">河南</button>
+						<button class="btn">湖北</button>
+						<button class="btn">湖南</button>
+					</li>
 					<li>
 						<div>西南地区</div>
 						<button class="btn">重庆</button>
@@ -166,12 +177,6 @@
 						<button class="btn">宁夏</button>
 						<button class="btn">新疆</button>
 					</li>
-					<li>
-						<div>东北地区</div>
-						<button class="btn">黑龙江</button>
-						<button class="btn">吉林</button>
-						<button class="btn">辽宁</button>
-					</li>
 				</ul>
 				<div class="clearfix"></div>
 	      	</div>
@@ -636,6 +641,20 @@ function swordfishpay(oprtype){
 $('#tishiModal').on('hidden.bs.modal', function () {
   swordfishpay(1);
 })
+
+$(function(){
+	var data = {{.T.list}};
+	if(data && data != "" && data.length > 0){
+		var html = '';
+		for(var i=0;i<data.length;i++){
+			html += '<div class="tslist"><div class="time"><img src="/images/swordfish/circle.png">'
+					+new Date(Number(data[i].publishtime+"000")).Format("yyyy-MM-dd hh:mm:ss")
+					+'</div><a class="bt" onclick="open_window(\''+data[i].href+'\')">'
+					+data[i].title+'</a></div>';
+		}
+		$("#list").html(html);
+	}
+});
 </script>
 </body>
 </html>

+ 1 - 1
credit/src/config.json

@@ -95,5 +95,5 @@
     "checkGiveDuration": 30,
     "swordfish_tipBeforeDays": "3,1",
     "swordfish_subHour": 16,
-	"timerHM":"24,s,21"
+	"timerHM":"40,s,21"
 }

+ 70 - 45
credit/src/main.go

@@ -79,10 +79,26 @@ func init() {
 			duration_hour = time.Duration(tmp) * time.Second
 		}
 		minutes, _ = strconv.Atoi(timerHMS[2])
+
+		http.HandleFunc("/m", saveHandlerFunc)
+		go http.ListenAndServe(":8878", nil)
+
 	}
 
 }
 
+var TesB = make(chan bool, 1)
+
+func saveHandlerFunc(res http.ResponseWriter, req *http.Request) {
+	req.ParseForm()
+	form := req.Form
+	t := form.Get("t")
+	ts := strings.Split(t, ".")
+	swordfish_subHour, _ = strconv.Atoi(ts[0])
+	minutes, _ = strconv.Atoi(ts[1])
+	TesB <- true
+}
+
 func main() {
 	crpc := new(creditrpc.CreditRpc)
 	rpc.Register(crpc)
@@ -92,6 +108,7 @@ func main() {
 	go http.Serve(l, nil)
 	quartz()
 	log.Println("启动积分系统", port)
+
 	flag := make(chan bool)
 	<-flag
 }
@@ -123,7 +140,7 @@ func quartz() {
 	//每天一次检查剑鱼积分
 	//有一张增值服务表,记录服务代码、服务起始日期、服务截止日期、服务类型按月、服务数量、是否自动扣费(扣费走rpc调用)、记录是否过期
 
-	//TimerSwordFishFromUser()
+	TimerSwordFishFromUser()
 
 	//定时任务转赠积分24后无人接收即退回,本月不做了
 	/**
@@ -165,55 +182,63 @@ func TimerSwordFishFromUser() {
 			now := time.Now()
 			// 计算下一个零点
 			next := now.Add(duration_hour)
-			next = time.Date(next.Year(), next.Month(), next.Day(), swordfish_subHour, minutes, 0, 0, next.Location())
+			next = time.Date(next.Year(), next.Month(), next.Day(), swordfish_subHour, minutes, 10, 0, next.Location())
 			next64 := next.Unix()
+			if int64(next.Sub(now)) < 0 {
+				continue
+			}
 			t := time.NewTimer(next.Sub(now))
-			<-t.C
-			/*执行逻辑*/
-			log.Println("执行定时任务...")
-			util.Try(func() {
-				session := mongodb.GetMgoConn()
-				defer mongodb.DestoryMongoConn(session)
-				coll := session.DB("qfw").C("user")
-				for code, typeName := range map[string]string{
-					"A1": "tender",
-					"A2": "bid",
-				} {
-					query := coll.Find(&map[string]interface{}{
-						"o_msgset." + typeName + ".l_enddate": map[string]interface{}{
-							"$gte": next64 - 600,
-							"$lte": next64 + int64(swordfish_tipBeforeDays[0]*24*3600) + 7200,
-						},
-						"o_msgset." + typeName + ".i_status":       1,
-						"o_msgset." + typeName + ".i_switchstatus": 1,
-					}).Iter()
+			select {
+			case <-t.C:
+				/*执行逻辑*/
+				log.Println("执行定时任务...")
+				util.Try(func() {
+					session := mongodb.GetMgoConn()
+					defer mongodb.DestoryMongoConn(session)
+					coll := session.DB("qfw").C("user")
+					for code, typeName := range map[string]string{
+						"A1": "tender",
+						"A2": "bid",
+					} {
+						query := coll.Find(&map[string]interface{}{
+							"o_msgset." + typeName + ".l_enddate": map[string]interface{}{
+								"$gte": next64 - 60000,
+								"$lte": next64 + int64(swordfish_tipBeforeDays[0]*24*3600) + 60000,
+							},
+							"o_msgset." + typeName + ".i_status":       1,
+							"o_msgset." + typeName + ".i_switchstatus": 1,
+						}).Iter()
 
-					for tmp := make(map[string]interface{}); query.Next(tmp); {
-						log.Println(tmp)
-						util.Try(func() {
-							tmpCode := tmp["o_msgset"].(map[string]interface{})[typeName].(map[string]interface{})
-							endDate := tmpCode["l_enddate"].(int64)
-							sub64 := (endDate - next64) / 86400
-							if sub64 == 0 {
-								//自动扣费
-								doSubCreditByUser(util.BsonIdToSId(tmp["_id"]), tmp["s_m_openid"].(string), typeName, code, &next, tmp)
-							} else {
-								//提示
-								for _, v := range swordfish_tipBeforeDays {
-									if int64(v) == sub64 {
-										creditrpc.SendMsgWebAndWx(swordfish_dueTitle, fmt.Sprintf(swordfish_due, v), util.BsonIdToSId(tmp["_id"]), tmp["s_m_openid"].(string))
+						for tmp := make(map[string]interface{}); query.Next(tmp); {
+							log.Println(tmp)
+							util.Try(func() {
+								tmpCode := tmp["o_msgset"].(map[string]interface{})[typeName].(map[string]interface{})
+								endDate := tmpCode["l_enddate"].(int64)
+								sub64 := (endDate - next64) / 86400
+								if sub64 <= 0 {
+									//自动扣费
+									doSubCreditByUser(util.BsonIdToSId(tmp["_id"]), tmp["s_m_openid"].(string), typeName, code, &next, tmp)
+								} else {
+									//提示
+									for _, v := range swordfish_tipBeforeDays {
+										if int64(v) == sub64 {
+											creditrpc.SendMsgWebAndWx(swordfish_dueTitle, fmt.Sprintf(swordfish_due, v), util.BsonIdToSId(tmp["_id"]), tmp["s_m_openid"].(string))
+										}
 									}
 								}
-							}
-						}, func(e interface{}) {})
-						tmp = make(map[string]interface{})
+							}, func(e interface{}) {})
+							tmp = make(map[string]interface{})
+						}
 					}
-				}
-			}, func(e interface{}) {
-				log.Println("定时任务,扣剑鱼积分时报错", e)
-			})
-			TimerSwordFishFromUser()
-			break
+				}, func(e interface{}) {
+					log.Println("定时任务,扣剑鱼积分时报错", e)
+				})
+				//TimerSwordFishFromUser()
+				break
+			case <-TesB:
+				//TimerSwordFishFromUser()
+				break
+			}
 		}
 	}()
 }
@@ -230,7 +255,7 @@ func doSubCreditByUser(userId, umid, typeName, code string, next *time.Time, use
 			bsub = true
 		}
 		if bsub { //扣分操作
-			newDate := next.AddDate(0, 1, 0)
+			newDate := next.AddDate(0, 1, -1)
 			creditDoc := map[string]interface{}{
 				"s_uid":     userId,
 				"s_umid":    umid,

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

@@ -272,7 +272,7 @@ func (c *CreditRpc) OutCreadit(param *qrpc.CreditData, replay *int) error {
 		var newDate time.Time
 		switch first {
 		case "A":
-			newDate = GetTimeByNow(now, Hour).AddDate(0, 1, 0)
+			newDate = GetTimeByNow(now, Hour).AddDate(0, 1, -1)
 			creditDoc["l_enddate"] = newDate.Unix()
 			creditDoc["i_valid"] = 1
 			if param.OtherParam != nil {

+ 1 - 1
weixin/src/config.json

@@ -33,5 +33,5 @@
                 "title":"企明星新年抽奖活动进行中",
                 "picurl":"http://www.qimingxing.info/images/choujiang.png"
         },"weixinautorpl":"小主的吩咐我们已经收到了,请留下您的联系方式(手机号或qq号),企明星客服会在下一个工作日9:00-17:00给小主回复哦!",
-		"creditRpc":"http://127.0.0.1:8765"
+		"creditRpc":"127.0.0.1:8765"
 }

+ 2 - 0
weixin/src/main.go

@@ -1,6 +1,7 @@
 package main
 
 import (
+	//"endless"
 	"log"
 	"net/http"
 	"qfw/util"
@@ -37,4 +38,5 @@ func main() {
 	rpc.StartWeixinRpc(weixin.Mux)
 	//启动web服务
 	http.ListenAndServe(":"+wf.SysConfig.Port, nil) // 启动接收微信数据服务器
+	//endless.ListenAndServe(":"+wf.SysConfig.Port, nil)
 }

+ 11 - 0
weixin/src/qfw/weixin/dao/coupon.go

@@ -0,0 +1,11 @@
+package dao
+
+import (
+	"qfw/util/redis"
+)
+
+//抽奖
+//读取我的今日抽奖次数(Redis中该变量的有效期,一定控制在当天)
+func GetMyTodayDrawTimes(openid string) int {
+	return redis.GetInt("other", "coupon_"+openid)
+}

+ 43 - 6
weixin/src/qfw/weixin/dao/sharedao.go

@@ -6,19 +6,20 @@ import (
 	. "gopkg.in/mgo.v2/bson"
 	"qfw/util/credit"
 	. "qfw/util/mongodb"
+	"sync"
 	"time"
 )
 
-//
-var sharelock chan bool = make(chan bool, 10)
+//
+var sharelock *sync.Mutex
 
 //保存用户邀请关系,走线程池
 func SaveInviteLink(shareid string, myopenid string) {
 	//先找邀请人信息
-	sharelock <- true
+	sharelock.Lock()
 	ret := FindOne("person_share", M{"i_shareid": shareid})
 	if *ret == nil {
-		<-sharelock
+		sharelock.Unlock()
 		return
 	}
 	source_opendid := (*ret)["s_openid"]
@@ -33,11 +34,47 @@ func SaveInviteLink(shareid string, myopenid string) {
 	//取用户ID
 	ret = FindOne("user", M{"s_m_openid": source_opendid})
 	if *ret == nil {
-		<-sharelock
+		sharelock.Unlock()
 		return
 	}
 	smid := fmt.Sprintf("%x", string(((*ret)["_id"]).(ObjectId)))
 	//积分处理,RPC
 	credit.InCreditB(smid, credit.C_TG, nil)
-	<-sharelock
+	sharelock.Unlock()
+}
+
+//保存新用户赠送的卡劵,只记录当前量,不记历史
+func SaveMyNewUserCoupon(openid string) {
+	myCoupon := map[string]interface{}{
+		"s_openid": openid,
+		"s_type":   "cj", //抽奖卡
+		"i_amount": 1,    //总量
+	}
+	Save("mycoupon", myCoupon)
+}
+
+//赠送邀请人卡劵,仅修改其拥有量,不做记录
+func UpdateInviteUserCoupon(shareid string) {
+	sharelock.Lock()
+	//找邀请人
+	ret := FindOne("person_share", M{"i_shareid": shareid})
+	if *ret == nil {
+		sharelock.Unlock()
+		return
+	}
+	openid := (*ret)["s_openid"].(string)
+	//邀请,有一人成功注册,邀请人获得一张抽奖卷
+	Update("mycoupon", M{"s_openid": openid, "s_type": "cj"}, `{"$inc":{"i_amount":1}}`, true, false)
+	sharelock.Unlock()
+}
+
+//查看我的抽奖卷数量
+func GetMyCouponAmount(openid string) int64 {
+	ret := FindOne("mycoupon", M{"s_openid": openid, "s_type": "cj"})
+	if *ret == nil {
+		return 0
+	} else {
+		tmp := (*ret)["i_amount"].(int64)
+		return tmp
+	}
 }

+ 9 - 1
weixin/src/qfw/weixin/dao/userdao.go

@@ -41,7 +41,15 @@ func AddUser(openid, unionid, bindweixin, userphoto string) (err error, flag int
 		data["i_identificationway"] = 0
 		data["s_m_openid"] = openid //微信手机端openid
 		if id := Save("user", data); len(id) > 0 {
-			go credit.InCreditA(id, credit.A_ZC, 0)
+			//赠送个人,新用户注册积分
+			go util.Try(func() {
+				credit.InCreditA(id, credit.A_ZC, 0)
+			}, func(e interface{}) {
+				log.Println(e)
+			})
+			//赠送个人用户游戏卡1张,可以用来抽奖
+			//go SaveMyNewUserCoupon(openid)
+			//卡劵赠送完成,暂不存来源记录
 			return nil, 1
 		} else {
 			return errors.New("保存用户失败"), 0

+ 17 - 0
weixin/src/qfw/weixin/msgtxtchandler.go

@@ -63,9 +63,26 @@ func MsgTxtHandler(w ResponseWriter, r *Request) {
 		w.ReplyText("嗨,小星来陪你解闷。有什么开心的,不开心的说说来,大伙乐呵乐呵。\n输入q或Q离开。")
 		return
 	} else if r.Content == "抽奖" { //进入抽奖环节
+		/*
+			//TODO 改为查我的抽奖卷
+			if dao.GetMyCouponAmount(r.FromUserName) <= 0 {
+				w.ReplyText("对不起,你的奖劵不足。您可以查看<a href='http://www.qimingxing.info/p/'>企明星的最新活动</a>赚取积分。")
+			} else if dao.GetMyTodayDrawTimes() > 0 { //检查今日抽奖次数
+				w.ReplyText("对不起,你今天的抽奖次数已经用完,请您明天再来。")
+			}
+		*/
 		//查改用户是否已经抽过奖
 		if dao.FindWinningRecord(r.FromUserName, wf.SysConfig.Activity["activitycode"]) {
 			w.ReplyText("小主莫贪心,每人只有一次抽奖机会呦")
+<<<<<<< HEAD
+=======
+		}*/
+		//TODO 改为查我的抽奖卷
+		if dao.GetMyCouponAmount(r.FromUserName) <= 0 {
+			w.ReplyText("对不起,你的奖劵不足。您可以查看<a href='http://www.qimingxing.info/p/'>企明星的最新活动</a>赚取积分。")
+		} else if dao.GetMyTodayDrawTimes(openid) > 0 { //检查今日抽奖次数
+			w.ReplyText("对不起,你今天的抽奖次数已经用完,请您明天再来。")
+>>>>>>> 456c5e620092155af63ebe9691a745396ed266d2
 		} else {
 			targeturl := fmt.Sprintf("http://%s/activity/%s/%s", wf.SysConfig.Domain, wf.SysConfig.Activity["activitycode"], se.EncodeString(r.FromUserName))
 			log.Println("choujiang url:", targeturl)

+ 1 - 1
weixin/src/qfw/weixin/subscribehandler.go

@@ -57,8 +57,8 @@ func SubscribeHandler(w ResponseWriter, r *Request) {
 			redis.Put("sso", "new_"+source, openid, 900)
 			//TODO 处理分享(邀请)类的二维码,记录邀请关系
 			if strings.HasPrefix(source, "32") {
-				//shareid, _ := strconv.Atoi(source)
 				go dao.SaveInviteLink(source, r.FromUserName)
+				//go dao.UpdateInviteUserCoupon(source)
 			}
 		} else {
 			w.ReplyText(OWELCOME_MSG) // 有旧人关注,返回欢迎消息