Ver Fonte

Merge branch 'develop' of 192.168.3.17:zhanghongbo/qfw into develop

wangchuanjin há 9 anos atrás
pai
commit
d5d7a7fc6b

+ 35 - 0
common/src/config.json

@@ -0,0 +1,35 @@
+{
+    "webServerPort": "80",
+    "redisServers": "enterprise=192.168.3.14:1379,service=192.168.3.14:2379,other=192.168.3.14:3379,sso=192.168.3.14:1379,credit=192.168.3.14:3379",
+    "useRedis": false,
+    "mongodbServers": "192.168.3.18:27080",
+    "elasticsearch": "http://192.168.3.18:9800",
+    "elasticPoolSize": 30,
+    "mongodbPoolSize": 5,
+    "mongodbName": "qfw",
+    "smtp": {
+        "addr": "smtp.exmail.qq.com",
+        "port": 465,
+        "user": "qyfw@topnet.net.cn",
+        "pwd": "qy123456",
+        "fromuser": "企明星"
+    },
+    "sms": {
+        "company": "企明星"
+    },
+    "entrelation": {
+        "level": 2,
+        "limit": 10
+    },
+    "allownfiletype": "gif,jpg,jpeg,png,doc,docx,xls,xlsx,zip,rar,pdf,txt",
+    "filesize": 15120,
+    "templateCache": false,
+    "httpCache": false,
+    "mailFailureTime": 3,
+    "chatServer": "127.0.0.1:83",
+    "chatRpc": "127.0.0.1:88",
+	"creditRpc":"127.0.0.1:8765",
+	"pushRpc":"127.0.0.1:8766",
+	"domainName":"http://www.qimingxing.info"
+
+}

+ 0 - 12
core/src/qfw/search/searchService.go

@@ -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 08:55:02"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-22 08:55:02"}},"marketisstart":true,"marketrate":300}
+{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-22 13:40:43"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-22 13:40:43"}},"marketisstart":true,"marketrate":300}

+ 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;

+ 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"
 }

+ 6 - 2
weixin/src/qfw/weixin/dao/userdao.go

@@ -42,9 +42,13 @@ func AddUser(openid, unionid, bindweixin, userphoto string) (err error, flag int
 		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)
+			//go SaveMyNewUserCoupon(openid)
 			//卡劵赠送完成,暂不存来源记录
 			return nil, 1
 		} else {

+ 9 - 7
weixin/src/qfw/weixin/msgtxtchandler.go

@@ -63,15 +63,17 @@ 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"]) {
+		if dao.FindWinningRecord(r.FromUserName, wf.SysConfig.Activity["activitycode"]) {
 			w.ReplyText("小主莫贪心,每人只有一次抽奖机会呦")
-		}*/
-		//TODO 改为查我的抽奖卷
-		if dao.GetMyCouponAmount(r.FromUserName) <= 0 {
-			w.ReplyText("对不起,你的奖劵不足。您可以查看<a href='http://www.qimingxing.info/p/'>企明星的最新活动</a>赚取积分。")
-		} else if dao.GetMyTodayDrawTimes() > 0 { //检查今日抽奖次数
-			w.ReplyText("对不起,你今天的抽奖次数已经用完,请您明天再来。")
 		} 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

@@ -58,7 +58,7 @@ func SubscribeHandler(w ResponseWriter, r *Request) {
 			//TODO 处理分享(邀请)类的二维码,记录邀请关系
 			if strings.HasPrefix(source, "32") {
 				go dao.SaveInviteLink(source, r.FromUserName)
-				go dao.UpdateInviteUserCoupon(source)
+				//go dao.UpdateInviteUserCoupon(source)
 			}
 		} else {
 			w.ReplyText(OWELCOME_MSG) // 有旧人关注,返回欢迎消息