|
@@ -39,13 +39,14 @@ type TaskInfo struct {
|
|
|
|
|
|
// 信息主题
|
|
// 信息主题
|
|
type MsgBody struct {
|
|
type MsgBody struct {
|
|
- Phone string
|
|
|
|
- UserId string
|
|
|
|
- MgoUserId string
|
|
|
|
- PositionId int64
|
|
|
|
- ActiveId int64
|
|
|
|
- TaskInfoId int64
|
|
|
|
- OrderCode string
|
|
|
|
|
|
+ Phone string `json:"phone"`
|
|
|
|
+ UserId string `json:"user_id"`
|
|
|
|
+ MgoUserId string `json:"mgo_user_id"`
|
|
|
|
+ PositionId int64 `json:"position_id"`
|
|
|
|
+ ActiveId int64 `json:"active_id"`
|
|
|
|
+ TaskInfoId int64 `json:"task_info_id"`
|
|
|
|
+ OrderCode string `json:"order_code"`
|
|
|
|
+ NickName string `json:"nick_name"`
|
|
}
|
|
}
|
|
|
|
|
|
// LotteryDrawTask 抽奖任务
|
|
// LotteryDrawTask 抽奖任务
|
|
@@ -111,7 +112,7 @@ func LotteryDrawTask(msg *model.Message) {
|
|
}
|
|
}
|
|
//当前周期内 是否已完成任务
|
|
//当前周期内 是否已完成任务
|
|
if taskInfo.CycleNum > 0 {
|
|
if taskInfo.CycleNum > 0 {
|
|
- tasks := db.Mysql.SelectBySql(fmt.Sprintf(`SELECT ltu.create_date FROM %s ltu WHERE ltu.active_id = ? AND ltu.task_id = ? AND ltu.create_date < ? AND ltu.create_date > ? `, tableTaskUser), taskInfo.ActiveId, taskInfo.Id, timeRange.EndTime.Format(date.Date_Full_Layout), timeRange.StartTime.Format(date.Date_Full_Layout))
|
|
|
|
|
|
+ tasks := db.Mysql.SelectBySql(fmt.Sprintf(`SELECT ltu.create_date FROM %s ltu WHERE ltu.active_id = ? AND ltu.task_id = ? AND ltu.position_id = ? AND ltu.create_date < ? AND ltu.create_date > ? `, tableTaskUser), msgBody.ActiveId, taskInfo.Id, msgBody.PositionId, timeRange.EndTime.Format(date.Date_Full_Layout), timeRange.StartTime.Format(date.Date_Full_Layout))
|
|
if tasks != nil && taskInfo.CycleNum <= len(*tasks) {
|
|
if tasks != nil && taskInfo.CycleNum <= len(*tasks) {
|
|
createDate := common.InterfaceToStr((*tasks)[0]["create_date"])
|
|
createDate := common.InterfaceToStr((*tasks)[0]["create_date"])
|
|
logger.Info(fmt.Sprintf("用户:%s ,此任务:%s ,在 %s 已完成", msgBody.Phone, taskInfo.Name, createDate))
|
|
logger.Info(fmt.Sprintf("用户:%s ,此任务:%s ,在 %s 已完成", msgBody.Phone, taskInfo.Name, createDate))
|
|
@@ -191,6 +192,24 @@ func LotteryDrawTask(msg *model.Message) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ logger.Info(" sse 中奖信息通知:", msg)
|
|
|
|
+
|
|
|
|
+ var userName = msgBody.NickName
|
|
|
|
+ if msgBody.Phone != "" {
|
|
|
|
+ var PhoneReg = regexp.MustCompile(`^(100\d{8}|1[3-9]\d{9})$`)
|
|
|
|
+ if PhoneReg.MatchString(msgBody.Phone) {
|
|
|
|
+ phone := []rune(msgBody.Phone)
|
|
|
|
+ userName = string(phone[0:3]) + "****" + string(phone[(len(phone)-4):])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ util.SseBroadcast.SendToUsers(model.SseMessage{
|
|
|
|
+ Name: taskInfo.Name,
|
|
|
|
+ User: encrypt.SE.EncodeString(msgBody.UserId),
|
|
|
|
+ State: model.TaskTarget,
|
|
|
|
+ Time: time.Now().Format(date.Date_Full_Layout),
|
|
|
|
+ Remark: fmt.Sprintf("%s 完成 %s 任务。", userName, taskInfo.Name),
|
|
|
|
+ ActiveId: encrypt.SE.EncodeString(strconv.FormatInt(msgBody.ActiveId, 10)),
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
type lotteryBody struct {
|
|
type lotteryBody struct {
|
|
@@ -228,9 +247,9 @@ func LotteryWinning(msg *model.Message) {
|
|
}
|
|
}
|
|
logger.Info(" sse 中奖信息通知:", msg)
|
|
logger.Info(" sse 中奖信息通知:", msg)
|
|
util.SseBroadcast.SendToUsers(model.SseMessage{
|
|
util.SseBroadcast.SendToUsers(model.SseMessage{
|
|
- Prize: lb.PrizeName,
|
|
|
|
|
|
+ Name: lb.PrizeName,
|
|
User: userName,
|
|
User: userName,
|
|
- State: model.AllTarget,
|
|
|
|
|
|
+ State: model.WinningTarget,
|
|
Time: time.Now().Format(date.Date_Full_Layout),
|
|
Time: time.Now().Format(date.Date_Full_Layout),
|
|
Remark: fmt.Sprintf("恭喜 %s 抽中 %s ", userName, lb.PrizeName),
|
|
Remark: fmt.Sprintf("恭喜 %s 抽中 %s ", userName, lb.PrizeName),
|
|
ActiveId: encrypt.SE.EncodeString(strconv.FormatInt(lb.ActiveId, 10)),
|
|
ActiveId: encrypt.SE.EncodeString(strconv.FormatInt(lb.ActiveId, 10)),
|