浏览代码

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

wangchuanjin 9 年之前
父节点
当前提交
ce86e37907

+ 2 - 1
common/src/qfw/util/encrypt_test.go

@@ -12,7 +12,8 @@ import (
 func TestEncrypt(t *testing.T) {
 	se := &SimpleEncrypt{Key: "topnet"}
 
-	log.Println(se.EncodeString("obEpLuH03fTYZ2e0xhJL3k7H6q48,ff,ff,swordfishaction"))
+	log.Println(se.EncodeString("oJULtwzXo6EFV1Ah-XeyRBimXGM8,ff,ff,swordfishaction"))
+	log.Println(se.DecodeString("GyUlIhEDDjcfWCAyIl4xBkgsERYiLAwZLCg9VkkSEkMWCEkHAwACCgMdBwcRDREdGwE="))
 }
 
 func Test_sim(t *testing.T) {

+ 1 - 28
core/src/timetask.json

@@ -1,29 +1,2 @@
-{
-    "comment": {
-        "c_rate": 720,
-        "commentrate": 900
-    },
-    "market": {
-        "demand": {
-            "attr": [
-                "i_hits",
-                "i_bids",
-                "i_status"
-            ],
-            "timepoint": "2016-01-21 14:42:23"
-        },
-        "service": {
-            "attr": [
-                "i_hits",
-                "i_sales",
-                "i_comments",
-                "i_score",
-                "i_appcounts"
-            ],
-            "timepoint": "2016-01-21 14:42:23"
-        }
-    },
-    "marketisstart": true,
-    "marketrate": 300
-}
+{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-21 17:20:57"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-21 17:20:57"}},"marketisstart":true,"marketrate":300}
 

+ 23 - 1
core/src/web/templates/index.html

@@ -251,7 +251,7 @@
 		<ul>
 		{{range $k,$v:=.T.sfdata}}
 		{{ if lt $k 8}}
-		<li><span></span><span><a target="_blank" href="{{index $v "href"}}"/>{{index $v "title"}}</a></span><span style="float:right;">{{if (index $v "publishtime")}}{{index $v "publishtime"}}{{else}}------{{end}}</span></li>
+		<li><span></span><span><a target="_blank" href="javascript:void(0);" class="reload" src="{{index $v "href"}}"/>{{index $v "title"}}</a></span><span style="float:right;">{{if (index $v "publishtime")}}{{index $v "publishtime"}}{{else}}------{{end}}</span></li>
 		{{if ge $k 3}}
 		{{if lt $k 4}}
 		</ul>
@@ -309,6 +309,28 @@
 </div>
 {{include "/common/bottom.html"}}
 <script>
