瀏覽代碼

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

zhangjinkun@topnet.net.cn 9 年之前
父節點
當前提交
7eb96f83f5

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

@@ -22,8 +22,8 @@ func Test_sim(t *testing.T) {
 	//s2 := "GyUlIhEDDjcfWCAyIl4xBkgsERYiLAwZLCg9VkkbLj4zMRYDPRs5ATVZOxccPAkzFxw7CCpEFj41QlRAQFdFXlRMQVZcHRIbBgsWBxYcFQwEBwoa"
 
 	//s3 := "RFYoal5bCFdXWQoQB0JuWwlXAQFZCUVfFj4JMFtT"
-	s4 := "oJULtwzXo6EFV1Ah-XeyRBimXGM8,uid,123456,wxpushlist"
-	se := SimpleEncrypt{Key: "topnet"}
+	s4 := "oJULtwzXo6EFV1Ah-XeyRBimXGM8"
+	se := SimpleEncrypt{Key: "topnet2015topnet2015"}
 	log.Println("=====", se.EncodeString(s4))
 	log.Println("=====", se.EncodeString(",1349385977,ASD"))
 	log.Println("---", se.DecodeString("GyUlIhEDDjcfWCAyIl4xBkgsERYiLAwZLCg9VkkBHQtcX1FBR1hJWldCREMHFhUBBwccBxYA"))

+ 33 - 0
core/src/luckdraw.json

@@ -34,6 +34,39 @@
 		"max":350,
 		"proportion":15
 	}],
