|
@@ -7,6 +7,7 @@ import (
|
|
|
"fmt"
|
|
|
"log"
|
|
|
. "mongodb"
|
|
|
+ . "p"
|
|
|
"pay"
|
|
|
qutil "qfw/util"
|
|
|
"qfw/util/jy"
|
|
@@ -33,6 +34,7 @@ func Run() {
|
|
|
go checkMemberServiceIsExpire()
|
|
|
go SendDataExportMailForPayed()
|
|
|
go updateDataExportStatus()
|
|
|
+ go bigMemberExpireRemind()
|
|
|
go updateProvincePackageStatus() //省份流量包
|
|
|
}
|
|
|
}
|
|
@@ -276,7 +278,7 @@ func checkIsExpire() {
|
|
|
it := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
"i_appid": 2,
|
|
|
"i_vip_status": map[string]interface{}{
|
|
|
- "$in": []int{1, 2},
|
|
|
+ "$gt": 0,
|
|
|
},
|
|
|
"l_vip_endtime": map[string]interface{}{
|
|
|
"$lte": now_unix + threeday,
|
|
@@ -295,6 +297,9 @@ func checkIsExpire() {
|
|
|
"i_vip_subtips": 0,
|
|
|
"i_vip_fastimport": 0,
|
|
|
},
|
|
|
+ "$unset": map[string]interface{}{
|
|
|
+ "i_vip_expire_tip_retry": "",
|
|
|
+ },
|
|
|
})
|
|
|
if delSess != nil {
|
|
|
for _, pushColl := range []string{"pushspace", "pushspace_temp", "pushspace_vip", "pushspace_project"} {
|
|
@@ -314,6 +319,9 @@ func checkIsExpire() {
|
|
|
"$set": map[string]interface{}{
|
|
|
"i_vip_expire_tip": 1,
|
|
|
},
|
|
|
+ "$unset": map[string]interface{}{
|
|
|
+ "i_vip_expire_tip_retry": "",
|
|
|
+ },
|
|
|
})
|
|
|
log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改即将到期状态", updateOk)
|
|
|
}
|
|
@@ -328,9 +336,9 @@ func expireRemind() {
|
|
|
crontab(false, TimeTaskConfig.ExpireRemind, func() {
|
|
|
defer qutil.Catch()
|
|
|
log.Println("定时任务,到期提醒,开始推送消息")
|
|
|
- if wxTplMsgErr := (&util.WxTplMsgCustom{}).Expired(); wxTplMsgErr != nil {
|
|
|
- log.Println(wxTplMsgErr)
|
|
|
- }
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ util.OnTrial_WTMCS.Reload()
|
|
|
+ util.Formal_WTMCS.Reload()
|
|
|
sess := util.MQFW.GetMgoConn()
|
|
|
for {
|
|
|
if sess != nil {
|
|
@@ -343,109 +351,142 @@ func expireRemind() {
|
|
|
it := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
"i_appid": 2,
|
|
|
"i_vip_expire_tip": map[string]interface{}{
|
|
|
- "$in": []int{1, 2},
|
|
|
+ "$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,
|
|
|
+ "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); {
|
|
|
- _id := BsonIdToSId(m["_id"])
|
|
|
- log.Println("发送消息", _id)
|
|
|
- i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
|
i_vip_expire_tip := qutil.IntAll(m["i_vip_expire_tip"])
|
|
|
- wxPushOk, appPushOk := false, false
|
|
|
if i_vip_expire_tip != 1 && i_vip_expire_tip != 2 {
|
|
|
continue
|
|
|
}
|
|
|
- l_vip_starttime := qutil.Int64All(m["l_vip_starttime"])
|
|
|
+ _id := BsonIdToSId(m["_id"])
|
|
|
l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
|
+ if l_vip_endtime-now_unix > threeday && i_vip_expire_tip == 1 {
|
|
|
+ log.Println("即将到期提醒,结束时间大于三天,过滤掉", _id, l_vip_endtime)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
|
+ wxPushOk, appPushOk := false, false
|
|
|
+ l_vip_starttime := qutil.Int64All(m["l_vip_starttime"])
|
|
|
s_m_openid := qutil.ObjToString(m["s_m_openid"])
|
|
|
isPushWx := qutil.IntAllDef(m["i_ispush"], 1)
|
|
|
s_jpushid := qutil.ObjToString(m["s_jpushid"])
|
|
|
s_opushid := qutil.ObjToString(m["s_opushid"])
|
|
|
s_appponetype := qutil.ObjToString(m["s_appponetype"])
|
|
|
log.Println("到期提醒,推送消息", _id, "i_vip_status", i_vip_status, "l_vip_starttime", l_vip_starttime, "l_vip_endtime", l_vip_endtime, "i_vip_expire_tip", i_vip_expire_tip, "s_m_openid", s_m_openid, "isPushWx", isPushWx, "s_appponetype", s_appponetype, "s_jpushid", s_jpushid, "s_opushid", s_opushid)
|
|
|
- tp := ""
|
|
|
- tplId, first_value, first_color, keyword1_value, keyword2_value, keyword3_value, keyword4_value, remark := "", "", "", "", "", "", "", ""
|
|
|
- switch i_vip_status {
|
|
|
- case 1, -1:
|
|
|
- if i_vip_expire_tip == 1 {
|
|
|
- tp = "ontrial_soonexprie"
|
|
|
- tplId = MessageConfig.WxTpl_OnTrial_SoonExpire.Id
|
|
|
- first_value = MessageConfig.WxTpl_OnTrial_SoonExpire.First.Value
|
|
|
- first_color = MessageConfig.WxTpl_OnTrial_SoonExpire.First.Color
|
|
|
- remark = MessageConfig.WxTpl_OnTrial_SoonExpire.Remark.Value
|
|
|
- } else if i_vip_expire_tip == 2 {
|
|
|
- tp = "ontrial_expried"
|
|
|
- tplId = MessageConfig.WxTpl_OnTrial_Expired.Id
|
|
|
- first_value = MessageConfig.WxTpl_OnTrial_Expired.First.Value
|
|
|
- first_color = MessageConfig.WxTpl_OnTrial_Expired.First.Color
|
|
|
- remark = MessageConfig.WxTpl_OnTrial_Expired.Remark.Value
|
|
|
+ if isPushWx == 1 && s_m_openid != "" { //微信推送
|
|
|
+ tp := ""
|
|
|
+ tplId, first_color, keyword1_value, keyword2_value, keyword3_value, keyword4_value, remark := "", "", "", "", "", "", ""
|
|
|
+ var wtmc *WxTplMsgCustom
|
|
|
+ switch i_vip_status {
|
|
|
+ case 1, -1:
|
|
|
+ if i_vip_expire_tip == 1 {
|
|
|
+ tp = "ontrial_soonexprie"
|
|
|
+ tplId = MessageConfig.WxTpl_OnTrial_SoonExpire.Id
|
|
|
+ wtmc = util.OnTrial_WTMCS.Get(MessageConfig.WxTpl_OnTrial_SoonExpire.First.Value)
|
|
|
+ first_color = MessageConfig.WxTpl_OnTrial_SoonExpire.First.Color
|
|
|
+ remark = MessageConfig.WxTpl_OnTrial_SoonExpire.Remark.Value
|
|
|
+ } else if i_vip_expire_tip == 2 {
|
|
|
+ tp = "ontrial_expried"
|
|
|
+ tplId = MessageConfig.WxTpl_OnTrial_Expired.Id
|
|
|
+ wtmc = util.OnTrial_WTMCS.Get(MessageConfig.WxTpl_OnTrial_Expired.First.Value)
|
|
|
+ first_color = MessageConfig.WxTpl_OnTrial_Expired.First.Color
|
|
|
+ remark = MessageConfig.WxTpl_OnTrial_Expired.Remark.Value
|
|
|
+ }
|
|
|
+ keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
+ keyword2_value = qutil.FormatDateByInt64(&l_vip_endtime, qutil.Date_Short_Layout)
|
|
|
+ break
|
|
|
+ case 2, -2:
|
|
|
+ if i_vip_expire_tip == 1 {
|
|
|
+ tp = "soonexprie"
|
|
|
+ tplId = MessageConfig.WxTpl_SoonExpire.Id
|
|
|
+ wtmc = util.Formal_WTMCS.Get(MessageConfig.WxTpl_SoonExpire.First.Value)
|
|
|
+ first_color = MessageConfig.WxTpl_SoonExpire.First.Color
|
|
|
+ keyword2_value = MessageConfig.WxTpl_SoonExpire.Keyword2.Value
|
|
|
+ keyword3_value = MessageConfig.WxTpl_SoonExpire.Keyword3.Value
|
|
|
+ remark = MessageConfig.WxTpl_SoonExpire.Remark.Value
|
|
|
+ } else if i_vip_expire_tip == 2 {
|
|
|
+ tp = "expried"
|
|
|
+ tplId = MessageConfig.WxTpl_Expired.Id
|
|
|
+ wtmc = util.Formal_WTMCS.Get(MessageConfig.WxTpl_Expired.First.Value)
|
|
|
+ first_color = MessageConfig.WxTpl_Expired.First.Color
|
|
|
+ keyword2_value = MessageConfig.WxTpl_Expired.Keyword2.Value
|
|
|
+ keyword3_value = MessageConfig.WxTpl_Expired.Keyword3.Value
|
|
|
+ remark = MessageConfig.WxTpl_Expired.Remark.Value
|
|
|
+ }
|
|
|
+ keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
+ keyword4_value = qutil.FormatDateByInt64(&l_vip_endtime, qutil.Date_Short_Layout)
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ continue
|
|
|
}
|
|
|
- keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
- keyword2_value = qutil.FormatDateByInt64(&l_vip_endtime, qutil.Date_Short_Layout)
|
|
|
- break
|
|
|
- case 2, -2:
|
|
|
- if i_vip_expire_tip == 1 {
|
|
|
- tp = "soonexprie"
|
|
|
- tplId = MessageConfig.WxTpl_SoonExpire.Id
|
|
|
- first_value = MessageConfig.WxTpl_SoonExpire.First.Value
|
|
|
- first_color = MessageConfig.WxTpl_SoonExpire.First.Color
|
|
|
- keyword2_value = MessageConfig.WxTpl_SoonExpire.Keyword2.Value
|
|
|
- keyword3_value = MessageConfig.WxTpl_SoonExpire.Keyword3.Value
|
|
|
- remark = MessageConfig.WxTpl_SoonExpire.Remark.Value
|
|
|
- } else if i_vip_expire_tip == 2 {
|
|
|
- tp = "expried"
|
|
|
- tplId = MessageConfig.WxTpl_Expired.Id
|
|
|
- first_value = MessageConfig.WxTpl_Expired.First.Value
|
|
|
- first_color = MessageConfig.WxTpl_Expired.First.Color
|
|
|
- keyword2_value = MessageConfig.WxTpl_Expired.Keyword2.Value
|
|
|
- keyword3_value = MessageConfig.WxTpl_Expired.Keyword3.Value
|
|
|
- remark = MessageConfig.WxTpl_Expired.Remark.Value
|
|
|
+ if wtmc != nil {
|
|
|
+ tmplData := map[string]*qrpc.TmplItem{
|
|
|
+ "first": &qrpc.TmplItem{
|
|
|
+ Value: wtmc.FirstData,
|
|
|
+ Color: first_color,
|
|
|
+ },
|
|
|
+ "keyword1": &qrpc.TmplItem{
|
|
|
+ Value: keyword1_value,
|
|
|
+ },
|
|
|
+ "keyword2": &qrpc.TmplItem{
|
|
|
+ Value: keyword2_value,
|
|
|
+ },
|
|
|
+ "keyword3": &qrpc.TmplItem{
|
|
|
+ Value: keyword3_value,
|
|
|
+ },
|
|
|
+ "keyword4": &qrpc.TmplItem{
|
|
|
+ Value: keyword4_value,
|
|
|
+ },
|
|
|
+ "remark": &qrpc.TmplItem{
|
|
|
+ Value: remark,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ wxPushOk, _ = qrpc.WxSendTmplMsg(Config.Weixinrpc, &qrpc.WxTmplMsg{
|
|
|
+ OpenId: s_m_openid,
|
|
|
+ TplId: tplId,
|
|
|
+ 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))),
|
|
|
+ })
|
|
|
+ log.Println("到期提醒,微信推送", _id, wxPushOk, wtmc.AdvertCode, wtmc.FirstData)
|
|
|
}
|
|
|
- keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
- keyword4_value = qutil.FormatDateByInt64(&l_vip_endtime, qutil.Date_Short_Layout)
|
|
|
- break
|
|
|
}
|
|
|
- if isPushWx == 1 && s_m_openid != "" { //微信推送
|
|
|
- tmplData := map[string]*qrpc.TmplItem{
|
|
|
- "first": &qrpc.TmplItem{
|
|
|
- Value: first_value,
|
|
|
- Color: first_color,
|
|
|
- },
|
|
|
- "keyword1": &qrpc.TmplItem{
|
|
|
- Value: keyword1_value,
|
|
|
- },
|
|
|
- "keyword2": &qrpc.TmplItem{
|
|
|
- Value: keyword2_value,
|
|
|
- },
|
|
|
- "keyword3": &qrpc.TmplItem{
|
|
|
- Value: keyword3_value,
|
|
|
- },
|
|
|
- "keyword4": &qrpc.TmplItem{
|
|
|
- Value: keyword4_value,
|
|
|
- },
|
|
|
- "remark": &qrpc.TmplItem{
|
|
|
- Value: remark,
|
|
|
- },
|
|
|
+ if !wxPushOk && (m["s_opushid"] != nil || m["s_jpushid"] != nil) { //app推送
|
|
|
+ tp, app_descript := "", ""
|
|
|
+ switch i_vip_status {
|
|
|
+ case 1, -1:
|
|
|
+ if i_vip_expire_tip == 1 {
|
|
|
+ tp = "ontrial_soonexprie"
|
|
|
+ app_descript = MessageConfig.App_OnTrial_SoonExpire
|
|
|
+ } else if i_vip_expire_tip == 2 {
|
|
|
+ tp = "ontrial_expried"
|
|
|
+ app_descript = MessageConfig.App_OnTrial_Expired
|
|
|
+ }
|
|
|
+ break
|
|
|
+ case 2, -2:
|
|
|
+ if i_vip_expire_tip == 1 {
|
|
|
+ tp = "soonexprie"
|
|
|
+ app_descript = MessageConfig.App_SoonExpire
|
|
|
+ } else if i_vip_expire_tip == 2 {
|
|
|
+ tp = "expried"
|
|
|
+ app_descript = MessageConfig.App_Expired
|
|
|
+ }
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ continue
|
|
|
}
|
|
|
- wxPushOk, _ = qrpc.WxSendTmplMsg(Config.Weixinrpc, &qrpc.WxTmplMsg{
|
|
|
- OpenId: s_m_openid,
|
|
|
- TplId: tplId,
|
|
|
- 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", tp))),
|
|
|
- })
|
|
|
- log.Println("到期提醒,微信推送", _id, wxPushOk)
|
|
|
- } else if m["s_opushid"] != nil || m["s_jpushid"] != nil { //app推送
|
|
|
appPushOk = qrpc.AppPush(Config.AppPushServiceRpc, map[string]interface{}{
|
|
|
"phoneType": m["s_appponetype"],
|
|
|
"otherPushId": m["s_opushid"],
|
|
@@ -453,17 +494,23 @@ func expireRemind() {
|
|
|
"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))),
|
|
|
"userId": _id,
|
|
|
"type": "vipNotice",
|
|
|
- "descript": first_value,
|
|
|
+ "descript": app_descript,
|
|
|
"title": "剑鱼提醒",
|
|
|
})
|
|
|
log.Println("到期提醒,app推送", _id, appPushOk)
|
|
|
}
|
|
|
- if wxPushOk || appPushOk {
|
|
|
+ if wxPushOk || appPushOk || qutil.IntAll(m["i_vip_expire_tip_retry"]) >= 2 {
|
|
|
util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
|
"i_vip_expire_tip": 0,
|
|
|
},
|
|
|
})
|
|
|
+ } else if i_vip_expire_tip == 2 {
|
|
|
+ util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
+ "$inc": map[string]interface{}{
|
|
|
+ "i_vip_expire_tip_retry": 1,
|
|
|
+ },
|
|
|
+ })
|
|
|
}
|
|
|
m = make(map[string]interface{})
|
|
|
}
|
|
@@ -487,41 +534,77 @@ func checkMemberIsExpire() {
|
|
|
time.Sleep(time.Minute)
|
|
|
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()
|
|
|
+ }
|
|
|
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,
|
|
|
+ "$lte": now_unix + threeday,
|
|
|
},
|
|
|
- }).Select(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1}).Iter()
|
|
|
+ }).Select(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); {
|
|
|
_id := BsonIdToSId(m["_id"])
|
|
|
i_member_endtime := qutil.Int64All(m["i_member_endtime"])
|
|
|
i_member_status := qutil.IntAll(m["i_member_status"])
|
|
|
+ i_member_expire_tip := qutil.IntAll(m["i_member_expire_tip"])
|
|
|
if i_member_endtime <= now_unix {
|
|
|
util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
|
- "i_member_status": -i_member_status,
|
|
|
+ "i_member_status": -i_member_status,
|
|
|
+ "i_member_expire_tip": 2,
|
|
|
},
|
|
|
"$unset": map[string]interface{}{
|
|
|
- "i_mainaccount": "",
|
|
|
- "i_pay_sub_num": "",
|
|
|
- "i_free_sub_num": "",
|
|
|
- "i_member_sub_status": "",
|
|
|
- "s_member_mainid": "",
|
|
|
+ "i_member_expire_tip_retry": "",
|
|
|
+ "i_mainaccount": "",
|
|
|
+ "i_pay_sub_num": "",
|
|
|
+ "i_free_sub_num": "",
|
|
|
+ "i_member_sub_status": "",
|
|
|
+ "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, "表数据")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//大会员用户服务表
|
|
|
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, "更新到期用户服务表出错")
|
|
|
} else {
|
|
|
if !jy.ClearBigVipUserPower(_id) {
|
|
|
log.Println("清除 redis 大会员服务详情 缓存失败:", _id)
|
|
|
}
|
|
|
clearBigVipUserPower(_id)
|
|
|
}
|
|
|
+ } else if i_member_endtime-now_unix <= threeday && i_member_expire_tip != 1 {
|
|
|
+ updateOk := util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_member_expire_tip": 1,
|
|
|
+ },
|
|
|
+ "$unset": map[string]interface{}{
|
|
|
+ "i_member_expire_tip_retry": "",
|
|
|
+ },
|
|
|
+ })
|
|
|
+ log.Println("用户", _id, i_member_status, i_member_endtime, "修改大会员即将到期状态", updateOk)
|
|
|
}
|
|
|
m = make(map[string]interface{})
|
|
|
}
|
|
@@ -529,6 +612,157 @@ func checkMemberIsExpire() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+//大会员即将到期或者已到期发推送消息
|
|
|
+func bigMemberExpireRemind() {
|
|
|
+ crontab(false, TimeTaskConfig.ExpireRemind, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,大会员到期提醒,开始推送消息")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ 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_member_expire_tip": map[string]interface{}{
|
|
|
+ "$in": []int{1, 2},
|
|
|
+ },
|
|
|
+ }).Select(map[string]interface{}{
|
|
|
+ "s_m_openid": 1,
|
|
|
+ "s_jpushid": 1,
|
|
|
+ "s_opushid": 1,
|
|
|
+ "s_appponetype": 1,
|
|
|
+ "s_nickname": 1,
|
|
|
+ "i_ispush": 1,
|
|
|
+ "i_member_status": 1,
|
|
|
+ "i_member_starttime": 1,
|
|
|
+ "i_member_endtime": 1,
|
|
|
+ "i_member_expire_tip": 1,
|
|
|
+ }).Iter()
|
|
|
+ for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
+ i_member_expire_tip := qutil.IntAll(m["i_member_expire_tip"])
|
|
|
+ if i_member_expire_tip != 1 && i_member_expire_tip != 2 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ _id := BsonIdToSId(m["_id"])
|
|
|
+ i_member_endtime := qutil.Int64All(m["i_member_endtime"])
|
|
|
+ if i_member_endtime-now_unix > threeday && i_member_endtime == 1 {
|
|
|
+ log.Println("大会员即将到期提醒,结束时间大于三天,过滤掉", _id, i_member_endtime)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ i_member_status := qutil.IntAll(m["i_member_status"])
|
|
|
+ wxPushOk, appPushOk := false, false
|
|
|
+ i_member_starttime := qutil.Int64All(m["i_member_starttime"])
|
|
|
+ s_m_openid := qutil.ObjToString(m["s_m_openid"])
|
|
|
+ isPushWx := qutil.IntAllDef(m["i_ispush"], 1)
|
|
|
+ s_jpushid := qutil.ObjToString(m["s_jpushid"])
|
|
|
+ s_opushid := qutil.ObjToString(m["s_opushid"])
|
|
|
+ s_appponetype := qutil.ObjToString(m["s_appponetype"])
|
|
|
+ log.Println("大会员到期提醒,推送消息", _id, "i_member_status", i_member_status, "i_member_starttime", i_member_starttime, "i_member_endtime", i_member_endtime, "i_member_expire_tip", i_member_expire_tip, "s_m_openid", s_m_openid, "isPushWx", isPushWx, "s_appponetype", s_appponetype, "s_jpushid", s_jpushid, "s_opushid", s_opushid)
|
|
|
+ if isPushWx == 1 && s_m_openid != "" { //微信推送
|
|
|
+ //tp := ""
|
|
|
+ tplId, first_color, keyword1_value, keyword2_value, keyword3_value, keyword4_value, remark := "", "", "", "", "", "", ""
|
|
|
+ var wtmc *WxTplMsgCustom
|
|
|
+ if i_member_status > 0 {
|
|
|
+ //tp = "bigmember_soonexprie"
|
|
|
+ tplId = MessageConfig.WxTpl_BigMember_SoonExpire.Id
|
|
|
+ wtmc = util.Formal_WTMCS.Get(MessageConfig.WxTpl_BigMember_SoonExpire.First.Value)
|
|
|
+ first_color = MessageConfig.WxTpl_BigMember_SoonExpire.First.Color
|
|
|
+ keyword2_value = MessageConfig.WxTpl_BigMember_SoonExpire.Keyword2.Value
|
|
|
+ keyword3_value = MessageConfig.WxTpl_BigMember_SoonExpire.Keyword3.Value
|
|
|
+ remark = MessageConfig.WxTpl_BigMember_SoonExpire.Remark.Value
|
|
|
+ } else if i_member_status < 0 {
|
|
|
+ //tp = "bigmember_expried"
|
|
|
+ tplId = MessageConfig.WxTpl_BigMember_Expired.Id
|
|
|
+ wtmc = util.Formal_WTMCS.Get(MessageConfig.WxTpl_BigMember_Expired.First.Value)
|
|
|
+ first_color = MessageConfig.WxTpl_BigMember_Expired.First.Color
|
|
|
+ keyword2_value = MessageConfig.WxTpl_BigMember_Expired.Keyword2.Value
|
|
|
+ keyword3_value = MessageConfig.WxTpl_BigMember_Expired.Keyword3.Value
|
|
|
+ remark = MessageConfig.WxTpl_BigMember_Expired.Remark.Value
|
|
|
+ } else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if wtmc != nil {
|
|
|
+ keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
+ keyword4_value = qutil.FormatDateByInt64(&i_member_endtime, qutil.Date_Short_Layout)
|
|
|
+ tmplData := map[string]*qrpc.TmplItem{
|
|
|
+ "first": &qrpc.TmplItem{
|
|
|
+ Value: wtmc.FirstData,
|
|
|
+ Color: first_color,
|
|
|
+ },
|
|
|
+ "keyword1": &qrpc.TmplItem{
|
|
|
+ Value: keyword1_value,
|
|
|
+ },
|
|
|
+ "keyword2": &qrpc.TmplItem{
|
|
|
+ Value: keyword2_value,
|
|
|
+ },
|
|
|
+ "keyword3": &qrpc.TmplItem{
|
|
|
+ Value: keyword3_value,
|
|
|
+ },
|
|
|
+ "keyword4": &qrpc.TmplItem{
|
|
|
+ Value: keyword4_value,
|
|
|
+ },
|
|
|
+ "remark": &qrpc.TmplItem{
|
|
|
+ Value: remark,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ wxPushOk, _ = qrpc.WxSendTmplMsg(Config.Weixinrpc, &qrpc.WxTmplMsg{
|
|
|
+ OpenId: s_m_openid,
|
|
|
+ TplId: tplId,
|
|
|
+ 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))),
|
|
|
+ })
|
|
|
+ log.Println("大会员到期提醒,微信推送", _id, wxPushOk, wtmc.AdvertCode, wtmc.FirstData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !wxPushOk && (m["s_opushid"] != nil || m["s_jpushid"] != nil) { //app推送
|
|
|
+ tp, app_descript := "", ""
|
|
|
+ if i_member_status > 0 {
|
|
|
+ tp = "bigmember_soonexprie"
|
|
|
+ app_descript = MessageConfig.App_BigMember_SoonExpire
|
|
|
+ } else if i_member_status < 0 {
|
|
|
+ tp = "bigmember_expried"
|
|
|
+ app_descript = MessageConfig.App_BigMember_Expired
|
|
|
+ } else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ appPushOk = qrpc.AppPush(Config.AppPushServiceRpc, map[string]interface{}{
|
|
|
+ "phoneType": m["s_appponetype"],
|
|
|
+ "otherPushId": m["s_opushid"],
|
|
|
+ "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))),
|
|
|
+ "userId": _id,
|
|
|
+ "type": "vipNotice",
|
|
|
+ "descript": app_descript,
|
|
|
+ "title": "剑鱼提醒",
|
|
|
+ })
|
|
|
+ log.Println("大会员到期提醒,app推送", _id, appPushOk)
|
|
|
+ }
|
|
|
+ if wxPushOk || appPushOk || qutil.IntAll(m["i_member_expire_tip_retry"]) >= 2 {
|
|
|
+ util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_member_expire_tip": 0,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ util.MQFW.UpdateById("user", _id, map[string]interface{}{
|
|
|
+ "$inc": map[string]interface{}{
|
|
|
+ "i_member_expire_tip_retry": 1,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ log.Println("定时任务,大会员到期提醒,推送消息结束")
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
//查看是否有大会员用户定时开启会员
|
|
|
func checkMemberIsStart() {
|
|
|
crontab(true, TimeTaskConfig.MemberIsStart, func() {
|
|
@@ -603,7 +837,7 @@ func updateBigMemberService(userId string, now_unix int64) {
|
|
|
|
|
|
//大会员用户服务表 用户服务是否需要开启或关闭
|
|
|
func checkMemberServiceIsExpire() {
|
|
|
- crontab(true, TimeTaskConfig.MemberServiceIsExpire, func() {
|
|
|
+ crontab(false, TimeTaskConfig.MemberServiceIsExpire, func() {
|
|
|
defer qutil.Catch()
|
|
|
log.Println("定时任务,更新大会员服务表状态开始")
|
|
|
now_unix := time.Now().Unix()
|