|
@@ -19,7 +19,8 @@ import (
|
|
|
*/
|
|
|
|
|
|
type JyActivity struct {
|
|
|
- St, Ed time.Time //活动开始时间、结束时间
|
|
|
+ T1, T2, Ed time.Time //预热活动、开始时间、结束时间
|
|
|
+ DailyClock string //预热活动每天开始时间
|
|
|
ActivityCode string //活动code
|
|
|
Missions map[string]struct { //任务
|
|
|
Points int `json:"points"`
|
|
@@ -42,13 +43,19 @@ const (
|
|
|
BidderPlanBuySVipStatus = "bidderPlanActivity_v1_BuySVipCacheKey_%s" //购买
|
|
|
BidderPlanInviteMissionsStatus = "bidderPlanActivity_v1_InviteCacheKey_%s" //邀请
|
|
|
BidderPlanShareMissionsStatus = "bidderPlanActivity_v1_ShareCacheKey_%s" //分享
|
|
|
+ BidderPlanDailyBoonKey = "bidderPlanActivity_v1_DailyBoon_%s" //领取每日限量福利
|
|
|
+ BidderPlanHasDailyBoonKey = "bidderPlanActivity_v1_HasDailyBoon_%s" //是否领取过每日限量福利
|
|
|
+
|
|
|
+ BidderPlanShare = "bidderPlanActivity_v1_ShareOk_%s" //是否分享
|
|
|
+
|
|
|
)
|
|
|
|
|
|
var MembershipDay *JyActivity
|
|
|
|
|
|
func init() {
|
|
|
MembershipDay = &JyActivity{
|
|
|
- St: gtime.NewFromStrLayout(gcfg.Instance().MustGet(gctx.New(), "jyactivity.dateRange.st").String(), "2006-01-02T15:04:05Z").Time,
|
|
|
+ T1: gtime.NewFromStrLayout(gcfg.Instance().MustGet(gctx.New(), "jyactivity.dateRange.t1").String(), "2006-01-02T15:04:05Z").Time,
|
|
|
+ T2: gtime.NewFromStrLayout(gcfg.Instance().MustGet(gctx.New(), "jyactivity.dateRange.t2").String(), "2006-01-02T15:04:05Z").Time,
|
|
|
Ed: gtime.NewFromStrLayout(gcfg.Instance().MustGet(gctx.New(), "jyactivity.dateRange.ed").String(), "2006-01-02T15:04:05Z").Time,
|
|
|
}
|
|
|
MembershipDay.ActivityCode = gcfg.Instance().MustGet(gctx.New(), "jyactivity.code").String()
|
|
@@ -63,9 +70,16 @@ func init() {
|
|
|
}
|
|
|
|
|
|
// InActivity 是否在活动时间内
|
|
|
-func (BP *JyActivity) InActivity() bool {
|
|
|
+// bTime 是否在预热时间段内
|
|
|
+// iTime 是否在正式活动时间内
|
|
|
+func (BP *JyActivity) InActivity() (bTime, iTime bool) {
|
|
|
now := time.Now()
|
|
|
- return now.After(MembershipDay.St) && now.Before(MembershipDay.Ed)
|
|
|
+ bTime = now.After(MembershipDay.T1) && now.Before(MembershipDay.T2)
|
|
|
+ if bTime {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ iTime = now.After(MembershipDay.T2) && now.Before(MembershipDay.Ed)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// cacheLong 缓存时间
|
|
@@ -107,7 +121,7 @@ func (BP *JyActivity) GetScheduleQuery(userId string, schedule int) (status int)
|
|
|
|
|
|
// ScheduleGiven 活动任务进度奖励
|
|
|
func (BP *JyActivity) ScheduleGiven(userId string, schedule int) error {
|
|
|
- if !BP.InActivity() {
|
|
|
+ if _, inActivity := BP.InActivity(); !inActivity {
|
|
|
return fmt.Errorf("活动已结束")
|
|
|
}
|
|
|
if BP.GetScheduleQuery(userId, schedule) != 1 {
|
|
@@ -154,7 +168,7 @@ type FreeSubscribe struct {
|
|
|
// 是否购买超级订阅
|
|
|
func (BP *JyActivity) MissionsSVipBuyQuery(userId string) (status int) {
|
|
|
finish := func() bool {
|
|
|
- count := db.Mysql.CountBySql(`SELECT count(id) FROM dataexport_order WHERE product_type ='VIP订阅' AND order_money > 0 AND order_status>0 AND create_time > ? AND user_id=? `, BP.St.Format(dateFormate.Date_Full_Layout), userId)
|
|
|
+ count := db.Mysql.CountBySql(`SELECT count(id) FROM dataexport_order WHERE product_type ='VIP订阅' AND order_money > 0 AND order_status>0 AND create_time > ? AND create_time < ? AND user_id=? `, BP.T2.Format(dateFormate.Date_Full_Layout), BP.Ed.Format(dateFormate.Date_Full_Layout), userId)
|
|
|
if count > 0 {
|
|
|
return true
|
|
|
}
|
|
@@ -180,7 +194,7 @@ func (BP *JyActivity) MissionsSVipBuyQuery(userId string) (status int) {
|
|
|
|
|
|
// MissionsSVipBuyGiven 订阅任务领取奖励
|
|
|
func (BP *JyActivity) MissionsSVipBuyGiven(userId string) error {
|
|
|
- if !BP.InActivity() {
|
|
|
+ if _, inActivity := BP.InActivity(); !inActivity {
|
|
|
return fmt.Errorf("活动已结束")
|
|
|
}
|
|
|
status := BP.MissionsSVipBuyQuery(userId)
|
|
@@ -217,7 +231,7 @@ func (BP *JyActivity) MissionsInviteQuery(userId string) (status int) {
|
|
|
|
|
|
// MissionsInviteGiven 邀请任务奖励领取
|
|
|
func (BP *JyActivity) MissionsInviteGiven(userId string) error {
|
|
|
- if !BP.InActivity() {
|
|
|
+ if _, inActivity := BP.InActivity(); !inActivity {
|
|
|
return fmt.Errorf("活动已结束")
|
|
|
}
|
|
|
status := BP.MissionsInviteQuery(userId)
|
|
@@ -245,10 +259,8 @@ func (BP *JyActivity) MissionsInviteGiven(userId string) error {
|
|
|
// MissionsShareQuery 分享活动
|
|
|
// status:0 未完成 1 待领取 -1已领取
|
|
|
func (BP *JyActivity) MissionsShareQuery(userId string) (status int) {
|
|
|
- hasMsg := db.Mgo.Count("saleLeads", map[string]interface{}{
|
|
|
- "userid": userId,
|
|
|
- }) > 0
|
|
|
- if !hasMsg {
|
|
|
+ finished, _ := redis.Exists(BidderPlanRedis, fmt.Sprintf(BidderPlanShare, userId))
|
|
|
+ if !finished {
|
|
|
return 0
|
|
|
}
|
|
|
key := fmt.Sprintf(BidderPlanShareMissionsStatus, userId)
|
|
@@ -266,7 +278,7 @@ func (BP *JyActivity) MissionsShareQuery(userId string) (status int) {
|
|
|
|
|
|
// MissionsShareGiven 分享活动
|
|
|
func (BP *JyActivity) MissionsShareGiven(userId string) error {
|
|
|
- if !BP.InActivity() {
|
|
|
+ if _, inActivity := BP.InActivity(); !inActivity {
|
|
|
return fmt.Errorf("活动已结束")
|
|
|
}
|
|
|
status := BP.MissionsShareQuery(userId)
|