|
@@ -67,60 +67,30 @@ func FrequencyByDay() (err error) {
|
|
|
if noticeSecondTotal >= nowBeforSecond && noticeSecondTotal <= nowAfterSecond {
|
|
|
//获取用户信息
|
|
|
var openId string
|
|
|
- isAdmin := true
|
|
|
admin, err := models.GetAdminByAdminId(v.UserId)
|
|
|
if err != nil {
|
|
|
if err.Error() == utils.ErrNoRow() {
|
|
|
- isAdmin = false
|
|
|
- } else {
|
|
|
+ err = errors.New("账号不存在")
|
|
|
return err
|
|
|
}
|
|
|
+ return err
|
|
|
}
|
|
|
- if admin == nil {
|
|
|
- isAdmin = false
|
|
|
- }
|
|
|
- if isAdmin {
|
|
|
- if admin.Mobile == "" {
|
|
|
+ openId = admin.OpenId
|
|
|
+ //发送消息
|
|
|
+ if openId != "" {
|
|
|
+ openIdList := make([]*models.OpenIdList, 0)
|
|
|
+ openIdItem := new(models.OpenIdList)
|
|
|
+ openIdItem.OpenId = openId
|
|
|
+ openIdList = append(openIdList, openIdItem)
|
|
|
|
|
|
- } else {
|
|
|
- wxUser, err := models.GetWxUserByMobile(admin.Mobile)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if wxUser == nil {
|
|
|
- err = errors.New("用户信息不存在:mobile:" + admin.Mobile)
|
|
|
- return err
|
|
|
- }
|
|
|
- openId = wxUser.OpenId
|
|
|
- }
|
|
|
- } else {
|
|
|
- wxUser, err := models.GetWxUserByUserId(v.UserId)
|
|
|
+ first := "数据录入提醒"
|
|
|
+ keyword1 := v.SecName
|
|
|
+ keyword2 := "每日 " + v.NoticeTime
|
|
|
+ remark := v.SecName + "该更新了"
|
|
|
+ err = SendWxMsgWithFrequency(first, keyword1, keyword2, remark, openIdList)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- if wxUser == nil {
|
|
|
- err = errors.New("用户信息不存在:userId:" + strconv.Itoa(v.UserId))
|
|
|
- return err
|
|
|
- }
|
|
|
- openId = wxUser.OpenId
|
|
|
- }
|
|
|
- //发送消息
|
|
|
- if openId == "" {
|
|
|
- err = errors.New("openId is empty")
|
|
|
- return err
|
|
|
- }
|
|
|
- openIdList := make([]*models.OpenIdList, 0)
|
|
|
- openIdItem := new(models.OpenIdList)
|
|
|
- openIdItem.OpenId = openId
|
|
|
- openIdList = append(openIdList, openIdItem)
|
|
|
-
|
|
|
- first := "数据录入提醒"
|
|
|
- keyword1 := v.SecName
|
|
|
- keyword2 := "每日 " + v.NoticeTime
|
|
|
- remark := v.SecName + "该更新了"
|
|
|
- err = SendWxMsgWithFrequency(first, keyword1, keyword2, remark, openIdList)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -224,72 +194,42 @@ func FrequencyByWeek() (err error) {
|
|
|
if noticeSecondTotal >= nowBeforSecond && noticeSecondTotal <= nowAfterSecond {
|
|
|
//获取用户信息
|
|
|
var openId string
|
|
|
- isAdmin := true
|
|
|
admin, err := models.GetAdminByAdminId(v.UserId)
|
|
|
if err != nil {
|
|
|
if err.Error() == utils.ErrNoRow() {
|
|
|
- isAdmin = false
|
|
|
- } else {
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- if admin == nil {
|
|
|
- isAdmin = false
|
|
|
- }
|
|
|
- if isAdmin {
|
|
|
- if admin.Mobile == "" {
|
|
|
-
|
|
|
- } else {
|
|
|
- wxUser, err := models.GetWxUserByMobile(admin.Mobile)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if wxUser == nil {
|
|
|
- err = errors.New("用户信息不存在:mobile:" + admin.Mobile)
|
|
|
- return err
|
|
|
- }
|
|
|
- openId = wxUser.OpenId
|
|
|
- }
|
|
|
- } else {
|
|
|
- wxUser, err := models.GetWxUserByUserId(v.UserId)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if wxUser == nil {
|
|
|
- err = errors.New("用户信息不存在:userId:" + strconv.Itoa(v.UserId))
|
|
|
+ err = errors.New("账号不存在")
|
|
|
return err
|
|
|
}
|
|
|
- openId = wxUser.OpenId
|
|
|
- }
|
|
|
- //发送消息
|
|
|
- if openId == "" {
|
|
|
- err = errors.New("openId is empty")
|
|
|
return err
|
|
|
}
|
|
|
- openIdList := make([]*models.OpenIdList, 0)
|
|
|
- openIdItem := new(models.OpenIdList)
|
|
|
- openIdItem.OpenId = openId
|
|
|
- openIdList = append(openIdList, openIdItem)
|
|
|
+ openId = admin.OpenId
|
|
|
+ //发送消息
|
|
|
+ if openId != "" {
|
|
|
+ openIdList := make([]*models.OpenIdList, 0)
|
|
|
+ openIdItem := new(models.OpenIdList)
|
|
|
+ openIdItem.OpenId = openId
|
|
|
+ openIdList = append(openIdList, openIdItem)
|
|
|
|
|
|
- first := "数据录入提醒"
|
|
|
- keyword1 := v.SecName
|
|
|
- keyword2 := "每周 " + v.NoticeTime
|
|
|
- remark := v.SecName + "该更新了"
|
|
|
+ first := "数据录入提醒"
|
|
|
+ keyword1 := v.SecName
|
|
|
+ keyword2 := "每周 " + v.NoticeTime
|
|
|
+ remark := v.SecName + "该更新了"
|
|
|
|
|
|
- err = SendWxMsgWithFrequency(first, keyword1, keyword2, remark, openIdList)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- //发送成功,记录发送日志
|
|
|
- {
|
|
|
- sendRecord := new(models.EdbinfoSendMsgRecord)
|
|
|
- sendRecord.UserId = v.UserId
|
|
|
- sendRecord.TradeCode = v.TradeCode
|
|
|
- sendRecord.CreateTime = time.Now()
|
|
|
- err = models.AddEdbinfoSendMsgRecord(sendRecord)
|
|
|
+ err = SendWxMsgWithFrequency(first, keyword1, keyword2, remark, openIdList)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
+ //发送成功,记录发送日志
|
|
|
+ {
|
|
|
+ sendRecord := new(models.EdbinfoSendMsgRecord)
|
|
|
+ sendRecord.UserId = v.UserId
|
|
|
+ sendRecord.TradeCode = v.TradeCode
|
|
|
+ sendRecord.CreateTime = time.Now()
|
|
|
+ err = models.AddEdbinfoSendMsgRecord(sendRecord)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
utils.FileLog.Info("%s", v.TradeCode+":不在推送消息时间范围内")
|
|
@@ -382,61 +322,31 @@ func FrequencyByMonth() (err error) {
|
|
|
if noticeSecondTotal >= nowBeforSecond && noticeSecondTotal <= nowAfterSecond {
|
|
|
//获取用户信息
|
|
|
var openId string
|
|
|
- isAdmin := true
|
|
|
admin, err := models.GetAdminByAdminId(v.UserId)
|
|
|
if err != nil {
|
|
|
if err.Error() == utils.ErrNoRow() {
|
|
|
- isAdmin = false
|
|
|
- } else {
|
|
|
+ err = errors.New("账号不存在")
|
|
|
return err
|
|
|
}
|
|
|
+ return err
|
|
|
}
|
|
|
- if admin == nil {
|
|
|
- isAdmin = false
|
|
|
- }
|
|
|
- if isAdmin {
|
|
|
- if admin.Mobile == "" {
|
|
|
+ openId = admin.OpenId
|
|
|
+ //发送消息
|
|
|
+ if openId != "" {
|
|
|
+ openIdList := make([]*models.OpenIdList, 0)
|
|
|
+ openIdItem := new(models.OpenIdList)
|
|
|
+ openIdItem.OpenId = openId
|
|
|
+ openIdList = append(openIdList, openIdItem)
|
|
|
|
|
|
- } else {
|
|
|
- wxUser, err := models.GetWxUserByMobile(admin.Mobile)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if wxUser == nil {
|
|
|
- err = errors.New("用户信息不存在:mobile:" + admin.Mobile)
|
|
|
- return err
|
|
|
- }
|
|
|
- openId = wxUser.OpenId
|
|
|
- }
|
|
|
- } else {
|
|
|
- wxUser, err := models.GetWxUserByUserId(v.UserId)
|
|
|
+ first := "数据录入提醒"
|
|
|
+ keyword1 := v.SecName
|
|
|
+ keyword2 := "每月 " + v.NoticeTime
|
|
|
+ remark := v.SecName + "该更新了"
|
|
|
+
|
|
|
+ err = SendWxMsgWithFrequency(first, keyword1, keyword2, remark, openIdList)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- if wxUser == nil {
|
|
|
- err = errors.New("用户信息不存在:userId:" + strconv.Itoa(v.UserId))
|
|
|
- return err
|
|
|
- }
|
|
|
- openId = wxUser.OpenId
|
|
|
- }
|
|
|
- //发送消息
|
|
|
- if openId == "" {
|
|
|
- err = errors.New("openId is empty")
|
|
|
- return err
|
|
|
- }
|
|
|
- openIdList := make([]*models.OpenIdList, 0)
|
|
|
- openIdItem := new(models.OpenIdList)
|
|
|
- openIdItem.OpenId = openId
|
|
|
- openIdList = append(openIdList, openIdItem)
|
|
|
-
|
|
|
- first := "数据录入提醒"
|
|
|
- keyword1 := v.SecName
|
|
|
- keyword2 := "每月 " + v.NoticeTime
|
|
|
- remark := v.SecName + "该更新了"
|
|
|
-
|
|
|
- err = SendWxMsgWithFrequency(first, keyword1, keyword2, remark, openIdList)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
}
|
|
|
}
|
|
|
}
|