|
@@ -1,1204 +1,1289 @@
|
|
|
package timetask
|
|
|
|
|
|
import (
|
|
|
- "encoding/hex"
|
|
|
- "fmt"
|
|
|
- "github.com/gogf/gf/v2/util/gconv"
|
|
|
- "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
- . "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
- "jy/src/jfw/modules/subscribepay/src/entity/bidCreditReport"
|
|
|
- "jy/src/jfw/modules/subscribepay/src/pay"
|
|
|
- "jy/src/jfw/modules/subscribepay/src/util"
|
|
|
- "log"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
+ "encoding/hex"
|
|
|
+ "fmt"
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
+ . "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/entity/bidCreditReport"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/pay"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/util"
|
|
|
+ "log"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
|
|
|
- "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
|
+ "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
|
|
|
|
- qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
- . "app.yhyue.com/moapp/jybase/date"
|
|
|
- . "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
- qrpc "app.yhyue.com/moapp/jybase/rpc"
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
+ . "app.yhyue.com/moapp/jybase/date"
|
|
|
+ . "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
+ qrpc "app.yhyue.com/moapp/jybase/rpc"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
- oneDayLong = 86400
|
|
|
- threeday = 3 * oneDayLong
|
|
|
- thirtDays = 30 * oneDayLong
|
|
|
+ oneDayLong = 86400
|
|
|
+ threeday = 3 * oneDayLong
|
|
|
+ thirtDays = 30 * oneDayLong
|
|
|
|
|
|
- CollEntUser = "ent_user" // 企业版用户表
|
|
|
+ CollEntUser = "ent_user" // 企业版用户表
|
|
|
)
|
|
|
|
|
|
func Run() {
|
|
|
- if TimeTaskConfig.IsRun {
|
|
|
- for _, v := range []Identity{&Personal{}, &Ent{}} {
|
|
|
- go checkIsExpire(v)
|
|
|
- go checkMemberIsExpire(v)
|
|
|
- go updateProvincePackageStatus(v) //省份流量包
|
|
|
- go checkDocMemberIsExpire(v) // 剑鱼文库会员检查过期状态
|
|
|
- }
|
|
|
- go bigMemberExpireRemind()
|
|
|
- go syncVipUpgrade()
|
|
|
- go updateDataExportStatus()
|
|
|
- go SendDataExportMailForPayed()
|
|
|
- go courseTask()
|
|
|
- go expireRemind()
|
|
|
- go checkMemberIsStart()
|
|
|
- go checkEntIsStart() // 企业版大会员或超级订阅定时开通
|
|
|
- go checkMemberServiceIsExpire()
|
|
|
- go updateTimeLimitActitityOrderStatus() //修改限时活动的订单状态
|
|
|
- go bidCreditReport.BidCreditReport.NewOrderWarn()
|
|
|
- }
|
|
|
+ if TimeTaskConfig.IsRun {
|
|
|
+ for _, v := range []Identity{&Personal{}, &Ent{}} {
|
|
|
+ go checkIsExpire(v)
|
|
|
+ go checkMemberIsExpire(v)
|
|
|
+ go updateProvincePackageStatus(v) //省份流量包
|
|
|
+ go checkDocMemberIsExpire(v) // 剑鱼文库会员检查过期状态
|
|
|
+ }
|
|
|
+ for _, s := range []string{"user", "ent_user"} {
|
|
|
+ go ZmUserEquityRecovery(s)
|
|
|
+ }
|
|
|
+ go bigMemberExpireRemind()
|
|
|
+ go syncVipUpgrade()
|
|
|
+ go updateDataExportStatus()
|
|
|
+ go SendDataExportMailForPayed()
|
|
|
+ go courseTask()
|
|
|
+ go expireRemind()
|
|
|
+ go checkMemberIsStart()
|
|
|
+ go checkEntIsStart() // 企业版大会员或超级订阅定时开通
|
|
|
+ go checkMemberServiceIsExpire()
|
|
|
+ go updateTimeLimitActitityOrderStatus() //修改限时活动的订单状态
|
|
|
+ go bidCreditReport.BidCreditReport.NewOrderWarn()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 省份流量包到期时间 定时任务
|
|
|
func updateProvincePackageStatus(i Identity) {
|
|
|
- crontab(true, TimeTaskConfig.ProvinceExpire, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,开始更新省份订阅包状态开始")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- sess := util.MQFW.GetMgoConn()
|
|
|
- for {
|
|
|
- if sess != nil {
|
|
|
- defer util.MQFW.DestoryMongoConn(sess)
|
|
|
- break
|
|
|
- }
|
|
|
- time.Sleep(time.Minute)
|
|
|
- sess = util.MQFW.GetMgoConn()
|
|
|
- }
|
|
|
- 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); {
|
|
|
- _id := BsonIdToSId(m["_id"])
|
|
|
- if util.MQFW.UpdateById(i.SubsetColl(), _id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "o_jy.i_ppstatus": -1,
|
|
|
- "o_jy.i_areapackTip": 1,
|
|
|
- },
|
|
|
- }) {
|
|
|
- positionId := util.MongoIdToPositionId(_id)
|
|
|
- ok := jy.ClearBigVipUserPower(positionId)
|
|
|
- config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
- PositionId: positionId,
|
|
|
- AppId: "10000",
|
|
|
- })
|
|
|
- config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
- if !ok {
|
|
|
- log.Println("清除 redis省份订阅包服务详情 缓存失败:", _id)
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.Println("更新user表 省份订阅包状态失败:", _id)
|
|
|
- }
|
|
|
- m = make(map[string]interface{})
|
|
|
- }
|
|
|
- log.Println("定时任务,更新省份订阅包状态结束")
|
|
|
- })
|
|
|
+ crontab(true, TimeTaskConfig.ProvinceExpire, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,开始更新省份订阅包状态开始")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ sess := util.MQFW.GetMgoConn()
|
|
|
+ for {
|
|
|
+ if sess != nil {
|
|
|
+ defer util.MQFW.DestoryMongoConn(sess)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(time.Minute)
|
|
|
+ sess = util.MQFW.GetMgoConn()
|
|
|
+ }
|
|
|
+ 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); {
|
|
|
+ _id := BsonIdToSId(m["_id"])
|
|
|
+ if util.MQFW.UpdateById(i.SubsetColl(), _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "o_jy.i_ppstatus": -1,
|
|
|
+ "o_jy.i_areapackTip": 1,
|
|
|
+ },
|
|
|
+ }) {
|
|
|
+ positionId := util.MongoIdToPositionId(_id)
|
|
|
+ ok := jy.ClearBigVipUserPower(positionId)
|
|
|
+ config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
+ PositionId: positionId,
|
|
|
+ AppId: "10000",
|
|
|
+ })
|
|
|
+ config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
+ if !ok {
|
|
|
+ log.Println("清除 redis省份订阅包服务详情 缓存失败:", _id)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.Println("更新user表 省份订阅包状态失败:", _id)
|
|
|
+ }
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ log.Println("定时任务,更新省份订阅包状态结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 定时更新超过72小时订单
|
|
|
func updateDataExportStatus() {
|
|
|
- crontabByTicker(true, TimeTaskConfig.UpdateDEStatus, func() {
|
|
|
- log.Println("定时任务,开始更新超时订单状态")
|
|
|
- create_time := time.Now()
|
|
|
- create_time_stamp := create_time.Unix()
|
|
|
- start_time_stamp := create_time.Unix()
|
|
|
- order_countdown := Config.OrderCountdown //配置文件读取
|
|
|
- if strings.Contains(qutil.ObjToString(order_countdown), "h") {
|
|
|
- onehour, _ := time.ParseDuration(qutil.ObjToString(order_countdown))
|
|
|
- create_time_stamp = create_time.Add(-onehour).Unix()
|
|
|
- start_time_stamp = create_time.Add(-onehour).AddDate(0, 0, -1).Unix()
|
|
|
- } else {
|
|
|
- i_countdown := qutil.IntAll(order_countdown)
|
|
|
- create_time_stamp = create_time.AddDate(0, 0, -i_countdown).Unix()
|
|
|
- start_time_stamp = create_time.AddDate(0, 0, -i_countdown).AddDate(0, 0, -1).Unix()
|
|
|
- }
|
|
|
- over_time := FormatDateByInt64(&create_time_stamp, Date_Full_Layout)
|
|
|
- start_time := FormatDateByInt64(&start_time_stamp, Date_Full_Layout)
|
|
|
- log.Println("over_time:", over_time, "start_time:", start_time)
|
|
|
- //查询未支付超时订单(仅用户自主下单、销售代用户下单的订单)
|
|
|
- wooList := util.Mysql.SelectBySql(`SELECT * FROM dataexport_order WHERE order_status = 0 AND create_time < ? AND create_time > ? AND (is_backstage_order = 0 or (is_backstage_order=1 AND order_channel ='xdqd04'))`, over_time, start_time)
|
|
|
- if wooList != nil && len(*wooList) != 0 {
|
|
|
- for _, v := range *wooList {
|
|
|
- if v["order_code"] != nil {
|
|
|
- //订单编号
|
|
|
- order_code, _ := v["order_code"].(string)
|
|
|
- productType := 0 //取消卡券的时候 需要这个参数 商品类型0普通的1线上课程
|
|
|
- if product_type, _ := v["product_type"].(string); product_type != "中标必听课" {
|
|
|
- productType = 1
|
|
|
- }
|
|
|
- flag := false
|
|
|
- //仅用户自主下单、销售代用户下单的订单 可以取消
|
|
|
- cancelOrder := qutil.IntAll(v["is_backstage_order"]) == 0 || (qutil.IntAll(v["is_backstage_order"]) == 1 && qutil.ObjToString(v["order_channel"]) == "xdqd04")
|
|
|
- if qutil.IntAll(v["order_status"]) == 0 && cancelOrder && qutil.ObjToString(v["pay_way"]) != "transferAccounts" { //未支付状态下 删除订单需要先关闭订单
|
|
|
- flag = pay.CloseDataExportOrder(qutil.ObjToString(v["pay_way"]), qutil.ObjToString(v["out_trade_no"]), qutil.ObjToString(v["prepay_time"]))
|
|
|
- }
|
|
|
- if flag || (!(qutil.IntAll(v["course_status"]) == 2 || qutil.IntAll(v["course_status"]) == 4)) && qutil.ObjToString(v["pay_way"]) == "transferAccounts" && cancelOrder { //对公转账非审核中 和 转账成功 状态下超时取消订单
|
|
|
- queryMap := map[string]interface{}{
|
|
|
- "order_code": order_code,
|
|
|
- }
|
|
|
- flag = util.Mysql.Update("dataexport_order", queryMap, map[string]interface{}{"order_status": -2})
|
|
|
- }
|
|
|
- // discountId := ""
|
|
|
- // var filter map[string]interface{}
|
|
|
- // //关闭未支付订单
|
|
|
- // if err := json.Unmarshal([]byte(qutil.ObjToString(v["filter"])), &filter); err != nil {
|
|
|
- // log.Println("filter.json.Unmarshal出错", err)
|
|
|
- // } else {
|
|
|
- // if filter["discountId"] != nil {
|
|
|
- // discountId = strconv.Itoa(qutil.IntAll(filter["discountId"]))
|
|
|
- // }
|
|
|
- // }
|
|
|
- if !flag {
|
|
|
- log.Println("mysql 订单更新失败", order_code)
|
|
|
- } else {
|
|
|
- //解除卡卷绑定
|
|
|
- //用户领取卡卷的记录id
|
|
|
- userLotteryId, _ := v["d_relation_id"].(string)
|
|
|
- if userLotteryId != "" {
|
|
|
- //用户id
|
|
|
- userId, _ := v["user_id"].(string)
|
|
|
- go func(userId, userLotteryId, order_code string) {
|
|
|
- if !util.UpdateCouponState(userId, userLotteryId, "", "", order_code, qutil.ObjToString(v["product_type"]), "0", 0, productType) {
|
|
|
- log.Println(fmt.Sprintf("单号%s-解绑失败-卡卷%s", order_code, userLotteryId))
|
|
|
- }
|
|
|
- }(userId, userLotteryId, order_code)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- log.Println("定时任务,更新超时订单状态结束")
|
|
|
- })
|
|
|
+ crontabByTicker(true, TimeTaskConfig.UpdateDEStatus, func() {
|
|
|
+ log.Println("定时任务,开始更新超时订单状态")
|
|
|
+ create_time := time.Now()
|
|
|
+ create_time_stamp := create_time.Unix()
|
|
|
+ start_time_stamp := create_time.Unix()
|
|
|
+ order_countdown := Config.OrderCountdown //配置文件读取
|
|
|
+ if strings.Contains(qutil.ObjToString(order_countdown), "h") {
|
|
|
+ onehour, _ := time.ParseDuration(qutil.ObjToString(order_countdown))
|
|
|
+ create_time_stamp = create_time.Add(-onehour).Unix()
|
|
|
+ start_time_stamp = create_time.Add(-onehour).AddDate(0, 0, -1).Unix()
|
|
|
+ } else {
|
|
|
+ i_countdown := qutil.IntAll(order_countdown)
|
|
|
+ create_time_stamp = create_time.AddDate(0, 0, -i_countdown).Unix()
|
|
|
+ start_time_stamp = create_time.AddDate(0, 0, -i_countdown).AddDate(0, 0, -1).Unix()
|
|
|
+ }
|
|
|
+ over_time := FormatDateByInt64(&create_time_stamp, Date_Full_Layout)
|
|
|
+ start_time := FormatDateByInt64(&start_time_stamp, Date_Full_Layout)
|
|
|
+ log.Println("over_time:", over_time, "start_time:", start_time)
|
|
|
+ //查询未支付超时订单(仅用户自主下单、销售代用户下单的订单)
|
|
|
+ wooList := util.Mysql.SelectBySql(`SELECT * FROM dataexport_order WHERE order_status = 0 AND create_time < ? AND create_time > ? AND (is_backstage_order = 0 or (is_backstage_order=1 AND order_channel ='xdqd04'))`, over_time, start_time)
|
|
|
+ if wooList != nil && len(*wooList) != 0 {
|
|
|
+ for _, v := range *wooList {
|
|
|
+ if v["order_code"] != nil {
|
|
|
+ //订单编号
|
|
|
+ order_code, _ := v["order_code"].(string)
|
|
|
+ productType := 0 //取消卡券的时候 需要这个参数 商品类型0普通的1线上课程
|
|
|
+ if product_type, _ := v["product_type"].(string); product_type != "中标必听课" {
|
|
|
+ productType = 1
|
|
|
+ }
|
|
|
+ flag := false
|
|
|
+ //仅用户自主下单、销售代用户下单的订单 可以取消
|
|
|
+ cancelOrder := qutil.IntAll(v["is_backstage_order"]) == 0 || (qutil.IntAll(v["is_backstage_order"]) == 1 && qutil.ObjToString(v["order_channel"]) == "xdqd04")
|
|
|
+ if qutil.IntAll(v["order_status"]) == 0 && cancelOrder && qutil.ObjToString(v["pay_way"]) != "transferAccounts" { //未支付状态下 删除订单需要先关闭订单
|
|
|
+ flag = pay.CloseDataExportOrder(qutil.ObjToString(v["pay_way"]), qutil.ObjToString(v["out_trade_no"]), qutil.ObjToString(v["prepay_time"]))
|
|
|
+ }
|
|
|
+ if flag || (!(qutil.IntAll(v["course_status"]) == 2 || qutil.IntAll(v["course_status"]) == 4)) && qutil.ObjToString(v["pay_way"]) == "transferAccounts" && cancelOrder { //对公转账非审核中 和 转账成功 状态下超时取消订单
|
|
|
+ queryMap := map[string]interface{}{
|
|
|
+ "order_code": order_code,
|
|
|
+ }
|
|
|
+ flag = util.Mysql.Update("dataexport_order", queryMap, map[string]interface{}{"order_status": -2})
|
|
|
+ }
|
|
|
+ // discountId := ""
|
|
|
+ // var filter map[string]interface{}
|
|
|
+ // //关闭未支付订单
|
|
|
+ // if err := json.Unmarshal([]byte(qutil.ObjToString(v["filter"])), &filter); err != nil {
|
|
|
+ // log.Println("filter.json.Unmarshal出错", err)
|
|
|
+ // } else {
|
|
|
+ // if filter["discountId"] != nil {
|
|
|
+ // discountId = strconv.Itoa(qutil.IntAll(filter["discountId"]))
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ if !flag {
|
|
|
+ log.Println("mysql 订单更新失败", order_code)
|
|
|
+ } else {
|
|
|
+ //解除卡卷绑定
|
|
|
+ //用户领取卡卷的记录id
|
|
|
+ userLotteryId, _ := v["d_relation_id"].(string)
|
|
|
+ if userLotteryId != "" {
|
|
|
+ //用户id
|
|
|
+ userId, _ := v["user_id"].(string)
|
|
|
+ go func(userId, userLotteryId, order_code string) {
|
|
|
+ if !util.UpdateCouponState(userId, userLotteryId, "", "", order_code, qutil.ObjToString(v["product_type"]), "0", 0, productType) {
|
|
|
+ log.Println(fmt.Sprintf("单号%s-解绑失败-卡卷%s", order_code, userLotteryId))
|
|
|
+ }
|
|
|
+ }(userId, userLotteryId, order_code)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.Println("定时任务,更新超时订单状态结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 每天夜里12点 根据课程结束时间 更新课程状态 并 更新mysql预定此课程订单的状态为已取消
|
|
|
func courseTask() {
|
|
|
- crontab(true, TimeTaskConfig.CourseTask, func() {
|
|
|
- log.Println("定时任务,开始更新课程状态")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- sess := util.MQFW.GetMgoConn()
|
|
|
- defer util.MQFW.DestoryMongoConn(sess)
|
|
|
- //i_status : 0是保存未发布 1是已发布 -1是已下线
|
|
|
- it := sess.DB("qfw").C("jy_course").Find(map[string]interface{}{
|
|
|
- "i_status": 1,
|
|
|
- "l_starttime": map[string]interface{}{
|
|
|
- "$lte": now_unix,
|
|
|
- },
|
|
|
- }).Select(map[string]interface{}{"i_status": 1, "l_endtime": 1}).Iter()
|
|
|
- for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
- _id := BsonIdToSId(m["_id"])
|
|
|
- util.MQFW.UpdateById("jy_course", _id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_status": -1,
|
|
|
- },
|
|
|
- })
|
|
|
- go func(id string) { //更新已预订此课程订单的状态为已取消
|
|
|
- var updateSql = `UPDATE dataexport_order SET order_status = -2 WHERE order_status = 0 AND product_type = '招投标课程' AND filter_id = '` + id + `'`
|
|
|
- i := util.Mysql.UpdateOrDeleteBySql(updateSql)
|
|
|
- if i < 0 {
|
|
|
- log.Println("mysql 订单更新失败", id)
|
|
|
- }
|
|
|
- }(_id)
|
|
|
- m = make(map[string]interface{})
|
|
|
- }
|
|
|
- log.Println("定时任务,更新课程状态结束")
|
|
|
- })
|
|
|
+ crontab(true, TimeTaskConfig.CourseTask, func() {
|
|
|
+ log.Println("定时任务,开始更新课程状态")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ sess := util.MQFW.GetMgoConn()
|
|
|
+ defer util.MQFW.DestoryMongoConn(sess)
|
|
|
+ //i_status : 0是保存未发布 1是已发布 -1是已下线
|
|
|
+ it := sess.DB("qfw").C("jy_course").Find(map[string]interface{}{
|
|
|
+ "i_status": 1,
|
|
|
+ "l_starttime": map[string]interface{}{
|
|
|
+ "$lte": now_unix,
|
|
|
+ },
|
|
|
+ }).Select(map[string]interface{}{"i_status": 1, "l_endtime": 1}).Iter()
|
|
|
+ for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
+ _id := BsonIdToSId(m["_id"])
|
|
|
+ util.MQFW.UpdateById("jy_course", _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_status": -1,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ go func(id string) { //更新已预订此课程订单的状态为已取消
|
|
|
+ var updateSql = `UPDATE dataexport_order SET order_status = -2 WHERE order_status = 0 AND product_type = '招投标课程' AND filter_id = '` + id + `'`
|
|
|
+ i := util.Mysql.UpdateOrDeleteBySql(updateSql)
|
|
|
+ if i < 0 {
|
|
|
+ log.Println("mysql 订单更新失败", id)
|
|
|
+ }
|
|
|
+ }(_id)
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ log.Println("定时任务,更新课程状态结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// vip升级 下个月生效 同步
|
|
|
func syncVipUpgrade() {
|
|
|
- crontab(true, TimeTaskConfig.SyncVipUpgrade, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,开始同步vip升级数据")
|
|
|
- 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("vip_upgrade").Find(map[string]interface{}{
|
|
|
- "l_validtime": map[string]interface{}{
|
|
|
- "$lte": time.Now().Unix(),
|
|
|
- },
|
|
|
- "i_isvalid": map[string]interface{}{
|
|
|
- "$ne": 1,
|
|
|
- },
|
|
|
- }).Select(map[string]interface{}{"s_userid": 1, "o_area": 1, "a_buyerclass": 1, "o_buyset": 1}).Iter()
|
|
|
- for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
- _id := BsonIdToSId(m["_id"])
|
|
|
- s_userid := qutil.ObjToString(m["s_userid"])
|
|
|
- if s_userid == "" {
|
|
|
- log.Println("定时任务,同步vip升级数据有问题,userid是空", _id)
|
|
|
- continue
|
|
|
- }
|
|
|
- o_area, _ := m["o_area"].(map[string]interface{})
|
|
|
- o_buyset, _ := m["o_buyset"].(map[string]interface{})
|
|
|
- a_buyerclass, _ := m["a_buyerclass"].([]interface{})
|
|
|
- updateOk := false
|
|
|
- if IsObjectIdHex(s_userid) {
|
|
|
- updateOk = util.Compatible.Update(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{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "l_synctime": time.Now().Unix(),
|
|
|
- "i_isvalid": 1,
|
|
|
- },
|
|
|
- })
|
|
|
- log.Println("定时任务,同步vip升级数据成功", _id)
|
|
|
- positionId := util.MongoIdToPositionId(_id)
|
|
|
- go jy.ClearBigVipUserPower(positionId)
|
|
|
- go config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
- PositionId: positionId,
|
|
|
- AppId: "10000",
|
|
|
- })
|
|
|
- go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
- } else {
|
|
|
- log.Println("定时任务,同步vip升级数据更新用户表失败", _id)
|
|
|
- }
|
|
|
- m = make(map[string]interface{})
|
|
|
- }
|
|
|
- log.Println("定时任务,同步vip升级数据结束")
|
|
|
- })
|
|
|
+ crontab(true, TimeTaskConfig.SyncVipUpgrade, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,开始同步vip升级数据")
|
|
|
+ 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("vip_upgrade").Find(map[string]interface{}{
|
|
|
+ "l_validtime": map[string]interface{}{
|
|
|
+ "$lte": time.Now().Unix(),
|
|
|
+ },
|
|
|
+ "i_isvalid": map[string]interface{}{
|
|
|
+ "$ne": 1,
|
|
|
+ },
|
|
|
+ }).Select(map[string]interface{}{"s_userid": 1, "o_area": 1, "a_buyerclass": 1, "o_buyset": 1}).Iter()
|
|
|
+ for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
+ _id := BsonIdToSId(m["_id"])
|
|
|
+ s_userid := qutil.ObjToString(m["s_userid"])
|
|
|
+ if s_userid == "" {
|
|
|
+ log.Println("定时任务,同步vip升级数据有问题,userid是空", _id)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ o_area, _ := m["o_area"].(map[string]interface{})
|
|
|
+ o_buyset, _ := m["o_buyset"].(map[string]interface{})
|
|
|
+ a_buyerclass, _ := m["a_buyerclass"].([]interface{})
|
|
|
+ updateOk := false
|
|
|
+ if IsObjectIdHex(s_userid) {
|
|
|
+ updateOk = util.Compatible.Update(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{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "l_synctime": time.Now().Unix(),
|
|
|
+ "i_isvalid": 1,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ log.Println("定时任务,同步vip升级数据成功", _id)
|
|
|
+ positionId := util.MongoIdToPositionId(_id)
|
|
|
+ go jy.ClearBigVipUserPower(positionId)
|
|
|
+ go config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
+ PositionId: positionId,
|
|
|
+ AppId: "10000",
|
|
|
+ })
|
|
|
+ go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
+ } else {
|
|
|
+ log.Println("定时任务,同步vip升级数据更新用户表失败", _id)
|
|
|
+ }
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ log.Println("定时任务,同步vip升级数据结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 每天0点 检查试用、vip服务是否到期
|
|
|
func checkIsExpire(iy Identity) {
|
|
|
- crontab(true, TimeTaskConfig.CheckIsExpire, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,开始更新vip状态")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- sess := util.MQFW.GetMgoConn()
|
|
|
- for {
|
|
|
- if sess != nil {
|
|
|
- defer util.MQFW.DestoryMongoConn(sess)
|
|
|
- break
|
|
|
- }
|
|
|
- time.Sleep(time.Minute)
|
|
|
- sess = util.MQFW.GetMgoConn()
|
|
|
- }
|
|
|
- query := iy.UserQuery()
|
|
|
- query["i_vip_status"] = map[string]interface{}{
|
|
|
- "$gt": 0,
|
|
|
- }
|
|
|
- queryEndTime := now_unix + threeday
|
|
|
- if len(TimeTaskConfig.SubVipTipDuring) > 0 {
|
|
|
- queryEndTime = now_unix + oneDayLong*TimeTaskConfig.SubVipTipDuring[0].Cycle
|
|
|
- }
|
|
|
- query["l_vip_endtime"] = map[string]interface{}{
|
|
|
- "$lte": queryEndTime,
|
|
|
- }
|
|
|
- count, err := sess.DB("qfw").C(iy.UserColl()).Find(query).Count()
|
|
|
- log.Println("当前时间:", FormatDateByInt64(&now_unix, Date_Full_Layout), "数据总量:", count, "--err:", err)
|
|
|
- var i int64 = 0
|
|
|
- it := sess.DB("qfw").C(iy.UserColl()).Find(query).Select(iy.UserField(map[string]interface{}{"i_vip_status": 1, "l_vip_starttime": 1, "l_vip_endtime": 1, "i_userid": 1, "i_entid": 1, "base_user_id": 1, "o_vipjy": 1})).Iter()
|
|
|
- for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
- i++
|
|
|
- _id := BsonIdToSId(m["_id"])
|
|
|
- l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
|
- l_vip_starttime := qutil.Int64All(m["l_vip_starttime"])
|
|
|
- i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
|
- if l_vip_endtime <= now_unix {
|
|
|
- // TODO: 到期提醒(所有超级订阅都发送)
|
|
|
- ok := util.MQFW.UpdateById(iy.UserColl(), _id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_vip_status": -i_vip_status,
|
|
|
- "i_vip_expire_tip": 2,
|
|
|
- "i_vip_subtips": 0,
|
|
|
- "i_vip_fastimport": 0,
|
|
|
- },
|
|
|
- "$unset": map[string]interface{}{
|
|
|
- "i_vip_expire_tip_retry": "",
|
|
|
- },
|
|
|
- })
|
|
|
- if !ok {
|
|
|
- log.Println("用户:", _id, " 更新vip状态异常")
|
|
|
- }
|
|
|
- go iy.DelVipSubPush(m)
|
|
|
- positionId := util.MongoIdToPositionId(_id)
|
|
|
- go jy.ClearBigVipUserPower(positionId)
|
|
|
- go config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
- PositionId: positionId,
|
|
|
- AppId: "10000",
|
|
|
- })
|
|
|
- go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
- log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
|
|
|
- redis.Del("other", "p1_indexMessage_"+_id) //清除redis中vip状态
|
|
|
- filePackKey := fmt.Sprintf(jy.FilePackNumKey, _id, fmt.Sprint(time.Now().Month()))
|
|
|
- redis.Del(jy.PowerCacheDb, filePackKey) //清除redis中附件下载包次数
|
|
|
- vipFileUploadNumKey := fmt.Sprintf(jy.VipFileUploadNumKey, _id, fmt.Sprint(time.Now().Month()))
|
|
|
- redis.Del(jy.PowerCacheDb, vipFileUploadNumKey) //清除redis中vip使用次数
|
|
|
- } else {
|
|
|
- // TODO:即将到期提醒
|
|
|
- //(1)当超级订阅服务周期≥360天,到期前30天开始提醒;当超级订阅服务周期≥90天,到期前7天开始提醒;当超级订阅服务周期≥7天,到期当天提醒;
|
|
|
- //(2) 仅购买个人超级订阅(包含企业身份下个人购买的订单)
|
|
|
- //(3)老版本超级订阅不提醒(仅个人身份下有)
|
|
|
- showTip := func(s, e int64) bool {
|
|
|
- for _, cfg := range TimeTaskConfig.SubVipTipDuring {
|
|
|
- if e-s >= cfg.Cycle*oneDayLong && (now_unix+oneDayLong*(cfg.Day+1) > e && now_unix+oneDayLong*cfg.Day < e) {
|
|
|
- log.Println("用户 sVipTip", _id, i_vip_status, l_vip_endtime, "新增到期提醒", cfg.Day)
|
|
|
- return true
|
|
|
- }
|
|
|
- }
|
|
|
- return false
|
|
|
- }(l_vip_starttime, l_vip_endtime)
|
|
|
- if !showTip {
|
|
|
- continue
|
|
|
- }
|
|
|
- var (
|
|
|
- identity *pb.Identity
|
|
|
- entId = qutil.Int64All(m["i_entid"])
|
|
|
- entUserId = qutil.Int64All(m["i_userid"])
|
|
|
- baseUserId = qutil.Int64All(m["base_user_id"])
|
|
|
- )
|
|
|
- if iy.UserColl() == CollEntUser {
|
|
|
- if util.Mysql.Count("entniche_power",
|
|
|
- map[string]interface{}{
|
|
|
- "ent_id": entId,
|
|
|
- "ent_user_id": entUserId,
|
|
|
- }) >= 1 {
|
|
|
- continue
|
|
|
- }
|
|
|
- identity = util.Compatible.Middleground.UserCenter.IdentityByEntUserId(entUserId)
|
|
|
- } else {
|
|
|
- //老版本超级订阅不提醒
|
|
|
- if o_vipjy := qutil.ObjToMap(m["o_vipjy"]); o_vipjy != nil && len(*o_vipjy) > 0 {
|
|
|
- if o_buyset := qutil.ObjToMap((*o_vipjy)["o_buyset"]); o_buyset != nil && len(*o_buyset) > 0 {
|
|
|
- if qutil.IntAll((*o_buyset)["upgrade"]) != 1 {
|
|
|
- continue
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- identity = util.Compatible.Middleground.UserCenter.IdentityByUserId(baseUserId)
|
|
|
- }
|
|
|
+ crontab(true, TimeTaskConfig.CheckIsExpire, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,开始更新vip状态")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ sess := util.MQFW.GetMgoConn()
|
|
|
+ for {
|
|
|
+ if sess != nil {
|
|
|
+ defer util.MQFW.DestoryMongoConn(sess)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(time.Minute)
|
|
|
+ sess = util.MQFW.GetMgoConn()
|
|
|
+ }
|
|
|
+ query := iy.UserQuery()
|
|
|
+ query["i_vip_status"] = map[string]interface{}{
|
|
|
+ "$gt": 0,
|
|
|
+ }
|
|
|
+ queryEndTime := now_unix + threeday
|
|
|
+ if len(TimeTaskConfig.SubVipTipDuring) > 0 {
|
|
|
+ queryEndTime = now_unix + oneDayLong*TimeTaskConfig.SubVipTipDuring[0].Cycle
|
|
|
+ }
|
|
|
+ query["l_vip_endtime"] = map[string]interface{}{
|
|
|
+ "$lte": queryEndTime,
|
|
|
+ }
|
|
|
+ count, err := sess.DB("qfw").C(iy.UserColl()).Find(query).Count()
|
|
|
+ log.Println("当前时间:", FormatDateByInt64(&now_unix, Date_Full_Layout), "数据总量:", count, "--err:", err)
|
|
|
+ var i int64 = 0
|
|
|
+ it := sess.DB("qfw").C(iy.UserColl()).Find(query).Select(iy.UserField(map[string]interface{}{"i_vip_status": 1, "l_vip_starttime": 1, "l_vip_endtime": 1, "i_userid": 1, "i_entid": 1, "base_user_id": 1, "o_vipjy": 1})).Iter()
|
|
|
+ for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
+ i++
|
|
|
+ _id := BsonIdToSId(m["_id"])
|
|
|
+ l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
|
+ l_vip_starttime := qutil.Int64All(m["l_vip_starttime"])
|
|
|
+ i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
|
+ if l_vip_endtime <= now_unix {
|
|
|
+ // TODO: 到期提醒(所有超级订阅都发送)
|
|
|
+ ok := util.MQFW.UpdateById(iy.UserColl(), _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_vip_status": -i_vip_status,
|
|
|
+ "i_vip_expire_tip": 2,
|
|
|
+ "i_vip_subtips": 0,
|
|
|
+ "i_vip_fastimport": 0,
|
|
|
+ },
|
|
|
+ "$unset": map[string]interface{}{
|
|
|
+ "i_vip_expire_tip_retry": "",
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if !ok {
|
|
|
+ log.Println("用户:", _id, " 更新vip状态异常")
|
|
|
+ }
|
|
|
+ go iy.DelVipSubPush(m)
|
|
|
+ positionId := util.MongoIdToPositionId(_id)
|
|
|
+ go jy.ClearBigVipUserPower(positionId)
|
|
|
+ go config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
+ PositionId: positionId,
|
|
|
+ AppId: "10000",
|
|
|
+ })
|
|
|
+ go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
+ log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
|
|
|
+ redis.Del("other", "p1_indexMessage_"+_id) //清除redis中vip状态
|
|
|
+ filePackKey := fmt.Sprintf(jy.FilePackNumKey, _id, fmt.Sprint(time.Now().Month()))
|
|
|
+ redis.Del(jy.PowerCacheDb, filePackKey) //清除redis中附件下载包次数
|
|
|
+ vipFileUploadNumKey := fmt.Sprintf(jy.VipFileUploadNumKey, _id, fmt.Sprint(time.Now().Month()))
|
|
|
+ redis.Del(jy.PowerCacheDb, vipFileUploadNumKey) //清除redis中vip使用次数
|
|
|
+ } else {
|
|
|
+ // TODO:即将到期提醒
|
|
|
+ //(1)当超级订阅服务周期≥360天,到期前30天开始提醒;当超级订阅服务周期≥90天,到期前7天开始提醒;当超级订阅服务周期≥7天,到期当天提醒;
|
|
|
+ //(2) 仅购买个人超级订阅(包含企业身份下个人购买的订单)
|
|
|
+ //(3)老版本超级订阅不提醒(仅个人身份下有)
|
|
|
+ showTip := func(s, e int64) bool {
|
|
|
+ for _, cfg := range TimeTaskConfig.SubVipTipDuring {
|
|
|
+ if e-s >= cfg.Cycle*oneDayLong && (now_unix+oneDayLong*(cfg.Day+1) > e && now_unix+oneDayLong*cfg.Day < e) {
|
|
|
+ log.Println("用户 sVipTip", _id, i_vip_status, l_vip_endtime, "新增到期提醒", cfg.Day)
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }(l_vip_starttime, l_vip_endtime)
|
|
|
+ if !showTip {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ var (
|
|
|
+ identity *pb.Identity
|
|
|
+ entId = qutil.Int64All(m["i_entid"])
|
|
|
+ entUserId = qutil.Int64All(m["i_userid"])
|
|
|
+ baseUserId = qutil.Int64All(m["base_user_id"])
|
|
|
+ )
|
|
|
+ if iy.UserColl() == CollEntUser {
|
|
|
+ if util.Mysql.Count("entniche_power",
|
|
|
+ map[string]interface{}{
|
|
|
+ "ent_id": entId,
|
|
|
+ "ent_user_id": entUserId,
|
|
|
+ }) >= 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ identity = util.Compatible.Middleground.UserCenter.IdentityByEntUserId(entUserId)
|
|
|
+ } else {
|
|
|
+ //老版本超级订阅不提醒
|
|
|
+ if o_vipjy := qutil.ObjToMap(m["o_vipjy"]); o_vipjy != nil && len(*o_vipjy) > 0 {
|
|
|
+ if o_buyset := qutil.ObjToMap((*o_vipjy)["o_buyset"]); o_buyset != nil && len(*o_buyset) > 0 {
|
|
|
+ if qutil.IntAll((*o_buyset)["upgrade"]) != 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ identity = util.Compatible.Middleground.UserCenter.IdentityByUserId(baseUserId)
|
|
|
+ }
|
|
|
|
|
|
- updateOk := util.MQFW.UpdateById(iy.UserColl(), _id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_vip_expire_tip": 1,
|
|
|
- },
|
|
|
- })
|
|
|
- // 存入redis值,供前台弹框使用
|
|
|
- redis.Put("newother", fmt.Sprintf("Expire_SubvipTip_%d", identity.PositionId), l_vip_endtime, qutil.IntAll(l_vip_endtime-now_unix))
|
|
|
+ updateOk := util.MQFW.UpdateById(iy.UserColl(), _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_vip_expire_tip": 1,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ // 存入redis值,供前台弹框使用
|
|
|
+ redis.Put("newother", fmt.Sprintf("Expire_SubvipTip_%d", identity.PositionId), l_vip_endtime, qutil.IntAll(l_vip_endtime-now_unix))
|
|
|
|
|
|
- log.Println("用户 sVipTip", _id, identity.PositionId, i_vip_status, l_vip_endtime, "修改即将到期状态", updateOk)
|
|
|
- }
|
|
|
- m = make(map[string]interface{})
|
|
|
- }
|
|
|
- if i != count {
|
|
|
- log.Println("更新vip状态有异常,已处理:", i, "总量:", count)
|
|
|
- }
|
|
|
- log.Println("已处理:", i, "总量:", count)
|
|
|
- log.Println("定时任务,更新vip状态结束")
|
|
|
- })
|
|
|
+ log.Println("用户 sVipTip", _id, identity.PositionId, i_vip_status, l_vip_endtime, "修改即将到期状态", updateOk)
|
|
|
+ }
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ if i != count {
|
|
|
+ log.Println("更新vip状态有异常,已处理:", i, "总量:", count)
|
|
|
+ }
|
|
|
+ log.Println("已处理:", i, "总量:", count)
|
|
|
+ log.Println("定时任务,更新vip状态结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 即将到期或者已到期发推送消息
|
|
|
func expireRemind() {
|
|
|
- crontab(false, TimeTaskConfig.ExpireRemind, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,到期提醒,开始推送消息")
|
|
|
- doFunc := func(m map[string]interface{}) {
|
|
|
- i_vip_expire_tip := qutil.IntAll(m["i_vip_expire_tip"])
|
|
|
- if i_vip_expire_tip != 1 && i_vip_expire_tip != 2 {
|
|
|
- return
|
|
|
- }
|
|
|
- _id := qutil.ObjToString(m["_id"])
|
|
|
- l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
|
- 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)
|
|
|
- if isPushWx == 1 && s_m_openid != "" { //微信推送
|
|
|
- tp := ""
|
|
|
- tplId, keyword1_value, keyword2_value, keyword3_value, keyword4_value := "", "", "", "", ""
|
|
|
- switch i_vip_status {
|
|
|
- case 2, -2:
|
|
|
- keyword4_value = FormatDateByInt64(&l_vip_endtime, Date_Short_Layout)
|
|
|
- if i_vip_expire_tip == 1 {
|
|
|
- tp = "soonexprie"
|
|
|
- tplId = MessageConfig.WxTpl_SoonExpire.Id
|
|
|
- keyword2_value = MessageConfig.WxTpl_SoonExpire.Keyword2.Value
|
|
|
- keyword3_value = MessageConfig.WxTpl_SoonExpire.Keyword3.Value
|
|
|
- keyword4_value = fmt.Sprintf(MessageConfig.WxTpl_SoonExpire.Keyword4.Value, keyword4_value)
|
|
|
- } else if i_vip_expire_tip == 2 {
|
|
|
- tp = "expried"
|
|
|
- tplId = MessageConfig.WxTpl_Expired.Id
|
|
|
- keyword2_value = MessageConfig.WxTpl_Expired.Keyword2.Value
|
|
|
- keyword3_value = MessageConfig.WxTpl_Expired.Keyword3.Value
|
|
|
- keyword4_value = fmt.Sprintf(MessageConfig.WxTpl_Expired.Keyword4.Value, keyword4_value)
|
|
|
- }
|
|
|
- keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
- default:
|
|
|
- return
|
|
|
- }
|
|
|
- tmplData := map[string]*qrpc.TmplItem{
|
|
|
- "keyword1": &qrpc.TmplItem{
|
|
|
- Value: keyword1_value,
|
|
|
- },
|
|
|
- "keyword2": &qrpc.TmplItem{
|
|
|
- Value: keyword2_value,
|
|
|
- },
|
|
|
- "keyword3": &qrpc.TmplItem{
|
|
|
- Value: keyword3_value,
|
|
|
- },
|
|
|
- "keyword4": &qrpc.TmplItem{
|
|
|
- Value: keyword4_value,
|
|
|
- },
|
|
|
- }
|
|
|
- wxPushOk, _ = qrpc.WxSendTmplMsg(Config.Weixinrpc, &qrpc.WxTmplMsg{
|
|
|
- OpenId: s_m_openid,
|
|
|
- TplId: tplId,
|
|
|
- TmplData: tmplData,
|
|
|
- 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", tp))),
|
|
|
- })
|
|
|
- log.Println("到期提醒,微信推送", _id, wxPushOk)
|
|
|
- }
|
|
|
- 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
|
|
|
- }
|
|
|
- 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
|
|
|
- }
|
|
|
- default:
|
|
|
- return
|
|
|
- }
|
|
|
- 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+qutil.If(IsObjectIdHex(_id), ",_id,", ",entUserId,").(string)+strconv.Itoa(int(time.Now().Unix()))+",msgremind") + "__" + hex.EncodeToString([]byte(fmt.Sprintf("type=%s", tp))),
|
|
|
- "userId": _id,
|
|
|
- "type": "vipNotice",
|
|
|
- "descript": app_descript,
|
|
|
- "title": "剑鱼提醒",
|
|
|
- "category": "服务通知_账号动态",
|
|
|
- })
|
|
|
- log.Println("到期提醒,app推送", _id, appPushOk)
|
|
|
- }
|
|
|
- if wxPushOk || appPushOk {
|
|
|
- util.Compatible.UpdateByEntUserId(_id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_vip_expire_tip": 0,
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- field := 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,
|
|
|
- }
|
|
|
- (&Personal{}).LoadVipUsers(field, doFunc)
|
|
|
- (&Ent{}).LoadVipUsers(field, doFunc)
|
|
|
- log.Println("定时任务,到期提醒,推送消息结束")
|
|
|
- })
|
|
|
+ crontab(false, TimeTaskConfig.ExpireRemind, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,到期提醒,开始推送消息")
|
|
|
+ doFunc := func(m map[string]interface{}) {
|
|
|
+ i_vip_expire_tip := qutil.IntAll(m["i_vip_expire_tip"])
|
|
|
+ if i_vip_expire_tip != 1 && i_vip_expire_tip != 2 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ _id := qutil.ObjToString(m["_id"])
|
|
|
+ l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
|
+ 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)
|
|
|
+ if isPushWx == 1 && s_m_openid != "" { //微信推送
|
|
|
+ tp := ""
|
|
|
+ tplId, keyword1_value, keyword2_value, keyword3_value, keyword4_value := "", "", "", "", ""
|
|
|
+ switch i_vip_status {
|
|
|
+ case 2, -2:
|
|
|
+ keyword4_value = FormatDateByInt64(&l_vip_endtime, Date_Short_Layout)
|
|
|
+ if i_vip_expire_tip == 1 {
|
|
|
+ tp = "soonexprie"
|
|
|
+ tplId = MessageConfig.WxTpl_SoonExpire.Id
|
|
|
+ keyword2_value = MessageConfig.WxTpl_SoonExpire.Keyword2.Value
|
|
|
+ keyword3_value = MessageConfig.WxTpl_SoonExpire.Keyword3.Value
|
|
|
+ keyword4_value = fmt.Sprintf(MessageConfig.WxTpl_SoonExpire.Keyword4.Value, keyword4_value)
|
|
|
+ } else if i_vip_expire_tip == 2 {
|
|
|
+ tp = "expried"
|
|
|
+ tplId = MessageConfig.WxTpl_Expired.Id
|
|
|
+ keyword2_value = MessageConfig.WxTpl_Expired.Keyword2.Value
|
|
|
+ keyword3_value = MessageConfig.WxTpl_Expired.Keyword3.Value
|
|
|
+ keyword4_value = fmt.Sprintf(MessageConfig.WxTpl_Expired.Keyword4.Value, keyword4_value)
|
|
|
+ }
|
|
|
+ keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
+ default:
|
|
|
+ return
|
|
|
+ }
|
|
|
+ tmplData := map[string]*qrpc.TmplItem{
|
|
|
+ "keyword1": &qrpc.TmplItem{
|
|
|
+ Value: keyword1_value,
|
|
|
+ },
|
|
|
+ "keyword2": &qrpc.TmplItem{
|
|
|
+ Value: keyword2_value,
|
|
|
+ },
|
|
|
+ "keyword3": &qrpc.TmplItem{
|
|
|
+ Value: keyword3_value,
|
|
|
+ },
|
|
|
+ "keyword4": &qrpc.TmplItem{
|
|
|
+ Value: keyword4_value,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ wxPushOk, _ = qrpc.WxSendTmplMsg(Config.Weixinrpc, &qrpc.WxTmplMsg{
|
|
|
+ OpenId: s_m_openid,
|
|
|
+ TplId: tplId,
|
|
|
+ TmplData: tmplData,
|
|
|
+ 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", tp))),
|
|
|
+ })
|
|
|
+ log.Println("到期提醒,微信推送", _id, wxPushOk)
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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+qutil.If(IsObjectIdHex(_id), ",_id,", ",entUserId,").(string)+strconv.Itoa(int(time.Now().Unix()))+",msgremind") + "__" + hex.EncodeToString([]byte(fmt.Sprintf("type=%s", tp))),
|
|
|
+ "userId": _id,
|
|
|
+ "type": "vipNotice",
|
|
|
+ "descript": app_descript,
|
|
|
+ "title": "剑鱼提醒",
|
|
|
+ "category": "服务通知_账号动态",
|
|
|
+ })
|
|
|
+ log.Println("到期提醒,app推送", _id, appPushOk)
|
|
|
+ }
|
|
|
+ if wxPushOk || appPushOk {
|
|
|
+ util.Compatible.UpdateByEntUserId(_id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_vip_expire_tip": 0,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ field := 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,
|
|
|
+ }
|
|
|
+ (&Personal{}).LoadVipUsers(field, doFunc)
|
|
|
+ (&Ent{}).LoadVipUsers(field, doFunc)
|
|
|
+ log.Println("定时任务,到期提醒,推送消息结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 检测大会员到期时间 定时任务
|
|
|
func checkMemberIsExpire(i Identity) {
|
|
|
- crontab(true, TimeTaskConfig.MemberExpire, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,开始更新大会员状态")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- now_time := FormatDateByInt64(&now_unix, Date_Full_Layout)
|
|
|
- sess := util.MQFW.GetMgoConn()
|
|
|
- for {
|
|
|
- if sess != nil {
|
|
|
- defer util.MQFW.DestoryMongoConn(sess)
|
|
|
- break
|
|
|
- }
|
|
|
- time.Sleep(time.Minute)
|
|
|
- sess = util.MQFW.GetMgoConn()
|
|
|
- }
|
|
|
- query := i.UserQuery()
|
|
|
- query["i_member_status"] = map[string]interface{}{
|
|
|
- "$gt": 0,
|
|
|
- }
|
|
|
- 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); {
|
|
|
- _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(i.UserColl(), _id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_member_status": -i_member_status,
|
|
|
- "i_member_expire_tip": 2,
|
|
|
- },
|
|
|
- "$unset": map[string]interface{}{
|
|
|
- "i_member_expire_tip_retry": "",
|
|
|
- "i_mainaccount": "",
|
|
|
- "i_pay_sub_num": "",
|
|
|
- "i_free_sub_num": "",
|
|
|
- "i_member_sub_status": "",
|
|
|
- "s_member_mainid": "",
|
|
|
- },
|
|
|
- })
|
|
|
- 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 {
|
|
|
- log.Println(_id, "更新到期用户服务表出错")
|
|
|
- } else {
|
|
|
- positionId := util.MongoIdToPositionId(_id)
|
|
|
- ok := jy.ClearBigVipUserPower(positionId)
|
|
|
- config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
- PositionId: positionId,
|
|
|
- AppId: "10000",
|
|
|
- })
|
|
|
- go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
- if !ok {
|
|
|
- log.Println("清除 redis 大会员服务详情 缓存失败:", _id)
|
|
|
- }
|
|
|
- }
|
|
|
- } else if i_member_endtime-now_unix <= threeday && i_member_expire_tip != 1 {
|
|
|
- updateOk := util.MQFW.UpdateById(i.UserColl(), _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{})
|
|
|
- }
|
|
|
- log.Println("定时任务,更新大会员状态结束")
|
|
|
- })
|
|
|
+ crontab(true, TimeTaskConfig.MemberExpire, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,开始更新大会员状态")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ now_time := FormatDateByInt64(&now_unix, Date_Full_Layout)
|
|
|
+ sess := util.MQFW.GetMgoConn()
|
|
|
+ for {
|
|
|
+ if sess != nil {
|
|
|
+ defer util.MQFW.DestoryMongoConn(sess)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(time.Minute)
|
|
|
+ sess = util.MQFW.GetMgoConn()
|
|
|
+ }
|
|
|
+ query := i.UserQuery()
|
|
|
+ query["i_member_status"] = map[string]interface{}{
|
|
|
+ "$gt": 0,
|
|
|
+ }
|
|
|
+ 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); {
|
|
|
+ _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(i.UserColl(), _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_member_status": -i_member_status,
|
|
|
+ "i_member_expire_tip": 2,
|
|
|
+ },
|
|
|
+ "$unset": map[string]interface{}{
|
|
|
+ "i_member_expire_tip_retry": "",
|
|
|
+ "i_mainaccount": "",
|
|
|
+ "i_pay_sub_num": "",
|
|
|
+ "i_free_sub_num": "",
|
|
|
+ "i_member_sub_status": "",
|
|
|
+ "s_member_mainid": "",
|
|
|
+ },
|
|
|
+ })
|
|
|
+ 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 {
|
|
|
+ log.Println(_id, "更新到期用户服务表出错")
|
|
|
+ } else {
|
|
|
+ positionId := util.MongoIdToPositionId(_id)
|
|
|
+ ok := jy.ClearBigVipUserPower(positionId)
|
|
|
+ config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
+ PositionId: positionId,
|
|
|
+ AppId: "10000",
|
|
|
+ })
|
|
|
+ go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
+ if !ok {
|
|
|
+ log.Println("清除 redis 大会员服务详情 缓存失败:", _id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if i_member_endtime-now_unix <= threeday && i_member_expire_tip != 1 {
|
|
|
+ updateOk := util.MQFW.UpdateById(i.UserColl(), _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{})
|
|
|
+ }
|
|
|
+ log.Println("定时任务,更新大会员状态结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 大会员即将到期或者已到期发推送消息
|
|
|
func bigMemberExpireRemind() {
|
|
|
- crontab(false, TimeTaskConfig.ExpireRemind, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,大会员到期提醒,开始推送消息")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- doFunc := func(m map[string]interface{}) {
|
|
|
- i_member_expire_tip := qutil.IntAll(m["i_member_expire_tip"])
|
|
|
- if i_member_expire_tip != 1 && i_member_expire_tip != 2 {
|
|
|
- return
|
|
|
- }
|
|
|
- _id := qutil.ObjToString(m["_id"])
|
|
|
- i_member_endtime := qutil.Int64All(m["i_member_endtime"])
|
|
|
- if i_member_endtime-now_unix > threeday { //&& i_member_expire_tip == 1
|
|
|
- log.Println("大会员即将到期提醒,结束时间大于三天,过滤掉", _id, i_member_endtime)
|
|
|
- return
|
|
|
- }
|
|
|
- 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, keyword1_value, keyword2_value, keyword3_value, keyword4_value := "", "", "", "", ""
|
|
|
- keyword4_value = FormatDateByInt64(&i_member_endtime, Date_Short_Layout)
|
|
|
- if i_member_status > 0 {
|
|
|
- //tp = "bigmember_soonexprie"
|
|
|
- tplId = MessageConfig.WxTpl_BigMember_SoonExpire.Id
|
|
|
- keyword2_value = MessageConfig.WxTpl_BigMember_SoonExpire.Keyword2.Value
|
|
|
- keyword3_value = MessageConfig.WxTpl_BigMember_SoonExpire.Keyword3.Value
|
|
|
- keyword4_value = fmt.Sprintf(MessageConfig.WxTpl_BigMember_SoonExpire.Keyword4.Value, keyword4_value)
|
|
|
- } else if i_member_status < 0 {
|
|
|
- //tp = "bigmember_expried"
|
|
|
- tplId = MessageConfig.WxTpl_BigMember_Expired.Id
|
|
|
- keyword2_value = MessageConfig.WxTpl_BigMember_Expired.Keyword2.Value
|
|
|
- keyword3_value = MessageConfig.WxTpl_BigMember_Expired.Keyword3.Value
|
|
|
- keyword4_value = fmt.Sprintf(MessageConfig.WxTpl_BigMember_Expired.Keyword4.Value, keyword4_value)
|
|
|
- } else {
|
|
|
- return
|
|
|
- }
|
|
|
- keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
- tmplData := map[string]*qrpc.TmplItem{
|
|
|
- "keyword1": &qrpc.TmplItem{
|
|
|
- Value: keyword1_value,
|
|
|
- },
|
|
|
- "keyword2": &qrpc.TmplItem{
|
|
|
- Value: keyword2_value,
|
|
|
- },
|
|
|
- "keyword3": &qrpc.TmplItem{
|
|
|
- Value: keyword3_value,
|
|
|
- },
|
|
|
- "keyword4": &qrpc.TmplItem{
|
|
|
- Value: keyword4_value,
|
|
|
- },
|
|
|
- }
|
|
|
- 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)
|
|
|
- }
|
|
|
- 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 {
|
|
|
- return
|
|
|
- }
|
|
|
- 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+qutil.If(IsObjectIdHex(_id), ",_id,", ",entUserId,").(string)+strconv.Itoa(int(time.Now().Unix()))+",msgremind") + "__" + hex.EncodeToString([]byte(fmt.Sprintf("type=%s", tp))),
|
|
|
- "userId": _id,
|
|
|
- "type": "vipNotice",
|
|
|
- "descript": app_descript,
|
|
|
- "title": "剑鱼提醒",
|
|
|
- "category": "服务通知_账号动态",
|
|
|
- "menuName": "box",
|
|
|
- })
|
|
|
- log.Println("大会员到期提醒,app推送", _id, appPushOk)
|
|
|
- }
|
|
|
- if wxPushOk || appPushOk || qutil.IntAll(m["i_member_expire_tip_retry"]) >= 2 {
|
|
|
- util.Compatible.UpdateByEntUserId(_id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_member_expire_tip": 0,
|
|
|
- },
|
|
|
- })
|
|
|
- } else {
|
|
|
- util.Compatible.Update(_id, map[string]interface{}{
|
|
|
- "$inc": map[string]interface{}{
|
|
|
- "i_member_expire_tip_retry": 1,
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- field := 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,
|
|
|
- "i_member_expire_tip_retry": 1,
|
|
|
- }
|
|
|
- (&Personal{}).LoadBigMemberUsers(field, doFunc)
|
|
|
- (&Ent{}).LoadBigMemberUsers(field, doFunc)
|
|
|
- log.Println("定时任务,大会员到期提醒,推送消息结束")
|
|
|
- })
|
|
|
+ crontab(false, TimeTaskConfig.ExpireRemind, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,大会员到期提醒,开始推送消息")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ doFunc := func(m map[string]interface{}) {
|
|
|
+ i_member_expire_tip := qutil.IntAll(m["i_member_expire_tip"])
|
|
|
+ if i_member_expire_tip != 1 && i_member_expire_tip != 2 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ _id := qutil.ObjToString(m["_id"])
|
|
|
+ i_member_endtime := qutil.Int64All(m["i_member_endtime"])
|
|
|
+ if i_member_endtime-now_unix > threeday { //&& i_member_expire_tip == 1
|
|
|
+ log.Println("大会员即将到期提醒,结束时间大于三天,过滤掉", _id, i_member_endtime)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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, keyword1_value, keyword2_value, keyword3_value, keyword4_value := "", "", "", "", ""
|
|
|
+ keyword4_value = FormatDateByInt64(&i_member_endtime, Date_Short_Layout)
|
|
|
+ if i_member_status > 0 {
|
|
|
+ //tp = "bigmember_soonexprie"
|
|
|
+ tplId = MessageConfig.WxTpl_BigMember_SoonExpire.Id
|
|
|
+ keyword2_value = MessageConfig.WxTpl_BigMember_SoonExpire.Keyword2.Value
|
|
|
+ keyword3_value = MessageConfig.WxTpl_BigMember_SoonExpire.Keyword3.Value
|
|
|
+ keyword4_value = fmt.Sprintf(MessageConfig.WxTpl_BigMember_SoonExpire.Keyword4.Value, keyword4_value)
|
|
|
+ } else if i_member_status < 0 {
|
|
|
+ //tp = "bigmember_expried"
|
|
|
+ tplId = MessageConfig.WxTpl_BigMember_Expired.Id
|
|
|
+ keyword2_value = MessageConfig.WxTpl_BigMember_Expired.Keyword2.Value
|
|
|
+ keyword3_value = MessageConfig.WxTpl_BigMember_Expired.Keyword3.Value
|
|
|
+ keyword4_value = fmt.Sprintf(MessageConfig.WxTpl_BigMember_Expired.Keyword4.Value, keyword4_value)
|
|
|
+ } else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ keyword1_value = qutil.ObjToString(m["s_nickname"])
|
|
|
+ tmplData := map[string]*qrpc.TmplItem{
|
|
|
+ "keyword1": &qrpc.TmplItem{
|
|
|
+ Value: keyword1_value,
|
|
|
+ },
|
|
|
+ "keyword2": &qrpc.TmplItem{
|
|
|
+ Value: keyword2_value,
|
|
|
+ },
|
|
|
+ "keyword3": &qrpc.TmplItem{
|
|
|
+ Value: keyword3_value,
|
|
|
+ },
|
|
|
+ "keyword4": &qrpc.TmplItem{
|
|
|
+ Value: keyword4_value,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ 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 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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+qutil.If(IsObjectIdHex(_id), ",_id,", ",entUserId,").(string)+strconv.Itoa(int(time.Now().Unix()))+",msgremind") + "__" + hex.EncodeToString([]byte(fmt.Sprintf("type=%s", tp))),
|
|
|
+ "userId": _id,
|
|
|
+ "type": "vipNotice",
|
|
|
+ "descript": app_descript,
|
|
|
+ "title": "剑鱼提醒",
|
|
|
+ "category": "服务通知_账号动态",
|
|
|
+ "menuName": "box",
|
|
|
+ })
|
|
|
+ log.Println("大会员到期提醒,app推送", _id, appPushOk)
|
|
|
+ }
|
|
|
+ if wxPushOk || appPushOk || qutil.IntAll(m["i_member_expire_tip_retry"]) >= 2 {
|
|
|
+ util.Compatible.UpdateByEntUserId(_id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_member_expire_tip": 0,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ util.Compatible.Update(_id, map[string]interface{}{
|
|
|
+ "$inc": map[string]interface{}{
|
|
|
+ "i_member_expire_tip_retry": 1,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ field := 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,
|
|
|
+ "i_member_expire_tip_retry": 1,
|
|
|
+ }
|
|
|
+ (&Personal{}).LoadBigMemberUsers(field, doFunc)
|
|
|
+ (&Ent{}).LoadBigMemberUsers(field, doFunc)
|
|
|
+ log.Println("定时任务,大会员到期提醒,推送消息结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 查看是否有大会员用户定时开启会员
|
|
|
func checkMemberIsStart() {
|
|
|
- crontab(true, TimeTaskConfig.MemberIsStart, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,开始更新大会员状态-定时开启会员状态")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- sess := util.MQFW.GetMgoConn()
|
|
|
- for {
|
|
|
- if sess != nil {
|
|
|
- defer util.MQFW.DestoryMongoConn(sess)
|
|
|
- break
|
|
|
- }
|
|
|
- time.Sleep(time.Minute)
|
|
|
- sess = util.MQFW.GetMgoConn()
|
|
|
- }
|
|
|
- //定时开启大会员 i_member_status<0 && i_member_endtime 结束时间大于当前时间 && i_member_starttime 开始时间小于当前时间
|
|
|
- it := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
- "i_appid": 2,
|
|
|
- "i_member_status": map[string]interface{}{
|
|
|
- "$lt": 0,
|
|
|
- },
|
|
|
- "$and": []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "i_member_endtime": map[string]interface{}{
|
|
|
- "$gte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "i_member_starttime": map[string]interface{}{
|
|
|
- "$lte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- }).Select(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1, "i_member_starttime": 1}).Iter()
|
|
|
- for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
- log.Println("企业用户权益开通生效", BsonIdToSId(m["_id"]), m["user_phone"])
|
|
|
- _id := BsonIdToSId(m["_id"])
|
|
|
- i_member_endtime := qutil.Int64All(m["i_member_endtime"])
|
|
|
- i_member_starttime := qutil.Int64All(m["i_member_starttime"])
|
|
|
- i_member_status := qutil.IntAll(m["i_member_status"])
|
|
|
- if i_member_endtime > now_unix && i_member_starttime <= now_unix {
|
|
|
- util.Compatible.Update(_id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_member_status": -i_member_status,
|
|
|
- },
|
|
|
- })
|
|
|
- //大会员用户服务表更新
|
|
|
- updateBigMemberService(_id, now_unix)
|
|
|
- positionId := util.MongoIdToPositionId(_id)
|
|
|
- ok := jy.ClearBigVipUserPower(positionId)
|
|
|
- config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
- PositionId: positionId,
|
|
|
- AppId: "10000",
|
|
|
- })
|
|
|
- config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
- if !ok {
|
|
|
- log.Println("清除 redis 大会员服务详情 缓存失败:", _id)
|
|
|
- }
|
|
|
- }
|
|
|
- m = make(map[string]interface{})
|
|
|
- }
|
|
|
- log.Println("定时任务,更新大会员状态结束-定时开启会员状态")
|
|
|
- })
|
|
|
+ crontab(true, TimeTaskConfig.MemberIsStart, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,开始更新大会员状态-定时开启会员状态")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ sess := util.MQFW.GetMgoConn()
|
|
|
+ for {
|
|
|
+ if sess != nil {
|
|
|
+ defer util.MQFW.DestoryMongoConn(sess)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(time.Minute)
|
|
|
+ sess = util.MQFW.GetMgoConn()
|
|
|
+ }
|
|
|
+ //定时开启大会员 i_member_status<0 && i_member_endtime 结束时间大于当前时间 && i_member_starttime 开始时间小于当前时间
|
|
|
+ it := sess.DB("qfw").C("user").Find(map[string]interface{}{
|
|
|
+ "i_appid": 2,
|
|
|
+ "i_member_status": map[string]interface{}{
|
|
|
+ "$lt": 0,
|
|
|
+ },
|
|
|
+ "$and": []map[string]interface{}{
|
|
|
+ map[string]interface{}{
|
|
|
+ "i_member_endtime": map[string]interface{}{
|
|
|
+ "$gte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ map[string]interface{}{
|
|
|
+ "i_member_starttime": map[string]interface{}{
|
|
|
+ "$lte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }).Select(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1, "i_member_starttime": 1}).Iter()
|
|
|
+ for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
+ log.Println("企业用户权益开通生效", BsonIdToSId(m["_id"]), m["user_phone"])
|
|
|
+ _id := BsonIdToSId(m["_id"])
|
|
|
+ i_member_endtime := qutil.Int64All(m["i_member_endtime"])
|
|
|
+ i_member_starttime := qutil.Int64All(m["i_member_starttime"])
|
|
|
+ i_member_status := qutil.IntAll(m["i_member_status"])
|
|
|
+ if i_member_endtime > now_unix && i_member_starttime <= now_unix {
|
|
|
+ util.Compatible.Update(_id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_member_status": -i_member_status,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ //大会员用户服务表更新
|
|
|
+ updateBigMemberService(_id, now_unix)
|
|
|
+ positionId := util.MongoIdToPositionId(_id)
|
|
|
+ ok := jy.ClearBigVipUserPower(positionId)
|
|
|
+ config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
+ PositionId: positionId,
|
|
|
+ AppId: "10000",
|
|
|
+ })
|
|
|
+ config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
+ if !ok {
|
|
|
+ log.Println("清除 redis 大会员服务详情 缓存失败:", _id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ log.Println("定时任务,更新大会员状态结束-定时开启会员状态")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 查看企业版大会员、超级订阅是否开通
|
|
|
func checkEntIsStart() {
|
|
|
- crontab(true, TimeTaskConfig.MemberIsStart, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,开始更新大会员状态-定时开启会员状态")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- sess := util.MQFW.GetMgoConn()
|
|
|
- for {
|
|
|
- if sess != nil {
|
|
|
- defer util.MQFW.DestoryMongoConn(sess)
|
|
|
- break
|
|
|
- }
|
|
|
- time.Sleep(time.Minute)
|
|
|
- sess = util.MQFW.GetMgoConn()
|
|
|
- }
|
|
|
- count, _ := sess.DB("qfw").C(CollEntUser).Find(map[string]interface{}{
|
|
|
- "$or": []map[string]interface{}{
|
|
|
- {"i_member_status": map[string]interface{}{
|
|
|
- "$lt": 0},
|
|
|
- "$and": []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "i_member_endtime": map[string]interface{}{
|
|
|
- "$gte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "i_member_starttime": map[string]interface{}{
|
|
|
- "$lte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- }},
|
|
|
- {"i_vip_status": map[string]interface{}{
|
|
|
- "$lt": 0},
|
|
|
- "$and": []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "l_vip_endtime": map[string]interface{}{
|
|
|
- "$gte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "l_vip_starttime": map[string]interface{}{
|
|
|
- "$lte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- }},
|
|
|
- },
|
|
|
- }).Select(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1, "i_member_starttime": 1, "i_vip_status": 1, "l_vip_starttime": 1, "l_vip_endtime": 1, "i_entid": 1, "i_userid": 1}).Count()
|
|
|
+ crontab(true, TimeTaskConfig.MemberIsStart, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,开始更新大会员状态-定时开启会员状态")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ sess := util.MQFW.GetMgoConn()
|
|
|
+ for {
|
|
|
+ if sess != nil {
|
|
|
+ defer util.MQFW.DestoryMongoConn(sess)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(time.Minute)
|
|
|
+ sess = util.MQFW.GetMgoConn()
|
|
|
+ }
|
|
|
+ count, _ := sess.DB("qfw").C(CollEntUser).Find(map[string]interface{}{
|
|
|
+ "$or": []map[string]interface{}{
|
|
|
+ {"i_member_status": map[string]interface{}{
|
|
|
+ "$lt": 0},
|
|
|
+ "$and": []map[string]interface{}{
|
|
|
+ map[string]interface{}{
|
|
|
+ "i_member_endtime": map[string]interface{}{
|
|
|
+ "$gte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ map[string]interface{}{
|
|
|
+ "i_member_starttime": map[string]interface{}{
|
|
|
+ "$lte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }},
|
|
|
+ {"i_vip_status": map[string]interface{}{
|
|
|
+ "$lt": 0},
|
|
|
+ "$and": []map[string]interface{}{
|
|
|
+ map[string]interface{}{
|
|
|
+ "l_vip_endtime": map[string]interface{}{
|
|
|
+ "$gte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ map[string]interface{}{
|
|
|
+ "l_vip_starttime": map[string]interface{}{
|
|
|
+ "$lte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }},
|
|
|
+ },
|
|
|
+ }).Select(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1, "i_member_starttime": 1, "i_vip_status": 1, "l_vip_starttime": 1, "l_vip_endtime": 1, "i_entid": 1, "i_userid": 1}).Count()
|
|
|
|
|
|
- log.Println("企业定时任务时间:", now_unix, count)
|
|
|
- //定时开启大会员 i_member_status<0 && i_member_endtime 结束时间大于当前时间 && i_member_starttime 开始时间小于当前时间
|
|
|
- it := sess.DB("qfw").C(CollEntUser).Find(map[string]interface{}{
|
|
|
- "$or": []map[string]interface{}{
|
|
|
- {"i_member_status": map[string]interface{}{
|
|
|
- "$lt": 0},
|
|
|
- "$and": []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "i_member_endtime": map[string]interface{}{
|
|
|
- "$gte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "i_member_starttime": map[string]interface{}{
|
|
|
- "$lte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- }},
|
|
|
- {"i_vip_status": map[string]interface{}{
|
|
|
- "$lt": 0},
|
|
|
- "$and": []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "l_vip_endtime": map[string]interface{}{
|
|
|
- "$gte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "l_vip_starttime": map[string]interface{}{
|
|
|
- "$lte": now_unix,
|
|
|
- },
|
|
|
- },
|
|
|
- }},
|
|
|
- },
|
|
|
- }).Select(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1, "i_member_starttime": 1, "i_vip_status": 1, "l_vip_starttime": 1, "l_vip_endtime": 1, "i_entid": 1, "i_userid": 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_starttime := qutil.Int64All(m["i_member_starttime"])
|
|
|
- i_member_status := qutil.IntAll(m["i_member_status"])
|
|
|
- l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
|
- l_vip_starttime := qutil.Int64All(m["l_vip_starttime"])
|
|
|
- i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
|
- i_userid := qutil.IntAll(m["i_userid"])
|
|
|
- if i_member_endtime > now_unix && i_member_starttime <= now_unix {
|
|
|
- util.MQFW.UpdateById(CollEntUser, _id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_member_status": -i_member_status,
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
- if l_vip_endtime > now_unix && l_vip_starttime <= now_unix {
|
|
|
- util.MQFW.UpdateById(CollEntUser, _id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_vip_status": -i_vip_status,
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
- // 清缓存
|
|
|
- go clearEntCache(i_userid)
|
|
|
- m = make(map[string]interface{})
|
|
|
- }
|
|
|
- log.Println("定时任务,更新企业版大会员、超级订阅状态结束-定时开启会员状态")
|
|
|
- })
|
|
|
+ log.Println("企业定时任务时间:", now_unix, count)
|
|
|
+ //定时开启大会员 i_member_status<0 && i_member_endtime 结束时间大于当前时间 && i_member_starttime 开始时间小于当前时间
|
|
|
+ it := sess.DB("qfw").C(CollEntUser).Find(map[string]interface{}{
|
|
|
+ "$or": []map[string]interface{}{
|
|
|
+ {"i_member_status": map[string]interface{}{
|
|
|
+ "$lt": 0},
|
|
|
+ "$and": []map[string]interface{}{
|
|
|
+ map[string]interface{}{
|
|
|
+ "i_member_endtime": map[string]interface{}{
|
|
|
+ "$gte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ map[string]interface{}{
|
|
|
+ "i_member_starttime": map[string]interface{}{
|
|
|
+ "$lte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }},
|
|
|
+ {"i_vip_status": map[string]interface{}{
|
|
|
+ "$lt": 0},
|
|
|
+ "$and": []map[string]interface{}{
|
|
|
+ map[string]interface{}{
|
|
|
+ "l_vip_endtime": map[string]interface{}{
|
|
|
+ "$gte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ map[string]interface{}{
|
|
|
+ "l_vip_starttime": map[string]interface{}{
|
|
|
+ "$lte": now_unix,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }},
|
|
|
+ },
|
|
|
+ }).Select(map[string]interface{}{"i_member_status": 1, "i_member_endtime": 1, "i_member_starttime": 1, "i_vip_status": 1, "l_vip_starttime": 1, "l_vip_endtime": 1, "i_entid": 1, "i_userid": 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_starttime := qutil.Int64All(m["i_member_starttime"])
|
|
|
+ i_member_status := qutil.IntAll(m["i_member_status"])
|
|
|
+ l_vip_endtime := qutil.Int64All(m["l_vip_endtime"])
|
|
|
+ l_vip_starttime := qutil.Int64All(m["l_vip_starttime"])
|
|
|
+ i_vip_status := qutil.IntAll(m["i_vip_status"])
|
|
|
+ i_userid := qutil.IntAll(m["i_userid"])
|
|
|
+ if i_member_endtime > now_unix && i_member_starttime <= now_unix {
|
|
|
+ util.MQFW.UpdateById(CollEntUser, _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_member_status": -i_member_status,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if l_vip_endtime > now_unix && l_vip_starttime <= now_unix {
|
|
|
+ util.MQFW.UpdateById(CollEntUser, _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_vip_status": -i_vip_status,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 清缓存
|
|
|
+ go clearEntCache(i_userid)
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ log.Println("定时任务,更新企业版大会员、超级订阅状态结束-定时开启会员状态")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 企业版账号清权益缓存
|
|
|
func clearEntCache(userId int) {
|
|
|
|
|
|
- identity := config.Middleground.UserCenter.IdentityByEntUserId(int64(userId))
|
|
|
- if identity == nil {
|
|
|
- return
|
|
|
- }
|
|
|
- positionId := fmt.Sprint(identity.PositionId)
|
|
|
- ok := jy.ClearBigVipUserPower(positionId)
|
|
|
- config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
- PositionId: positionId,
|
|
|
- AppId: "10000",
|
|
|
- })
|
|
|
- config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
- if !ok {
|
|
|
- log.Println("清除 redis 大会员超级订阅服务详情 缓存失败:", positionId)
|
|
|
- }
|
|
|
+ identity := config.Middleground.UserCenter.IdentityByEntUserId(int64(userId))
|
|
|
+ if identity == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ positionId := fmt.Sprint(identity.PositionId)
|
|
|
+ ok := jy.ClearBigVipUserPower(positionId)
|
|
|
+ config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
+ PositionId: positionId,
|
|
|
+ AppId: "10000",
|
|
|
+ })
|
|
|
+ config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
+ if !ok {
|
|
|
+ log.Println("清除 redis 大会员超级订阅服务详情 缓存失败:", positionId)
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
// 大会员更新用户服务表
|
|
|
func updateBigMemberService(userId string, now_unix int64) {
|
|
|
- now_time := FormatDateByInt64(&now_unix, Date_Full_Layout)
|
|
|
- userServiceList := util.Mysql.SelectBySql(`select * from `+jy.BigmemberUserPowerTable+` where s_userid=? AND i_status = 1 AND l_starttime <= ? AND l_endtime > ?`, userId, now_time, now_time)
|
|
|
- if len(*userServiceList) > 0 {
|
|
|
- for _, v := range *userServiceList {
|
|
|
- var serviceid = v["s_serviceid"]
|
|
|
- if util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_status = 0 , a.l_updatetime=? WHERE a.s_userid = ? AND a.s_serviceid = ? `, now_time, userId, serviceid) < 0 {
|
|
|
- log.Println(userId, "开启大会员用户服务表出错")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ now_time := FormatDateByInt64(&now_unix, Date_Full_Layout)
|
|
|
+ userServiceList := util.Mysql.SelectBySql(`select * from `+jy.BigmemberUserPowerTable+` where s_userid=? AND i_status = 1 AND l_starttime <= ? AND l_endtime > ?`, userId, now_time, now_time)
|
|
|
+ if len(*userServiceList) > 0 {
|
|
|
+ for _, v := range *userServiceList {
|
|
|
+ var serviceid = v["s_serviceid"]
|
|
|
+ if util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_status = 0 , a.l_updatetime=? WHERE a.s_userid = ? AND a.s_serviceid = ? `, now_time, userId, serviceid) < 0 {
|
|
|
+ log.Println(userId, "开启大会员用户服务表出错")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 大会员用户服务表 用户服务是否需要开启或关闭
|
|
|
func checkMemberServiceIsExpire() {
|
|
|
- crontab(true, TimeTaskConfig.MemberServiceIsExpire, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,更新大会员服务表状态开始")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- now_time := FormatDateByInt64(&now_unix, Date_Full_Layout)
|
|
|
- //待使用服务更新状态 wait & 服务到期更新状态 overdue
|
|
|
- wooList := util.Mysql.SelectBySql(`SELECT * FROM `+jy.BigmemberUserPowerTable+` a WHERE (a.i_status = 1 AND a.l_starttime <= ? AND a.l_endtime > ?) OR (a.i_status = 0 AND a.l_endtime < ?)`, now_time, now_time, now_time)
|
|
|
- if len(*wooList) > 0 {
|
|
|
- // log.Println(len(*wooList), "-----:", wooList)
|
|
|
- var useridMap = map[string]bool{}
|
|
|
- for _, v := range *wooList {
|
|
|
- var starttime int64 = -1
|
|
|
- var endtime int64 = -1
|
|
|
- var serviceid = v["s_serviceid"]
|
|
|
- var userid = v["s_userid"]
|
|
|
- if !useridMap[userid.(string)] {
|
|
|
- useridMap[userid.(string)] = true
|
|
|
- }
|
|
|
- if thisTime, err := time.ParseInLocation(Date_Full_Layout, v["l_starttime"].(string), time.Local); err == nil {
|
|
|
- starttime = thisTime.Unix()
|
|
|
- }
|
|
|
- if thisTime, err := time.ParseInLocation(Date_Full_Layout, v["l_endtime"].(string), time.Local); err == nil {
|
|
|
- endtime = thisTime.Unix()
|
|
|
- }
|
|
|
- if starttime <= now_unix && endtime > now_unix {
|
|
|
- if util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_status = 0, a.l_updatetime=? WHERE a.s_userid = ? AND a.s_serviceid = ? `, now_time, userid, serviceid) < 0 {
|
|
|
- log.Println(userid, "开启大会员用户服务表出错")
|
|
|
- }
|
|
|
- } else if endtime < now_unix {
|
|
|
- if util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_frequency = 0 , a.i_status = -1, a.l_updatetime=? WHERE a.s_userid = ? AND a.s_serviceid = ?`, now_time, userid, serviceid) < 0 {
|
|
|
- log.Println(userid, "关闭大会员用户服务表出错")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // log.Println("useridMap:", useridMap)
|
|
|
- if useridMap != nil && len(useridMap) > 0 {
|
|
|
- for k, _ := range useridMap {
|
|
|
- positionId := util.MongoIdToPositionId(k)
|
|
|
- ok := jy.ClearBigVipUserPower(positionId)
|
|
|
- config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
- PositionId: positionId,
|
|
|
- AppId: "10000",
|
|
|
- })
|
|
|
- config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
- if !ok {
|
|
|
- log.Println("清除 redis 大会员服务详情 缓存失败:", k)
|
|
|
- }
|
|
|
+ crontab(true, TimeTaskConfig.MemberServiceIsExpire, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,更新大会员服务表状态开始")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ now_time := FormatDateByInt64(&now_unix, Date_Full_Layout)
|
|
|
+ //待使用服务更新状态 wait & 服务到期更新状态 overdue
|
|
|
+ wooList := util.Mysql.SelectBySql(`SELECT * FROM `+jy.BigmemberUserPowerTable+` a WHERE (a.i_status = 1 AND a.l_starttime <= ? AND a.l_endtime > ?) OR (a.i_status = 0 AND a.l_endtime < ?)`, now_time, now_time, now_time)
|
|
|
+ if len(*wooList) > 0 {
|
|
|
+ // log.Println(len(*wooList), "-----:", wooList)
|
|
|
+ var useridMap = map[string]bool{}
|
|
|
+ for _, v := range *wooList {
|
|
|
+ var starttime int64 = -1
|
|
|
+ var endtime int64 = -1
|
|
|
+ var serviceid = v["s_serviceid"]
|
|
|
+ var userid = v["s_userid"]
|
|
|
+ if !useridMap[userid.(string)] {
|
|
|
+ useridMap[userid.(string)] = true
|
|
|
+ }
|
|
|
+ if thisTime, err := time.ParseInLocation(Date_Full_Layout, v["l_starttime"].(string), time.Local); err == nil {
|
|
|
+ starttime = thisTime.Unix()
|
|
|
+ }
|
|
|
+ if thisTime, err := time.ParseInLocation(Date_Full_Layout, v["l_endtime"].(string), time.Local); err == nil {
|
|
|
+ endtime = thisTime.Unix()
|
|
|
+ }
|
|
|
+ if starttime <= now_unix && endtime > now_unix {
|
|
|
+ if util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_status = 0, a.l_updatetime=? WHERE a.s_userid = ? AND a.s_serviceid = ? `, now_time, userid, serviceid) < 0 {
|
|
|
+ log.Println(userid, "开启大会员用户服务表出错")
|
|
|
+ }
|
|
|
+ } else if endtime < now_unix {
|
|
|
+ if util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_frequency = 0 , a.i_status = -1, a.l_updatetime=? WHERE a.s_userid = ? AND a.s_serviceid = ?`, now_time, userid, serviceid) < 0 {
|
|
|
+ log.Println(userid, "关闭大会员用户服务表出错")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // log.Println("useridMap:", useridMap)
|
|
|
+ if useridMap != nil && len(useridMap) > 0 {
|
|
|
+ for k, _ := range useridMap {
|
|
|
+ positionId := util.MongoIdToPositionId(k)
|
|
|
+ ok := jy.ClearBigVipUserPower(positionId)
|
|
|
+ config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
+ PositionId: positionId,
|
|
|
+ AppId: "10000",
|
|
|
+ })
|
|
|
+ config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
+ if !ok {
|
|
|
+ log.Println("清除 redis 大会员服务详情 缓存失败:", k)
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- log.Println("定时任务,更新大会员服务表状态结束")
|
|
|
- })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.Println("定时任务,更新大会员服务表状态结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
func updateTimeLimitActitityOrderStatus() { //修改限时活动的订单状态
|
|
|
- crontabByTicker(true, TimeTaskConfig.UpdateTimeLimitActivityOrderStatus, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,更新限时活动订单状态开始")
|
|
|
- now := time.Now().Add(-time.Duration(config.Config.ActivityOrderCountdown) * time.Minute)
|
|
|
- //获取倒计时时间
|
|
|
- starttime := now.Format(Date_Full_Layout)
|
|
|
- limitTime := 20 //默认二十秒
|
|
|
- if strings.Contains(TimeTaskConfig.UpdateTimeLimitActivityOrderStatus, "s") {
|
|
|
- cStr := strings.Split(TimeTaskConfig.UpdateTimeLimitActivityOrderStatus, "s")[0]
|
|
|
- limitTime, _ = strconv.Atoi(cStr)
|
|
|
- }
|
|
|
- endtime := now.Add(-time.Duration(limitTime) * time.Second).Format(Date_Full_Layout)
|
|
|
- data := util.Mysql.SelectBySql(`select * from dataexport_order where order_status =0 and expiration_time>=? and expiration_time<? and is_backstage_order = 0`, starttime, endtime)
|
|
|
- log.Println(fmt.Sprintf(`select * from dataexport_order where order_status =0 and expiration_time<%s and expiration_time>=%s`, starttime, endtime))
|
|
|
- if data != nil && len(*data) > 0 {
|
|
|
- for _, v := range *data {
|
|
|
- //对公转账审核中不取消卡券
|
|
|
- if gconv.String(v["pay_way"]) == "transferAccounts" && gconv.Int64(v["course_status"]) == 2 {
|
|
|
- continue
|
|
|
- }
|
|
|
- //订单编号
|
|
|
- order_code, _ := v["order_code"].(string)
|
|
|
- productType := 0 //取消卡券的时候 需要这个参数 商品类型0普通的1线上课程
|
|
|
- if product_type, _ := v["product_type"].(string); product_type != "中标必听课" {
|
|
|
- productType = 1
|
|
|
- }
|
|
|
- flag := false
|
|
|
- if qutil.IntAll(v["order_status"]) == 0 && qutil.IntAll(v["is_backstage_order"]) == 0 && qutil.ObjToString(v["pay_way"]) != "transferAccounts" { //未支付状态下 删除订单需要先关闭订单
|
|
|
- flag = pay.CloseDataExportOrder(qutil.ObjToString(v["pay_way"]), qutil.ObjToString(v["out_trade_no"]), qutil.ObjToString(v["prepay_time"]))
|
|
|
- }
|
|
|
- if flag || (!(qutil.IntAll(v["course_status"]) == 2 || qutil.IntAll(v["course_status"]) == 4)) && qutil.ObjToString(v["pay_way"]) == "transferAccounts" && qutil.IntAll(v["is_backstage_order"]) == 0 { //对公转账非审核中 和 转账成功 状态下超时取消订单
|
|
|
- queryMap := map[string]interface{}{
|
|
|
- "order_code": order_code,
|
|
|
- }
|
|
|
- flag = util.Mysql.Update("dataexport_order", queryMap, map[string]interface{}{"order_status": -2})
|
|
|
- }
|
|
|
+ crontabByTicker(true, TimeTaskConfig.UpdateTimeLimitActivityOrderStatus, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,更新限时活动订单状态开始")
|
|
|
+ now := time.Now().Add(-time.Duration(config.Config.ActivityOrderCountdown) * time.Minute)
|
|
|
+ //获取倒计时时间
|
|
|
+ starttime := now.Format(Date_Full_Layout)
|
|
|
+ limitTime := 20 //默认二十秒
|
|
|
+ if strings.Contains(TimeTaskConfig.UpdateTimeLimitActivityOrderStatus, "s") {
|
|
|
+ cStr := strings.Split(TimeTaskConfig.UpdateTimeLimitActivityOrderStatus, "s")[0]
|
|
|
+ limitTime, _ = strconv.Atoi(cStr)
|
|
|
+ }
|
|
|
+ endtime := now.Add(-time.Duration(limitTime) * time.Second).Format(Date_Full_Layout)
|
|
|
+ data := util.Mysql.SelectBySql(`select * from dataexport_order where order_status =0 and expiration_time>=? and expiration_time<? and is_backstage_order = 0`, starttime, endtime)
|
|
|
+ log.Println(fmt.Sprintf(`select * from dataexport_order where order_status =0 and expiration_time<%s and expiration_time>=%s`, starttime, endtime))
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ for _, v := range *data {
|
|
|
+ //对公转账审核中不取消卡券
|
|
|
+ if gconv.String(v["pay_way"]) == "transferAccounts" && gconv.Int64(v["course_status"]) == 2 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //订单编号
|
|
|
+ order_code, _ := v["order_code"].(string)
|
|
|
+ productType := 0 //取消卡券的时候 需要这个参数 商品类型0普通的1线上课程
|
|
|
+ if product_type, _ := v["product_type"].(string); product_type != "中标必听课" {
|
|
|
+ productType = 1
|
|
|
+ }
|
|
|
+ flag := false
|
|
|
+ if qutil.IntAll(v["order_status"]) == 0 && qutil.IntAll(v["is_backstage_order"]) == 0 && qutil.ObjToString(v["pay_way"]) != "transferAccounts" { //未支付状态下 删除订单需要先关闭订单
|
|
|
+ flag = pay.CloseDataExportOrder(qutil.ObjToString(v["pay_way"]), qutil.ObjToString(v["out_trade_no"]), qutil.ObjToString(v["prepay_time"]))
|
|
|
+ }
|
|
|
+ if flag || (!(qutil.IntAll(v["course_status"]) == 2 || qutil.IntAll(v["course_status"]) == 4)) && qutil.ObjToString(v["pay_way"]) == "transferAccounts" && qutil.IntAll(v["is_backstage_order"]) == 0 { //对公转账非审核中 和 转账成功 状态下超时取消订单
|
|
|
+ queryMap := map[string]interface{}{
|
|
|
+ "order_code": order_code,
|
|
|
+ }
|
|
|
+ flag = util.Mysql.Update("dataexport_order", queryMap, map[string]interface{}{"order_status": -2})
|
|
|
+ }
|
|
|
|
|
|
- if !flag {
|
|
|
- log.Println("mysql 订单更新失败", order_code)
|
|
|
- } else {
|
|
|
- //解除卡卷绑定
|
|
|
- //用户领取卡卷的记录id
|
|
|
- userLotteryId, _ := v["d_relation_id"].(string)
|
|
|
- if userLotteryId != "" {
|
|
|
- //用户id
|
|
|
- userId, _ := v["user_id"].(string)
|
|
|
- go func(userId, userLotteryId, order_code string) {
|
|
|
- if !util.UpdateCouponState(userId, userLotteryId, "", "", order_code, qutil.ObjToString(v["product_type"]), "0", 0, productType) {
|
|
|
- log.Println(fmt.Sprintf("单号%s-解绑失败-卡卷%s", order_code, userLotteryId))
|
|
|
- }
|
|
|
- }(userId, userLotteryId, order_code)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- log.Println("定时任务,更新限时活动订单结束")
|
|
|
- })
|
|
|
+ if !flag {
|
|
|
+ log.Println("mysql 订单更新失败", order_code)
|
|
|
+ } else {
|
|
|
+ //解除卡卷绑定
|
|
|
+ //用户领取卡卷的记录id
|
|
|
+ userLotteryId, _ := v["d_relation_id"].(string)
|
|
|
+ if userLotteryId != "" {
|
|
|
+ //用户id
|
|
|
+ userId, _ := v["user_id"].(string)
|
|
|
+ go func(userId, userLotteryId, order_code string) {
|
|
|
+ if !util.UpdateCouponState(userId, userLotteryId, "", "", order_code, qutil.ObjToString(v["product_type"]), "0", 0, productType) {
|
|
|
+ log.Println(fmt.Sprintf("单号%s-解绑失败-卡卷%s", order_code, userLotteryId))
|
|
|
+ }
|
|
|
+ }(userId, userLotteryId, order_code)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.Println("定时任务,更新限时活动订单结束")
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
func crontab(flag bool, c string, f func()) {
|
|
|
- array := strings.Split(c, ":")
|
|
|
- if len(array) != 2 {
|
|
|
- log.Fatalln("定时任务参数错误!", c)
|
|
|
- }
|
|
|
- if flag {
|
|
|
- go f()
|
|
|
- }
|
|
|
- now := time.Now()
|
|
|
- t := time.Date(now.Year(), now.Month(), now.Day(), qutil.IntAll(array[0]), qutil.IntAll(array[1]), 0, 0, time.Local)
|
|
|
- if t.Before(now) {
|
|
|
- t = t.AddDate(0, 0, 1)
|
|
|
- }
|
|
|
- timer := time.NewTimer(t.Sub(now))
|
|
|
- for {
|
|
|
- select {
|
|
|
- case <-timer.C:
|
|
|
- go f()
|
|
|
- timer.Reset(24 * time.Hour)
|
|
|
- }
|
|
|
- }
|
|
|
+ array := strings.Split(c, ":")
|
|
|
+ if len(array) != 2 {
|
|
|
+ log.Fatalln("定时任务参数错误!", c)
|
|
|
+ }
|
|
|
+ if flag {
|
|
|
+ go f()
|
|
|
+ }
|
|
|
+ now := time.Now()
|
|
|
+ t := time.Date(now.Year(), now.Month(), now.Day(), qutil.IntAll(array[0]), qutil.IntAll(array[1]), 0, 0, time.Local)
|
|
|
+ if t.Before(now) {
|
|
|
+ t = t.AddDate(0, 0, 1)
|
|
|
+ }
|
|
|
+ timer := time.NewTimer(t.Sub(now))
|
|
|
+ for {
|
|
|
+ select {
|
|
|
+ case <-timer.C:
|
|
|
+ go f()
|
|
|
+ timer.Reset(24 * time.Hour)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func crontabByTicker(flag bool, c string, f func()) {
|
|
|
- if c == "0" {
|
|
|
- log.Println("定时任务参数有误:", c)
|
|
|
- return
|
|
|
- }
|
|
|
- countdown := 5 * 60
|
|
|
- if strings.Contains(c, "h") {
|
|
|
- cStr := strings.Split(c, "h")[0]
|
|
|
- countdown, _ = strconv.Atoi(cStr)
|
|
|
- countdown = countdown * 60 * 60
|
|
|
- } else if strings.Contains(c, "s") {
|
|
|
- cStr := strings.Split(c, "s")[0]
|
|
|
- countdown, _ = strconv.Atoi(cStr)
|
|
|
- countdown = countdown
|
|
|
- } else {
|
|
|
- countdown, _ = strconv.Atoi(c)
|
|
|
- countdown = countdown * 60
|
|
|
- }
|
|
|
- if flag {
|
|
|
- go f()
|
|
|
- }
|
|
|
- ticker := time.NewTicker(time.Duration(countdown) * time.Second)
|
|
|
- go func(t *time.Ticker) {
|
|
|
- for {
|
|
|
- select {
|
|
|
- case <-t.C:
|
|
|
- go f()
|
|
|
- fmt.Println("get ticker", time.Now().Format("2006-01-02 15:04:05"))
|
|
|
- }
|
|
|
- }
|
|
|
- }(ticker)
|
|
|
+ if c == "0" {
|
|
|
+ log.Println("定时任务参数有误:", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ countdown := 5 * 60
|
|
|
+ if strings.Contains(c, "h") {
|
|
|
+ cStr := strings.Split(c, "h")[0]
|
|
|
+ countdown, _ = strconv.Atoi(cStr)
|
|
|
+ countdown = countdown * 60 * 60
|
|
|
+ } else if strings.Contains(c, "s") {
|
|
|
+ cStr := strings.Split(c, "s")[0]
|
|
|
+ countdown, _ = strconv.Atoi(cStr)
|
|
|
+ countdown = countdown
|
|
|
+ } else {
|
|
|
+ countdown, _ = strconv.Atoi(c)
|
|
|
+ countdown = countdown * 60
|
|
|
+ }
|
|
|
+ if flag {
|
|
|
+ go f()
|
|
|
+ }
|
|
|
+ ticker := time.NewTicker(time.Duration(countdown) * time.Second)
|
|
|
+ go func(t *time.Ticker) {
|
|
|
+ for {
|
|
|
+ select {
|
|
|
+ case <-t.C:
|
|
|
+ go f()
|
|
|
+ fmt.Println("get ticker", time.Now().Format("2006-01-02 15:04:05"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }(ticker)
|
|
|
}
|
|
|
|
|
|
func checkDocMemberIsExpire(iy Identity) {
|
|
|
- crontab(true, TimeTaskConfig.CheckDocMemberIsExpire, func() {
|
|
|
- defer qutil.Catch()
|
|
|
- log.Println("定时任务,开始更新文库会员状态")
|
|
|
- now_unix := time.Now().Unix()
|
|
|
- sess := util.MQFW.GetMgoConn()
|
|
|
- for {
|
|
|
- if sess != nil {
|
|
|
- defer util.MQFW.DestoryMongoConn(sess)
|
|
|
- break
|
|
|
- }
|
|
|
- time.Sleep(time.Minute)
|
|
|
- sess = util.MQFW.GetMgoConn()
|
|
|
- }
|
|
|
- query := iy.UserQuery()
|
|
|
- query["i_doc_status"] = map[string]interface{}{
|
|
|
- "$gt": 0,
|
|
|
- }
|
|
|
- query["l_doc_endtime"] = map[string]interface{}{
|
|
|
- "$lte": now_unix,
|
|
|
- }
|
|
|
- count, err := sess.DB("qfw").C(iy.UserColl()).Find(query).Count()
|
|
|
- log.Println("当前时间:", FormatDateByInt64(&now_unix, Date_Full_Layout), "数据总量:", count, "--err:", err)
|
|
|
- var i int64 = 0
|
|
|
- it := sess.DB("qfw").C(iy.UserColl()).Find(query).Select(iy.UserField(map[string]interface{}{"i_doc_status": 1, "l_doc_endtime": 1, "i_userid": 1, "i_entid": 1, "base_user_id": 1, "o_vipjy": 1})).Iter()
|
|
|
- for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
- i++
|
|
|
- _id := BsonIdToSId(m["_id"])
|
|
|
- l_doc_endtime := qutil.Int64All(m["l_doc_endtime"])
|
|
|
- i_doc_status := qutil.IntAll(m["i_doc_status"])
|
|
|
- if l_doc_endtime <= now_unix {
|
|
|
- ok := util.MQFW.UpdateById(iy.UserColl(), _id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_doc_status": -i_doc_status,
|
|
|
- },
|
|
|
- })
|
|
|
- if !ok {
|
|
|
- log.Println("用户:", _id, " 更新doc状态异常")
|
|
|
- } else {
|
|
|
- var (
|
|
|
- identity *pb.Identity
|
|
|
- entUserId = qutil.Int64All(m["i_userid"])
|
|
|
- baseUserId = qutil.Int64All(m["base_user_id"])
|
|
|
- )
|
|
|
- if iy.UserColl() == CollEntUser {
|
|
|
- identity = util.Compatible.Middleground.UserCenter.IdentityByEntUserId(entUserId)
|
|
|
- } else {
|
|
|
- identity = util.Compatible.Middleground.UserCenter.IdentityByUserId(baseUserId)
|
|
|
- }
|
|
|
- go config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
- PositionId: strconv.Itoa(int(identity.PositionId)),
|
|
|
- AppId: "10000",
|
|
|
- })
|
|
|
- go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", identity.PositionId)
|
|
|
- }
|
|
|
- m = make(map[string]interface{})
|
|
|
- }
|
|
|
- }
|
|
|
- if i != count {
|
|
|
- log.Println("更新doc状态有异常,已处理:", i, "总量:", count)
|
|
|
- }
|
|
|
- log.Println("doc 已处理:", i, "总量:", count)
|
|
|
- log.Println("定时任务,更新doc状态结束")
|
|
|
- })
|
|
|
+ crontab(true, TimeTaskConfig.CheckDocMemberIsExpire, func() {
|
|
|
+ defer qutil.Catch()
|
|
|
+ log.Println("定时任务,开始更新文库会员状态")
|
|
|
+ now_unix := time.Now().Unix()
|
|
|
+ sess := util.MQFW.GetMgoConn()
|
|
|
+ for {
|
|
|
+ if sess != nil {
|
|
|
+ defer util.MQFW.DestoryMongoConn(sess)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(time.Minute)
|
|
|
+ sess = util.MQFW.GetMgoConn()
|
|
|
+ }
|
|
|
+ query := iy.UserQuery()
|
|
|
+ query["i_doc_status"] = map[string]interface{}{
|
|
|
+ "$gt": 0,
|
|
|
+ }
|
|
|
+ query["l_doc_endtime"] = map[string]interface{}{
|
|
|
+ "$lte": now_unix,
|
|
|
+ }
|
|
|
+ count, err := sess.DB("qfw").C(iy.UserColl()).Find(query).Count()
|
|
|
+ log.Println("当前时间:", FormatDateByInt64(&now_unix, Date_Full_Layout), "数据总量:", count, "--err:", err)
|
|
|
+ var i int64 = 0
|
|
|
+ it := sess.DB("qfw").C(iy.UserColl()).Find(query).Select(iy.UserField(map[string]interface{}{"i_doc_status": 1, "l_doc_endtime": 1, "i_userid": 1, "i_entid": 1, "base_user_id": 1, "o_vipjy": 1})).Iter()
|
|
|
+ for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
+ i++
|
|
|
+ _id := BsonIdToSId(m["_id"])
|
|
|
+ l_doc_endtime := qutil.Int64All(m["l_doc_endtime"])
|
|
|
+ i_doc_status := qutil.IntAll(m["i_doc_status"])
|
|
|
+ if l_doc_endtime <= now_unix {
|
|
|
+ ok := util.MQFW.UpdateById(iy.UserColl(), _id, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_doc_status": -i_doc_status,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if !ok {
|
|
|
+ log.Println("用户:", _id, " 更新doc状态异常")
|
|
|
+ } else {
|
|
|
+ var (
|
|
|
+ identity *pb.Identity
|
|
|
+ entUserId = qutil.Int64All(m["i_userid"])
|
|
|
+ baseUserId = qutil.Int64All(m["base_user_id"])
|
|
|
+ )
|
|
|
+ if iy.UserColl() == CollEntUser {
|
|
|
+ identity = util.Compatible.Middleground.UserCenter.IdentityByEntUserId(entUserId)
|
|
|
+ } else {
|
|
|
+ identity = util.Compatible.Middleground.UserCenter.IdentityByUserId(baseUserId)
|
|
|
+ }
|
|
|
+ go config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
+ PositionId: strconv.Itoa(int(identity.PositionId)),
|
|
|
+ AppId: "10000",
|
|
|
+ })
|
|
|
+ go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", identity.PositionId)
|
|
|
+ }
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if i != count {
|
|
|
+ log.Println("更新doc状态有异常,已处理:", i, "总量:", count)
|
|
|
+ }
|
|
|
+ log.Println("doc 已处理:", i, "总量:", count)
|
|
|
+ log.Println("定时任务,更新doc状态结束")
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func ZmUserEquityRecovery(userTable string) {
|
|
|
+ yesterday := time.Now().Add(-time.Hour * 10)
|
|
|
+ now := time.Date(yesterday.Year(),
|
|
|
+ yesterday.Month(),
|
|
|
+ yesterday.Day(),
|
|
|
+ 23, 59, 59, 0,
|
|
|
+ time.Local)
|
|
|
+ crontab(false, TimeTaskConfig.ZmUserEquityRecovery, func() {
|
|
|
+ queryMap := map[string]interface{}{"i_zhima_number": 1, "i_zhima_status": 1, "_id": 1, "i_zhima_endtime": 1, "i_zhima_starttime": 1}
|
|
|
+ if userTable == CollEntUser {
|
|
|
+ queryMap["i_userid"] = 1
|
|
|
+ }
|
|
|
+ sess := util.MQFW.GetMgoConn()
|
|
|
+ it := sess.DB("qfw").C(userTable).Find(map[string]interface{}{
|
|
|
+ "i_zhima_status": map[string]interface{}{
|
|
|
+ "$gt": 0},
|
|
|
+ }).Select(queryMap).Iter()
|
|
|
+ for m := make(map[string]interface{}); it.Next(&m); {
|
|
|
+ userId := BsonIdToSId(m["_id"])
|
|
|
+ if userTable == CollEntUser {
|
|
|
+ identity := config.Middleground.UserCenter.IdentityByEntUserId(gconv.Int64(m["i_userid"]))
|
|
|
+ if identity == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ userId = fmt.Sprint(identity.PositionId)
|
|
|
+ }
|
|
|
+
|
|
|
+ i_zhima_endtime := qutil.Int64All(m["i_zhima_endtime"])
|
|
|
+ i_zhima_starttime := qutil.Int64All(m["i_zhima_starttime"])
|
|
|
+ i_zhima_status := qutil.IntAll(m["i_zhima_status"])
|
|
|
+ i_zhima_number := qutil.IntAll(m["i_zhima_number"])
|
|
|
+
|
|
|
+ zhimaEndtime := time.Unix(i_zhima_endtime, 0)
|
|
|
+ zhimaStarttime := time.Unix(i_zhima_starttime, 0)
|
|
|
+ for zhimaEndtime.After(zhimaStarttime) {
|
|
|
+ newZmTime := zhimaStarttime.AddDate(0, 1, 0)
|
|
|
+ if newZmTime.Format("2006-01-02") == now.Format("2006-01-02") {
|
|
|
+ log.Println("每月芝麻权益重新分配", userId, newZmTime.Format("2006-01-02"), now.Format("2006-01-02"))
|
|
|
+ var (
|
|
|
+ number int
|
|
|
+ )
|
|
|
+ //计算周期内数量
|
|
|
+ balanceDetails := util.Mysql.CountBySql("SELECT count(1) FROM bid_credit_report where create_time>=? and mold>0 and user_id =? and pack_type>0", FormatDate(&zhimaStarttime, Date_Full_Layout), userId)
|
|
|
+ number = i_zhima_number - gconv.Int(balanceDetails)
|
|
|
+ if number > 0 {
|
|
|
+ util.Mysql.Insert("bid_credit_balance_details", map[string]interface{}{
|
|
|
+ "user_id": userId,
|
|
|
+ "pack_type": i_zhima_status,
|
|
|
+ "operation": 3,
|
|
|
+ "number": -number,
|
|
|
+ "residue_number": 0,
|
|
|
+ "create_time": time.Now().Format(Date_Full_Layout),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if newZmTime.Format("2006-01-02") != time.Unix(i_zhima_endtime, 0).Format("2006-01-02") {
|
|
|
+ util.Mysql.Insert("bid_credit_balance_details", map[string]interface{}{
|
|
|
+ "user_id": userId,
|
|
|
+ "pack_type": i_zhima_status,
|
|
|
+ "operation": 4,
|
|
|
+ "number": i_zhima_number,
|
|
|
+ "residue_number": i_zhima_number,
|
|
|
+ "create_time": time.Now().Format(Date_Full_Layout),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ zhimaStarttime = newZmTime
|
|
|
+ }
|
|
|
+ if i_zhima_endtime <= now.Unix() {
|
|
|
+ util.MQFW.UpdateById(userTable, BsonIdToSId(m["_id"]), map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_zhima_status": -i_zhima_status,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 清缓存
|
|
|
+ m = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
}
|