+	"getAmounttwo":[{
+		"min":0,
+		"max":35,
+		"proportion":0
+	},{
+		"min":50,
+		"max":80,
+		"proportion":24.71
+	},{
+		"min":95,
+		"max":120,
+		"proportion":0.5
+	},{
+		"min":140,
+		"max":175,
+		"proportion":50
+	},{
+		"min":190,
+		"max":220,
+		"proportion":0
+	},{
+		"min":235,
+		"max":270,
+		"proportion":24.71
+	},{
+		"min":280,
+		"max":310,
+		"proportion":0.08
+	},{
+		"min":325,
+		"max":350,
+		"proportion":0
+	}],
 	"promotioncode":"2001001501",
 	"weixin":{
 		"sendname":"企明星",

+ 217 - 19
core/src/qfw/active/activemanage.go

@@ -4,9 +4,11 @@
 package active
 
 import (
+	"container/list"
 	"fmt"
 	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
+	"log"
 	"math/rand"
 	. "qfw/coreconfig"
 	"qfw/coreutil"
@@ -17,9 +19,184 @@ import (
 	"qfw/util/redis"
 	qrpc "qfw/util/rpc"
 	"strconv"
+	"strings"
+	"sync"
 	"time"
 )
 
+//限制与解除数组
+var limitrule, unlimitrule [][]int
+
+//时间间隔
+var unlimitduration int
+
+//提示语
+var limitmsg, unlimitmsg string
+
+//锁
+var limitLock = new(sync.Mutex)
+
+//限制状态
+var limitStatus = false
+
+//流量池
+var tList = list.New()
+
+//全局抽奖次数
+var times int64
+
+//通知openid
+var notifyIds []string
+
+//对池的管理
+func listFun() {
+	tList.Remove(tList.Front())
+	tList.PushBack(times)
+	time.AfterFunc(1*time.Second, listFun)
+}
+
+//取值
+func CheckLimit() bool {
+	times++
+	return limitStatus
+}
+
+func getValFromList(n int) (val int, flag bool) {
+	Try(func() {
+		B := tList.Back()
+		Bn := B.Value.(int64)
+		ti := 1
+		n = n - 1
+		A := B.Prev()
+		flag = true
+		for ti < n {
+			if A != nil {
+				ti++
+				A = A.Prev()
+			} else {
+				flag = false
+				break
+			}
+		}
+		val = int(Bn - A.Value.(int64))
+	}, func(e interface{}) {
+		log.Println("ERROR", e)
+	})
+	return
+}
+
+//限制的监测
+func limitFun() {
+	limitLock.Lock()
+	//非限制状态
+	if !limitStatus {
+		for _, v := range limitrule {
+			//取的秒的区间
+			if val, flag := getValFromList(v[0]); flag && val >= v[1] {
+				//限制状态
+				limitStatus = true
+				//发送模板消息
+				str := fmt.Sprintf(limitmsg, v[0], val, v[1])
+				go func() {
+					log.Println("发送限制抽奖通知", str)
+					Try(func() {
+						for _, id := range notifyIds {
+							coreutil.SendManagerNotifyMsg(&qrpc.NotifyMsg{
+								Openid: id,
+								Title:  "抽奖进入限制状态通知",
+								Detail: "系统",
+								Result: str,
+								Remark: "",
+							})
+						}
+					}, func(e interface{}) {})
+				}()
+				break
+			}
+		}
+	}
+	limitLock.Unlock()
+	time.AfterFunc(5*time.Second, limitFun)
+}
+
+//解除限制的监测
+func unlimitFun() {
+	limitLock.Lock()
+	//非限制状态
+	if limitStatus {
+		allb := true
+		str := ""
+		for _, v := range unlimitrule {
+			//取的秒的区间
+			val, flag := getValFromList(v[0])
+			if !flag || val >= v[1] {
+				allb = false
+				break
+			} else {
+				str += " [间隔:" + strconv.Itoa(v[0]) + "," + "实际次数:" + strconv.Itoa(val) + ",限制:" + strconv.Itoa(v[1]) + "]"
+			}
+		}
+		if allb {
+			limitStatus = false
+			//发送解除通知
+			go func() {
+				log.Println("发送解除抽奖限制通知", str)
+				Try(func() {
+					for _, id := range notifyIds {
+						coreutil.SendManagerNotifyMsg(&qrpc.NotifyMsg{
+							Openid: id,
+							Title:  "抽奖进入限制状态通知",
+							Detail: "系统",
+							Result: fmt.Sprintf(unlimitmsg, str),
+							Remark: "",
+						})
+					}
+				}, func(e interface{}) {})
+			}()
+		}
+
+	}
+	limitLock.Unlock()
+	time.AfterFunc(time.Duration(unlimitduration)*time.Second, unlimitFun)
+}
+
+//初始化内容
+func init() {
+	tmpLimtRules := RedPackage.Limit["limitrules"].([]interface{})
+	limitrule = make([][]int, len(tmpLimtRules))
+	for i, k := range tmpLimtRules {
+		minR := k.([]interface{})
+		tmpInts := make([]int, len(minR))
+		limitrule[i] = tmpInts
+		for j, v := range minR {
+			tmpInts[j] = int(v.(float64))
+		}
+	}
+	tmpUnLimtRules := RedPackage.Limit["unlimitrules"].([]interface{})
+	unlimitrule = make([][]int, len(tmpUnLimtRules))
+	for i, k := range tmpUnLimtRules {
+		minR := k.([]interface{})
+		tmpInts := make([]int, len(minR))
+		unlimitrule[i] = tmpInts
+		for j, v := range minR {
+			tmpInts[j] = int(v.(float64))
+		}
+	}
+	unlimitduration = int(RedPackage.Limit["unlimitduration"].(float64))
+	limitmsg = RedPackage.Limit["limitmsg"].(string)
+	unlimitmsg = RedPackage.Limit["unlimitmsg"].(string)
+
+	notifyIds = ObjArrToStringArr(RedPackage.Limit["notifyIds"].([]interface{}))
+
+	for tList.Len() < 3600 {
+		tList.PushBack(int64(0))
+	}
+
+	go listFun()
+	go limitFun()
+	go unlimitFun()
+}
+
 type Activemanage struct {
 	*xweb.Action
 	luckdraw    xweb.Mapper `xweb:"/activity/(\\w+)/([^.]*)"`
@@ -53,7 +230,13 @@ func (a *Activemanage) Luckdraw(activecode, id string) error {
 	if activecode == "topcj" {
 		f := FindOne("user", "{'s_m_openid':'"+openid+"'}")
 		username := (*f)["s_bindweixin"]
-		userid := (*f)["_id"]
+		//看user里是否有黑名单字段
+		if (*f)["s_black"] != nil {
+			a.SetSession("black", "T")
+		} else {
+			a.SetSession("black", "F")
+		}
+		userid := strings.Split(fmt.Sprintf("%s", (*f)["_id"]), `"`)[1]
 		if *f == nil {
 			a.T["flog"] = "B"
 			a.T["msg"] = "您的微信号无效!!"
@@ -88,6 +271,7 @@ func (a *Activemanage) Luckdraw(activecode, id string) error {
 
 //
 func (a *Activemanage) Getluckdraw() error {
+	CheckLimit()
 	flog := "F"
 	//提示语
 	msg := ""
@@ -113,10 +297,17 @@ func (a *Activemanage) Getluckdraw() error {
 	data := make(map[string]interface{})
 	data["s_openid"] = openid
 	data["s_actcode"] = s_actcode
-	i := getLuckDraw()
-
+	black := a.GetSession("black")
+	var i int
+	if black == "T" {
+		//黑名单指针范围
+		i = int(rand.Float64()*30 + 50)
+	} else {
+		i = getLuckDraw()
+	}
 	s_prize := getPrize(i)
 	data["s_prize"] = s_prize
+	data["i_degree"] = i
 	data["l_timestamp"] = time.Now().Unix()
 	nowdate := time.Now().Unix()
 	enddate := LuckDraw.EndDate
@@ -127,12 +318,12 @@ func (a *Activemanage) Getluckdraw() error {
 		flog = "T"
 	}
 	//红包
-	if (i > 185 && i < 220) || (i > 320 && i < 355) {
+	if (i > 184 && i < 221) || (i > 319 && i < 356) {
 		var amount int //红包金额以“元”为单位,微信红包以“分”为单位
-		if i > 185 && i < 220 {
+		if i > 184 && i < 221 {
 			amount = 500 //红包金额以“元”为单位,微信红包以“分”为单位
 
-		} else if i > 320 && i < 355 {
+		} else if i > 319 && i < 356 {
 			amount = 100 //红包金额以“元”为单位,微信红包以“分”为单位
 		}
 		bm := qrpc.BonusMsg{Mchbillno: fmt.Sprint(today.Unix()),
@@ -168,7 +359,7 @@ func (a *Activemanage) Getluckdraw() error {
 
 		}
 		msg = "  小主是真真的好运气," + s_prize + "落入您囊中。红包将由系统自动发放到您的微信,请注意查收。<br/><br/>  分享至朋友圈或好友即可以获得明天抽奖资格呦!乖,快去分享吧!大奖可能就在明天~~"
-	} else if (i > 275 && i < 310) || (i > 95 && i < 130) {
+	} else if (i > 274 && i < 311) || (i > 94 && i < 131) {
 		//时间判断,提醒不同
 		//now := time.Now()
 		//不在工作时间
@@ -178,8 +369,8 @@ func (a *Activemanage) Getluckdraw() error {
 		//} else { //在工作时间
 		msg = "  小主是真真的好运气," + s_prize + "落入您囊中。请将您的联系方式和邮寄地址留言给企明星。我们会在活动截止后尽快为您发出。<br/><br/>  分享至朋友圈或好友即可以获得明天抽奖资格呦!乖,快去分享吧!大奖可能就在明天~~"
 		//}
-	} else if i > 140 && i < 175 {
-		obid := BsonIdToSId(a.GetSession("userId"))
+	} else if i > 139 && i < 176 {
+		obid := a.GetSession("userId").(string)
 		b := credit.UpuserCreditSession(obid, "b6", "B", nil, a.Action)
 		if b == true {
 			msg = "  小主是真真的好运气,200积分落入您囊中。积分将由系统自动发放到您的企明星账户,请登录www.qmx.top查看。<br/><br/>  分享至朋友圈或好友即可以获得明天抽奖资格呦!乖,快去分享吧!大奖可能就在明天~~"
@@ -195,7 +386,14 @@ func (a *Activemanage) Getluckdraw() error {
 
 //
 func getLuckDraw() int {
-	array := LuckDraw.GetAmount
+	th := time.Now().Hour()
+	thflog := (th < 23 && th > 7) //限时 23到第二天7点 第二套方案
+	array := []map[string]interface{}{}
+	if CheckLimit() || !thflog {
+		array = LuckDraw.GetAmounttwo //第二套方案
+	} else {
+		array = LuckDraw.GetAmount //第一套方案
+	}
 	weightValue := getWeightRandom(array)
 	min := IntAll(array[weightValue]["min"])
 	max := IntAll(array[weightValue]["max"])
@@ -208,22 +406,22 @@ func getLuckDraw() int {
 		amount := min + rand.New(rand.NewSource(time.Now().UnixNano())).Intn(max-min)
 		if amount <= 0 {
 			return 1
-		} else if amount > 275 && amount < 310 {
+		} else if amount > 274 && amount < 311 {
 			count := Count("winningrecord", "{'s_prize':'《牛奶可乐经济学》'}")
 			if count > 6 {
 				amount = 245
 			}
-		} else if amount > 95 && amount < 130 {
+		} else if amount > 94 && amount < 131 {
 			count := Count("winningrecord", "{'s_prize':'限量版U盘'}")
 			if count > 100 {
 				amount = 255
 			}
-		} else if amount > 185 && amount < 220 {
+		} else if amount > 184 && amount < 221 {
 			count := Count("winningrecord", "{'s_prize':'五元现金红包'}")
 			if count > 200 {
 				amount = 65
 			}
-		} else if amount > 320 && amount < 355 {
+		} else if amount > 319 && amount < 356 {
 			count := Count("winningrecord", "{'s_prize':'一元现金红包'}")
 			if count > 2500 {
 				amount = 75
@@ -256,19 +454,19 @@ func getPrize(i int) string {
 	if i > 0 {
 		if 0 <= i && i < 45 {
 			prize = "iPad mini"
-		} else if 91 <= i && i < 136 {
+		} else if 95 <= i && i < 121 {
 			prize = "限量版U盘"
 
-		} else if 140 <= i && i < 175 {
+		} else if 140 <= i && i < 176 {
 			prize = "200积分"
 
-		} else if 181 <= i && i < 226 {
+		} else if 190 <= i && i < 221 {
 			prize = "五元现金红包"
 
-		} else if 271 <= i && i < 316 {
+		} else if 280 <= i && i < 311 {
 			prize = "《牛奶可乐经济学》"
 
-		} else if 320 <= i && i < 355 {
+		} else if 325 <= i && i < 351 {
 			prize = "一元现金红包"
 
 		} else {

+ 1 - 0
core/src/qfw/coreconfig/LuckDraw.go

@@ -7,6 +7,7 @@ import (
 //系统配置
 type luckDraw struct {
 	GetAmount     []map[string]interface{} `json:"getAmount"`
+	GetAmounttwo  []map[string]interface{} `json:"getAmounttwo"`
 	StartDate     int64                    `json:"startDate"`
 	EndDate       int64                    `json:"endDate"`
 	Promotioncode string                   `json:"promotioncode"`

+ 47 - 0
core/src/qfw/coreconfig/MessageConfig_test.go

@@ -1,7 +1,9 @@
 package coreconfig
 
 import (
+	"container/list"
 	"log"
+	"time"
 	//"qfw/coreconfig"
 	"qfw/util"
 	"testing"
@@ -12,3 +14,48 @@ func TestGetMessage(t *testing.T) {
 	ret := util.GetPropertie("indentify.success.result", MessageConfig)
 	log.Println(ret)
 }
+
+var tList *list.List
+var times int
+
+func listFun() {
+	times++
+	tList.Remove(tList.Front())
+	tList.PushBack(times)
+	time.AfterFunc(1*time.Second, listFun)
+}
+
+func TestList(t *testing.T) {
+	tList = list.New()
+	for tList.Len() < 3000 {
+		tList.PushBack(0)
+	}
+	go listFun()
+
+	/**
+	i := 0
+	for i < 10 {
+		i++
+		h.Remove(h.Front())
+		h.PushBack(i)
+
+		for e := h.Front(); e != nil; e = e.Next() {
+			log.Print(e.Value, "  ")
+		}
+	}
+	**/
+
+	go func() {
+		for {
+			log.Print("\n----------")
+			for e := tList.Front(); e != nil; e = e.Next() {
+				log.Print(e.Value, "  ")
+			}
+			log.Print("\n----------")
+			time.Sleep(5 * time.Second)
+		}
+	}()
+
+	b := make(chan bool, 1)
+	<-b
+}

+ 1 - 0
core/src/qfw/coreconfig/RedPackage.go

@@ -15,6 +15,7 @@ type redPackage struct {
 	Weixin        map[string]interface{}   `json:"weixin"`
 	Msg           map[string]interface{}   `json:"msg"`
 	IsReissue     bool                     `json:"isReissue"`
+	Limit         map[string]interface{}   `json:"limit"`
 }
 
 var RedPackage redPackage

+ 105 - 59
core/src/redpackage.json

@@ -1,61 +1,107 @@
 {
-	"startDate":1450022400,
-	"endDate":1452700800,
-	"getAmount":[{
-		"min":3,
-		"max":6,
-		"proportion":97.1
-	},{
-		"min":6,
-		"max":11,
-		"proportion":2
-	},{
-		"min":11,
-		"max":51,
-		"proportion":0.75
-	},{
-		"min":51,
-		"max":151,
-		"proportion":0.1
-	},{
-		"min":151,
-		"max":201,
-		"proportion":0.05
-	}],
-	"showAmount":[{
-		"min":3,
-		"max":10,
-		"count":2
-	},{
-		"min":10,
-		"max":50,
-		"count":4
-	},{
-		"min":50,
-		"max":100,
-		"count":6
-	},{
-		"min":100,
-		"max":150,
-		"count":4
-	},{
-		"min":150,
-		"max":200,
-		"count":4
-	}],
-	"promotioncode":"2001001501",
-	"weixin":{
-		"sendname":"企明星",
-		"wishing":"企明星扫码送红包活动",
-		"actname":"企明星扫码送红包活动",
-		"remark":"拆红包愉快!",
-		"successtitle":"友情提示",
-		"successremark":"因参加活动的用户较多,如果您在十分钟内未收到企明星发放的红包,请及时联系客服QQ。"
-	},
-	"msg":{
-		"title":"红包到账啦!",
-		"content":"您的企明星红包到账啦,快打开微信猛戳红包!"
-	},
-	"reissueTime":"8:10",
-	"isReissue":false
+    "startDate": 1450022400,
+    "endDate": 1452700800,
+    "getAmount": [
+        {
+            "min": 3,
+            "max": 6,
+            "proportion": 97.1
+        },
+        {
+            "min": 6,
+            "max": 11,
+            "proportion": 2
+        },
+        {
+            "min": 11,
+            "max": 51,
+            "proportion": 0.75
+        },
+        {
+            "min": 51,
+            "max": 151,
+            "proportion": 0.1
+        },
+        {
+            "min": 151,
+            "max": 201,
+            "proportion": 0.05
+        }
+    ],
+    "showAmount": [
+        {
+            "min": 3,
+            "max": 10,
+            "count": 2
+        },
+        {
+            "min": 10,
+            "max": 50,
+            "count": 4
+        },
+        {
+            "min": 50,
+            "max": 100,
+            "count": 6
+        },
+        {
+            "min": 100,
+            "max": 150,
+            "count": 4
+        },
+        {
+            "min": 150,
+            "max": 200,
+            "count": 4
+        }
+    ],
+    "promotioncode": "2001001501",
+    "weixin": {
+        "sendname": "企明星",
+        "wishing": "企明星扫码送红包活动",
+        "actname": "企明星扫码送红包活动",
+        "remark": "拆红包愉快!",
+        "successtitle": "友情提示",
+        "successremark": "因参加活动的用户较多,如果您在十分钟内未收到企明星发放的红包,请及时联系客服QQ。"
+    },
+    "msg": {
+        "title": "红包到账啦!",
+        "content": "您的企明星红包到账啦,快打开微信猛戳红包!"
+    },
+    "limit": {
+        "limitrules": [
+			[
+                10,
+                50
+            ],
+            [
+                30,
+                100
+            ],
+            [
+                60,
+                180
+            ]
+        ],
+        "limitmsg": "抽奖进入限止状态,原因:%d秒内抽奖次数为%d超过%d次。",
+        "unlimitduration": 1800,
+		"notifyIds":["oJULtwzXo6EFV1Ah-XeyRBimXGM8"],
+        "unlimitrules": [
+            [
+                3600,
+                800
+            ],
+            [
+                2500,
+                500
+            ],
+            [
+                600,
+                100
+            ]
+        ],
+        "unlimitmsg": "解除抽奖限止,%s。"
+    },
+    "reissueTime": "8:10",
+    "isReissue": false
 }

+ 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-28 12:54:36"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-28 12:54:36"}},"marketisstart":true,"marketrate":300}
+{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-29 16:14:37"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-29 16:14:37"}},"marketisstart":true,"marketrate":300}

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

@@ -553,9 +553,6 @@ a:focus, a:hover{
 	padding-bottom: 0px !important;
 }
 .ent-serviceintroduction{
-	height: 60px;
-	overflow: hidden;
-	text-overflow: ellipsis;
 	word-wrap: break-word;
 	word-break: break-all;
 	white-space: normal !important;

+ 5 - 0
core/src/web/staticres/css/qfw.css

@@ -484,6 +484,11 @@ a.new_red:hover, a.new_red:active {
 	color: #FF5A5F;
 	box-shadow: none;
 }
+.btn.disabled, .btn.disabled.active, .btn.disabled.focus, .btn.disabled:active, .btn.disabled:focus, .btn.disabled:hover, .btn[disabled], .btn[disabled].active, .btn[disabled].focus, .btn[disabled]:active, .btn[disabled]:focus, .btn[disabled]:hover, fieldset[disabled] .btn, fieldset[disabled] .btn.active, fieldset[disabled] .btn.focus, fieldset[disabled] .btn:active, fieldset[disabled] .btn:focus, fieldset[disabled] .btn:hover{
+	color: #FFFFFF;
+	background-color: #aea79f;
+	border-color: #aea79f;
+}
 .btn-sm, .btn-group-sm > .btn{
 	padding-top: 3px;
 	padding-bottom: 3px;

+ 3 - 3
core/src/web/staticres/js/entportrait.js

@@ -156,17 +156,17 @@ function ServiceList(){
 					html += '<td>&nbsp;</td><td>&nbsp;</td>';
 				}
 				html += '</tr><tr>'
-					+'<td colspan="3"><div class="ent-serviceintroduction"><div>'+r[i].s_introduction+'</div></div></td>'
+					+'<td colspan="3"><div class="ent-serviceintroduction">'+r[i].s_introduction+'</div></td>'
 					+'</tr>';
 			}
 			$("#serviceListPaging").parent().prevAll().remove();
 			$("#serviceListPaging").parent().before(html);
-			$(".ent-serviceintroduction").each(function(){
+			/*$(".ent-serviceintroduction").each(function(){
 				console.info($(this).height() +"------"+ $(this).children("div").height());
 				if($(this).height() < $(this).children("div").height()){
 					$(this).parent().append("......");
 				}
-			});
+			});*/
 		});
 	});
 }

二進制
core/src/web/staticres/wxswordfish/images/guide-0.png


+ 124 - 21
core/src/web/templates/swordfish/wxshare.html

@@ -1,34 +1,137 @@
-<html >
+<html>
 <head>
 <title>企明星-剑鱼</title>
-<meta charset="utf-8">
-<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
-<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0" user-scalable="no" />
-<meta name="renderer" content="webkit">
-<link href="/css/bootstrap.min.css" rel="stylesheet">
-
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+<link href="/wxswordfish/style.css" rel="stylesheet">
+<link href="/swiper/swiper.min.css" rel="stylesheet">
 <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
 <script src="/js/jquery.js"></script>
-<script src="/js/bootstrap.min.js"></script>
-
 <script src="/wxswordfish/share.js"></script>
+<script src="/swiper/swiper.min.js"></script>
 <script>
 	initShare({{.T.signature}},{{.T.shareid}});
 </script>
 </head>
-<body style="margin:0px; background-color:#C5F7FE;">
-<img src="/wxswordfish/images/share-cj.jpg" class="img-responsive" alt="Cinque Terre">
-<img id="img2" style="position:absolute;" class="img-responsive" src="/front/weixinshare/{{.T.shareid}}" >
-</body>
-<script>
+<body>
+<div class="swiper-container">
+    <div class="swiper-wrapper">
+        <div class="swiper-slide">
+			<img src="/wxswordfish/images/guide-0.png" alt="Cinque Terre">
+			<img id="QRcode" style="position:absolute;z-index: 2;" src="/front/weixinshare/{{.T.shareid}}" >
+		</div>
+       	<div class="swiper-slide">
+			<img src="/wxswordfish/images/guide-2.png">
+		</div>
+       	<div class="swiper-slide">
+			<img src="/wxswordfish/images/guide-3.png">
+		</div>
+		<div class="swiper-slide">
+			<img src="/wxswordfish/images/guide-4.png">
+		</div>
+		<div class="swiper-slide">
+			<img src="/wxswordfish/images/guide-5.png">
+		</div>
+		<div class="swiper-slide">
+			<img src="/wxswordfish/images/guide-0.png">
+		</div>
+    </div>
+    <!-- 如果需要分页器 -->
+   	<div class="swiper-pagination"></div>
+	<div class="guide-bottom">
+		<img class="arrow-up" src="/wxswordfish/images/up.png">
+		<img src="/wxswordfish/images/index.png" class="jumpGuide" onclick="backToIndex()">
+	</div>
+</div>
+<script type="text/javascript">
+var mySwiper = null;
+var currentIndex = 0;
 $(function(){
-	var width=$(window).width();
-	var max=750
-	if(width>max){
-		width=max
+	initShare({{.T.signature}},{{.T.shareid}});
+	var width = $(window).width();
+	var height = $(window).height();
+	var defaultHeight = 416;
+	var max = 750;
+	if(width > max){
+		width = max;
 	}
-	$("#img2").css({"width":width*0.48,"top":width*0.78,"left":width*0.26})
-	
-})
+	width = width*0.48;
+	var top = 330;
+	if(height > defaultHeight){
+		top = top / defaultHeight * height;
+	}
+	$("#QRcode").css({"width":width,"height":width,"top": top-width,"left":"50%","margin-left": -(width/2)});
+	$(".bottom-toolbar,.feedback-dialog").remove();
+	var flag = true;
+	mySwiper = new Swiper('.swiper-container', {
+		loop: true,
+        pagination: '.swiper-pagination',
+        paginationClickable: false,
+        direction: 'vertical',
+		touchMoveStopPropagation: false,
+		virtualTranslate: true,
+		onInit: function(swiper){
+			$("[data-swiper-slide-index='5']>img").attr("src","/wxswordfish/images/guide-6.png");
+		},
+		onSlideChangeStart: function(swiper){
+			if(flag){
+				flag = false;
+				return;
+			}
+			var prevSlide = $(swiper.slides[swiper.previousIndex]);
+			prevSlide.addClass("slide-active");
+			var activeSlide = $(swiper.slides[swiper.activeIndex]);
+			if(currentIndex == 0 && swiper.activeIndex == 0){
+				activeSlide.addClass("slide-down");
+			}else{
+				if(currentIndex > swiper.activeIndex){
+					activeSlide.addClass("slide-down");
+				}else if(currentIndex < swiper.activeIndex){
+					activeSlide.addClass("slide-up");
+				}
+			}
+			currentIndex = swiper.activeIndex;
+			if(currentIndex == 7){
+				currentIndex = 0;
+			}
+			if(swiper.isEnd || swiper.activeIndex == 1){
+				$("#QRcode").show();
+			}else{
+				$("#QRcode").hide();
+			}
+			activeSlide.one("webkitAnimationEnd",function(){
+				$(this).removeClass("slide-up").removeClass("slide-down");
+				prevSlide.removeClass("slide-active");
+			});
+		}
+    });
+	/*
+	var imgHeight = 1159;
+	var imgWidth = 750;
+	var width = document.body.clientWidth;
+	var height = document.body.clientHeight;
+	if(imgWidth > width){
+		var h = width / imgWidth * imgHeight;
+		$(".swiper-slide img").css({width: width,height: h,marginTop: -(h / 2)});
+	}else if(imgHeight > height){
+		$(".swiper-slide img").css({width: height / imgHeight * imgWidth,height: height,marginTop: -(height / 2)});
+	}*/
+});
+function backToIndex(){
+	if(mySwiper == null || mySwiper.activeIndex == 1){
+		return;
+	}
+	currentIndex = 1;
+	var prevSlide = $(mySwiper.slides[mySwiper.activeIndex]);
+	prevSlide.addClass("slide-active");
+	var activeSlide = $(mySwiper.slides[1]);
+	activeSlide.addClass("slide-down");
+	activeSlide.one("webkitAnimationEnd",function(){
+		$(this).removeClass("slide-up").removeClass("slide-down");
+		prevSlide.removeClass("slide-active");
+		mySwiper.slideTo(1, 1000, false);
+		$("#QRcode").show();
+	});
+}
 </script>
+</body>
 </html>

+ 34 - 0
core/src/web/templates/swordfish/wxshare_copy.html

@@ -0,0 +1,34 @@
+<html >
+<head>
+<title>企明星-剑鱼</title>
+<meta charset="utf-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
+<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0" user-scalable="no" />
+<meta name="renderer" content="webkit">
+<link href="/css/bootstrap.min.css" rel="stylesheet">
+
+<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
+<script src="/js/jquery.js"></script>
+<script src="/js/bootstrap.min.js"></script>
+
+<script src="/wxswordfish/share.js"></script>
+<script>
+	initShare({{.T.signature}},{{.T.shareid}});
+</script>
+</head>
+<body style="margin:0px; background-color:#C5F7FE;">
+<img src="/wxswordfish/images/share-cj.jpg" class="img-responsive" alt="Cinque Terre">
+<img id="img2" style="position:absolute;" class="img-responsive" src="/front/weixinshare/{{.T.shareid}}" >
+</body>
+<script>
+$(function(){
+	var width=$(window).width();
+	var max=750
+	if(width>max){
+		width=max
+	}
+	$("#img2").css({"width":width*0.48,"top":width*0.78,"left":width*0.26})
+	
+})
+</script>
+</html>

+ 1 - 1
core/src/web/templates/swordfish/wxshareguide.html

@@ -1,6 +1,6 @@
 <html>
 <head>
-<title>企明星-剑鱼-演示</title>
+<title>企明星-剑鱼-分享</title>
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
 <link href="/wxswordfish/style.css" rel="stylesheet">
 <link href="/swiper/swiper.min.css" rel="stylesheet">

+ 25 - 0
df

@@ -0,0 +1,25 @@
+diff --cc core/src/timetask.json
+index 0eba9db,8be7bc9..0000000
+--- a/core/src/timetask.json
++++ b/core/src/timetask.json
+@@@ -1,1 -1,1 +1,5 @@@
+- {"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-28 09:39:35"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-28 09:39:35"}},"marketisstart":true,"marketrate":300}
+ -{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-28 12:54:36"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-28 12:54:36"}},"marketisstart":true,"marketrate":300}
+++<<<<<<< HEAD
+++{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-28 09:39:35"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-28 09:39:35"}},"marketisstart":true,"marketrate":300}
+++=======
+++{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-28 12:54:36"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-28 12:54:36"}},"marketisstart":true,"marketrate":300}
+++>>>>>>> e697f24fdd22cbe16dc2ce282d2d1689a6e445a7
+diff --git a/common/src/qfw/util/sq/sq.go b/common/src/qfw/util/sq/sq.go
+index 96ac697..11e2d32 100644
+--- a/common/src/qfw/util/sq/sq.go
++++ b/common/src/qfw/util/sq/sq.go
+@@ -13,7 +13,7 @@ import (
+ const key string = "qmx20150708one_versionV1.0"
+ 
+ func init() {
+-	CheckSq()
++	//CheckSq()
+ }
+ 
+ func CheckSq() bool {

+ 3 - 1
weixin/src/config.json

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

+ 3 - 3
weixin/src/qfw/weixin/clickhandler.go

@@ -36,7 +36,7 @@ func ClickHandler(w ResponseWriter, r *Request) {
 					w.ReplyText("您已经提交认证信息,正在审核中,请耐心等待")
 				} else if state == 1 {
 					//w.ReplyText("恭喜您,身份认证已通过,请点击<a href='http://" + wf.SysConfig.Domain + "/ent/wsite/edit/" + r.FromUserName + "'>进入微官网</a>")
-					urlstr := "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wf.SysConfig.Appid + "&redirect_uri=http://" + wf.SysConfig.Domain + "/weixinoauth?action=msiteaction&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
+					urlstr := "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wf.SysConfig.Appid + "&redirect_uri=http://" + wf.SysConfig.Domain + "/weixinoauth/action/msiteaction&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
 					w.ReplyText("恭喜您,身份认证已通过,请点击<a href='" + urlstr + "'>进入微官网</a>")
 				} else {
 					str := "欢迎您进行企业认证"
@@ -56,7 +56,7 @@ func ClickHandler(w ResponseWriter, r *Request) {
 					w.ReplyText("您已经提交认证信息,正在审核中,请耐心等待")
 				} else if state == 1 {
 					//w.ReplyText("恭喜您,身份认证已通过,请点击<a href='http://" + wf.SysConfig.Domain + "/ent/wsite/edit/" + r.FromUserName + "'>进入微官网</a>")
-					urlstr := "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wf.SysConfig.Appid + "&redirect_uri=http://" + wf.SysConfig.Domain + "/weixinoauth?action=msiteaction&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
+					urlstr := "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wf.SysConfig.Appid + "&redirect_uri=http://" + wf.SysConfig.Domain + "/weixinoauth/action/msiteaction&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
 					w.ReplyText("恭喜您,身份认证已通过,请点击<a href='" + urlstr + "'>进入微官网</a>")
 				} else {
 					str := "欢迎您进行个人认证"
@@ -76,7 +76,7 @@ func ClickHandler(w ResponseWriter, r *Request) {
 					w.ReplyText("您已经提交认证信息,正在审核中,请耐心等待")
 				} else if state == 1 {
 					//w.ReplyText("恭喜您,身份认证已通过,请点击<a href='http://" + wf.SysConfig.Domain + "/ent/wsite/edit/" + r.FromUserName + "'>进入微官网</a>")
-					urlstr := "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wf.SysConfig.Appid + "&redirect_uri=http://" + wf.SysConfig.Domain + "/weixinoauth?action=msiteaction&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
+					urlstr := "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wf.SysConfig.Appid + "&redirect_uri=http://" + wf.SysConfig.Domain + "/weixinoauth/action/msiteaction&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
 					w.ReplyText("恭喜您,身份认证已通过,请点击<a href='" + urlstr + "'>进入微官网</a>")
 				} else {
 					str := "欢迎您进行机构认证"

+ 13 - 4
weixin/src/qfw/weixin/dao/sharedao.go

@@ -14,11 +14,20 @@ import (
 //锁
 var sharelock *sync.Mutex = &sync.Mutex{}
 
-//保存用户邀请关系,走线程池
-func SaveInviteLink(shareid string, myopenid string) {
+//保存用户邀请关系
+func SaveInviteLink(shareid string, myopenid string,isolduser bool) {
 	log.Println("save user invitelink ", myopenid, shareid)
-	//先找邀请人信息
-	sharelock.Lock()
+		sharelock.Lock()
+	//对于老用户的处理
+	if isolduser{//找我自己是不是别人邀请的
+		invite:=FindOne("person_invitelink",`{"s_target_openid":"`+myopenid+`"}`)
+		if *invite!=nil{
+			sharelock.Unlock()
+			return
+		}
+	}
+	//找邀请人信息
+
 	ret := FindOne("person_share", M{"i_shareid": shareid})
 	if *ret == nil {
 		log.Println("wu share info!!!!")

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

@@ -65,6 +65,7 @@ func MsgTxtHandler(w ResponseWriter, r *Request) {
 		w.ReplyText("嗨,小星来陪你解闷。有什么开心的,不开心的说说来,大伙乐呵乐呵。\n输入q或Q离开。")
 		return
 	} else if r.Content == "抽奖" { //进入抽奖环节
+		//w.ReplyText("非常抱歉!系统维护中,请稍后再试。")
 		targeturl := fmt.Sprintf("http://%s/activity/%s/%s", wf.SysConfig.Domain, wf.SysConfig.Activity["activitycode"], se.EncodeString(r.FromUserName))
 		w.ReplyNews([]Article{Article{PicUrl: wf.SysConfig.Activity["picurl"], Title: wf.SysConfig.Activity["title"], Url: targeturl}})
 	} else if strings.HasPrefix(r.Content, "内部报名") { //绑定拓普员工姓名

+ 2 - 2
weixin/src/qfw/weixin/paybonusact.go

@@ -85,13 +85,13 @@ type GroupBonusMsg struct {
 var se util.SimpleEncrypt = util.SimpleEncrypt{Key: "topnet2015topnet2015"}
 
 //发红包(传统红包)
-func PayBonusAct1(w http.ResponseWriter, r *http.Request) {
+func PayNormalBonusAct(w http.ResponseWriter, r *http.Request) {
 	if r.Method == "GET" {
 		w.Write([]byte(html))
 	} else {
 		//动作
 		cert := r.FormValue("cert")
-		s_cert := se.EncodeString(time.Now().Format("2006010215"))
+		s_cert := se.EncodeString(time.Now().Format("200601021504"))
 		if s_cert != cert {
 			w.Write([]byte("error cert"))
 			return

+ 6 - 9
weixin/src/qfw/weixin/subscribehandler.go

@@ -8,25 +8,19 @@ import (
 	"net/http"
 	"os"
 	"qfw/util"
+	wxutil "qfw/weixin/util"
 	"qfw/util/redis"
 	"qfw/weixin/dao"
 	"qfw/weixinconfig"
-	"regexp"
 	"strings"
 	"time"
 )
 
-var WELCOME_MSG string
-var OWELCOME_MSG string
 
-var digitreg *regexp.Regexp = regexp.MustCompile("^\\d+$")
 
 //关注事件处理
 func SubscribeHandler(w ResponseWriter, r *Request) {
-	if WELCOME_MSG == "" || OWELCOME_MSG == "" {
-		WELCOME_MSG = weixinconfig.SysConfig.WelcomeTip
-		OWELCOME_MSG = weixinconfig.SysConfig.OWelcomeTip
-	}
+	wxutil.SubscribeInc()
 	openid := r.FromUserName
 	ret, err := w.GetUserBaseInfo(openid)
 	var unionid, bindweixin, userphoto string
@@ -57,11 +51,14 @@ func SubscribeHandler(w ResponseWriter, r *Request) {
 			redis.Put("sso", "new_"+source, openid, 900)
 			//TODO 处理分享(邀请)类的二维码,记录邀请关系
 			if strings.HasPrefix(source, "32") {
-				go dao.SaveInviteLink(source, r.FromUserName)
+				go dao.SaveInviteLink(source, r.FromUserName, false)
 				//go dao.UpdateInviteUserCoupon(source)
 			}
 		} else {
 			w.ReplyText(OWELCOME_MSG) // 有旧人关注,返回欢迎消息
+			if strings.HasPrefix(source, "32") {
+				go dao.SaveInviteLink(source, r.FromUserName, true)
+			}
 		}
 		DoLogin(source, openid)
 	} else {

+ 42 - 0
weixin/src/qfw/weixin/util/subscribefilter.go

@@ -0,0 +1,42 @@
+package util
+
+//实时统计状态
+import (
+	"log"
+	"fmt"
+	"qfw/util/mongodb"
+	"sync/atomic"
+	"time"
+)
+
+var tmp int32 = 0
+var starttime, endtime int64
+var dutrat time.Duration //时间间隔
+var times int32
+
+//累加
+func SubscribeInc() {
+	atomic.AddInt32(&tmp, 1)
+}
+
+func subscribeStats() {
+	endtime = time.Now().Unix()
+	total := atomic.SwapInt32(&tmp, 0)
+	//
+	if total > times {
+		log.Printf("flash black user [%d - %d] \n ",starttime,endtime)
+		//刷数据
+		mongodb.Update("user", fmt.Sprintf(`{"l_registedate":{"$gte":%d,"$lte":%d}}`, starttime, endtime), `{"$set":{"black":1}}`, false, true)
+	}
+	starttime = time.Now().Unix()
+	endtime = starttime
+	time.AfterFunc(dutrat, subscribeStats)
+}
+
+//启动过滤,3分钟,超过20次,认为是非法操作
+func StartSubscribeFilter(cyc, ts int) {
+	times = int32(ts)
+	dutrat = time.Duration(cyc) * time.Minute
+	starttime = time.Now().Unix()
+	go time.AfterFunc(dutrat, subscribeStats)
+}

+ 1 - 0
weixin/src/qfw/weixin/util/util.go

@@ -0,0 +1 @@
+package util

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

@@ -2,6 +2,7 @@ package weixin
 
 import (
 	"net/http"
+	"qfw/weixin/util"
 	wf "qfw/weixinconfig"
 	"regexp"
 )
@@ -10,12 +11,17 @@ var Mux *Weixin
 
 //语音用到的正则
 var clear_voice_reg, keyword_voice_reg, notify_xiaoxing, chat_bye *regexp.Regexp
+var WELCOME_MSG string
+var OWELCOME_MSG string
+var digitreg *regexp.Regexp = regexp.MustCompile("^\\d+$")
 
 func InitWeixinSdk() {
 	keyword_voice_reg, _ = regexp.Compile("查询|搜索|检索|看|找|查|搜")
 	clear_voice_reg, _ = regexp.Compile("!|!|\\s+")
 	notify_xiaoxing, _ = regexp.Compile("小星|阿星|助手|助理")
 	chat_bye, _ = regexp.Compile("再见|拜拜|不说了|不聊了")
+	WELCOME_MSG = wf.SysConfig.WelcomeTip
+	OWELCOME_MSG = wf.SysConfig.OWelcomeTip
 
 	// my-token 验证微信公众平台的Token
 	// app-id, app-secret用于高级API调用。
@@ -42,9 +48,10 @@ func InitWeixinSdk() {
 	//单点登录请求
 	http.HandleFunc("/"+wf.SysConfig.Appcontext+"/sso/", SsoHandle)
 	//支付
-	http.HandleFunc("/"+wf.SysConfig.Appcontext+"/paybonus", PayBonusAct)
+	http.HandleFunc("/"+wf.SysConfig.Appcontext+"/paybonus", PayNormalBonusAct)
 	http.HandleFunc("/"+wf.SysConfig.Appcontext+"/recharge", RechargeAct)
 	http.HandleFunc("/"+wf.SysConfig.Appcontext+"/paycallback", PayCallback)
+	//监控
 
 	//生成推广二维码
 	http.HandleFunc("/"+wf.SysConfig.Appcontext+"/adv/", AdvHandle)
@@ -52,4 +59,5 @@ func InitWeixinSdk() {
 	//执行其他一些初始化的动作
 	InitRobotHttpClient()
 	InitSSLClient()
+	util.StartSubscribeFilter(wf.SysConfig.SubscribeMonitorCyc, wf.SysConfig.SubscribeMonitorTimes)
 }

+ 12 - 0
weixin/src/qfw/weixin/weixinsdkssl.go

@@ -1,6 +1,7 @@
 package weixin
 
 import (
+	"encoding/json"
 	"bytes"
 	"crypto/tls"
 	"crypto/x509"
@@ -76,6 +77,17 @@ func (wx *Weixin) PostXmlCustom(url string, obj interface{}) ([]byte, error) {
 	return bs, err
 }
 
+//Post Json Data
+func (wx *Weixin) PostJsonCustom(url string, obj interface{}) ([]byte,error){
+	var bs []byte
+	data, err := json.Marshal(obj)
+	if err != nil {
+		return bs, err
+	}
+	bs, err = postSSLRequest(url, wx.tokenChan, data)
+	return bs,err
+}
+
 //发送安全请求
 func postSSLRequest(reqURL string, c chan accessToken, data []byte) ([]byte, error) {
 	for i := 0; i < retryMaxN; i++ {

+ 2 - 0
weixin/src/qfw/weixinconfig/weixinconfig.go

@@ -30,6 +30,8 @@ type wxconfig struct {
 	FreezeTip       string            `json:"freezeTip"`
 	Activity        map[string]string `json:"activity"` //活动配置
 	WeixinAutoRpl   string            `json:"weixinautorpl"`
+	SubscribeMonitorCyc int `json:"subscribemonitorcyc"`
+	SubscribeMonitorTimes int `json:"subscribemonitortimes"`
 }
 
 //系统配置

二進制
weixin/src/weixin