Sfoglia il codice sorgente

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

zhangjinkun@topnet.net.cn 9 anni fa
parent
commit
f7f20ef9c1

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

+ 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 - 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/qfw/weixin/dao/userdao.go

@@ -48,7 +48,7 @@ func AddUser(openid, unionid, bindweixin, userphoto string) (err error, flag int
 				log.Println(e)
 			})
 			//赠送个人用户游戏卡1张,可以用来抽奖
-			go SaveMyNewUserCoupon(openid)
+			//go SaveMyNewUserCoupon(openid)
 			//卡劵赠送完成,暂不存来源记录
 			return nil, 1
 		} else {

+ 12 - 1
weixin/src/qfw/weixin/msgtxtchandler.go

@@ -63,15 +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"]) {
+		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

@@ -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) // 有旧人关注,返回欢迎消息