|
@@ -1,19 +1,13 @@
|
|
|
package entity
|
|
|
|
|
|
import (
|
|
|
- "fmt"
|
|
|
"log"
|
|
|
. "resourceBrushLibrary/config"
|
|
|
- . "resourceBrushLibrary/rpc"
|
|
|
- "strconv"
|
|
|
"sync"
|
|
|
"time"
|
|
|
|
|
|
- "app.yhyue.com/moapp/MessageCenter/rpc/type/message"
|
|
|
util "app.yhyue.com/moapp/jybase/common"
|
|
|
date "app.yhyue.com/moapp/jybase/date"
|
|
|
- . "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
- . "bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
|
|
|
)
|
|
|
|
|
|
type Point struct {
|
|
@@ -41,80 +35,4 @@ func (p *Point) Run() {
|
|
|
}, `select appId,userId,timePoints,endDate from integral_solde where timePoints>0 and end_time=?`, date.FormatDate(&end, date.Date_Short_Layout))
|
|
|
wait.Wait()
|
|
|
})
|
|
|
- //积分即将到期
|
|
|
- util.SimpleCrontab(false, Config.PointSoonExpireTip, func() {
|
|
|
- p.expire(1)
|
|
|
- })
|
|
|
- //积分已到期
|
|
|
- util.SimpleCrontab(false, Config.PointExpiredTip, func() {
|
|
|
- p.expire(2)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-func (p *Point) expire(t int) {
|
|
|
- var c *MsgConf
|
|
|
- var end time.Time
|
|
|
- if t == 1 {
|
|
|
- c = Config.Messages.PointSoonExpire
|
|
|
- end = time.Now().AddDate(0, 0, Config.PointExpireBefore)
|
|
|
- } else {
|
|
|
- c = Config.Messages.PointExpired
|
|
|
- end = time.Now().AddDate(0, 0, -1)
|
|
|
- }
|
|
|
- pool := make(chan bool, Config.CheckPointExpirePool)
|
|
|
- wait := &sync.WaitGroup{}
|
|
|
- Mysql_Point.SelectByBath(1, func(l *[]map[string]interface{}) bool {
|
|
|
- pool <- true
|
|
|
- wait.Add(1)
|
|
|
- go func(userId, end_time string, timePoints int) {
|
|
|
- defer util.Catch()
|
|
|
- defer func() {
|
|
|
- <-pool
|
|
|
- wait.Done()
|
|
|
- }()
|
|
|
- wxUrl, appUrl := "/front/sess/", "/jyapp/free/sess/"
|
|
|
- mgoUserId := userId
|
|
|
- if !IsObjectIdHex(userId) {
|
|
|
- mgoUserId = ""
|
|
|
- }
|
|
|
- urlAppend := Se.EncodeString(userId+","+util.If(IsObjectIdHex(userId), "_id", "positionId").(string)+","+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(c.MobileUrl)
|
|
|
- wxUrl += urlAppend
|
|
|
- appUrl += urlAppend
|
|
|
- content := ""
|
|
|
- if t == 1 {
|
|
|
- content = fmt.Sprintf(c.Content, Config.PointExpireBefore, timePoints)
|
|
|
- } else {
|
|
|
- content = fmt.Sprintf(c.Content, timePoints)
|
|
|
- }
|
|
|
- tmplData := map[string]*message.TmplItem{
|
|
|
- "thing1": &message.TmplItem{
|
|
|
- Value: c.Title,
|
|
|
- },
|
|
|
- "thing2": &message.TmplItem{
|
|
|
- Value: content,
|
|
|
- },
|
|
|
- "thing3": &message.TmplItem{
|
|
|
- Value: end_time,
|
|
|
- },
|
|
|
- "thing4": c.CustomWxTpl.TmplData["thing19"],
|
|
|
- }
|
|
|
- SendMsg(&message.MultipleSaveMsgReq{
|
|
|
- UserIds: mgoUserId,
|
|
|
- Title: c.Title,
|
|
|
- Content: content,
|
|
|
- MsgType: c.MsgType,
|
|
|
- Link: c.PcUrl + "," + c.MobileUrl + "," + c.MobileUrl,
|
|
|
- Appid: c.Appid,
|
|
|
- AppPushUrl: appUrl,
|
|
|
- WxPushUrl: Config.Webdomain + wxUrl,
|
|
|
- IosPushUrl: appUrl,
|
|
|
- CustomWxTpl: &message.CustomWxTpl{
|
|
|
- TplId: c.CustomWxTpl.TplId,
|
|
|
- TmplData: tmplData,
|
|
|
- },
|
|
|
- })
|
|
|
- }(util.ObjToString((*l)[0]["userId"]), util.ObjToString((*l)[0]["end_time"]), util.IntAll((*l)[0]["timePoints"]))
|
|
|
- return true
|
|
|
- }, `select userId,timePoints,end_time from integral_solde where timePoints>0 and end_time=?`, date.FormatDate(&end, date.Date_Short_Layout))
|
|
|
- wait.Wait()
|
|
|
}
|