+$(function(){
+var areload=$("a.reload");
+areload.click(function(){
+	var h=$(this).attr("src");
+	open_window(h);
+	return false;
+})
+})
+function redirect(link){ 
+	if(!/^http/.test(link)){
+		link="http://"+link
+	}
+	window.location.href="/visit/redirect?url="+escape(link)
+
+}
+function open_window(link){
+	if(!/^http/.test(link)){
+		link="http://"+link
+	}
+    var arg = '\u003cscript\u003elocation.replace("'+link+'")\u003c/script\u003e';
+    window.open('javascript:window.name;', arg);
+}
 $(".bmzhsk").mouseover(function(){
 	$(".index-new-bmrzqy").addClass("hidden");
 	$(".index-new-bmjy").addClass("hidden");

+ 1 - 1
core/src/web/templates/member/accountset/bindmail.html

@@ -97,7 +97,7 @@
 					<label class="col-md-1 control-label">验证码</label>
 					<div class="input-group col-md-4 checkCodeId">
 						<input type="text" name="identCode" class="form-control" onkeyup="rePlaceUnDigital(this)" datatype="n6" maxlength="6" nullmsg="请输入邮箱验证码" errormsg="邮箱验证码格式错误" ajaxurl="/front/ajaxReq?oprType=checkIdentCode">
-						<span class="input-group-addon"><div id="sendIdentCodeBtn" class="sendIdentCodeBtn">获取邮箱验证码</div></span>
+						<span id="sendIdentCodeBtn" class="input-group-addon" style="width:96px;">获取邮箱验证码</span>
 					</div>
 					<div class="col-md-7"><span class="Validform_checktip">请输入邮箱验证码</span></div>
 				</div>

+ 1 - 1
core/src/web/templates/member/accountset/bindphone.html

@@ -71,7 +71,7 @@
 					<label class="col-md-1 control-label">验证码</label>
 					<div class="input-group col-md-4 checkCodeId">
 						<input type="text" name="identCode" class="form-control" onkeyup="rePlaceUnDigital(this)" datatype="n6" maxlength="6" nullmsg="请输入短信验证码" errormsg="请输入短信验证码" ajaxurl="/front/ajaxReq?oprType=checkIdentCode">
-						<span class="input-group-addon"><div id="sendIdentCodeBtn" class="sendIdentCodeBtn">获取短信验证码</div></span>
+						<span id="sendIdentCodeBtn" class="input-group-addon" style="width:96px;">获取短信验证码</span>
 					</div>
 					<div class="col-md-7"><span class="Validform_checktip">请输入短信验证码</span></div>
 				</div>

+ 2 - 2
core/src/web/templates/member/accountset/updatephone.html

@@ -78,7 +78,7 @@
 						<label class="col-md-2 control-label">短信验证码</label>
 						<div class="input-group col-md-4 checkCodeId">
 							<input type="text" class="form-control" name="oldIdentCode" onkeyup="rePlaceUnDigital(this)" datatype="n6" maxlength="6" nullmsg="请输入短信验证码" errormsg="短信验证码格式错误" ajaxurl="/front/ajaxReq?oprType=checkOldIdentCode">
-							<span class="input-group-addon"><div class="sendIdentCodeBtn" id="sendIdentCodeBtn_old">获取短信验证码</div></span>
+							<span id="sendIdentCodeBtn_old" class="input-group-addon" style="width:96px;">获取短信验证码</span>
 						</div>
 						<div class="col-md-6"><span class="Validform_checktip">请输入短信验证码</span></div>
 					</div>
@@ -126,7 +126,7 @@
 						<label class="col-md-2 control-label">短信验证码</label>
 						<div class="input-group col-md-4 checkCodeId">
 							<input type="text" class="form-control" name="newIdentCode" onkeyup="rePlaceUnDigital(this)" datatype="n6" maxlength="6" nullmsg="请输入短信验证码" errormsg="短信验证码格式错误" ajaxurl="/front/ajaxReq?oprType=checkIdentCode">
-							<span class="input-group-addon"><div id="sendIdentCodeBtn_new" class="sendIdentCodeBtn">获取短信验证码</div></span>
+							<span id="sendIdentCodeBtn_new" class="input-group-addon" style="width:96px;">获取短信验证码</span>
 						</div>
 						<div class="col-md-6"><span class="Validform_checktip">请输入短信验证码</span></div>
 					</div>

+ 2 - 1
credit/src/config.json

@@ -94,5 +94,6 @@
     "saveLogDuration": 1,
     "checkGiveDuration": 30,
     "swordfish_tipBeforeDays": "3,1",
-    "swordfish_subHour": 18
+    "swordfish_subHour": 16,
+	"timerHM":"24,s,21"
 }

+ 22 - 7
credit/src/main.go

@@ -27,6 +27,8 @@ var SysConfig map[string]interface{}
 var swordfish_subHour int
 var swordfish_tipBeforeDays []int
 var swordfish_dueTitle, swordfish_due, swordfish_closeTitle, swordfish_close, swordfish_payTitle, swordfish_pay string
+var duration_hour time.Duration = 24 * time.Hour
+var minutes = 0
 
 func init() {
 	util.ReadConfig(&SysConfig)
@@ -64,6 +66,21 @@ func init() {
 
 	creditlog.Smtp = SysConfig["smtp"].(map[string]interface{})
 
+	timerHM := util.ObjToString(SysConfig["timerHM"])
+	if timerHM != "" {
+		timerHMS := strings.Split(timerHM, ",")
+		tmp, _ := strconv.Atoi(timerHMS[0])
+		switch timerHMS[1] {
+		case "h":
+			duration_hour = time.Duration(tmp) * time.Hour
+		case "m":
+			duration_hour = time.Duration(tmp) * time.Minute
+		case "s":
+			duration_hour = time.Duration(tmp) * time.Second
+		}
+		minutes, _ = strconv.Atoi(timerHMS[2])
+	}
+
 }
 
 func main() {
@@ -106,7 +123,7 @@ func quartz() {
 	//每天一次检查剑鱼积分
 	//有一张增值服务表,记录服务代码、服务起始日期、服务截止日期、服务类型按月、服务数量、是否自动扣费(扣费走rpc调用)、记录是否过期
 
-	TimerSwordFishFromUser()
+	//TimerSwordFishFromUser()
 
 	//定时任务转赠积分24后无人接收即退回,本月不做了
 	/**
@@ -147,10 +164,8 @@ func TimerSwordFishFromUser() {
 		for {
 			now := time.Now()
 			// 计算下一个零点
-			//next := now.Add(24 * time.Hour)
-			//next = time.Date(next.Year(), next.Month(), next.Day(), swordfish_subHour, 0, 0, 0, next.Location())
-			next := now.Add(30 * time.Second)
-			//next = time.Date(next.Year(), next.Month(), next.Day(), swordfish_subHour, 0, 0, 0, next.Location())
+			next := now.Add(duration_hour)
+			next = time.Date(next.Year(), next.Month(), next.Day(), swordfish_subHour, minutes, 0, 0, next.Location())
 			next64 := next.Unix()
 			t := time.NewTimer(next.Sub(now))
 			<-t.C
@@ -167,7 +182,7 @@ func TimerSwordFishFromUser() {
 					query := coll.Find(&map[string]interface{}{
 						"o_msgset." + typeName + ".l_enddate": map[string]interface{}{
 							"$gte": next64 - 600,
-							"$lte": next64 + int64(swordfish_tipBeforeDays[0]*60),
+							"$lte": next64 + int64(swordfish_tipBeforeDays[0]*24*3600) + 7200,
 						},
 						"o_msgset." + typeName + ".i_status":       1,
 						"o_msgset." + typeName + ".i_switchstatus": 1,
@@ -178,7 +193,7 @@ func TimerSwordFishFromUser() {
 						util.Try(func() {
 							tmpCode := tmp["o_msgset"].(map[string]interface{})[typeName].(map[string]interface{})
 							endDate := tmpCode["l_enddate"].(int64)
-							sub64 := (endDate - next64) / (60)
+							sub64 := (endDate - next64) / 86400
 							if sub64 == 0 {
 								//自动扣费
 								doSubCreditByUser(util.BsonIdToSId(tmp["_id"]), tmp["s_m_openid"].(string), typeName, code, &next, tmp)

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

@@ -24,7 +24,7 @@ var Smtp map[string]interface{}
 //对map的同步
 var lock sync.Mutex
 
-func AddLog(logs map[string]interface{}) {
+func AddLog_BACK(logs map[string]interface{}) {
 	lock.Lock()
 	arr = append(arr, logs)
 	lock.Unlock()

+ 30 - 24
credit/src/qfw/creditrpc/creditrpc.go

@@ -60,6 +60,8 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 			}
 		}
 	}()
+	lock := GetMutex(param.Uid)
+	lock.Lock()
 	//a类为即时保存
 	//b、c、d、e为定时保存
 	log.Println("---请求", param)
@@ -91,8 +93,6 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 		case "b":
 			key := param.Code + "_" + param.Uid
 			//[0/1,time,alltimes] //是否完成,次数,总次数,
-			lock := GetMutex(param.Uid)
-			lock.Lock()
 			if param.Code == "b1" { //签到
 				now := time.Now()
 				daykey := key + "_" + fmt.Sprintf("%d", now.Day())
@@ -114,8 +114,9 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 							creditDoc["i_scorenow"] = i_scorenow + Score[param.Code+"_1"] + int(thist)*Score[param.Code]
 							redis.Put(consts.RedisDB, key, newobj, GetSubSecond(int(newobj[2]-thist)))
 							redis.Put(consts.RedisDB, daykey, true, GetSubSecond(1))
-							creditlog.AddLog(creditDoc)
-							*replay = creditDoc["i_score"].(int)
+							if creditlog.Save(creditDoc) {
+								*replay = creditDoc["i_score"].(int)
+							}
 						} else {
 							//不是连续签到
 							bcon = false
@@ -133,8 +134,9 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 						creditDoc["i_scorenow"] = i_scorenow + Score[param.Code+"_1"]
 						redis.Put(consts.RedisDB, key, newobj, GetSubSecond(int(newobj[2])))
 						redis.Put(consts.RedisDB, daykey, true, GetSubSecond(1))
-						creditlog.AddLog(creditDoc)
-						*replay = creditDoc["i_score"].(int)
+						if creditlog.Save(creditDoc) {
+							*replay = creditDoc["i_score"].(int)
+						}
 					}
 				}
 			} else {
@@ -149,8 +151,9 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 						redis.Put(consts.RedisDB, key, newobj, GetSubSecond(1))
 						creditDoc["i_score"] = Score[param.Code]
 						creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
-						creditlog.AddLog(creditDoc)
-						*replay = creditDoc["i_score"].(int)
+						if creditlog.Save(creditDoc) {
+							*replay = creditDoc["i_score"].(int)
+						}
 					}
 				} else {
 					times := Score[param.Code+"_n"]
@@ -162,15 +165,12 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 					creditDoc["i_score"] = Score[param.Code]
 					creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
 					redis.Put(consts.RedisDB, key, newobj, GetSubSecond(1))
-					creditlog.AddLog(creditDoc)
-					*replay = creditDoc["i_score"].(int)
+					if creditlog.Save(creditDoc) {
+						*replay = creditDoc["i_score"].(int)
+					}
 				}
 			}
-			lock.Unlock()
-			//
 		case "c":
-			lock := GetMutex(param.Uid)
-			lock.Lock()
 			if param.Code == "c1" { //交易
 				objid := param.OtherParam["objid"]
 				if objid != nil {
@@ -189,10 +189,12 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 							"i_score":     Score[param.Code],
 							"i_scorenow":  i_scorenow + Score[param.Code],
 						}
-						creditlog.AddLog(creditDoc)
-						creditlog.AddLog(newDoc)
+						//creditlog.AddLog(creditDoc)
+						//creditlog.AddLog(newDoc)
 						redis.Put(consts.RedisDB, key, true, GetSubSecond(1))
-						*replay = creditDoc["i_score"].(int)
+						if creditlog.Save(creditDoc) && creditlog.Save(newDoc) {
+							*replay = creditDoc["i_score"].(int)
+						}
 					}
 				}
 			} else if param.Code == "c2" { //评价
@@ -203,29 +205,33 @@ func (c *CreditRpc) InCreadit(param *qrpc.CreditData, replay *int) error {
 						creditDoc["i_score"] = Score[param.Code]
 						creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
 						creditDoc["o_param"] = param.OtherParam
-						creditlog.AddLog(creditDoc)
+						if creditlog.Save(creditDoc) {
+							*replay = creditDoc["i_score"].(int)
+						}
 						redis.Put(consts.RedisDB, key, true, GetSubSecond(1))
-						*replay = creditDoc["i_score"].(int)
+
 					}
 				}
 			} else {
 				creditDoc["i_score"] = Score[param.Code]
 				creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]
 				creditDoc["o_param"] = param.OtherParam
-				creditlog.AddLog(creditDoc)
-				*replay = creditDoc["i_score"].(int)
+				if creditlog.Save(creditDoc) {
+					*replay = creditDoc["i_score"].(int)
+				}
 			}
-			lock.Unlock()
 		default: //定时任务
 			sc := util.If(param.Num > 0, param.Num, Score[param.Code]).(int)
 			if sc > 0 {
 				creditDoc["i_score"] = sc
 				creditDoc["i_scorenow"] = i_scorenow + sc
-				creditlog.AddLog(creditDoc)
-				*replay = creditDoc["i_score"].(int)
+				if creditlog.Save(creditDoc) {
+					*replay = creditDoc["i_score"].(int)
+				}
 			}
 		}
 	}
+	lock.Unlock()
 	return nil
 }