|
@@ -121,6 +121,7 @@ func limitFun() {
|
|
|
|
|
|
//解除限制的监测
|
|
|
func unlimitFun() {
|
|
|
+
|
|
|
limitLock.Lock()
|
|
|
//非限制状态
|
|
|
if limitStatus {
|
|
@@ -202,6 +203,7 @@ type Activemanage struct {
|
|
|
luckdraw xweb.Mapper `xweb:"/activity/(\\w+)/([^.]*)"`
|
|
|
getluckdraw xweb.Mapper `xweb:"/activity/luckdraw"`
|
|
|
addredis xweb.Mapper `xweb:"/activity/addredis"`
|
|
|
+ flop xweb.Mapper `xweb:"/activity/flop/(.*)"`
|
|
|
}
|
|
|
|
|
|
//分享成功后建立redis判断值
|
|
@@ -222,6 +224,13 @@ func (a *Activemanage) Addredis() error {
|
|
|
|
|
|
//进入抽奖页面
|
|
|
func (a *Activemanage) Luckdraw(activecode, id string) error {
|
|
|
+ nowdate := time.Now().Unix()
|
|
|
+ enddate := LuckDraw.EndDate
|
|
|
+ if nowdate > enddate {
|
|
|
+ a.T["flog"] = "G"
|
|
|
+ a.T["msg"] = " 抱歉,来晚了,活动已经结束了!敬请期待下一次活动吧,注意看预告呦……"
|
|
|
+ return a.Render("/active/luckdraw.html", &a.T)
|
|
|
+ }
|
|
|
//userInfo := a.GetSession("userInfo").(*map[string]interface{})
|
|
|
//se := SimpleEncrypt{Key: "topnet2015topnet2015"}
|
|
|
openid := se.DecodeString(id)
|
|
@@ -239,7 +248,7 @@ func (a *Activemanage) Luckdraw(activecode, id string) error {
|
|
|
userid := strings.Split(fmt.Sprintf("%s", (*f)["_id"]), `"`)[1]
|
|
|
if *f == nil {
|
|
|
a.T["flog"] = "B"
|
|
|
- a.T["msg"] = "您的微信号无效!!"
|
|
|
+ a.T["msg"] = " 您的微信号无效!!"
|
|
|
return a.Render("/active/luckdraw.html", &a.T)
|
|
|
}
|
|
|
a.SetSession("userName", username)
|
|
@@ -297,12 +306,13 @@ func (a *Activemanage) Getluckdraw() error {
|
|
|
data["s_openid"] = openid
|
|
|
data["s_actcode"] = s_actcode
|
|
|
black := a.GetSession("black")
|
|
|
+ plan := redis.GetStr("other", "s_luckydraw_mode")
|
|
|
var i int
|
|
|
- if black == "T" {
|
|
|
+ if black == "T" || plan == "" || plan == "3" {
|
|
|
//黑名单指针范围
|
|
|
- i = rand.Intn(30) + 50
|
|
|
+ i = rand.Intn(30) + 50 //手动第三套方案
|
|
|
} else {
|
|
|
- i = getLuckDraw()
|
|
|
+ i = getLuckDraw(plan)
|
|
|
}
|
|
|
s_prize := getPrize(i)
|
|
|
data["s_prize"] = s_prize
|
|
@@ -312,17 +322,21 @@ func (a *Activemanage) Getluckdraw() error {
|
|
|
enddate := LuckDraw.EndDate
|
|
|
if nowdate < enddate {
|
|
|
id = Save("winningrecord", data)
|
|
|
+ } else {
|
|
|
+ flog = "G"
|
|
|
+ msg = " 抱歉,来晚了,活动已经结束了!敬请期待下一次活动吧,注意看预告呦……"
|
|
|
+ return a.Write(`{"flog":"` + flog + `","msg":"` + msg + `"}`)
|
|
|
}
|
|
|
if len(id) > 0 {
|
|
|
flog = "T"
|
|
|
}
|
|
|
//红包
|
|
|
- if (i > 184 && i < 221) || (i > 319 && i < 356) {
|
|
|
+ if (i > 189 && i < 221) || (i > 324 && i < 351) {
|
|
|
var amount int //红包金额以“元”为单位,微信红包以“分”为单位
|
|
|
- if i > 184 && i < 221 {
|
|
|
+ if i > 189 && i < 221 {
|
|
|
amount = 500 //红包金额以“元”为单位,微信红包以“分”为单位
|
|
|
|
|
|
- } else if i > 319 && i < 356 {
|
|
|
+ } else if i > 324 && i < 351 {
|
|
|
amount = 100 //红包金额以“元”为单位,微信红包以“分”为单位
|
|
|
}
|
|
|
bm := qrpc.BonusMsg{Mchbillno: fmt.Sprint(today.Unix()),
|
|
@@ -358,7 +372,7 @@ func (a *Activemanage) Getluckdraw() error {
|
|
|
|
|
|
}
|
|
|
msg = " 小主是真真的好运气," + s_prize + "落入您囊中。红包将由系统自动发放到您的微信,请注意查收。<br/><br/> 分享给好友参加明天抽奖呦!乖,快去分享吧!大奖可能就在明天~~"
|
|
|
- } else if (i > 274 && i < 311) || (i > 94 && i < 131) {
|
|
|
+ } else if (i > 279 && i < 311) || (i > 94 && i < 121) {
|
|
|
//时间判断,提醒不同
|
|
|
//now := time.Now()
|
|
|
//不在工作时间
|
|
@@ -366,7 +380,7 @@ func (a *Activemanage) Getluckdraw() error {
|
|
|
//
|
|
|
// msg = " 小主是真真的好运气," + s_prize + "落入您囊中!<br/> 请在微信留下您的联系方式(手机号或qq号),企明星客服会在下一个工作日9:00-17:00给小主回复哦!<br/> 小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)"
|
|
|
//} else { //在工作时间
|
|
|
- msg = " 小主是真真的好运气," + s_prize + "落入您囊中。请将您的联系方式和邮寄地址留言给企明星。我们会在活动截止后尽快为您发出。<br/><br/> 分享给好友参加明天抽奖呦!乖,快去分享吧!大奖可能就在明天~~"
|
|
|
+ msg = " 小主是真真的好运气," + s_prize + "落入您囊中。请将您的姓名+联系方式+邮寄地址留言给企明星。我们会在活动截止后尽快为您发出。<br/><br/> 分享给好友参加明天抽奖呦!乖,快去分享吧!大奖可能就在明天~~"
|
|
|
//}
|
|
|
} else if i > 139 && i < 176 {
|
|
|
obid := a.GetSession("userId").(string)
|
|
@@ -384,14 +398,22 @@ func (a *Activemanage) Getluckdraw() error {
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func getLuckDraw() int {
|
|
|
+func getLuckDraw(plan string) int {
|
|
|
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 //第一套方案
|
|
|
+ //手动
|
|
|
+ if plan == "1" {
|
|
|
+ array = LuckDraw.GetAmount //手动第一套方案
|
|
|
+ } else if plan == "2" {
|
|
|
+ array = LuckDraw.GetAmounttwo //手动第二套方案
|
|
|
+ } else if plan == "0" {
|
|
|
+ //自动
|
|
|
+ if CheckLimit() || !thflog {
|
|
|
+ array = LuckDraw.GetAmounttwo //第二套方案
|
|
|
+ } else {
|
|
|
+ array = LuckDraw.GetAmount //第一套方案
|
|
|
+ }
|
|
|
}
|
|
|
weightValue := getWeightRandom(array)
|
|
|
min := IntAll(array[weightValue]["min"])
|
|
@@ -405,24 +427,24 @@ func getLuckDraw() int {
|
|
|
amount := min + rand.New(rand.NewSource(time.Now().UnixNano())).Intn(max-min)
|
|
|
if amount <= 0 {
|
|
|
return 1
|
|
|
- } else if amount > 274 && amount < 311 {
|
|
|
- count := Count("winningrecord", "{'s_prize':'《牛奶可乐经济学》'}")
|
|
|
- if count > 6 {
|
|
|
- amount = 245
|
|
|
- }
|
|
|
- } else if amount > 94 && amount < 131 {
|
|
|
+ } else if amount > 279 && amount < 311 {
|
|
|
+ //count := Count("winningrecord", "{'s_prize':'《牛奶可乐经济学》'}")
|
|
|
+ //if count > 6 {
|
|
|
+ amount = 245
|
|
|
+ //}
|
|
|
+ } else if amount > 94 && amount < 121 {
|
|
|
count := Count("winningrecord", "{'s_prize':'限量版U盘'}")
|
|
|
if count > 100 {
|
|
|
amount = 255
|
|
|
}
|
|
|
- } else if amount > 184 && amount < 221 {
|
|
|
+ } else if amount > 189 && amount < 221 {
|
|
|
count := Count("winningrecord", "{'s_prize':'五元现金红包'}")
|
|
|
- if count > 200 {
|
|
|
+ if count > 250 {
|
|
|
amount = 65
|
|
|
}
|
|
|
- } else if amount > 319 && amount < 356 {
|
|
|
+ } else if amount > 324 && amount < 356 {
|
|
|
count := Count("winningrecord", "{'s_prize':'一元现金红包'}")
|
|
|
- if count > 2500 {
|
|
|
+ if count > 3100 {
|
|
|
amount = 75
|
|
|
}
|
|
|
}
|