|
@@ -27,23 +27,25 @@ const (
|
|
|
|
|
|
func Run() {
|
|
func Run() {
|
|
if TimeTaskConfig.IsRun {
|
|
if TimeTaskConfig.IsRun {
|
|
|
|
+ for _, v := range []Identity{&Personal{}, &Ent{}} {
|
|
|
|
+ go checkIsExpire(v)
|
|
|
|
+ go checkMemberIsExpire(v)
|
|
|
|
+ go checkMemberIsStart(v)
|
|
|
|
+ go checkMemberServiceIsExpire(v)
|
|
|
|
+ go bigMemberExpireRemind(v)
|
|
|
|
+ go updateProvincePackageStatus(v) //省份流量包
|
|
|
|
+ go updateTimeLimitActitityOrderStatus(v) //修改限时活动的订单状态
|
|
|
|
+ }
|
|
go syncVipUpgrade()
|
|
go syncVipUpgrade()
|
|
- go checkIsExpire()
|
|
|
|
- go expireRemind()
|
|
|
|
- go courseTask()
|
|
|
|
- go checkMemberIsExpire()
|
|
|
|
- go checkMemberIsStart()
|
|
|
|
- go checkMemberServiceIsExpire()
|
|
|
|
- go SendDataExportMailForPayed()
|
|
|
|
go updateDataExportStatus()
|
|
go updateDataExportStatus()
|
|
- go bigMemberExpireRemind()
|
|
|
|
- go updateProvincePackageStatus() //省份流量包
|
|
|
|
- go updateTimeLimitActitityOrderStatus() //修改限时活动的订单状态
|
|
|
|
|
|
+ go SendDataExportMailForPayed()
|
|
|
|
+ go courseTask()
|
|
|
|
+ go expireRemind()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//省份流量包到期时间 定时任务
|
|
//省份流量包到期时间 定时任务
|
|
-func updateProvincePackageStatus() {
|
|
|
|
|
|
+func updateProvincePackageStatus(i Identity) {
|
|
crontab(true, TimeTaskConfig.ProvinceExpire, func() {
|
|
crontab(true, TimeTaskConfig.ProvinceExpire, func() {
|
|
defer qutil.Catch()
|
|
defer qutil.Catch()
|
|
log.Println("定时任务,开始更新省份订阅包状态开始")
|
|
log.Println("定时任务,开始更新省份订阅包状态开始")
|
|
@@ -57,18 +59,17 @@ func updateProvincePackageStatus() {
|
|
time.Sleep(time.Minute)
|
|
time.Sleep(time.Minute)
|
|
sess = util.MQFW.GetMgoConn()
|
|
sess = util.MQFW.GetMgoConn()
|
|
}
|
|
}
|
|
- it := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
|
- "i_appid": 2,
|
|
|
|
- "o_jy.i_ppstatus": map[string]interface{}{
|
|
|
|
- "$gt": -1,
|
|
|
|
- },
|
|
|
|
- "o_jy.l_areaEnd_p": map[string]interface{}{
|
|
|
|
- "$lte": now_unix,
|
|
|
|
- },
|
|
|
|
- }).Select(map[string]interface{}{"o_jy.i_ppstatus": 1, "o_jy.l_areaEnd_p": 1}).Iter()
|
|
|
|
|
|
+ query := i.SubsetQuery(2)
|
|
|
|
+ query["o_jy.i_ppstatus"] = map[string]interface{}{
|
|
|
|
+ "$gt": -1,
|
|
|
|
+ }
|
|
|
|
+ query["o_jy.l_areaEnd_p"] = map[string]interface{}{
|
|
|
|
+ "$lte": now_unix,
|
|
|
|
+ }
|
|
|
|
+ it := sess.DB("qfw").C(i.SubsetColl()).Find(query).Select(map[string]interface{}{"o_jy.i_ppstatus": 1, "o_jy.l_areaEnd_p": 1}).Iter()
|
|
for m := make(map[string]interface{}); it.Next(&m); {
|
|
for m := make(map[string]interface{}); it.Next(&m); {
|
|
_id := BsonIdToSId(m["_id"])
|
|
_id := BsonIdToSId(m["_id"])
|
|
- if util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
|
|
|
+ if util.MQFW.UpdateById(i.SubsetColl(), _id, map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"o_jy.i_ppstatus": -1,
|
|
"o_jy.i_ppstatus": -1,
|
|
"o_jy.i_areapackTip": 1,
|
|
"o_jy.i_areapackTip": 1,
|
|
@@ -228,13 +229,28 @@ func syncVipUpgrade() {
|
|
o_area, _ := m["o_area"].(map[string]interface{})
|
|
o_area, _ := m["o_area"].(map[string]interface{})
|
|
o_buyset, _ := m["o_buyset"].(map[string]interface{})
|
|
o_buyset, _ := m["o_buyset"].(map[string]interface{})
|
|
a_buyerclass, _ := m["a_buyerclass"].([]interface{})
|
|
a_buyerclass, _ := m["a_buyerclass"].([]interface{})
|
|
- if util.MQFW.UpdateById("user", s_userid, map[string]interface{}{
|
|
|
|
- "$set": map[string]interface{}{
|
|
|
|
- "o_vipjy.o_area": o_area,
|
|
|
|
- "o_vipjy.a_buyerclass": a_buyerclass,
|
|
|
|
- "o_vipjy.o_buyset": o_buyset,
|
|
|
|
- },
|
|
|
|
- }) {
|
|
|
|
|
|
+ updateOk := false
|
|
|
|
+ if IsObjectIdHex(s_userid) {
|
|
|
|
+ updateOk = util.MQFW.UpdateById("user", s_userid, map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{
|
|
|
|
+ "o_vipjy.o_area": o_area,
|
|
|
|
+ "o_vipjy.a_buyerclass": a_buyerclass,
|
|
|
|
+ "o_vipjy.o_buyset": o_buyset,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ updateOk = util.MQFW.Update("entniche_user", map[string]interface{}{
|
|
|
|
+ "i_type": 2,
|
|
|
|
+ "i_userid": qutil.IntAll(s_userid),
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{
|
|
|
|
+ "o_vipjy.o_area": o_area,
|
|
|
|
+ "o_vipjy.a_buyerclass": a_buyerclass,
|
|
|
|
+ "o_vipjy.o_buyset": o_buyset,
|
|
|
|
+ },
|
|
|
|
+ }, false, false)
|
|
|
|
+ }
|
|
|
|
+ if updateOk {
|
|
util.MQFW.UpdateById("vip_upgrade", _id, map[string]interface{}{
|
|
util.MQFW.UpdateById("vip_upgrade", _id, map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"l_synctime": time.Now().Unix(),
|
|
"l_synctime": time.Now().Unix(),
|
|
@@ -253,7 +269,7 @@ func syncVipUpgrade() {
|
|
}
|
|
}
|
|
|
|
|
|
//每天0点 检查试用、vip服务是否到期
|
|
//每天0点 检查试用、vip服务是否到期
|
|
-func checkIsExpire() {
|
|
|
|
|
|
+func checkIsExpire(iy Identity) {
|
|
crontab(true, TimeTaskConfig.CheckIsExpire, func() {
|
|
crontab(true, TimeTaskConfig.CheckIsExpire, func() {
|
|
defer qutil.Catch()
|
|
defer qutil.Catch()
|
|
log.Println("定时任务,开始更新vip状态")
|
|
log.Println("定时任务,开始更新vip状态")
|
|
@@ -267,26 +283,17 @@ func checkIsExpire() {
|
|
time.Sleep(time.Minute)
|
|
time.Sleep(time.Minute)
|
|
sess = util.MQFW.GetMgoConn()
|
|
sess = util.MQFW.GetMgoConn()
|
|
}
|
|
}
|
|
- count, err := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
|
- "i_appid": 2,
|
|
|
|
- "i_vip_status": map[string]interface{}{
|
|
|
|
- "$gt": 0,
|
|
|
|
- },
|
|
|
|
- "l_vip_endtime": map[string]interface{}{
|
|
|
|
- "$lte": now_unix + threeday,
|
|
|
|
- },
|
|
|
|
- }).Count()
|
|
|
|
|
|
+ query := iy.UserQuery()
|
|
|
|
+ query["i_vip_status"] = map[string]interface{}{
|
|
|
|
+ "$gt": 0,
|
|
|
|
+ }
|
|
|
|
+ query["l_vip_endtime"] = map[string]interface{}{
|
|
|
|
+ "$lte": now_unix + threeday,
|
|
|
|
+ }
|
|
|
|
+ count, err := sess.DB("qfw").C(iy.UserColl()).Find(query).Count()
|
|
log.Println("当前时间:", FormatDateByInt64(&now_unix, Date_Full_Layout), "数据总量:", count, "--err:", err)
|
|
log.Println("当前时间:", FormatDateByInt64(&now_unix, Date_Full_Layout), "数据总量:", count, "--err:", err)
|
|
var i int64 = 0
|
|
var i int64 = 0
|
|
- it := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
|
- "i_appid": 2,
|
|
|
|
- "i_vip_status": map[string]interface{}{
|
|
|
|
- "$gt": 0,
|
|
|
|
- },
|
|
|
|
- "l_vip_endtime": map[string]interface{}{
|
|
|
|
- "$lte": now_unix + threeday,
|
|
|
|
- },
|
|
|
|
- }).Select(map[string]interface{}{"i_vip_status": 1, "l_vip_endtime": 1, "i_vip_expire_tip": 1}).Iter()
|
|
|
|
|
|
+ it := sess.DB("qfw").C(iy.UserColl()).Find(query).Select(iy.UserField(map[string]interface{}{"i_vip_status": 1, "l_vip_endtime": 1, "i_vip_expire_tip": 1})).Iter()
|
|
for m := make(map[string]interface{}); it.Next(&m); {
|
|
for m := make(map[string]interface{}); it.Next(&m); {
|
|
i++
|
|
i++
|
|
_id := BsonIdToSId(m["_id"])
|
|
_id := BsonIdToSId(m["_id"])
|
|
@@ -294,7 +301,7 @@ func checkIsExpire() {
|
|
i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
i_vip_expire_tip := qutil.IntAll(m["i_vip_expire_tip"])
|
|
i_vip_expire_tip := qutil.IntAll(m["i_vip_expire_tip"])
|
|
if l_vip_endtime <= now_unix {
|
|
if l_vip_endtime <= now_unix {
|
|
- ok := util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
|
|
|
+ ok := util.MQFW.UpdateById(iy.UserColl(), _id, map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"i_vip_status": -i_vip_status,
|
|
"i_vip_status": -i_vip_status,
|
|
"i_vip_expire_tip": 2,
|
|
"i_vip_expire_tip": 2,
|
|
@@ -308,31 +315,7 @@ func checkIsExpire() {
|
|
if !ok {
|
|
if !ok {
|
|
log.Println("用户:", _id, " 更新vip状态异常")
|
|
log.Println("用户:", _id, " 更新vip状态异常")
|
|
}
|
|
}
|
|
- go func(_id string) {
|
|
|
|
- delSess := util.Mgo_log.GetMgoConn()
|
|
|
|
- delSessErrCount := 0
|
|
|
|
- for {
|
|
|
|
- if delSessErrCount == 10 {
|
|
|
|
- break
|
|
|
|
- } else if delSess != nil {
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- delSessErrCount++
|
|
|
|
- time.Sleep(5 * time.Second)
|
|
|
|
- delSess = util.Mgo_log.GetMgoConn()
|
|
|
|
- }
|
|
|
|
- if delSess != nil {
|
|
|
|
- defer util.Mgo_log.DestoryMongoConn(delSess)
|
|
|
|
- for _, pushColl := range []string{"pushspace", "pushspace_temp", "pushspace_vip", "pushspace_project"} {
|
|
|
|
- _, err := delSess.DB("push").C(pushColl).RemoveAll(map[string]interface{}{"userid": _id})
|
|
|
|
- if err != nil {
|
|
|
|
- log.Println("用户", _id, "已到期删除", pushColl, "表数据出错", err)
|
|
|
|
- } else {
|
|
|
|
- log.Println("用户", _id, "已到期删除", pushColl, "表数据")
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }(_id)
|
|
|
|
|
|
+ go iy.DelVipSubPush(m)
|
|
go jy.ClearBigVipUserPower(_id)
|
|
go jy.ClearBigVipUserPower(_id)
|
|
log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
|
|
log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
|
|
redis.Del("other", "p1_indexMessage_"+_id) //清除redis中vip状态
|
|
redis.Del("other", "p1_indexMessage_"+_id) //清除redis中vip状态
|
|
@@ -341,7 +324,7 @@ func checkIsExpire() {
|
|
vipFileUploadNumKey := fmt.Sprintf(jy.VipFileUploadNumKey, _id, fmt.Sprint(time.Now().Month()))
|
|
vipFileUploadNumKey := fmt.Sprintf(jy.VipFileUploadNumKey, _id, fmt.Sprint(time.Now().Month()))
|
|
redis.Del(jy.PowerCacheDb, vipFileUploadNumKey) //清除redis中vip使用次数
|
|
redis.Del(jy.PowerCacheDb, vipFileUploadNumKey) //清除redis中vip使用次数
|
|
} else if l_vip_endtime-now_unix <= threeday && i_vip_expire_tip != 1 {
|
|
} else if l_vip_endtime-now_unix <= threeday && i_vip_expire_tip != 1 {
|
|
- updateOk := util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
|
|
|
+ updateOk := util.MQFW.UpdateById(iy.UserColl(), _id, map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"i_vip_expire_tip": 1,
|
|
"i_vip_expire_tip": 1,
|
|
},
|
|
},
|
|
@@ -369,43 +352,16 @@ func expireRemind() {
|
|
now_unix := time.Now().Unix()
|
|
now_unix := time.Now().Unix()
|
|
util.OnTrial_WTMCS.Reload()
|
|
util.OnTrial_WTMCS.Reload()
|
|
util.Formal_WTMCS.Reload()
|
|
util.Formal_WTMCS.Reload()
|
|
- sess := util.MQFW.GetMgoConn()
|
|
|
|
- for {
|
|
|
|
- if sess != nil {
|
|
|
|
- defer util.MQFW.DestoryMongoConn(sess)
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- time.Sleep(time.Minute)
|
|
|
|
- sess = util.MQFW.GetMgoConn()
|
|
|
|
- }
|
|
|
|
- it := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
|
- "i_appid": 2,
|
|
|
|
- "i_vip_expire_tip": map[string]interface{}{
|
|
|
|
- "$gt": 0,
|
|
|
|
- },
|
|
|
|
- }).Select(map[string]interface{}{
|
|
|
|
- "s_m_openid": 1,
|
|
|
|
- "s_jpushid": 1,
|
|
|
|
- "s_opushid": 1,
|
|
|
|
- "s_appponetype": 1,
|
|
|
|
- "s_nickname": 1,
|
|
|
|
- "i_ispush": 1,
|
|
|
|
- "i_vip_status": 1,
|
|
|
|
- "l_vip_starttime": 1,
|
|
|
|
- "l_vip_endtime": 1,
|
|
|
|
- "i_vip_expire_tip": 1,
|
|
|
|
- "i_vip_expire_tip_retry": 1,
|
|
|
|
- }).Iter()
|
|
|
|
- for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
|
|
|
+ doFunc := func(m map[string]interface{}) {
|
|
i_vip_expire_tip := qutil.IntAll(m["i_vip_expire_tip"])
|
|
i_vip_expire_tip := qutil.IntAll(m["i_vip_expire_tip"])
|
|
if i_vip_expire_tip != 1 && i_vip_expire_tip != 2 {
|
|
if i_vip_expire_tip != 1 && i_vip_expire_tip != 2 {
|
|
- continue
|
|
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- _id := BsonIdToSId(m["_id"])
|
|
|
|
|
|
+ _id := qutil.ObjToString(m["_id"])
|
|
l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
if l_vip_endtime-now_unix > threeday && i_vip_expire_tip == 1 {
|
|
if l_vip_endtime-now_unix > threeday && i_vip_expire_tip == 1 {
|
|
log.Println("即将到期提醒,结束时间大于三天,过滤掉", _id, l_vip_endtime)
|
|
log.Println("即将到期提醒,结束时间大于三天,过滤掉", _id, l_vip_endtime)
|
|
- continue
|
|
|
|
|
|
+ return
|
|
}
|
|
}
|
|
i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
wxPushOk, appPushOk := false, false
|
|
wxPushOk, appPushOk := false, false
|
|
@@ -437,7 +393,7 @@ func expireRemind() {
|
|
}
|
|
}
|
|
keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
keyword2_value = FormatDateByInt64(&l_vip_endtime, Date_Short_Layout)
|
|
keyword2_value = FormatDateByInt64(&l_vip_endtime, Date_Short_Layout)
|
|
- break
|
|
|
|
|
|
+ return
|
|
case 2, -2:
|
|
case 2, -2:
|
|
if i_vip_expire_tip == 1 {
|
|
if i_vip_expire_tip == 1 {
|
|
tp = "soonexprie"
|
|
tp = "soonexprie"
|
|
@@ -458,9 +414,9 @@ func expireRemind() {
|
|
}
|
|
}
|
|
keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
keyword4_value = FormatDateByInt64(&l_vip_endtime, Date_Short_Layout)
|
|
keyword4_value = FormatDateByInt64(&l_vip_endtime, Date_Short_Layout)
|
|
- break
|
|
|
|
|
|
+ return
|
|
default:
|
|
default:
|
|
- continue
|
|
|
|
|
|
+ return
|
|
}
|
|
}
|
|
if wtmc != nil {
|
|
if wtmc != nil {
|
|
tmplData := map[string]*qrpc.TmplItem{
|
|
tmplData := map[string]*qrpc.TmplItem{
|
|
@@ -488,7 +444,7 @@ func expireRemind() {
|
|
OpenId: s_m_openid,
|
|
OpenId: s_m_openid,
|
|
TplId: tplId,
|
|
TplId: tplId,
|
|
TmplData: tmplData,
|
|
TmplData: tmplData,
|
|
- Url: Config.WebDomain + "/front/sess/" + util.Se_Topnet.EncodeString(s_m_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",msgremind") + "__" + hex.EncodeToString([]byte(fmt.Sprintf("type=%s&advertcode=%s", tp, wtmc.AdvertCode))),
|
|
|
|
|
|
+ Url: Config.WebDomain + "/front/sess/" + util.Se_Topnet.EncodeString(_id+qutil.If(IsObjectIdHex(_id), ",_id,", ",entUserId,").(string)+strconv.Itoa(int(time.Now().Unix()))+",msgremind") + "__" + hex.EncodeToString([]byte(fmt.Sprintf("type=%s&advertcode=%s", tp, wtmc.AdvertCode))),
|
|
})
|
|
})
|
|
log.Println("到期提醒,微信推送", _id, wxPushOk, wtmc.AdvertCode, wtmc.FirstData)
|
|
log.Println("到期提醒,微信推送", _id, wxPushOk, wtmc.AdvertCode, wtmc.FirstData)
|
|
}
|
|
}
|
|
@@ -504,7 +460,7 @@ func expireRemind() {
|
|
tp = "ontrial_expried"
|
|
tp = "ontrial_expried"
|
|
app_descript = MessageConfig.App_OnTrial_Expired
|
|
app_descript = MessageConfig.App_OnTrial_Expired
|
|
}
|
|
}
|
|
- break
|
|
|
|
|
|
+ return
|
|
case 2, -2:
|
|
case 2, -2:
|
|
if i_vip_expire_tip == 1 {
|
|
if i_vip_expire_tip == 1 {
|
|
tp = "soonexprie"
|
|
tp = "soonexprie"
|
|
@@ -513,15 +469,15 @@ func expireRemind() {
|
|
tp = "expried"
|
|
tp = "expried"
|
|
app_descript = MessageConfig.App_Expired
|
|
app_descript = MessageConfig.App_Expired
|
|
}
|
|
}
|
|
- break
|
|
|
|
|
|
+ return
|
|
default:
|
|
default:
|
|
- continue
|
|
|
|
|
|
+ return
|
|
}
|
|
}
|
|
appPushOk = qrpc.AppPush(Config.AppPushServiceRpc, map[string]interface{}{
|
|
appPushOk = qrpc.AppPush(Config.AppPushServiceRpc, map[string]interface{}{
|
|
"phoneType": m["s_appponetype"],
|
|
"phoneType": m["s_appponetype"],
|
|
"otherPushId": m["s_opushid"],
|
|
"otherPushId": m["s_opushid"],
|
|
"jgPushId": m["s_jpushid"],
|
|
"jgPushId": m["s_jpushid"],
|
|
- "url": "/jyapp/free/sess/" + util.Se_Topnet.EncodeString(_id+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",msgremind") + "__" + hex.EncodeToString([]byte(fmt.Sprintf("type=%s", tp))),
|
|
|
|
|
|
+ "url": "/jyapp/free/sess/" + util.Se_Topnet.EncodeString(_id+qutil.If(IsObjectIdHex(_id), ",_id,", ",entUserId,").(string)+strconv.Itoa(int(time.Now().Unix()))+",msgremind") + "__" + hex.EncodeToString([]byte(fmt.Sprintf("type=%s", tp))),
|
|
"userId": _id,
|
|
"userId": _id,
|
|
"type": "vipNotice",
|
|
"type": "vipNotice",
|
|
"descript": app_descript,
|
|
"descript": app_descript,
|
|
@@ -542,14 +498,15 @@ func expireRemind() {
|
|
},
|
|
},
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- m = make(map[string]interface{})
|
|
|
|
}
|
|
}
|
|
|
|
+ (&Personal{}).LoadVipUsers(doFunc)
|
|
|
|
+ (&Ent{}).LoadVipUsers(doFunc)
|
|
log.Println("定时任务,到期提醒,推送消息结束")
|
|
log.Println("定时任务,到期提醒,推送消息结束")
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
//检测大会员到期时间 定时任务
|
|
//检测大会员到期时间 定时任务
|
|
-func checkMemberIsExpire() {
|
|
|
|
|
|
+func checkMemberIsExpire(i Identity) {
|
|
crontab(true, TimeTaskConfig.MemberExpire, func() {
|
|
crontab(true, TimeTaskConfig.MemberExpire, func() {
|
|
defer qutil.Catch()
|
|
defer qutil.Catch()
|
|
log.Println("定时任务,开始更新大会员状态")
|
|
log.Println("定时任务,开始更新大会员状态")
|
|
@@ -564,35 +521,21 @@ func checkMemberIsExpire() {
|
|
time.Sleep(time.Minute)
|
|
time.Sleep(time.Minute)
|
|
sess = util.MQFW.GetMgoConn()
|
|
sess = util.MQFW.GetMgoConn()
|
|
}
|
|
}
|
|
- delSess := util.Mgo_log.GetMgoConn()
|
|
|
|
- delSessErrCount := 0
|
|
|
|
- for {
|
|
|
|
- if delSessErrCount == 10 {
|
|
|
|
- break
|
|
|
|
- } else if delSess != nil {
|
|
|
|
- defer util.Mgo_log.DestoryMongoConn(delSess)
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- delSessErrCount++
|
|
|
|
- time.Sleep(5 * time.Second)
|
|
|
|
- delSess = util.Mgo_log.GetMgoConn()
|
|
|
|
|
|
+ query := i.UserQuery()
|
|
|
|
+ query["i_member_status"] = map[string]interface{}{
|
|
|
|
+ "$gt": 0,
|
|
}
|
|
}
|
|
- it := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
|
- "i_appid": 2,
|
|
|
|
- "i_member_status": map[string]interface{}{
|
|
|
|
- "$gt": 0,
|
|
|
|
- },
|
|
|
|
- "i_member_endtime": map[string]interface{}{
|
|
|
|
- "$lte": now_unix + threeday,
|
|
|
|
- },
|
|
|
|
- }).Select(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1, "i_member_expire_tip": 1}).Iter()
|
|
|
|
|
|
+ query["i_member_endtime"] = map[string]interface{}{
|
|
|
|
+ "$lte": now_unix + threeday,
|
|
|
|
+ }
|
|
|
|
+ it := sess.DB("qfw").C(i.UserColl()).Find(query).Select(i.UserField(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1, "i_member_expire_tip": 1})).Iter()
|
|
for m := make(map[string]interface{}); it.Next(&m); {
|
|
for m := make(map[string]interface{}); it.Next(&m); {
|
|
_id := BsonIdToSId(m["_id"])
|
|
_id := BsonIdToSId(m["_id"])
|
|
i_member_endtime := qutil.Int64All(m["i_member_endtime"])
|
|
i_member_endtime := qutil.Int64All(m["i_member_endtime"])
|
|
i_member_status := qutil.IntAll(m["i_member_status"])
|
|
i_member_status := qutil.IntAll(m["i_member_status"])
|
|
i_member_expire_tip := qutil.IntAll(m["i_member_expire_tip"])
|
|
i_member_expire_tip := qutil.IntAll(m["i_member_expire_tip"])
|
|
if i_member_endtime <= now_unix {
|
|
if i_member_endtime <= now_unix {
|
|
- util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
|
|
|
+ util.MQFW.UpdateById(i.UserColl(), _id, map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"i_member_status": -i_member_status,
|
|
"i_member_status": -i_member_status,
|
|
"i_member_expire_tip": 2,
|
|
"i_member_expire_tip": 2,
|
|
@@ -606,16 +549,7 @@ func checkMemberIsExpire() {
|
|
"s_member_mainid": "",
|
|
"s_member_mainid": "",
|
|
},
|
|
},
|
|
})
|
|
})
|
|
- if delSess != nil {
|
|
|
|
- for _, pushColl := range []string{"pushspace_member", "pushspace_member_temp", "pushspace_member_wait", "pushspace_member_project"} {
|
|
|
|
- _, err := delSess.DB("push").C(pushColl).RemoveAll(map[string]interface{}{"userid": _id})
|
|
|
|
- if err != nil {
|
|
|
|
- log.Println("用户", _id, "大会员已到期删除", pushColl, "表数据出错", err)
|
|
|
|
- } else {
|
|
|
|
- log.Println("用户", _id, "大会员已到期删除", pushColl, "表数据")
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ go i.DelBigMemberSubPush(m)
|
|
//大会员用户服务表
|
|
//大会员用户服务表
|
|
if util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_frequency = 0 , a.i_status = -1, a.l_updatetime=? WHERE a.s_userid = ?`, now_time, _id) < 0 {
|
|
if util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_frequency = 0 , a.i_status = -1, a.l_updatetime=? WHERE a.s_userid = ?`, now_time, _id) < 0 {
|
|
log.Println(_id, "更新到期用户服务表出错")
|
|
log.Println(_id, "更新到期用户服务表出错")
|
|
@@ -626,7 +560,7 @@ func checkMemberIsExpire() {
|
|
clearBigVipUserPower(_id)
|
|
clearBigVipUserPower(_id)
|
|
}
|
|
}
|
|
} else if i_member_endtime-now_unix <= threeday && i_member_expire_tip != 1 {
|
|
} else if i_member_endtime-now_unix <= threeday && i_member_expire_tip != 1 {
|
|
- updateOk := util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
|
|
|
+ updateOk := util.MQFW.UpdateById(i.UserColl(), _id, map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"i_member_expire_tip": 1,
|
|
"i_member_expire_tip": 1,
|
|
},
|
|
},
|
|
@@ -643,7 +577,7 @@ func checkMemberIsExpire() {
|
|
}
|
|
}
|
|
|
|
|
|
//大会员即将到期或者已到期发推送消息
|
|
//大会员即将到期或者已到期发推送消息
|
|
-func bigMemberExpireRemind() {
|
|
|
|
|
|
+func bigMemberExpireRemind(i Identity) {
|
|
crontab(false, TimeTaskConfig.ExpireRemind, func() {
|
|
crontab(false, TimeTaskConfig.ExpireRemind, func() {
|
|
defer qutil.Catch()
|
|
defer qutil.Catch()
|
|
log.Println("定时任务,大会员到期提醒,开始推送消息")
|
|
log.Println("定时任务,大会员到期提醒,开始推送消息")
|
|
@@ -795,7 +729,7 @@ func bigMemberExpireRemind() {
|
|
}
|
|
}
|
|
|
|
|
|
//查看是否有大会员用户定时开启会员
|
|
//查看是否有大会员用户定时开启会员
|
|
-func checkMemberIsStart() {
|
|
|
|
|
|
+func checkMemberIsStart(i Identity) {
|
|
crontab(true, TimeTaskConfig.MemberIsStart, func() {
|
|
crontab(true, TimeTaskConfig.MemberIsStart, func() {
|
|
defer qutil.Catch()
|
|
defer qutil.Catch()
|
|
log.Println("定时任务,开始更新大会员状态-定时开启会员状态")
|
|
log.Println("定时任务,开始更新大会员状态-定时开启会员状态")
|
|
@@ -867,7 +801,7 @@ func updateBigMemberService(userId string, now_unix int64) {
|
|
}
|
|
}
|
|
|
|
|
|
//大会员用户服务表 用户服务是否需要开启或关闭
|
|
//大会员用户服务表 用户服务是否需要开启或关闭
|
|
-func checkMemberServiceIsExpire() {
|
|
|
|
|
|
+func checkMemberServiceIsExpire(i Identity) {
|
|
crontab(false, TimeTaskConfig.MemberServiceIsExpire, func() {
|
|
crontab(false, TimeTaskConfig.MemberServiceIsExpire, func() {
|
|
defer qutil.Catch()
|
|
defer qutil.Catch()
|
|
log.Println("定时任务,更新大会员服务表状态开始")
|
|
log.Println("定时任务,更新大会员服务表状态开始")
|
|
@@ -916,7 +850,7 @@ func checkMemberServiceIsExpire() {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-func updateTimeLimitActitityOrderStatus() { //修改限时活动的订单状态
|
|
|
|
|
|
+func updateTimeLimitActitityOrderStatus(i Identity) { //修改限时活动的订单状态
|
|
crontabByTicker(true, TimeTaskConfig.UpdateTimeLimitActivityOrderStatus, func() {
|
|
crontabByTicker(true, TimeTaskConfig.UpdateTimeLimitActivityOrderStatus, func() {
|
|
defer qutil.Catch()
|
|
defer qutil.Catch()
|
|
log.Println("定时任务,更新限时活动订单状态开始")
|
|
log.Println("定时任务,更新限时活动订单状态开始")
|